2020-01-06 06:37:25 +01:00
|
|
|
{ pkgs ? import <nixpkgs> { } }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
ops = let
|
|
|
|
opsImport = import ((import <nixpkgs> { }).fetchgit {
|
|
|
|
url = "https://github.com/mrVanDalo/plops.git";
|
|
|
|
rev = "9fabba016a3553ae6e13d5d17d279c4de2eb00ad";
|
|
|
|
sha256 = "193pajq1gcd9jyd12nii06q1sf49xdhbjbfqk3lcq83s0miqfs63";
|
|
|
|
});
|
|
|
|
overlay = self: super: {
|
|
|
|
# overwrite ssh to use the generated ssh configuration
|
|
|
|
openssh = super.writers.writeBashBin "ssh" ''
|
|
|
|
${super.openssh}/bin/ssh -F ${
|
|
|
|
toString ./generated/ssh-configuration
|
|
|
|
} "$@"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in opsImport { overlays = [ overlay ]; };
|
|
|
|
|
|
|
|
lib = ops.lib;
|
|
|
|
pkgs = ops.pkgs;
|
|
|
|
|
|
|
|
source = {
|
|
|
|
|
|
|
|
nixPkgs.nixpkgs.git = {
|
|
|
|
ref = "nixos-19.09";
|
|
|
|
url = "https://github.com/NixOS/nixpkgs-channels";
|
|
|
|
};
|
|
|
|
|
|
|
|
system = name: {
|
|
|
|
configs.file = toString ./configs;
|
2020-01-07 05:47:25 +01:00
|
|
|
test-assets.file = toString ./assets;
|
|
|
|
test-generated.file = toString ./generated;
|
2020-01-06 06:37:25 +01:00
|
|
|
nixos-config.symlink = "configs/${name}/configuration.nix";
|
|
|
|
};
|
|
|
|
|
|
|
|
modules.cluster-module.git = {
|
|
|
|
url = "https://git.ingolf-wagner.de/nix-modules/cluster.git";
|
|
|
|
ref = "1.2.0";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
servers = import ./generated/nixos-machines.nix;
|
|
|
|
|
|
|
|
deployServer = name:
|
2020-01-07 05:47:25 +01:00
|
|
|
{ user ? "root", host, ... }:
|
2020-01-06 06:37:25 +01:00
|
|
|
with ops;
|
2020-01-07 05:47:25 +01:00
|
|
|
jobs "deploy-${name}" "${user}@${host.ipv4}" [
|
2020-01-06 06:37:25 +01:00
|
|
|
(populate (source.system name))
|
|
|
|
(populate source.nixPkgs)
|
|
|
|
(populate source.modules)
|
|
|
|
switch
|
|
|
|
];
|
|
|
|
|
|
|
|
moshServer = name:
|
2020-01-07 05:47:25 +01:00
|
|
|
{ user ? "root", host, ... }:
|
2020-01-06 06:37:25 +01:00
|
|
|
pkgs.writers.writeDashBin "mosh-${name}" ''
|
|
|
|
${pkgs.mosh}/bin/mosh \
|
|
|
|
--ssh="${pkgs.openssh}/bin/ssh -F ${
|
|
|
|
toString ./generated/ssh-configuration
|
|
|
|
}" \
|
2020-01-07 05:47:25 +01:00
|
|
|
"${user}@${host.ipv4}"
|
2020-01-06 06:37:25 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
in pkgs.mkShell {
|
|
|
|
buildInputs = lib.mapAttrsToList deployServer servers
|
|
|
|
++ mapAttrsToList moshServer servers;
|
|
|
|
|
|
|
|
}
|