69 lines
1.8 KiB
Nix
69 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
inputs,
|
|
}: let
|
|
inherit (inputs) deploy-rs;
|
|
in rec {
|
|
## Create deployment configuration for use with deploy-rs.
|
|
##
|
|
## ```nix
|
|
## mkDeploy {
|
|
## inherit self;
|
|
## overrides = {
|
|
## my-host.system.sudo = "doas -u";
|
|
## };
|
|
## }
|
|
## ```
|
|
##
|
|
#@ { self: Flake, overrides: Attrs ? {} } -> Attrs
|
|
mkDeploy = {
|
|
self,
|
|
overrides ? {},
|
|
exclude ? [],
|
|
}: let
|
|
hosts =
|
|
builtins.removeAttrs
|
|
(self.nixosConfigurations or {})
|
|
exclude;
|
|
names = builtins.attrNames hosts;
|
|
nodes =
|
|
lib.foldl (
|
|
result: name: let
|
|
host = hosts.${name};
|
|
user = overrides.user or null;
|
|
remoteBuild = overrides.remoteBuild or null;
|
|
inherit (host.pkgs) system;
|
|
in
|
|
result
|
|
// {
|
|
${name} =
|
|
(overrides.${name} or {})
|
|
// {
|
|
hostname = overrides.${name}.hostname or "${name}";
|
|
profiles =
|
|
(overrides.${name}.profiles or {})
|
|
// {
|
|
system =
|
|
(overrides.${name}.profiles.system or {})
|
|
// {
|
|
user = "root";
|
|
path = deploy-rs.lib.${system}.activate.nixos host;
|
|
}
|
|
// lib.optionalAttrs (user != null) {
|
|
sshUser = user;
|
|
}
|
|
// lib.optionalAttrs (remoteBuild != null) {
|
|
inherit remoteBuild;
|
|
}
|
|
// lib.optionalAttrs (host.config.system.security.doas.enable or false) {
|
|
sudo = "doas -u";
|
|
};
|
|
};
|
|
};
|
|
}
|
|
) {}
|
|
names;
|
|
in {
|
|
inherit nodes;
|
|
};
|
|
}
|