about summary refs log tree commit diff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/nixfiles.nix10
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/nixfiles.nix b/packages/nixfiles.nix
index 02e89f2..bfc869a 100644
--- a/packages/nixfiles.nix
+++ b/packages/nixfiles.nix
@@ -26,6 +26,12 @@
     # Hopefully Naïm will not sue me for copyright infrigment.
     text = ''
       nixfiles="''${NIXFILES:-.}"
+      rebuild="nixos-rebuild"
+      rebuild_opts=(--fast --use-remote-sudo)
+      if [[ "$(uname)" == Darwin ]]; then
+          rebuild="darwin-rebuild"
+          rebuild_opts=()
+      fi
       cmd=$1
       shift
       case $cmd in
@@ -108,10 +114,10 @@
               # Assumes that hosts are configured in the OpenSSH configuration.
               host=''${cmd#@}
               hostname=$(ssh -q "$host" 'echo "$HOSTNAME"')
-              exec nixos-rebuild -v --flake "$nixfiles#$hostname" --target-host "$host" --use-remote-sudo --show-trace "$@"
+              exec "$rebuild" -v --flake "$nixfiles#$hostname" --target-host "$host" "''${rebuild_opts[@]}" --show-trace "$@"
               ;;
           *)
-              exec nixos-rebuild -v --fast --flake "$nixfiles" --use-remote-sudo --show-trace "$cmd" "$@"
+              exec "$rebuild" -v --flake "$nixfiles" "''${rebuild_opts[@]}" --show-trace "$cmd" "$@"
               ;;
       esac
     '';

Consider giving Nix/NixOS a try! <3