-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
Typed nixpkgs.config married to NixOS
#57123
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
Changes from all commits
4e99024
fbf0f8d
6d3fb98
7b5b2f1
1ba7e12
2dd1619
a1b8e9e
fba8be4
52e5e07
db77324
c7d13f0
bc61a1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,7 +94,7 @@ rec { | |
|
|
||
|
|
||
| # When adding new types don't forget to document them in | ||
| # nixos/doc/manual/development/option-types.xml! | ||
| # ../nixos/doc/manual/development/option-types.xml! | ||
| types = rec { | ||
| unspecified = mkOptionType { | ||
| name = "unspecified"; | ||
|
|
@@ -291,6 +291,15 @@ rec { | |
| functor = (defaultFunctor name) // { wrapped = elemType; }; | ||
| }; | ||
|
|
||
| # Same as attrsOf, but lazy towards attribute values (at the cost of not supporting mkIf and etc) | ||
| lazyAttrsOf = elemType: attrsOf elemType // { | ||
| merge = loc: defs: zipAttrsWith (name: defs: | ||
| (mergeDefinitions (loc ++ [name]) elemType defs).mergedValue | ||
| ) | ||
| # Push down position info. | ||
| (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs); | ||
| }; | ||
|
|
||
| # List or attribute set of ... | ||
| loaOf = elemType: | ||
| let | ||
|
|
@@ -356,6 +365,30 @@ rec { | |
| functor = (defaultFunctor name) // { wrapped = elemType; }; | ||
| }; | ||
|
|
||
| # A function to something mergeable (i.e., to a monoid). You | ||
| # should use something else. This type is a last resort and should | ||
| # only be used when there is absolutely nothing else you can do. | ||
| # Most uses of this type imply bad design. | ||
| functionTo = elemType: mkOptionType { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to get #44601 moving and merged so it can be used here |
||
| name = "function that evaluates to a(n) ${elemType.name}"; | ||
| check = isFunction; | ||
| merge = loc: defs: | ||
| fnArgs: elemType.merge loc (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs); | ||
| getSubOptions = elemType.getSubOptions; | ||
| getSubModules = elemType.getSubModules; | ||
| substSubModules = m: functionTo (elemType.substSubModules m); | ||
| }; | ||
|
|
||
| # An opaque value. The result of evaluation of an option of this | ||
| # type is a list of { file, value } pairs describing all the | ||
| # values assigned to this option (with corresponding files where | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the complete opposite of opaque? Having access to all assignments is as transparent as can be, nothing gets hidden, maybe it should be called |
||
| # these values were applied). | ||
| opaque = mkOptionType { | ||
| name = "opaque"; | ||
| description = "opaque value"; | ||
| merge = loc: args: args; | ||
| }; | ||
|
|
||
| # A submodule (like typed attribute set). See NixOS manual. | ||
| submodule = opts: | ||
| let | ||
|
|
@@ -368,7 +401,7 @@ rec { | |
| merge = loc: defs: | ||
| let | ||
| coerce = def: if isFunction def then def else { config = def; }; | ||
| modules = opts' ++ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs; | ||
| modules = opts' ++ map (def: { inherit (def) file; imports = [(coerce def.value)]; }) defs; | ||
| in (evalModules { | ||
| inherit modules; | ||
| args.name = last loc; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,42 +6,6 @@ let | |
| cfg = config.nixpkgs; | ||
| opt = options.nixpkgs; | ||
|
|
||
| isConfig = x: | ||
| builtins.isAttrs x || lib.isFunction x; | ||
|
|
||
| optCall = f: x: | ||
| if lib.isFunction f | ||
| then f x | ||
| else f; | ||
|
|
||
| mergeConfig = lhs_: rhs_: | ||
| let | ||
| lhs = optCall lhs_ { inherit pkgs; }; | ||
| rhs = optCall rhs_ { inherit pkgs; }; | ||
| in | ||
| lhs // rhs // | ||
| optionalAttrs (lhs ? packageOverrides) { | ||
| packageOverrides = pkgs: | ||
| optCall lhs.packageOverrides pkgs // | ||
| optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; | ||
| } // | ||
| optionalAttrs (lhs ? perlPackageOverrides) { | ||
| perlPackageOverrides = pkgs: | ||
| optCall lhs.perlPackageOverrides pkgs // | ||
| optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; | ||
| }; | ||
|
|
||
| configType = mkOptionType { | ||
| name = "nixpkgs-config"; | ||
| description = "nixpkgs config"; | ||
| check = x: | ||
| let traceXIfNot = c: | ||
| if c x then true | ||
| else lib.traceSeqN 1 x false; | ||
| in traceXIfNot isConfig; | ||
| merge = args: fold (def: mergeConfig def.value) {}; | ||
| }; | ||
|
|
||
| overlayType = mkOptionType { | ||
| name = "nixpkgs-overlay"; | ||
| description = "nixpkgs overlay"; | ||
|
|
@@ -56,7 +20,8 @@ let | |
| }; | ||
|
|
||
| defaultPkgs = import ../../.. { | ||
| inherit (cfg) config overlays localSystem crossSystem; | ||
| configs = cfg.config; | ||
| inherit (cfg) overlays localSystem crossSystem; | ||
| }; | ||
|
|
||
| finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs; | ||
|
|
@@ -113,7 +78,7 @@ in | |
| '' | ||
| { allowBroken = true; allowUnfree = true; } | ||
| ''; | ||
| type = configType; | ||
| type = types.opaque; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And with such a type, all the values you can set won't be visible in the manual. I really think the whole |
||
| description = '' | ||
| The configuration of the Nix Packages collection. (For | ||
| details, see the Nixpkgs documentation.) It allows you to set | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's worth introducing this confusing and slightly module breaking type (because it makes
mkIf, etc. not work anymore), just to add support for using the slightly deprecatedpackageOverridesas overlays. If people want overlays they can use overlays directly, if the package set they're using doesn't support this then that should be fixed there imo.