diff --git a/flake.lock b/flake.lock index dc0c9b39..fc742252 100644 --- a/flake.lock +++ b/flake.lock @@ -27,7 +27,6 @@ }, "original": { "owner": "numtide", - "ref": "master", "repo": "flake-utils", "type": "github" } @@ -54,16 +53,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1616250371, - "narHash": "sha256-bG3/Dt3f/x8qUZ6djnfUVG8erVzwA9I4pxrtzmCizoI=", - "owner": "chvp", + "lastModified": 1616527350, + "narHash": "sha256-VkMevY2WLU+K7T/P4wVj18Ms8zyeRfp05ILf556m5Y8=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "e132ddfecfeba08f3b09b72064ded55b9fceb45a", + "rev": "d3f7e969b9860fb80750147aeb56dab1c730e756", "type": "github" }, "original": { - "owner": "chvp", - "ref": "master", + "owner": "nixos", + "ref": "nixos-unstable-small", "repo": "nixpkgs", "type": "github" } @@ -71,9 +70,28 @@ "root": { "inputs": { "emacs-overlay": "emacs-overlay", - "flake-utils": "flake-utils", "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "inputs": { + "flake-utils": "flake-utils" + }, + "locked": { + "lastModified": 1616328024, + "narHash": "sha256-t5FrJlYiN1HojtN3eRWlPhmzH2+5pdB22AfosbphI6c=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "51cb739c9c9c2258bc70747eb7bc22975ae244bd", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "ref": "master", + "repo": "flake-utils-plus", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 80f970ba..24a54080 100644 --- a/flake.nix +++ b/flake.nix @@ -3,53 +3,36 @@ inputs = { emacs-overlay.url = "github:nix-community/emacs-overlay/master"; - flake-utils.url = "github:numtide/flake-utils/master"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - nixpkgs.url = "github:chvp/nixpkgs/master"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small"; + utils.url = "github:gytis-ivaskevicius/flake-utils-plus/master"; }; - outputs = { self, emacs-overlay, nixpkgs, home-manager, flake-utils }: - let - version-suffix = nixpkgs.rev or (builtins.toString nixpkgs.lastModified); - pkgsFor = system: import nixpkgs { - inherit system; - }; - mkSystem = system: hostname: nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - ({ pkgs, ... }: { nixpkgs.overlays = [ emacs-overlay.overlay ]; }) - home-manager.nixosModules.home-manager - (./modules) - (./. + "/machines/${hostname}") - ({ pkgs, ... }: { - environment.etc."nixpkgs".source = (pkgs.runCommandNoCC "nixpkgs" { } '' - cp -r ${nixpkgs} $out - chmod 700 $out - echo "${version-suffix}" > $out/.version-suffix - ''); - nix.nixPath = [ "nixpkgs=/etc/nixpkgs" ]; - }) - ]; - }; - in - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = pkgsFor system; - in - { - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ nixpkgs-fmt ]; - }; - }) // { - nixosConfigurations = { - kharbranth = mkSystem "x86_64-linux" "kharbranth"; - kholinar = mkSystem "x86_64-linux" "kholinar"; - lasting-integrity = mkSystem "x86_64-linux" "lasting-integrity"; - urithiru = mkSystem "x86_64-linux" "urithiru"; - }; + outputs = inputs@{ self, nixpkgs, emacs-overlay, home-manager, utils }: utils.lib.systemFlake { + inherit self inputs; + channels.nixpkgs = { + input = nixpkgs; + patches = [ ]; + # TODO: Try to find a way to get rid of this and return to the + # list built up in the config. + config = { allowUnfree = true; }; }; + sharedOverlays = [ emacs-overlay.overlay ]; + sharedModules = [ + utils.nixosModules.saneFlakeDefaults + home-manager.nixosModules.home-manager + ./modules + ]; + nixosProfiles = { + kharbranth = { system = "x86_64-linux"; modules = [ ./machines/kharbranth ]; }; + kholinar = { system = "x86_64-linux"; modules = [ ./machines/kholinar ]; }; + lasting-integrity = { system = "x86_64-linux"; modules = [ ./machines/lasting-integrity ]; }; + urithiru = { system = "x86_64-linux"; modules = [ ./machines/urithiru ]; }; + }; + devShellBuilder = channels: + let pkgs = channels.nixpkgs; in pkgs.mkShell { buildInputs = [ pkgs.nixpkgs-fmt ]; }; + }; } diff --git a/modules/nix.nix b/modules/nix.nix index 594a1180..f35a79ad 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -43,10 +43,6 @@ in default = true; example = false; }; - enableFlakes = lib.mkOption { - default = true; - example = false; - }; unfreePackages = lib.mkOption { default = [ ]; example = [ "teams" ]; @@ -82,17 +78,11 @@ in '' + (lib.optionalString config.chvp.nix.enableDirenv '' keep-outputs = true keep-derivations = true - '') + (lib.optionalString config.chvp.nix.enableFlakes '' - experimental-features = nix-command flakes ''); }; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.chvp.nix.unfreePackages; - nixpkgs.overlays = lib.mkIf config.chvp.nix.enableFlakes [ - (self: super: { - nix = super.nixUnstable; - }) - ]; + nixpkgs.overlays = [ (self: super: { nix = super.nixUnstable; }) ]; home-manager.users.charlotte = { ... }: lib.recursiveUpdate