nixfmt: shell.nix
This commit is contained in:
parent
e09acc8946
commit
fccbc04336
1 changed files with 166 additions and 164 deletions
108
shell.nix
108
shell.nix
|
@ -1,37 +1,36 @@
|
||||||
let
|
let
|
||||||
|
|
||||||
|
#ops = import ../plops ;
|
||||||
#ops = import ../plops ;
|
ops = import ((import <nixpkgs> { }).fetchgit {
|
||||||
ops = import ((import <nixpkgs> {}).fetchgit {
|
|
||||||
url = "https://github.com/mrVanDalo/plops.git";
|
url = "https://github.com/mrVanDalo/plops.git";
|
||||||
rev = "bad0f386afe20cb6a6b8692a3ec365556f8bdabb";
|
rev = "bad0f386afe20cb6a6b8692a3ec365556f8bdabb";
|
||||||
sha256 = "1qfc7kkfg83dy1jliw3afaq7q758b4ybz9md74g5fqpqjdxhxrnw";
|
sha256 = "1qfc7kkfg83dy1jliw3afaq7q758b4ybz9md74g5fqpqjdxhxrnw";
|
||||||
});
|
});
|
||||||
|
|
||||||
lib = ops.lib;
|
lib = ops.lib;
|
||||||
pkgs = ops.pkgs;
|
pkgs = ops.pkgs;
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
|
|
||||||
raspberryNixPkgs = {
|
raspberryNixPkgs = {
|
||||||
nixpkgs.git = {
|
nixpkgs.git = {
|
||||||
ref = (ops.importJson ./.channelRaspberryStable.json).rev;
|
ref = (ops.importJson ./.channelRaspberryStable.json).rev;
|
||||||
url = https://github.com/NixOS/nixpkgs-channels;
|
url = "https://github.com/NixOS/nixpkgs-channels";
|
||||||
};
|
};
|
||||||
nixpkgs-unstable.git = {
|
nixpkgs-unstable.git = {
|
||||||
ref = (ops.importJson ./.channelRaspberryUnstable.json).rev;
|
ref = (ops.importJson ./.channelRaspberryUnstable.json).rev;
|
||||||
url = https://github.com/NixOS/nixpkgs-channels;
|
url = "https://github.com/NixOS/nixpkgs-channels";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixPkgs = {
|
nixPkgs = {
|
||||||
nixpkgs.git = {
|
nixpkgs.git = {
|
||||||
ref = (ops.importJson ./.channelStable.json).rev;
|
ref = (ops.importJson ./.channelStable.json).rev;
|
||||||
url = https://github.com/NixOS/nixpkgs-channels;
|
url = "https://github.com/NixOS/nixpkgs-channels";
|
||||||
};
|
};
|
||||||
nixpkgs-unstable.git = {
|
nixpkgs-unstable.git = {
|
||||||
ref = (ops.importJson ./.channelUnstable.json).rev;
|
ref = (ops.importJson ./.channelUnstable.json).rev;
|
||||||
url = https://github.com/NixOS/nixpkgs-channels;
|
url = "https://github.com/NixOS/nixpkgs-channels";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,41 +72,42 @@ source = {
|
||||||
assets.file = toString ./assets;
|
assets.file = toString ./assets;
|
||||||
|
|
||||||
nix-writers.git = {
|
nix-writers.git = {
|
||||||
url = https://cgit.krebsco.de/nix-writers/;
|
url = "https://cgit.krebsco.de/nix-writers/";
|
||||||
ref = (ops.importJson ./.nix-writers.json).rev;
|
ref = (ops.importJson ./.nix-writers.json).rev;
|
||||||
};
|
};
|
||||||
|
|
||||||
#backup-module.file = toString ~/dev/backup;
|
#backup-module.file = toString ~/dev/backup;
|
||||||
backup-module.git = {
|
backup-module.git = {
|
||||||
url = https://git.ingolf-wagner.de/nix-modules/backup.git;
|
url = "https://git.ingolf-wagner.de/nix-modules/backup.git";
|
||||||
ref = "1.3.3";
|
ref = "1.3.3";
|
||||||
};
|
};
|
||||||
|
|
||||||
#kops-lib.file = toString ~/dev/krops-lib;
|
#kops-lib.file = toString ~/dev/krops-lib;
|
||||||
krops-lib.git = {
|
krops-lib.git = {
|
||||||
url = https://git.ingolf-wagner.de/nix-modules/krops.git;
|
url = "https://git.ingolf-wagner.de/nix-modules/krops.git";
|
||||||
ref = "1.0.2";
|
ref = "1.0.2";
|
||||||
};
|
};
|
||||||
|
|
||||||
#cluster-module.file = toString ~/dev/cluster-module;
|
#cluster-module.file = toString ~/dev/cluster-module;
|
||||||
cluster-module.git = {
|
cluster-module.git = {
|
||||||
url = https://git.ingolf-wagner.de/nix-modules/cluster.git;
|
url = "https://git.ingolf-wagner.de/nix-modules/cluster.git";
|
||||||
ref = "1.2.0";
|
ref = "1.2.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
#home-manager.file = toString ~/dev/home-manager;
|
#home-manager.file = toString ~/dev/home-manager;
|
||||||
home-manager.git = {
|
home-manager.git = {
|
||||||
url = https://github.com/rycee/home-manager.git;
|
url = "https://github.com/rycee/home-manager.git";
|
||||||
ref = "024d1aa227978fe2dae2fb3e56bab9a7237c2401";
|
ref = "024d1aa227978fe2dae2fb3e56bab9a7237c2401";
|
||||||
};
|
};
|
||||||
|
|
||||||
background-image-generators.git = {
|
background-image-generators.git = {
|
||||||
url = https://git.ingolf-wagner.de/nix-modules/background-image-generators.git;
|
url =
|
||||||
|
"https://git.ingolf-wagner.de/nix-modules/background-image-generators.git";
|
||||||
ref = "1.0.0";
|
ref = "1.0.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
cleverca22.git = {
|
cleverca22.git = {
|
||||||
url = https://github.com/mrVanDalo/nixos-configs.git;
|
url = "https://github.com/mrVanDalo/nixos-configs.git";
|
||||||
ref = "76260ad60cd99d40ab25df1400b0663d48e736db";
|
ref = "76260ad60cd99d40ab25df1400b0663d48e736db";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,9 +115,10 @@ source = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
serverDeployment = name: { host ? "${name}.private", user ? "root" }:
|
serverDeployment = name:
|
||||||
|
{ host ? "${name}.private", user ? "root" }:
|
||||||
with ops;
|
with ops;
|
||||||
jobs "deploy-${name}" "${user}@${host}" [
|
jobs "deploy-${name}" "${user}@${host}" [
|
||||||
(populateTmpfs (source.keys name))
|
(populateTmpfs (source.keys name))
|
||||||
|
@ -126,22 +127,19 @@ serverDeployment = name: { host ? "${name}.private", user ? "root" }:
|
||||||
(populate source.modules)
|
(populate source.modules)
|
||||||
(populate source.nixPkgs)
|
(populate source.nixPkgs)
|
||||||
switch
|
switch
|
||||||
];
|
];
|
||||||
|
|
||||||
serverPushSecrets = name: { host ? "${name}.private", user ? "root" }:
|
serverPushSecrets = name:
|
||||||
|
{ host ? "${name}.private", user ? "root" }:
|
||||||
with ops;
|
with ops;
|
||||||
jobs "push-${name}" "${user}@${host}" [
|
jobs "push-${name}" "${user}@${host}" [
|
||||||
(populateTmpfs (source.keys name))
|
(populateTmpfs (source.keys name))
|
||||||
(populate (source.secrets name))
|
(populate (source.secrets name))
|
||||||
];
|
];
|
||||||
|
|
||||||
desktopDeployment = name: {
|
desktopDeployment = name:
|
||||||
host ? "${name}.private",
|
{ host ? "${name}.private", target ? "/var/src/", user ? "root"
|
||||||
target ? "/var/src/",
|
, commandPrefix ? "deploy", enableSwitch ? true }:
|
||||||
user ? "root",
|
|
||||||
commandPrefix ? "deploy",
|
|
||||||
enableSwitch ? true
|
|
||||||
}:
|
|
||||||
with ops;
|
with ops;
|
||||||
jobs "${commandPrefix}-${name}" "${user}@${host}${target}" ([
|
jobs "${commandPrefix}-${name}" "${user}@${host}${target}" ([
|
||||||
(populate (source.secrets name))
|
(populate (source.secrets name))
|
||||||
|
@ -149,52 +147,56 @@ desktopDeployment = name: {
|
||||||
(populate source.modules)
|
(populate source.modules)
|
||||||
(populate source.desktopSecrets)
|
(populate source.desktopSecrets)
|
||||||
(populate source.nixPkgs)
|
(populate source.nixPkgs)
|
||||||
] ++ (if enableSwitch then [ switch ] else [])) ;
|
] ++ (if enableSwitch then [ switch ] else [ ]));
|
||||||
|
|
||||||
cleanupNix = name:
|
cleanupNix = name:
|
||||||
let
|
let
|
||||||
target = {
|
target = {
|
||||||
host = "${name}.private";
|
host = "${name}.private";
|
||||||
user = "root";
|
user = "root";
|
||||||
port = "22";
|
port = "22";
|
||||||
};
|
};
|
||||||
in
|
in pkgs.writers.writeDashBin "clean-${name}" # sh
|
||||||
pkgs.writers.writeDashBin "clean-${name}" /* sh */ ''
|
''
|
||||||
set -eu
|
set -eu
|
||||||
${pkgs.openssh}/bin/ssh \
|
${pkgs.openssh}/bin/ssh \
|
||||||
${target.user}@${target.host} -p ${target.port} \
|
${target.user}@${target.host} -p ${target.port} \
|
||||||
nix-collect-garbage -d
|
nix-collect-garbage -d
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# generate tasks
|
||||||
|
|
||||||
# generate tasks
|
servers = with lib;
|
||||||
|
|
||||||
servers = with lib;
|
|
||||||
let
|
let
|
||||||
serverList = [ "workhorse" "sputnik" "porani" ];
|
serverList = [ "workhorse" "sputnik" "porani" ];
|
||||||
deployments = flip map serverList ( name: serverDeployment name {} );
|
deployments = flip map serverList (name: serverDeployment name { });
|
||||||
secretPushes = flip map serverList ( name: serverPushSecrets name {} );
|
secretPushes = flip map serverList (name: serverPushSecrets name { });
|
||||||
cleanup = flip map serverList ( name: cleanupNix name );
|
cleanup = flip map serverList (name: cleanupNix name);
|
||||||
in
|
in deployments ++ secretPushes ++ cleanup;
|
||||||
deployments ++ secretPushes ++ cleanup;
|
|
||||||
|
|
||||||
desktops = with lib;
|
desktops = with lib;
|
||||||
let
|
let
|
||||||
desktopList = [ "pepe" "workout" "sterni" ];
|
desktopList = [ "pepe" "workout" "sterni" ];
|
||||||
deployments = flip map desktopList (name: desktopDeployment name {} );
|
deployments = flip map desktopList (name: desktopDeployment name { });
|
||||||
cleanup = flip map desktopList ( name: cleanupNix name );
|
cleanup = flip map desktopList (name: cleanupNix name);
|
||||||
install = flip map desktopList (name: desktopDeployment name {
|
install = flip map desktopList (name:
|
||||||
|
desktopDeployment name {
|
||||||
commandPrefix = "install";
|
commandPrefix = "install";
|
||||||
host = "wz7tdziakduqtmqbbt65ttmmj2q23jkjdyeyg2vfwe52vbvsp6tjimqd.onion";
|
host =
|
||||||
|
"wz7tdziakduqtmqbbt65ttmmj2q23jkjdyeyg2vfwe52vbvsp6tjimqd.onion";
|
||||||
target = "/mnt/var/src";
|
target = "/mnt/var/src";
|
||||||
enableSwitch = false;
|
enableSwitch = false;
|
||||||
} );
|
});
|
||||||
in
|
in deployments ++ cleanup ++ install;
|
||||||
deployments ++ cleanup ++ install;
|
|
||||||
|
|
||||||
in
|
in pkgs.mkShell {
|
||||||
pkgs.mkShell {
|
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
servers ++ desktops;
|
servers ++ desktops ++ [
|
||||||
|
(pkgs.writers.writeBashBin "reformat" ''
|
||||||
|
find ${
|
||||||
|
toString ./.
|
||||||
|
} -type f | egrep "nix$" | grep -v wetten | while read line ; do ${pkgs.nixfmt}/bin/nixfmt "$line"; done
|
||||||
|
'')
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue