Skip to content

Conversation

mightyiam
Copy link
Contributor

Thaigersprint/thaigersprint-2025#1

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Thaigersprint/thaigersprint-2025#1

Co-authored-by: Jeremy Fleischman <jeremyfleischman@gmail.com>
@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/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Feb 17, 2025
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Diff LGTM but I fail to understand why is that attribute needed.

@mightyiam
Copy link
Contributor Author

Thank you for the review, @drupol. Of course, this is not motivated by need. This is a drive-by PR motivated by my usage of this nix option. Fits in the "nice to have" category. Nix configuration options don't change frequently, so I think we can afford to include options for all of them. But that's obviously not what is implemented here.

'';
};

extra-system-features = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

Given that settings.system-features already will do merge across the whole of the nixos module system, why do we need to document this option?

@Mic92
Copy link
Member

Mic92 commented Feb 18, 2025

Thank you for the review, @drupol. Of course, this is not motivated by need. This is a drive-by PR motivated by my usage of this nix option. Fits in the "nice to have" category. Nix configuration options don't change frequently, so I think we can afford to include options for all of them. But that's obviously not what is implemented here.

Why is it nice to have? What is the use-case in NixOS over just using the system-features option?

@mightyiam
Copy link
Contributor Author

TLDR; I wanted to let the readers of nix.settings.system-features documentation know of extra-system-features and then I took that a step further and created nix.settings.extra-system-features.

Providing a value for nix.settings.system-features overrides its default option value, which is currently a list of several features. To merely add to that list, one can provide the addition features as the value of nix.settings.extra-system-features. To be clear, these are passed to Nix in its configuration file with no further processing. It is Nix that puts the extra ones on top of the base ones.

So, the value of the extra-system-features in NixOS is similar to the upstream Nix option that it represents; being able to merely add on top of system-features. Although I'm not sure what the upstream default value for system-features is.

But that value is already provided by this NixOS module, because nix.settings is freeform. I'm already using nix.settings.extra-system-features myself and I imagine others do, as well. The value suggested by this PR is type checking and documentation. In particular, a user who reads the documentation for nix.settings.system-features and does not know of the existence of the upstream extra-system-features might assume that the only way to add additional features is to do:

nix.settings.system-features = [
  "<explicitly provide>"
  "<the default features>"
  "add-some-feature"
];

which carries the risk of missing out on future default features.

This PR adds a documentation reference from nix.settings.system-features to nix.settings.extra-system-features.

@Mic92
Copy link
Member

Mic92 commented Feb 18, 2025

TLDR; I wanted to let the readers of nix.settings.system-features documentation know of extra-system-features and then I took that a step further and created nix.settings.extra-system-features.

Providing a value for nix.settings.system-features overrides its default option value, which is currently a list of several features. To merely add to that list, one can provide the addition features as the value of nix.settings.extra-system-features. To be clear, these are passed to Nix in its configuration file with no further processing. It is Nix that puts the extra ones on top of the base ones.

So, the value of the extra-system-features in NixOS is similar to the upstream Nix option that it represents; being able to merely add on top of system-features. Although I'm not sure what the upstream default value for system-features is.

But that value is already provided by this NixOS module, because nix.settings is freeform. I'm already using nix.settings.extra-system-features myself and I imagine others do, as well. The value suggested by this PR is type checking and documentation. In particular, a user who reads the documentation for nix.settings.system-features and does not know of the existence of the upstream extra-system-features might assume that the only way to add additional features is to do:

nix.settings.system-features = [
  "<explicitly provide>"
  "<the default features>"
  "add-some-feature"
];

which carries the risk of missing out on future default features.

This PR adds a documentation reference from nix.settings.system-features to nix.settings.extra-system-features.

That reasoning didn't came across when reading the current description. As of now we define both options and it's unclear which one is the right one to use for which use-case. However I am wondering if we should not instead move the default from lib.mkOption to config so that users only need to set to nix.settings.system-features without having to re-set the existing features defined by the default.

@Mic92
Copy link
Member

Mic92 commented Feb 18, 2025

Looks like this is what did this before but it got removed by @ck3d https://github.com/NixOS/nixpkgs/pull/372878/files

@Mic92
Copy link
Member

Mic92 commented Feb 18, 2025

@ck3d your intent from the pull request doesn't seem to match up with the change you did:

Assign default for option system-features at the common place. It allows use to re-use the default value in cause of setting the option.

The former behavior merged existing system-features but now this no longer the case.

@Mic92
Copy link
Member

Mic92 commented Feb 18, 2025

Alternative fix #383052

@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 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/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 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.

3 participants