mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
home-manager: Feature test for flake support (#6824)
Feature testing flakes / nix-command is more robust over configuration sniffing. Ultimately, the deciding factor should be if flakes work -- not if the config looks like they will / won't work. This alternative test both asserts that the `nix` command is enabled, and that flakes are enabled, without depending on whether or not flakes are emitted as an experimental feature. This is both repairing support for Determinate Nix 3, and prepares for a potential future where Nix itself considers Flakes stable. Closes #6702
This commit is contained in:
committed by
GitHub
parent
d5cdf55bd9
commit
85c513aa86
@@ -43,13 +43,9 @@ function setWorkDir() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks whether the 'flakes' and 'nix-command' Nix options are enabled.
|
||||
# Check to see if flakes are functionally available.
|
||||
function hasFlakeSupport() {
|
||||
type -p nix > /dev/null \
|
||||
&& nix show-config 2> /dev/null \
|
||||
| grep experimental-features \
|
||||
| grep flakes \
|
||||
| grep -q nix-command
|
||||
nix eval --expr 'builtins.getFlake' > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Escape string for use in Nix files.
|
||||
|
||||
Reference in New Issue
Block a user