diff --git a/bij.sh b/bij.sh index e2e681e..8c5b100 100755 --- a/bij.sh +++ b/bij.sh @@ -43,6 +43,8 @@ if [[ -z ${FLAKE} ]]; then FLAKE="$(pwd)" fi +FLAKE_STORE_PATH="$(nix flake archive --json "${FLAKE}" | jq -r .path)" + if [[ "${#ARGS[@]}" -lt 1 ]]; then echo "Command not specified" exit 1 @@ -62,15 +64,15 @@ HOST="${ARGS[1]}" if [[ -z ${TARGET} ]]; then # Use fqdn as target - TARGET="$(nix --extra-experimental-features "nix-command flakes" eval --raw "${FLAKE}#nixosConfigurations.${HOST}" --apply "host: host.config.networking.fqdn")" + TARGET="$(nix --extra-experimental-features "nix-command flakes" eval --raw "${FLAKE_STORE_PATH}#nixosConfigurations.${HOST}" --apply "host: host.config.networking.fqdn")" fi case "${COMMAND}" in apply) - nixos-rebuild switch --flake "${FLAKE}#${HOST}" --target-host "${TARGET}" --use-substitutes --use-remote-sudo + nixos-rebuild switch --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" --use-substitutes --use-remote-sudo ;; build) - nixos-rebuild build --flake "${FLAKE}#${HOST}" + nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}" ;; exec) # shellcheck disable=SC2029 diff --git a/flake.nix b/flake.nix index ddf36da..c51da55 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ name = "bij"; text = builtins.readFile ./bij.sh; runtimeInputs = with pkgs; [ + jq ]; }; default = bij;