From 49375b980197db7b4e0d17327b52d37d6ce33f35 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 13 Mar 2022 13:27:43 +0100 Subject: flake: deploy overrides --- flake.nix | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 5e5e6d0d..5a62065d 100644 --- a/flake.nix +++ b/flake.nix @@ -174,20 +174,24 @@ description = "GKleen's flakey nixos configuration"; }; - deploy.nodes = mapAttrs (hostname: _: { - inherit hostname; - sshUser = "root"; - - profilesOrder = ["system"]; # system first - profiles = { - system = { - path = deploy-rs.lib.${self.nixosConfigurations.${hostname}.config.nixpkgs.system}.activate.nixos self.nixosConfigurations.${hostname}; - }; - } // (mapAttrs (_user: usercfg: { - user = usercfg.home.username; - path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; - }) self.nixosConfigurations.${hostname}.config.home-manager.users); - }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); + deploy.nodes = let + defaults = mapAttrs (hostname: _: { + inherit hostname; + sshUser = "root"; + + profilesOrder = ["system"]; # system first + profiles = { + system = { + path = deploy-rs.lib.${self.nixosConfigurations.${hostname}.config.nixpkgs.system}.activate.nixos self.nixosConfigurations.${hostname}; + }; + } // (mapAttrs (_user: usercfg: { + user = usercfg.home.username; + path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; + }) self.nixosConfigurations.${hostname}.config.home-manager.users); + }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); + overrides = if pathExists ./deploy then nixImport { dir = ./deploy; _import = path: _name: import (./deploy + "/${path}") inputs; } else {}; + filterEnabled = attrs: mapAttrs (_n: v: filterAttrs (n: _v: n != "enabled") v) (filterAttrs (_n: v: v.enabled or true) attrs); + in mapAttrs (_n: v: if v ? "profiles" then v // { profiles = filterEnabled v.profiles; } else v) (filterEnabled (recursiveUpdate defaults overrides)); checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; }; -- cgit v1.2.3