From fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 15 May 2021 16:40:27 +0200 Subject: ... --- flake.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 5204b447..ea3d0747 100644 --- a/flake.nix +++ b/flake.nix @@ -26,11 +26,11 @@ outputs = { self, nixpkgs, home-manager, sops-nix }@inputs: let - inherit (builtins) attrNames attrValues elemAt toJSON; + inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; inherit (nixpkgs) lib; utils = import ./utils { inherit lib; }; inherit (utils) recImport overrideModule; - inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem; + inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs; accountUserName = accountName: let @@ -118,11 +118,11 @@ netboot = { path = "nixos/modules/installer/netboot/netboot-minimal.nix"; output = out: (self.legacyPackages.${system}.symlinkJoin { name = "netboot"; paths = with out.config.system.build; [ netbootRamdisk kernel netbootIpxeScript ]; preferLocalBuild = true; }); }; }; + installerConfig = if pathExists ./installer.nix then "installer.nix" else (if pathExists ./installer then "installer" else null); installers = let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system); mkInstaller = system: name: {profile, output}: output (mkNixosConfiguration [profile { config = { nixpkgs.system = system; }; }] ./. installerConfig "installer"); - installerConfig = if builtins.pathExists ./installer.nix then "installer.nix" else (if builtins.pathExists ./installer then "installer" else null); - in if !(builtins.isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {}; + in if !(isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {}; in { nixosModules = @@ -131,9 +131,9 @@ users = recImport rec { dir = ./users; _import = mkUserModule dir; }; userProfiles = forAllUsers (userName: recImport rec { dir = ./user-profiles; _import = mkUserProfile userName dir; }); accounts = recursiveUpdate rootAccounts (recImport rec { dir = ./accounts; _import = mkAccountModule dir; }); - rootAccounts = listToAttrs (map (hostName: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) (attrNames self.nixosConfigurations ++ lib.optional (installers != {}) "installer" )); + rootAccounts = mapAttrs' (hostName: _value: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) self.nixosConfigurations; in modulesAttrs // { inherit systemProfiles users userProfiles accounts; }; - nixosConfigurations = recImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; + nixosConfigurations = optionalAttrs (!(isNull installerConfig)) { installer = installerConfig; } // recImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; homeManagerModules = recImport rec { dir = ./home-modules; }; -- cgit v1.2.3