From a6b63572b15ecd6f810436fab028747018fbcb0a Mon Sep 17 00:00:00 2001 From: George Shammas Date: Sun, 26 Nov 2023 17:35:43 -0500 Subject: [PATCH] Update nix --- default.nix | 22 +++++++++++++--------- flake.lock | 12 ++++++------ flake.nix | 38 ++++++++++++++++++++++++++++++-------- shell.nix | 22 +++++++++++++--------- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/default.nix b/default.nix index f8a169d..873ece4 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,13 @@ -(import ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; } -) { - src = ./.; -}).defaultNix +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).defaultNix diff --git a/flake.lock b/flake.lock index befe409..a2d45cb 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -18,11 +18,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1685616147, - "narHash": "sha256-Y2BAkfSSCkH/SNIG2glh9vbdiQyWAFWr5Q4K0JgChlg=", + "lastModified": 1701037719, + "narHash": "sha256-iRugJrfdbc4rBybmtl09L3e2KseKjjjx8H9eUEuMO4M=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4e80f80864db80ef05482325a379243c41f925fa", + "rev": "627af21e87ce5d6a456f485292ac4ac2bc1f469f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b83a464..7829c05 100644 --- a/flake.nix +++ b/flake.nix @@ -12,10 +12,11 @@ version = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile ./.version + versionSuffix); - versionSuffix = if officialRelease then - "" - else - "pre${ + versionSuffix = + if officialRelease then + "" + else + "pre${ nixpkgs.lib.substring 0 8 (self.lastModifiedDate or self.lastModified) }_${self.shortRev or "dirty"}"; @@ -30,7 +31,8 @@ inherit system; overlays = [ self.overlay ]; }); - in { + in + { overlay = final: prev: { ifconfigio = with final; with pkgs; @@ -38,7 +40,7 @@ name = "ifconfig.io-${version}"; src = self; - vendorSha256 = "sha256-FnIJff+T5bB3HKET5srQibXnyHjbOVIgcKEoViSY6TA="; + vendorHash = "sha256-ZtKaYvPGP7L18pwtglFJJngDAVchiOsLKYWuT5YkcLk="; tags = [ "jsoniter" ]; @@ -70,15 +72,35 @@ defaultPackage = forAllSystems (system: self.packages.${system}.ifconfigio); - nixosModules.ifconfigio = { pkgs, ... }: { + nixosModules.ifconfigio = { pkgs, lib, ... }: { nixpkgs.overlays = [ self.overlay ]; - systemd.packages = [ pkgs.ifconfigio ]; users.users.ifconfigio = { description = "ifconfig.io daemon user"; group = "ifconfigio"; isSystemUser = true; + home = "/opt/ifconfig"; }; users.groups.ifconfigio = { }; + systemd.services.ifconfigio = { + description = "ifconfig.io web service"; + enable = true; + wantedBy = [ "multi-user.target" ]; + environment = { + GIN_MODE = lib.mkDefault "release"; + TLS = lib.mkDefault "0"; + }; + script = '' + # For some reason the systemd WorkingDir is not doing what we need + # so we `cd` to it explicitly. + cd "${pkgs.ifconfigio}/usr/lib/ifconfig.io" + exec "${pkgs.ifconfigio}/bin/ifconfig.io" + ''; + serviceConfig = { + User = "ifconfigio"; + WorkingDir = "${pkgs.ifconfigio}/usr/lib/ifconfig.io"; + LimitNOFILE = 200000; + }; + }; }; }; diff --git a/shell.nix b/shell.nix index b769069..9eb132a 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,13 @@ -(import ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; } -) { - src = ./.; -}).shellNix +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).shellNix