From 0384654ee4b7b379a168c09d2cd7f7b80c20e5f4 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 15 Jun 2024 12:37:15 -0400 Subject: [PATCH] flake: Don't dynamically declare nixosConfigurations This makes it easier to add hosts that have multiple nixosConfigurations due to compiling for different architectures. --- flake.nix | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index b4ce676e..ea633205 100644 --- a/flake.nix +++ b/flake.nix @@ -27,10 +27,23 @@ inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; inherit (builtins) attrNames listToAttrs map replaceStrings readDir; - flakeOutputs = [ "overlays" "nixosModules" "nixosConfigurations" "homeManagerModules" "packages" "checks" ]; - flakeDirectories = [ "overlays" "modules" "hardware" "home" "packages" "tests" ]; + flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" "checks" ]; + flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ]; in { + nixosConfigurations = + { + nixos = nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs // { nix-config = self; }; + + modules = [ + ./. + ./hardware/laptop.nix + ]; + }; + }; + formatter.x86_64-linux = nixpkgs-fmt; } // (listToAttrs @@ -44,10 +57,7 @@ attributeValue = (listToAttrs (map (file: { - name = - if file == "laptop.nix" - then "nixos" - else replaceStrings [ ".nix" ] [ "" ] file; + name = replaceStrings [ ".nix" ] [ "" ] file; value = if directory == "packages" then callPackage ./${directory}/${file} { } @@ -59,19 +69,7 @@ inherit self; pkgs = nixpkgs.legacyPackages.x86_64-linux; } - else - if directory == "hardware" - then - nixosSystem - { - system = "x86_64-linux"; - specialArgs = attrs // { nix-config = self; }; - modules = [ - ./. - ./${directory}/${file} - ]; - } - else import ./${directory}/${file}; + else import ./${directory}/${file}; }) (attrNames (readDir ./${directory}))));