73 lines
1.8 KiB
Nix
73 lines
1.8 KiB
Nix
{ 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;
|
|
assets.file = toString ./assets;
|
|
generated.file = toString ./generated;
|
|
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:
|
|
{ user, host, ... }:
|
|
with ops;
|
|
jobs "deploy-${name}" "${user}@${host}" [
|
|
(populate (source.system name))
|
|
(populate source.nixPkgs)
|
|
(populate source.modules)
|
|
switch
|
|
];
|
|
|
|
moshServer = name:
|
|
{ user, host, ... }:
|
|
pkgs.writers.writeDashBin "mosh-${name}" ''
|
|
${pkgs.mosh}/bin/mosh \
|
|
--ssh="${pkgs.openssh}/bin/ssh -F ${
|
|
toString ./generated/ssh-configuration
|
|
}" \
|
|
"${user}@${host}"
|
|
'';
|
|
|
|
in pkgs.mkShell {
|
|
buildInputs = lib.mapAttrsToList deployServer servers
|
|
++ mapAttrsToList moshServer servers;
|
|
|
|
}
|