Rework build-flakes script
Some checks failed
Run nix flake check / flake-check (push) Has been cancelled
Some checks failed
Run nix flake check / flake-check (push) Has been cancelled
This commit is contained in:
parent
77d1782f36
commit
dd255955ca
@ -8,21 +8,7 @@ let
|
|||||||
nixos-rebuild
|
nixos-rebuild
|
||||||
jq
|
jq
|
||||||
];
|
];
|
||||||
text = ''
|
text = builtins.readFile ./build-flakes.sh;
|
||||||
cd /root/nixos-servers
|
|
||||||
git pull
|
|
||||||
echo "Starting nixos-servers builds"
|
|
||||||
for host in $(nix flake show --json| jq -r '.nixosConfigurations | keys[]'); do
|
|
||||||
echo "Building $host"
|
|
||||||
nixos-rebuild --verbose -L --flake ".#$host" build
|
|
||||||
done
|
|
||||||
echo "All nixos-servers builds complete"
|
|
||||||
|
|
||||||
echo "Building gunter"
|
|
||||||
cd /root/nixos
|
|
||||||
git pull
|
|
||||||
nixos-rebuild --verbose -L --flake ".#gunter" build
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
48
services/nix-cache/build-flakes.sh
Normal file
48
services/nix-cache/build-flakes.sh
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
JOB_NAME="build_flakes"
|
||||||
|
|
||||||
|
cd /root/nixos-servers
|
||||||
|
git pull
|
||||||
|
echo "Starting nixos-servers builds"
|
||||||
|
for host in $(nix flake show --json| jq -r '.nixosConfigurations | keys[]'); do
|
||||||
|
echo "Building $host"
|
||||||
|
nixos-rebuild --verbose -L --flake ".#$host" build
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Build failed for $host"
|
||||||
|
cat <<EOF | curl --data-binary @- "https://pushgw.home.2rjus.net/metrics/job/$JOB_NAME"
|
||||||
|
# TYPE build_flakes_error gauge
|
||||||
|
# HELP build_flakes_error 0 if the build was successful, 1 if it failed
|
||||||
|
build_flakes_error{instance="$HOSTNAME", host="$host"} 1
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "Build successful for $host"
|
||||||
|
cat <<EOF | curl --data-binary @- "https://pushgw.home.2rjus.net/metrics/job/$JOB_NAME"
|
||||||
|
# TYPE build_flakes_error gauge
|
||||||
|
# HELP build_flakes_error 0 if the build was successful, 1 if it failed
|
||||||
|
build_flakes_error{instance="$HOSTNAME", host="$host"} 0
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "All nixos-servers builds complete"
|
||||||
|
|
||||||
|
echo "Building gunter"
|
||||||
|
cd /root/nixos
|
||||||
|
git pull
|
||||||
|
host="gunter"
|
||||||
|
nixos-rebuild --verbose -L --flake ".#gunter" build
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Build failed for $host"
|
||||||
|
cat <<EOF | curl --data-binary @- "https://pushgw.home.2rjus.net/metrics/job/$JOB_NAME"
|
||||||
|
# TYPE build_flakes_error gauge
|
||||||
|
# HELP build_flakes_error 0 if the build was successful, 1 if it failed
|
||||||
|
build_flakes_error{instance="$HOSTNAME", host="gunter"} 1
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "Build successful for $host"
|
||||||
|
cat <<EOF | curl --data-binary @- "https://pushgw.home.2rjus.net/metrics/job/$JOB_NAME"
|
||||||
|
# TYPE build_flakes_error gauge
|
||||||
|
# HELP build_flakes_error 0 if the build was successful, 1 if it failed
|
||||||
|
build_flakes_error{instance="$HOSTNAME", host="gunter"} 0
|
||||||
|
EOF
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user