feat(scripts): Unify behaviour and improve generation
All checks were successful
Build all the nodes / bridge01 (push) Successful in 1m17s
Build all the nodes / geo01 (push) Successful in 1m16s
Build all the nodes / geo02 (push) Successful in 1m22s
Build all the nodes / compute01 (push) Successful in 1m38s
Build all the nodes / storage01 (push) Successful in 1m13s
Build all the nodes / rescue01 (push) Successful in 1m22s
Build all the nodes / vault01 (push) Successful in 1m20s
Run pre-commit on all files / check (push) Successful in 24s
Build all the nodes / web01 (push) Successful in 1m46s
Build all the nodes / web02 (push) Successful in 1m6s
Build all the nodes / web03 (push) Successful in 1m9s
All checks were successful
Build all the nodes / bridge01 (push) Successful in 1m17s
Build all the nodes / geo01 (push) Successful in 1m16s
Build all the nodes / geo02 (push) Successful in 1m22s
Build all the nodes / compute01 (push) Successful in 1m38s
Build all the nodes / storage01 (push) Successful in 1m13s
Build all the nodes / rescue01 (push) Successful in 1m22s
Build all the nodes / vault01 (push) Successful in 1m20s
Run pre-commit on all files / check (push) Successful in 24s
Build all the nodes / web01 (push) Successful in 1m46s
Build all the nodes / web02 (push) Successful in 1m6s
Build all the nodes / web03 (push) Successful in 1m9s
This commit is contained in:
parent
2ffd7732ba
commit
6fbda40e5e
6 changed files with 93 additions and 96 deletions
|
@ -114,7 +114,7 @@ in
|
|||
(pkgs.callPackage "${sources.agenix}/pkgs/agenix.nix" { })
|
||||
(pkgs.callPackage "${sources.lon}/nix/packages/lon.nix" { })
|
||||
|
||||
] ++ (import ./scripts { inherit pkgs; });
|
||||
] ++ (pkgs.callPackage ./scripts { });
|
||||
|
||||
shellHook = ''
|
||||
${git-checks.shellHook}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
set -eu -o pipefail
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
shopt -s lastpipe
|
||||
|
||||
drv=$("@colmena@/bin/colmena" eval --instantiate -E "{ nodes, ... }: nodes.${BUILD_NODE}.config.system.build.toplevel")
|
||||
drv=$(colmena eval --instantiate -E "{ nodes, ... }: nodes.${BUILD_NODE}.config.system.build.toplevel")
|
||||
|
||||
# Build the derivation and send it to the great beyond
|
||||
nix-store --query --requisites --force-realise --include-outputs "$drv" | grep -v '.*\.drv' >paths.txt
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
#!@bash@/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
@ -82,19 +78,18 @@ retrieve_current_system () {
|
|||
ssh -n "root@$1" "readlink -f /run/current-system"
|
||||
}
|
||||
|
||||
|
||||
return_status=0
|
||||
echo "$RESULTS" | @jq@/bin/jq -c '.[]' |
|
||||
echo "$RESULTS" | jq -c '.[]' |
|
||||
while IFS=$'\n' read -r c; do
|
||||
|
||||
machine=$(echo "$c" | @jq@/bin/jq -r '.machine')
|
||||
machine=$(echo "$c" | jq -r '.machine')
|
||||
if [[ -n ${node-} ]] && [[ "$machine" != "$node" ]]; then
|
||||
echo "Skipping ${machine}"
|
||||
continue
|
||||
fi
|
||||
expected_path=$(echo "$c" | @jq@/bin/jq -r '.path')
|
||||
domain=$(echo "$c" | @jq@/bin/jq -r '.domain')
|
||||
drv_path=$(echo "$c" | @jq@/bin/jq -r '.drv')
|
||||
expected_path=$(echo "$c" | jq -r '.path')
|
||||
domain=$(echo "$c" | jq -r '.domain')
|
||||
drv_path=$(echo "$c" | jq -r '.drv')
|
||||
|
||||
err=0
|
||||
current_path=$(retrieve_current_system "$domain") || err=1
|
||||
|
@ -109,7 +104,7 @@ while IFS=$'\n' read -r c; do
|
|||
nix-copy-closure --from "root@$domain" "$current_path"
|
||||
nix-store -r "$drv_path"
|
||||
echo "$machine -> error. nvd output:"
|
||||
@nvd@/bin/nvd diff "$expected_path" "$current_path"
|
||||
nvd diff "$expected_path" "$current_path"
|
||||
return_status=1
|
||||
else
|
||||
echo "☠️ $machine -> error:"
|
||||
|
|
|
@ -1,39 +1,34 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
|
||||
# Dependencies
|
||||
colmena,
|
||||
jq,
|
||||
nvd,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
substitutions = {
|
||||
inherit (pkgs)
|
||||
bash
|
||||
inherit (lib) mapAttrsToList;
|
||||
|
||||
scripts = {
|
||||
cache-node = [ colmena ];
|
||||
check-deployment = [
|
||||
colmena
|
||||
coreutils
|
||||
nvd
|
||||
git
|
||||
jq
|
||||
;
|
||||
};
|
||||
|
||||
mkShellScript =
|
||||
name:
|
||||
(pkgs.substituteAll (
|
||||
{
|
||||
inherit name;
|
||||
src = ./. + "/${name}.sh";
|
||||
dir = "/bin/";
|
||||
isExecutable = true;
|
||||
|
||||
checkPhase = ''
|
||||
${pkgs.stdenv.shellDryRun} "$target"
|
||||
'';
|
||||
}
|
||||
// substitutions
|
||||
));
|
||||
|
||||
scripts = [
|
||||
"cache-node"
|
||||
"check-deployment"
|
||||
"launch-vm"
|
||||
"list-nodes"
|
||||
nvd
|
||||
];
|
||||
launch-vm = [ colmena ];
|
||||
list-nodes = [ jq ];
|
||||
};
|
||||
in
|
||||
|
||||
builtins.map mkShellScript scripts
|
||||
mapAttrsToList (
|
||||
name: runtimeInputs:
|
||||
writeShellApplication {
|
||||
inherit name runtimeInputs;
|
||||
|
||||
text = builtins.readFile ./${name}.sh;
|
||||
}
|
||||
) scripts
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#!@bash@/bin/bash
|
||||
# shellcheck shell=bash
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
shopt -s lastpipe
|
||||
|
||||
MACHINE=""
|
||||
HOSTFWD=""
|
||||
|
@ -25,9 +24,12 @@ while getopts 'p:o:h' opt; do
|
|||
done
|
||||
shift "$((OPTIND - 1))"
|
||||
|
||||
if [ -z "$MACHINE" ]; then echo "-o option needed"; exit 1; fi
|
||||
if [ -z "$MACHINE" ]; then
|
||||
echo "-o option needed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DRV_PATH=$(@colmena@/bin/colmena eval --instantiate -E "{nodes, ...}: nodes.$MACHINE.config.system.build.vm")
|
||||
DRV_PATH=$(colmena eval --instantiate -E "{nodes, ...}: nodes.$MACHINE.config.system.build.vm")
|
||||
|
||||
echo "Realising $DRV_PATH"
|
||||
RESULT=$(nix-store -r "$DRV_PATH")
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!@bash@/bin/bash
|
||||
# shellcheck shell=bash
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
shopt -s lastpipe
|
||||
|
||||
cd $(@git@/bin/git rev-parse --show-toplevel)
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
nix-instantiate --strict --eval --json -A nodes | @jq@/bin/jq .
|
||||
nix-instantiate --strict --eval --json -A nodes | jq .
|
||||
|
|
Loading…
Reference in a new issue