Skip to content

nh: validate nix features & version #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 8, 2025
Merged

nh: validate nix features & version #277

merged 4 commits into from
May 8, 2025

Conversation

NotAShelf
Copy link
Collaborator

Isolated from #258. We now check for a minimum Nix version (should be equal to nixVersions.latest from the stable branch) and required Nix features (flakes and nix-command) as a part of our startup checks, which previously only checked for NH_FLAKE or/and FLAKE being set. This also moves the checks out of main and to a dedicated module for future maintainability reasons.

Closes #237

@NotAShelf
Copy link
Collaborator Author

@drupol (pinging as the other nh maintainer)

This new change causes fixupPhase to fail during nix build because the testing sendbox does not have the required features check. Do you think we can set the required variables (or disable the check via NH_NO_CHECKS) only during build? env.NH_NO_CHECKS would do for suppressing the warning, but I believe that'll disable the functionality entirely even after build.

@drupol
Copy link

drupol commented May 8, 2025

Hello,

I don't have a strong opinion on this yet, do what you think is better, and ping me when it's done, I'll have a look.

@NotAShelf
Copy link
Collaborator Author

Apparently the checks were failing because we ran installations in preFixup. Moving those to postInstall appears to have fixed the build fail.

@NotAShelf NotAShelf merged commit d36ff53 into master May 8, 2025
4 checks passed
@andersk
Copy link

andersk commented May 30, 2025

This does not work with Determinate Nix, for which nix-command and flakes are not considered experimental (even if explicitly listed in extra-experimental-features).

$ nix --version
nix (Determinate Nix 3.6.1) 2.29.0
$ cat ~/.config/nix/nix.conf 
# WARNING: this file is generated from the nix.settings option in
# your Home Manager configuration at $XDG_CONFIG_HOME/nix/nix.conf.
# Do not edit it!
extra-experimental-features = nix-command flakes
extra-substituters = https://nix-community.cachix.org
extra-trusted-public-keys = nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
$ nix config show experimental-features

$ nh home switch .
! Missing required Nix features: nix-command, flakes (nh/src/checks.rs:101)
Error: 
   0: Missing required experimental features. Please enable: nix-command, flakes

Location:
   src/checks.rs:105

@NotAShelf
Copy link
Collaborator Author

We only support mainsteam Nix, and Lix to a degree.

@viperML
Copy link
Collaborator

viperML commented May 31, 2025

It shouldn't be too hard to support Dix for this. In any case we won't try too hard to support Dix if it start to diverge too mucho from Nix for other things...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nh <cmd> repl does not work
4 participants