[flake] Add some scripts

This commit is contained in:
Malte Tammena 2022-01-14 18:10:58 +01:00
parent fd7550b7f1
commit 52ecc4cd5f

View file

@ -334,12 +334,30 @@
sudo ${nixos-rebuild}/bin/nixos-rebuild $1 --flake .
'')
(with pkgs;
writeScriptBin "all-hosts" ''
nix eval --json .#nixosConfigurations --apply builtins.attrNames 2>/dev/null | jq -r .[]
'')
(with pkgs;
writeScriptBin "option" ''
host=$1
option=$2
nix eval .#nixosConfigurations.$host.config.$option 2>/dev/null
'')
(with pkgs;
writeScriptBin "hm-option" ''
host=$1
option=$2
user=$3
if [[ -z $user ]]; then
user=$USER
fi
nix eval .#nixosConfigurations.$host.config.home-manager.users.$user.$option 2>/dev/null
'')
(with pkgs;
writeScriptBin "test-config" ''
#!${stdenv.shell}
hosts=$(nix eval --json .#nixosConfigurations --apply builtins.attrNames | jq -r .[])
for host in $hosts; do
for host in $(all-hosts); do
echo == Checking ''${host}..
nixos-rebuild --flake .#$host dry-build 2> /tmp/build-output
if [[ $? -ne 0 ]]; then