From 9d8ce77eaa0d207f0d3e96606dc44abc4e8e0ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 4 Sep 2022 13:04:56 +0200 Subject: [PATCH] nixos-rebuild: use nom if available in PATH --- .../linux/nixos-rebuild/nixos-rebuild.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh index 2051368a49f64c..395a54819e5417 100755 --- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh +++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh @@ -14,6 +14,10 @@ showSyntax() { exit 1 } +nom=nix +if type -p nom &>/dev/null; then + nom=nom +fi # Parse the command line. origArgs=("$@") @@ -236,7 +240,7 @@ nixBuild() { logVerbose "Building in legacy (non-flake) mode." if [ -z "$buildHost" ]; then logVerbose "No --build-host given, running nix-build locally" - runCmd nix-build "$@" + runCmd $nom-build "$@" else logVerbose "buildHost set to \"$buildHost\", running nix-build remotely" local instArgs=() @@ -284,10 +288,10 @@ nixFlakeBuild() { logVerbose "Building in flake mode." if [[ -z "$buildHost" && -z "$targetHost" && "$action" != switch && "$action" != boot && "$action" != test && "$action" != dry-activate ]] then - runCmd nix "${flakeFlags[@]}" build "$@" + runCmd $nom build "${flakeFlags[@]}" "$@" readlink -f ./result elif [ -z "$buildHost" ]; then - runCmd nix "${flakeFlags[@]}" build "$@" --out-link "${tmpDir}/result" + runCmd $nom build "${flakeFlags[@]}" "$@" --out-link "${tmpDir}/result" readlink -f "${tmpDir}/result" else local attr="$1" @@ -426,11 +430,11 @@ trap cleanup EXIT # Re-execute nixos-rebuild from the Nixpkgs tree. if [[ -z $_NIXOS_REBUILD_REEXEC && -n $canRun && -z $fast ]]; then if [[ -z $flake ]]; then - if p=$(runCmd nix-build --no-out-link --expr 'with import {}; config.system.build.nixos-rebuild' "${extraBuildFlags[@]}"); then + if p=$(runCmd $nom-build --no-out-link --expr 'with import {}; config.system.build.nixos-rebuild' "${extraBuildFlags[@]}"); then SHOULD_REEXEC=1 fi else - runCmd nix "${flakeFlags[@]}" build --out-link "${tmpDir}/nixos-rebuild" "$flake#$flakeAttr.config.system.build.nixos-rebuild" "${extraBuildFlags[@]}" "${lockFlags[@]}" + runCmd $nom build "${flakeFlags[@]}" --out-link "${tmpDir}/nixos-rebuild" "$flake#$flakeAttr.config.system.build.nixos-rebuild" "${extraBuildFlags[@]}" "${lockFlags[@]}" if p=$(readlink -e "${tmpDir}/nixos-rebuild"); then SHOULD_REEXEC=1 fi