Skip to content

nixos/nixpkgs: Properly validate and merge nixpkgs config#272686

Open
dasJ wants to merge 2 commits intoNixOS:masterfrom
helsinki-systems:feat/type-nixpkgs-config
Open

nixos/nixpkgs: Properly validate and merge nixpkgs config#272686
dasJ wants to merge 2 commits intoNixOS:masterfrom
helsinki-systems:feat/type-nixpkgs-config

Conversation

@dasJ
Copy link
Member

@dasJ dasJ commented Dec 7, 2023

Description of changes

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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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.

dasJ added 2 commits December 7, 2023 14:41
This allows proper merging, especially with the next commit in mind.
This uses nixpkgs config as a submodule rather than a custom merging
function. This has the benefit of proper merge functions (like listOf)
in configuration options rather than the `recursiveUpdate` with the
hacked-in two lists of packages.
@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 Dec 7, 2023
@dasJ dasJ requested a review from 0x4A6F December 7, 2023 13:50
{ allowBroken = true; allowUnfree = true; }
'';
type = configType;
type = types.submodule ../../../pkgs/top-level/config.nix;
Copy link
Member

Choose a reason for hiding this comment

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

I'm debating whether it should be this or types.deferredModule, ie pass a whole unevaluated (sub)module to Nixpkgs, and therefore also, make the Nixpkgs entrypoint accept a module for config.

The latter is somewhat more in the spirit of turning the "Nixpkgs invocation interface" entirely into a module, which is an admittedly unclear goal of #231940.

@infinisil
Copy link
Member

allowUnfreePredicate should have a better type:

# configuration.nix
{ lib, ... }: {
  imports = [
    {
      nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
        "zsh-abbr"
      ];
    }
    {
      nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
        "slack"
      ];
    }
  ];
}
$ nix-instantiate --eval nixos --arg configuration ./configuration.nix -A config.nixpkgs.config.allowUnfreePredicate
<LAMBDA>

$ gh pr checkout https://github.com/NixOS/nixpkgs/pull/272686
Switched to branch 'feat/type-nixpkgs-config'

$ nix-instantiate --eval nixos --arg configuration ./configuration.nix -A config.nixpkgs.config.allowUnfreePredicate
error: The option `nixpkgs.config.allowUnfreePredicate' is defined multiple times while it's expected to be unique.

Definition values:
- In `/home/tweagysil/src/nixpkgs/main/configuration.nix': <function>
- In `/home/tweagysil/src/nixpkgs/main/configuration.nix': <function>
Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

@roberth
Copy link
Member

roberth commented Dec 7, 2023

Haskell would call that Any, which adds "or" monoid semantics to Bool. Just a mergeable bool type.
Let's keep something more recognizable in the name though.
functionTo boolOr?
functionTo boolWithOr?
functionTo disjunction?
functionTo disjunctiveBool?
functionTo anyBool?

@infinisil infinisil mentioned this pull request Dec 7, 2023
2 tasks
@infinisil
Copy link
Member

infinisil commented Dec 7, 2023

#272764

Edit: Now merged, lib.types.boolByOr can (and should) now be used for the allowedInsecurePredicate and allowedUnfreePredicate options :)

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 3, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 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/`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants