forked from pub-solar/os
lib: use improved deploy-rs lib with overlay'ed pkg
This commit is contained in:
parent
09b8cc835f
commit
dfe092a702
109
lib/deploy.nix
109
lib/deploy.nix
|
@ -5,58 +5,75 @@
|
||||||
* Licensed under the MIT license
|
* Licensed under the MIT license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{ lib, inputs }: let
|
{ lib, inputs }:
|
||||||
getFqdn = c: let
|
let
|
||||||
net = c.config.networking;
|
getFqdn =
|
||||||
fqdn =
|
c:
|
||||||
if (net ? domain) && (net.domain != null)
|
let
|
||||||
then "${net.hostName}.${net.domain}"
|
net = c.config.networking;
|
||||||
else net.hostName;
|
fqdn =
|
||||||
in
|
if (net ? domain) && (net.domain != null) then "${net.hostName}.${net.domain}" else net.hostName;
|
||||||
|
in
|
||||||
fqdn;
|
fqdn;
|
||||||
in {
|
in {
|
||||||
mkDeployNodes = systemConfigurations: extraConfig:
|
mkDeployNodes =
|
||||||
/*
|
systemConfigurations: extraConfig:
|
||||||
*
|
/*
|
||||||
Synopsis: mkNodes _systemConfigurations_ _extraConfig_
|
*
|
||||||
|
Synopsis: mkNodes _systemConfigurations_ _extraConfig_
|
||||||
|
|
||||||
Generate the `nodes` attribute expected by deploy-rs
|
Generate the `nodes` attribute expected by deploy-rs
|
||||||
where _systemConfigurations_ are `nodes`.
|
where _systemConfigurations_ are `nodes`.
|
||||||
|
|
||||||
_systemConfigurations_ should take the form of a flake's
|
_systemConfigurations_ should take the form of a flake's
|
||||||
_nixosConfigurations_. Note that deploy-rs does not currently support
|
_nixosConfigurations_. Note that deploy-rs does not currently support
|
||||||
deploying to darwin hosts.
|
deploying to darwin hosts.
|
||||||
|
|
||||||
_extraConfig_, if specified, will be merged into each of the
|
_extraConfig_, if specified, will be merged into each of the
|
||||||
nodes' configurations.
|
nodes' configurations.
|
||||||
|
|
||||||
Example _systemConfigurations_ input:
|
Example _systemConfigurations_ input:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
hostname-1 = {
|
hostname-1 = {
|
||||||
fastConnection = true;
|
fastConnection = true;
|
||||||
sshOpts = [ "-p" "25" ];
|
sshOpts = [ "-p" "25" ];
|
||||||
};
|
};
|
||||||
hostname-2 = {
|
hostname-2 = {
|
||||||
sshOpts = [ "-p" "19999" ];
|
sshOpts = [ "-p" "19999" ];
|
||||||
sshUser = "root";
|
sshUser = "root";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
lib.recursiveUpdate
|
lib.recursiveUpdate (lib.mapAttrs ( _: c: {
|
||||||
(lib.mapAttrs
|
hostname = getFqdn c;
|
||||||
(
|
profiles.system =
|
||||||
_: c: {
|
let
|
||||||
hostname = getFqdn c;
|
system = c.pkgs.system;
|
||||||
profiles.system = {
|
|
||||||
user = "root";
|
# Unmodified nixpkgs
|
||||||
path = inputs.deploy-rs.lib.${c.pkgs.stdenv.hostPlatform.system}.activate.nixos c;
|
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;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
in
|
||||||
)
|
{
|
||||||
systemConfigurations)
|
user = "root";
|
||||||
extraConfig;
|
path = deployPkgs.deploy-rs.lib.activate.nixos c;
|
||||||
|
};
|
||||||
|
}) systemConfigurations) extraConfig;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue