Skip to content

nixos-generate-config: Add nixpkgs.hostPlatform to hardware-configuration.nix - #177672

Merged
lovesegfault merged 6 commits into
NixOS:masterfrom
hercules-ci:nixos-generate-config-add-nixpkgs.system
Jun 23, 2022
Merged

lovesegfault merged 6 commits into
NixOS:masterfrom
hercules-ci:nixos-generate-config-add-nixpkgs.system

Conversation

@roberth

@roberth roberth commented Jun 14, 2022

Copy link
Copy Markdown
Member
Description of changes

Resolves #177664

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jun 14, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more correct to set localSystem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, you have a point, but localSystem isn't correct either, when crossSystem is set.
So the thing is, we can't really specify the host system with a single option.

What we want to set is the "host" system.

Variable Meaning when straight Meaning when cross
system host build
localSystem host build
crossSystem null host

So there's no variable for host.

Damn, for a minute I thought this change was going to be simple.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with nixos-generate-config assuming you're not cross-compiling. It can also add a comment to the gen'd code saying "If you're cross-compiling, make sure to set crossSystem", or something like that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've added new options.

Variable Meaning when straight Meaning when cross
hostSystem host host
buildSystem build (=host) build
LEGACY system host build
LEGACY localSystem host build
LEGACY crossSystem null host

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get your message before my previous comment somehow.

I'd be fine with nixos-generate-config assuming you're not cross-compiling. It can also add a comment to the gen'd code saying "If you're cross-compiling, make sure to set crossSystem", or something like that.

The existing options are too complicated and less meaningful than the general / Nixpkgs terminology. We ought to fix that.

I appreciate that you try to reduce scope creep, but in this case doing half the work results in the generation of half-assed config state that resides on user machines. hardware-configuration.nix should either be a legacy one without any nixpkgs.* options, or one with nixpkgs.hostPlatform. Supporting a third variation would be painful.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to change this line after everything else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that you try to reduce scope creep, but in this case doing half the work results in the generation of half-assed config state that resides on user machines. hardware-configuration.nix should either be a legacy one without any nixpkgs.* options, or one with nixpkgs.hostPlatform. Supporting a third variation would be painful.

I was mostly trying to unblock you, without asking you to do a bunch of extra work :)

The existing options are too complicated and less meaningful than the general / Nixpkgs terminology. We ought to fix that.

I agree, excited about the changes you made!

@ofborg ofborg Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jun 14, 2022
@roberth
roberth requested a review from Ericson2314 June 14, 2022 20:38
@roberth
roberth force-pushed the nixos-generate-config-add-nixpkgs.system branch from d170afe to dad484a Compare June 14, 2022 21:27
Comment thread nixos/modules/misc/nixpkgs.nix Resolved
@roberth
roberth force-pushed the nixos-generate-config-add-nixpkgs.system branch from dad484a to 69ff12a Compare June 14, 2022 22:27
Comment thread nixos/modules/misc/nixpkgs.nix Resolved
Comment thread nixos/modules/misc/nixpkgs.nix Resolved
@Ericson2314
Ericson2314 requested a review from alyssais June 15, 2022 05:31
@roberth
roberth force-pushed the nixos-generate-config-add-nixpkgs.system branch from 69ff12a to 0f68d14 Compare June 15, 2022 11:19
@roberth

roberth commented Jun 15, 2022

Copy link
Copy Markdown
Member Author

@ofborg test installer

@lovesegfault lovesegfault left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, a couple of questions:

  1. Shouldn't localSystem get deprecated too?
  2. Add a lib.warn to the deprecated items?
  3. Add something to the release notes?

@github-actions github-actions Bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Jun 16, 2022
@roberth

roberth commented Jun 16, 2022

Copy link
Copy Markdown
Member Author
  1. Shouldn't localSystem get deprecated too?

Kind of. It's bunched in with the other "legacy" options in the assertion the enforces the mutual exclusion of the old and new options.

  1. Add a lib.warn to the deprecated items?

Not yet. The new options need to exist for some time to make it feasible for the ecosystem to start a migration. For now it's only a preview for flakes users and "typical" NixOS users. Deployment tools like NixOps and the numerous other ones can only switch when the new options are supported in all releases. Adding warnings will only upset people.

  1. Add something to the release notes?

Ah yes, of course. Done.


The manual does not need changes yet, because the old way is fully supported. Changes can be made if and when it is decided later that this becomes the blessed way.

@roberth roberth changed the title nixos-generate-config: Add nixpkgs.system to hardware-config.nix nixos-generate-config: Add nixpkgs.hostPlatform to hardware-config.nix Jun 16, 2022
@roberth roberth changed the title nixos-generate-config: Add nixpkgs.hostPlatform to hardware-config.nix nixos-generate-config: Add nixpkgs.hostPlatform to hardware-configuration.nix Jun 16, 2022
@lovesegfault
lovesegfault requested a review from Ericson2314 June 16, 2022 21:27
@lovesegfault

Copy link
Copy Markdown
Member

Sounds good, thanks for this!

@roberth
roberth force-pushed the nixos-generate-config-add-nixpkgs.system branch from 3714d76 to 1b4f4dd Compare June 21, 2022 12:22
The substr solution assumed a newline to be present.
The new solution will not remove the newline if it goes missing in the future.

Apparently this is idiomatic perl.

Thanks pennae for the suggestion!
@roberth

roberth commented Jun 21, 2022

Copy link
Copy Markdown
Member Author

@ofborg test installer

@lovesegfault
lovesegfault merged commit c7eacbf into NixOS:master Jun 23, 2022
@K900

K900 commented Jun 25, 2022

Copy link
Copy Markdown
Contributor

Tests are broken now: https://hydra.nixos.org/build/181556482/nixlog/1

@roberth

roberth commented Jun 25, 2022

Copy link
Copy Markdown
Member Author

What? I ran those tests on ofborg! I guess I'll fix them.

@roberth

roberth commented Jun 25, 2022

Copy link
Copy Markdown
Member Author

This should help with the channel blocker, although ofborg is broken and I can't run the tests locally.
#178958

@roberth

roberth commented Jun 25, 2022

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nixos-generate-config does not set nixpkgs.system (purity, flakes)

4 participants