2022-08-02 19:01:17 +00:00
#!/usr/bin/env fish
2023-06-23 18:08:22 +00:00
set -f nix_os (uname)
set -f nix_hostname (hostname -s)
2023-06-24 18:19:50 +00:00
set -f other_hostname $argv[1]
2022-08-02 19:01:17 +00:00
2023-06-23 18:08:22 +00:00
switch $nix_os
2022-08-02 19:01:17 +00:00
case Darwin
2023-05-04 09:14:12 +00:00
set -f config_dir "$HOME/.config/nixpkgs"
2022-08-02 19:01:17 +00:00
case Linux
2023-05-04 09:14:12 +00:00
set -f config_dir /etc/nixos
2022-08-02 19:01:17 +00:00
case '*'
echo "Unsupported OS"
exit 1
end
pushd "$config_dir"
rm -rf result
2023-07-28 23:53:37 +00:00
if test -z "$DIRENV_DIR"
eval (direnv export fish 2>/dev/null)
end
2023-06-24 18:19:50 +00:00
if test "$other_hostname" = ""
switch $nix_os
case Darwin
git pull
nom build ".#darwinConfigurations.$nix_hostname.config.system.build.toplevel"
2023-06-28 18:16:02 +00:00
if test $status -eq 0
env TERM=xterm-256color darwin-rebuild switch --flake ".#$nix_hostname"
end
2023-06-24 18:19:50 +00:00
case Linux
sudo git pull
sudo nixos-rebuild switch --flake .
end
else
git pull
2024-07-23 20:03:30 +00:00
nom build --eval-store auto --store "ssh-ng://$other_hostname.ts.kempkens.network" ".#nixosConfigurations.$other_hostname.config.system.build.toplevel"
if test $status -eq 0
deploy --skip-checks ".#$other_hostname"
end
2022-08-02 19:01:17 +00:00
end
2023-06-25 17:16:26 +00:00
if test $status -eq 0
if test "$other_hostname" = ""
attic push nifoc-systems /run/current-system
else
ssh -t "$other_hostname" attic push nifoc-systems /run/current-system
end
end
2023-03-20 12:48:37 +00:00
rm -f result
2022-08-09 16:30:54 +00:00
2022-08-02 19:01:17 +00:00
popd