From 77296ff433c0dc6e9b5cad522b6a46dafaa204ba Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Mon, 15 Feb 2021 11:24:43 -0700 Subject: [PATCH] deploy: move logic to lib --- flake.nix | 15 +++------------ lib/default.nix | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 3df3d02e..0f4d60b9 100644 --- a/flake.nix +++ b/flake.nix @@ -40,9 +40,9 @@ }: let inherit (utils.lib) eachDefaultSystem flattenTreeSystem; - inherit (nixos.lib) recursiveUpdate mapAttrs; + inherit (nixos.lib) recursiveUpdate; inherit (self.lib) overlays nixosModules genPackages genPkgs - genHomeActivationPackages; + genHomeActivationPackages mkNodes; extern = import ./extern { inherit inputs; }; @@ -72,16 +72,7 @@ defaultTemplate = self.templates.flk; - deploy.nodes = mapAttrs - (_: config: { - hostname = config.config.networking.hostName; - - profiles.system = { - user = "root"; - path = deploy.lib.x86_64-linux.activate.nixos config; - }; - }) - self.nixosConfigurations; + deploy.nodes = mkNodes deploy self.nixosConfigurations; checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) diff --git a/lib/default.nix b/lib/default.nix index 8300ffbc..de395e21 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -42,6 +42,21 @@ let in map fullPath (attrNames (readDir overlayDir)); + /** + Synopsis: mkNodes _nixosConfigurations_ + + Generate the `nodes` attribute expected by deploy-rs + where _nixosConfigurations_ are `nodes`. + **/ + mkNodes = deploy: mapAttrs (_: config: { + hostname = config.config.networking.hostName; + + profiles.system = { + user = "root"; + path = deploy.lib.x86_64-linux.activate.nixos config; + }; + }); + /** Synopsis: importDefaults _path_ @@ -72,7 +87,7 @@ let in { inherit importDefaults mapFilterAttrs genAttrs' pkgImport - pathsToImportedAttrs; + pathsToImportedAttrs mkNodes; overlays = pathsToImportedAttrs overlayPaths;