nixos-config/terranix/tinc-test/02-build/shell.nix
Ingolf Wagner 973e3b3305
reformat
2021-11-01 19:30:41 +01:00

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