nixos-config/terranix/tinc-test/02-build/shell.nix

74 lines
1.8 KiB
Nix
Raw Normal View History

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;
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:
{ user ? "root", host, ... }:
2020-01-06 06:37:25 +01:00
with ops;
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:
{ 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
}" \
"${user}@${host.ipv4}"
2020-01-06 06:37:25 +01:00
'';
in pkgs.mkShell {
buildInputs = lib.mapAttrsToList deployServer servers
++ mapAttrsToList moshServer servers;
}