From dfe092a702e0ed3ce91df5706485cf9dad58b6af Mon Sep 17 00:00:00 2001 From: teutat3s Date: Thu, 13 Jun 2024 01:17:18 +0200 Subject: [PATCH] lib: use improved deploy-rs lib with overlay'ed pkg --- lib/deploy.nix | 109 ++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 46 deletions(-) diff --git a/lib/deploy.nix b/lib/deploy.nix index 5e9f6418..e97dfe35 100644 --- a/lib/deploy.nix +++ b/lib/deploy.nix @@ -5,58 +5,75 @@ * Licensed under the MIT license */ -{ lib, inputs }: let - getFqdn = c: let - net = c.config.networking; - fqdn = - if (net ? domain) && (net.domain != null) - then "${net.hostName}.${net.domain}" - else net.hostName; - in +{ lib, inputs }: +let + getFqdn = + c: + let + net = c.config.networking; + fqdn = + if (net ? domain) && (net.domain != null) then "${net.hostName}.${net.domain}" else net.hostName; + in fqdn; in { - mkDeployNodes = systemConfigurations: extraConfig: - /* - * - Synopsis: mkNodes _systemConfigurations_ _extraConfig_ + mkDeployNodes = + systemConfigurations: extraConfig: + /* + * + Synopsis: mkNodes _systemConfigurations_ _extraConfig_ - Generate the `nodes` attribute expected by deploy-rs - where _systemConfigurations_ are `nodes`. + Generate the `nodes` attribute expected by deploy-rs + where _systemConfigurations_ are `nodes`. - _systemConfigurations_ should take the form of a flake's - _nixosConfigurations_. Note that deploy-rs does not currently support - deploying to darwin hosts. + _systemConfigurations_ should take the form of a flake's + _nixosConfigurations_. Note that deploy-rs does not currently support + deploying to darwin hosts. - _extraConfig_, if specified, will be merged into each of the - nodes' configurations. + _extraConfig_, if specified, will be merged into each of the + nodes' configurations. - Example _systemConfigurations_ input: + Example _systemConfigurations_ input: - ``` - { - hostname-1 = { - fastConnection = true; - sshOpts = [ "-p" "25" ]; - }; - hostname-2 = { - sshOpts = [ "-p" "19999" ]; - sshUser = "root"; - }; - } - ``` - * - */ - lib.recursiveUpdate - (lib.mapAttrs - ( - _: c: { - hostname = getFqdn c; - profiles.system = { - user = "root"; - path = inputs.deploy-rs.lib.${c.pkgs.stdenv.hostPlatform.system}.activate.nixos c; + ``` + { + hostname-1 = { + fastConnection = true; + sshOpts = [ "-p" "25" ]; + }; + hostname-2 = { + sshOpts = [ "-p" "19999" ]; + sshUser = "root"; + }; + } + ``` + * + */ + lib.recursiveUpdate (lib.mapAttrs ( _: c: { + hostname = getFqdn c; + profiles.system = + let + system = c.pkgs.system; + + # Unmodified nixpkgs + pkgs = import inputs.nixpkgs { inherit system; }; + + # nixpkgs with deploy-rs overlay but force the nixpkgs package + deployPkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + inputs.deploy-rs.overlays.default + (self: super: { + deploy-rs = { + inherit (pkgs) deploy-rs; + lib = super.deploy-rs.lib; + }; + }) + ]; }; - } - ) - systemConfigurations) - extraConfig; + in + { + user = "root"; + path = deployPkgs.deploy-rs.lib.activate.nixos c; + }; + }) systemConfigurations) extraConfig; }