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

nixpkgs module: Fix defaulting of localSystem and system #40708

Merged
merged 1 commit into from May 31, 2018

Conversation

Ericson2314
Copy link
Member

Motivation for this change

My c6f7d43 made the mistake of not
having enough defaults. Now both variables are default as the explicit
value of the other, or a fallback. The fallback of system is the
default of localSystem.system. The fallback of localSystem is not
the other default (projected), as that would cause a cycle, but { system = builtins.currentTime; } just as nixpkgs itself does it.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

CC @ElvishJerricco

My c6f7d43 made the mistake of not
having enough defaults. Now both variables are default as the *explicit*
value of the other, or a fallback. The fallback of `system` is the
default of `localSystem.system`. The fallback of `localSystem` is not
the other default (projected), as that would cause a cycle, but `{
system = builtins.currentTime; }` just as nixpkgs itself does it.
@dtzWill
Copy link
Member

dtzWill commented May 18, 2018

{ system = builtins.currentTime; }

😲

@dtzWill
Copy link
Member

dtzWill commented May 18, 2018

Also I'm super excited to test this, thanks!! (but not sure when I'll get to it... hopefully soon!)

@matthewbauer matthewbauer merged commit e754f60 into NixOS:master May 31, 2018
@Ericson2314 Ericson2314 deleted the nixos-nixpkgs-defaults branch May 31, 2018 20:47
Ericson2314 added a commit to obsidiansystems/nixpkgs that referenced this pull request Sep 7, 2018
Take two of NixOS#40708 (4fe2898).

That PR attempted to bidirectionally default `config.nixpkgs.system` and
`config.nixpkgs.localSystem.system` to each be updated by the other. But
this is not possible with the way the module system works. Divergence in
certain cases in inevitable.

This PR is more conservative and just has `system` default `localSystem`
and `localSystem` make the final call as-is. This solves a number of
issues.

 - `localSystem` completely overrides `system`, just like with nixpkgs
 proper. There is no need to specify `localSystem.system` to clobber the
 old system.

 - `config.nixpkgs.localSystem` is exactly what is passed to nixpkgs. No
 spooky steps.

 - `config.nixpkgs.localSystem` is elaborated just as nixpkgs would so
 that all attributes are available, not just the ones the user
 specified.

The remaining issue is just that `config.nixpkgs.system` doesn't update
based on `config.nixpkgs.localSystem.system`. It should never be
referred to lest it is a bogus stale value because
`config.nixpkgs.localSystem` overwrites it.

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

Successfully merging this pull request may close these issues.

None yet

4 participants