nixfmt: shell.nix

This commit is contained in:
Ingolf Wagner 2019-12-20 17:52:19 +13:00
parent e09acc8946
commit fccbc04336
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -1,6 +1,5 @@
let
#ops = import ../plops ;
ops = import ((import <nixpkgs> { }).fetchgit {
url = "https://github.com/mrVanDalo/plops.git";
@ -16,22 +15,22 @@ source = {
raspberryNixPkgs = {
nixpkgs.git = {
ref = (ops.importJson ./.channelRaspberryStable.json).rev;
url = https://github.com/NixOS/nixpkgs-channels;
url = "https://github.com/NixOS/nixpkgs-channels";
};
nixpkgs-unstable.git = {
ref = (ops.importJson ./.channelRaspberryUnstable.json).rev;
url = https://github.com/NixOS/nixpkgs-channels;
url = "https://github.com/NixOS/nixpkgs-channels";
};
};
nixPkgs = {
nixpkgs.git = {
ref = (ops.importJson ./.channelStable.json).rev;
url = https://github.com/NixOS/nixpkgs-channels;
url = "https://github.com/NixOS/nixpkgs-channels";
};
nixpkgs-unstable.git = {
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;
nix-writers.git = {
url = https://cgit.krebsco.de/nix-writers/;
url = "https://cgit.krebsco.de/nix-writers/";
ref = (ops.importJson ./.nix-writers.json).rev;
};
#backup-module.file = toString ~/dev/backup;
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";
};
#kops-lib.file = toString ~/dev/krops-lib;
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";
};
#cluster-module.file = toString ~/dev/cluster-module;
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";
};
#home-manager.file = toString ~/dev/home-manager;
home-manager.git = {
url = https://github.com/rycee/home-manager.git;
url = "https://github.com/rycee/home-manager.git";
ref = "024d1aa227978fe2dae2fb3e56bab9a7237c2401";
};
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";
};
cleverca22.git = {
url = https://github.com/mrVanDalo/nixos-configs.git;
url = "https://github.com/mrVanDalo/nixos-configs.git";
ref = "76260ad60cd99d40ab25df1400b0663d48e736db";
};
@ -117,7 +117,8 @@ source = {
};
serverDeployment = name: { host ? "${name}.private", user ? "root" }:
serverDeployment = name:
{ host ? "${name}.private", user ? "root" }:
with ops;
jobs "deploy-${name}" "${user}@${host}" [
(populateTmpfs (source.keys name))
@ -128,20 +129,17 @@ serverDeployment = name: { host ? "${name}.private", user ? "root" }:
switch
];
serverPushSecrets = name: { host ? "${name}.private", user ? "root" }:
serverPushSecrets = name:
{ host ? "${name}.private", user ? "root" }:
with ops;
jobs "push-${name}" "${user}@${host}" [
(populateTmpfs (source.keys name))
(populate (source.secrets name))
];
desktopDeployment = name: {
host ? "${name}.private",
target ? "/var/src/",
user ? "root",
commandPrefix ? "deploy",
enableSwitch ? true
}:
desktopDeployment = name:
{ host ? "${name}.private", target ? "/var/src/", user ? "root"
, commandPrefix ? "deploy", enableSwitch ? true }:
with ops;
jobs "${commandPrefix}-${name}" "${user}@${host}${target}" ([
(populate (source.secrets name))
@ -158,15 +156,14 @@ cleanupNix = name:
user = "root";
port = "22";
};
in
pkgs.writers.writeDashBin "clean-${name}" /* sh */ ''
in pkgs.writers.writeDashBin "clean-${name}" # sh
''
set -eu
${pkgs.openssh}/bin/ssh \
${target.user}@${target.host} -p ${target.port} \
nix-collect-garbage -d
'';
# generate tasks
servers = with lib;
@ -175,26 +172,31 @@ servers = with lib;
deployments = flip map serverList (name: serverDeployment name { });
secretPushes = flip map serverList (name: serverPushSecrets name { });
cleanup = flip map serverList (name: cleanupNix name);
in
deployments ++ secretPushes ++ cleanup;
in deployments ++ secretPushes ++ cleanup;
desktops = with lib;
let
desktopList = [ "pepe" "workout" "sterni" ];
deployments = flip map desktopList (name: desktopDeployment name { });
cleanup = flip map desktopList (name: cleanupNix name);
install = flip map desktopList (name: desktopDeployment name {
install = flip map desktopList (name:
desktopDeployment name {
commandPrefix = "install";
host = "wz7tdziakduqtmqbbt65ttmmj2q23jkjdyeyg2vfwe52vbvsp6tjimqd.onion";
host =
"wz7tdziakduqtmqbbt65ttmmj2q23jkjdyeyg2vfwe52vbvsp6tjimqd.onion";
target = "/mnt/var/src";
enableSwitch = false;
});
in
deployments ++ cleanup ++ install;
in deployments ++ cleanup ++ install;
in
pkgs.mkShell {
in pkgs.mkShell {
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
'')
];
}