mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 22:32:58 +03:00
nixos-rebuild: do not depend on nix.conf to activate flakes
This commit is contained in:
parent
e449d07a26
commit
c6a3a0f4f5
@ -521,7 +521,7 @@
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--flake</option> <replaceable>flake-uri</replaceable>[<replaceable>name</replaceable>]
|
||||
<option>--flake</option> <replaceable>flake-uri</replaceable><optional>#<replaceable>name</replaceable></optional>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
@ -17,6 +17,7 @@ showSyntax() {
|
||||
origArgs=("$@")
|
||||
extraBuildFlags=()
|
||||
lockFlags=()
|
||||
flakeFlags=()
|
||||
action=
|
||||
buildNix=1
|
||||
fast=
|
||||
@ -99,6 +100,7 @@ while [ "$#" -gt 0 ]; do
|
||||
;;
|
||||
--flake)
|
||||
flake="$1"
|
||||
flakeFlags=(--experimental-features 'nix-command flakes')
|
||||
shift 1
|
||||
;;
|
||||
--recreate-lock-file|--no-update-lock-file|--no-write-lock-file|--no-registries|--commit-lock-file)
|
||||
@ -281,7 +283,7 @@ fi
|
||||
|
||||
# Resolve the flake.
|
||||
if [[ -n $flake ]]; then
|
||||
flake=$(nix flake info --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url)
|
||||
flake=$(nix "${flakeFlags[@]}" flake info --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url)
|
||||
fi
|
||||
|
||||
# Find configuration.nix and open editor instead of building.
|
||||
@ -290,7 +292,7 @@ if [ "$action" = edit ]; then
|
||||
NIXOS_CONFIG=${NIXOS_CONFIG:-$(nix-instantiate --find-file nixos-config)}
|
||||
exec "${EDITOR:-nano}" "$NIXOS_CONFIG"
|
||||
else
|
||||
exec nix edit "${lockFlags[@]}" -- "$flake#$flakeAttr"
|
||||
exec nix "${flakeFlags[@]}" edit "${lockFlags[@]}" -- "$flake#$flakeAttr"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
@ -416,7 +418,7 @@ if [ -z "$rollback" ]; then
|
||||
pathToConfig="$(nixBuild '<nixpkgs/nixos>' --no-out-link -A system "${extraBuildFlags[@]}")"
|
||||
else
|
||||
outLink=$tmpDir/result
|
||||
nix build "$flake#$flakeAttr.config.system.build.toplevel" \
|
||||
nix "${flakeFlags[@]}" build "$flake#$flakeAttr.config.system.build.toplevel" \
|
||||
"${extraBuildFlags[@]}" "${lockFlags[@]}" --out-link $outLink
|
||||
pathToConfig="$(readlink -f $outLink)"
|
||||
fi
|
||||
@ -426,7 +428,7 @@ if [ -z "$rollback" ]; then
|
||||
if [[ -z $flake ]]; then
|
||||
pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A system -k "${extraBuildFlags[@]}")"
|
||||
else
|
||||
nix build "$flake#$flakeAttr.config.system.build.toplevel" "${extraBuildFlags[@]}" "${lockFlags[@]}"
|
||||
nix "${flakeFlags[@]}" build "$flake#$flakeAttr.config.system.build.toplevel" "${extraBuildFlags[@]}" "${lockFlags[@]}"
|
||||
pathToConfig="$(readlink -f ./result)"
|
||||
fi
|
||||
elif [ "$action" = build-vm ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user