2021-09-25 20:28:25 +02:00
|
|
|
{ pkgs, writeCommand, lib, secrets }:
|
|
|
|
let
|
|
|
|
|
|
|
|
# command that ensures we use flake.nix during switch
|
|
|
|
command = targetPath:
|
|
|
|
let
|
2021-11-01 11:00:53 +01:00
|
|
|
commandLine = "TMPDIR=/tmp nixos-rebuild switch --flake ${targetPath} -L --keep-going";
|
2021-11-01 09:20:42 +01:00
|
|
|
in
|
|
|
|
''
|
2021-09-25 20:28:25 +02:00
|
|
|
echo '${commandLine}'
|
|
|
|
nix-shell \
|
|
|
|
-E "with import <nixpkgs> {}; mkShell { buildInputs = [ git (nixos { nix.package = nixFlakes; }).nixos-rebuild ]; }" \
|
|
|
|
--run '${commandLine}'
|
|
|
|
'';
|
|
|
|
|
|
|
|
source = {
|
2021-10-26 07:54:50 +02:00
|
|
|
secrets.file = {
|
|
|
|
path = "${secrets}/secrets";
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
2021-09-25 20:28:25 +02:00
|
|
|
private_assets.pass = {
|
|
|
|
dir = toString ~/.password-store;
|
|
|
|
name = "krops/private_assets";
|
|
|
|
};
|
2021-10-26 07:54:50 +02:00
|
|
|
assets.file = {
|
|
|
|
path = toString ./assets;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
configs.file = {
|
|
|
|
path = toString ./configs;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
library.file = {
|
|
|
|
path = toString ./library;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
modules.file = {
|
|
|
|
path = toString ./modules;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
pkgs.file = {
|
|
|
|
path = toString ./pkgs;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
system.file = {
|
|
|
|
path = toString ./system;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
"flake.nix".file = {
|
|
|
|
path = toString ./flake.nix;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
|
|
|
"flake.lock".file = {
|
|
|
|
path = toString ./flake.lock;
|
|
|
|
useChecksum = true;
|
|
|
|
};
|
2021-09-25 20:28:25 +02:00
|
|
|
};
|
|
|
|
|
2021-09-25 20:30:49 +02:00
|
|
|
server = { name, host }:
|
|
|
|
let
|
|
|
|
system = writeCommand "/bin/system" {
|
|
|
|
source = lib.evalSource [ source ];
|
|
|
|
force = true;
|
|
|
|
target = lib.mkTarget "root@${host}/var/krops";
|
|
|
|
inherit command;
|
|
|
|
};
|
2021-11-01 09:20:42 +01:00
|
|
|
in
|
|
|
|
{
|
2021-09-25 20:30:49 +02:00
|
|
|
"${name}" = pkgs.writers.writeBashBin name ''
|
|
|
|
echo "deploy system"
|
|
|
|
${system}/bin/system
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-09-25 20:28:25 +02:00
|
|
|
desktop = { name, host }:
|
|
|
|
let
|
|
|
|
system = writeCommand "/bin/system" {
|
|
|
|
source = lib.evalSource [ source ];
|
|
|
|
force = true;
|
|
|
|
target = lib.mkTarget "root@${host}/var/krops";
|
|
|
|
inherit command;
|
|
|
|
};
|
|
|
|
network = writeCommand "/bin/secrets" {
|
|
|
|
source = lib.evalSource [{
|
|
|
|
system-connections.pass = {
|
|
|
|
dir = toString ~/.password-store;
|
|
|
|
name = "krops/desktop_secrets/network-manager/system-connections";
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
force = true;
|
|
|
|
target = lib.mkTarget "root@${host}/etc/NetworkManager";
|
|
|
|
};
|
2021-11-01 09:20:42 +01:00
|
|
|
in
|
|
|
|
{
|
2021-09-26 10:18:18 +02:00
|
|
|
"${name}" = pkgs.writers.writeBashBin "${name}-all" ''
|
2021-09-25 20:28:25 +02:00
|
|
|
echo "deploy network secerts"
|
|
|
|
${network}/bin/secrets
|
|
|
|
echo "deploy system"
|
|
|
|
${system}/bin/system
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-11-01 09:20:42 +01:00
|
|
|
in
|
|
|
|
(desktop {
|
2021-09-25 20:30:49 +02:00
|
|
|
name = "sterni";
|
|
|
|
host = "sterni.private";
|
2021-11-01 09:40:39 +01:00
|
|
|
}) //
|
|
|
|
(desktop {
|
2021-09-25 20:32:19 +02:00
|
|
|
name = "sternchen";
|
|
|
|
host = "sternchen.secret";
|
2021-11-01 09:40:39 +01:00
|
|
|
}) //
|
|
|
|
(server {
|
2021-09-25 20:30:49 +02:00
|
|
|
name = "pepe";
|
|
|
|
host = "pepe.private";
|
2021-11-01 09:40:39 +01:00
|
|
|
}) //
|
|
|
|
(server {
|
2021-09-25 20:30:49 +02:00
|
|
|
name = "workhorse";
|
|
|
|
host = "workhorse.private";
|
2021-11-01 09:40:39 +01:00
|
|
|
}) //
|
|
|
|
(server {
|
2021-09-25 20:30:49 +02:00
|
|
|
name = "sputnik";
|
|
|
|
host = "sputnik.private";
|
|
|
|
})
|