Skip to content
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

nixos-option: Fix when using flake based setup #52

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

azuwis
Copy link
Contributor

@azuwis azuwis commented Jul 29, 2024

On NixOS 24.05, nixos-config is not set in NIX_PATH1 in flake based setup , then the expr will cause an error:

$ nix-instantiate --eval --expr 'with import <nixpkgs/lib>; (evalModules {modules = import <nixpkgs/nixos/modules/module-list.nix> ++ [ ];}).config'

...
error: Neither nixpkgs.hostPlatform nor the legacy option nixpkgs.system has been set.
...

Fix it by setting nixpkgs.hostPlatform = builtins.currentSystem.

On NixOS 24.05, `nixos-config` is not set in NIX_PATH[1] in flake based
setup , then the expr will cause an error:

$ nix-instantiate --eval --expr 'with import <nixpkgs/lib>; (evalModules {modules = import <nixpkgs/nixos/modules/module-list.nix> ++ [ ];}).config'
```
...
error: Neither nixpkgs.hostPlatform nor the legacy option nixpkgs.system has been set.
...
```

Fix it by setting `nixpkgs.hostPlatform = builtins.currentSystem`.

[1]: https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/misc/nixpkgs-flake.nix#L97-L102
@SebTM
Copy link
Contributor

SebTM commented Aug 3, 2024

Hey, thanks for the contribution - I can reproduce the issue (unstable) but as I don't use / have experience with nix-instantiate so far I would like to have someone else (using it) giving it a thumb up 🙏🏻

I checked that there is no --impure flag for nix-instantiate so I suspect it to be impure in itself that was my first concern seeing builtins.currentSystem.

@azuwis
Copy link
Contributor Author

azuwis commented Aug 13, 2024

AFAIK nix-instantiate is impure, otherwise import <nixpkgs/lib> will not work in the original code.

@SebTM SebTM merged commit 7558fc9 into nix-community:master Aug 14, 2024
2 checks passed
@SebTM
Copy link
Contributor

SebTM commented Aug 14, 2024

Merged, let's see if some issues get raised or it will be included in the next release as it's only a small change :)

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.

2 participants