Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a23a985594bf
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9884cb3ed004
Choose a head ref
  • 4 commits
  • 5 files changed
  • 2 contributors

Commits on Jan 8, 2020

  1. nixos/certmgr: Flip either submodule path type

    For upcoming allowance of paths as submodules
    infinisil committed Jan 8, 2020
    Copy the full SHA
    228a7b1 View commit details
  2. Copy the full SHA
    6525da6 View commit details

Commits on Jan 9, 2020

  1. nixos/doc: Add incompatibility note for either submodule path

    Co-Authored-By: Robert Hensing <roberth@users.noreply.github.com>
    infinisil and roberth committed Jan 9, 2020
    Copy the full SHA
    9d4b59b View commit details

Commits on Jan 12, 2020

  1. Merge pull request #76861 from Infinisil/paths-as-submodules

    lib/types: Allow paths as submodule values
    roberth authored Jan 12, 2020
    Copy the full SHA
    9884cb3 View commit details
Showing with 21 additions and 10 deletions.
  1. +1 −2 lib/tests/modules.sh
  2. +5 −3 lib/types.nix
  3. +3 −3 nixos/doc/manual/development/option-types.xml
  4. +10 −0 nixos/doc/manual/release-notes/rl-2003.xml
  5. +2 −2 nixos/modules/services/security/certmgr.nix
3 changes: 1 addition & 2 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
@@ -174,8 +174,7 @@ checkConfigOutput "true" config.submodule.inner ./declare-submoduleWith-modules.
checkConfigOutput "true" config.submodule.outer ./declare-submoduleWith-modules.nix

## Paths should be allowed as values and work as expected
# Temporarily disabled until https://github.com/NixOS/nixpkgs/pull/76861
#checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix

# Check that disabledModules works recursively and correctly
checkConfigOutput "true" config.enable ./disable-recursive/main.nix
8 changes: 5 additions & 3 deletions lib/types.nix
Original file line number Diff line number Diff line change
@@ -430,14 +430,16 @@ rec {
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);

allModules = defs: modules ++ imap1 (n: { value, file }:
# Annotate the value with the location of its definition for better error messages
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
if isAttrs value || isFunction value then
# Annotate the value with the location of its definition for better error messages
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
else value
) defs;

in
mkOptionType rec {
name = "submodule";
check = x: isAttrs x || isFunction x;
check = x: isAttrs x || isFunction x || path.check x;
merge = loc: defs:
(evalModules {
modules = allModules defs;
6 changes: 3 additions & 3 deletions nixos/doc/manual/development/option-types.xml
Original file line number Diff line number Diff line change
@@ -257,9 +257,9 @@
<listitem>
<para>
A set of sub options <replaceable>o</replaceable>.
<replaceable>o</replaceable> can be an attribute set or a function
returning an attribute set. Submodules are used in composed types to
create modular options. This is equivalent to
<replaceable>o</replaceable> can be an attribute set, a function
returning an attribute set, or a path to a file containing such a value. Submodules are used in
composed types to create modular options. This is equivalent to
<literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
Submodules are detailed in
<xref
10 changes: 10 additions & 0 deletions nixos/doc/manual/release-notes/rl-2003.xml
Original file line number Diff line number Diff line change
@@ -391,6 +391,16 @@ users.users.me =
<link xlink:href="https://github.com/NixOS/nixpkgs/pull/63103">PR #63103</link>.
</para>
</listitem>
<listitem>
<para>
For NixOS modules, the types <literal>types.submodule</literal> and <literal>types.submoduleWith</literal> now support
paths as allowed values, similar to how <literal>imports</literal> supports paths.
Because of this, if you have a module that defines an option of type
<literal>either (submodule ...) path</literal>, it will break since a path
is now treated as the first type instead of the second. To fix this, change
the type to <literal>either path (submodule ...)</literal>.
</para>
</listitem>
</itemizedlist>
</section>

4 changes: 2 additions & 2 deletions nixos/modules/services/security/certmgr.nix
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ in
otherCert = "/var/certmgr/specs/other-cert.json";
}
'';
type = with types; attrsOf (either (submodule {
type = with types; attrsOf (either path (submodule {
options = {
service = mkOption {
type = nullOr str;
@@ -148,7 +148,7 @@ in
description = "certmgr spec request object.";
};
};
}) path);
}));
description = ''
Certificate specs as described by:
<link xlink:href="https://github.com/cloudflare/certmgr#certificate-specs" />