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: bdfb1bd01b2d
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f08e3e38d4bf
Choose a head ref

Commits on Dec 5, 2019

  1. heimer: init at 1.11.0

    dtzWill committed Dec 5, 2019
    Copy the full SHA
    c431073 View commit details
  2. heimer: 1.11.0 -> 1.12.0

    dtzWill committed Dec 5, 2019
    Copy the full SHA
    6e7d5a7 View commit details
  3. heimer: meta

    dtzWill committed Dec 5, 2019
    Copy the full SHA
    dd6e506 View commit details
  4. lib/modules: file -> _file for a more idempotent unifyModuleSyntax

    This will be useful for doing more complicated module evaluations
    infinisil committed Dec 5, 2019
    Copy the full SHA
    aa61342 View commit details
  5. lib/modules: Make unifyModuleSyntax fully idempotent

    Because why not
    infinisil committed Dec 5, 2019
    Copy the full SHA
    3cc77ce View commit details

Commits on Dec 8, 2019

  1. netdata: 1.18.1 -> 1.19.0

    Izorkin committed Dec 8, 2019
    Copy the full SHA
    e21ad3a View commit details
  2. Copy the full SHA
    bfb42cd View commit details

Commits on Dec 11, 2019

  1. buildRustCrate: builtins -> lib where possible

    We can just use `lib` instead of `builtins` in all cases but the
    `hashString` case. Also changed a few lines to make use of some optional
    helpers from lib.
    andir committed Dec 11, 2019
    Copy the full SHA
    0aac0e8 View commit details
  2. buildRustCrate: move the color loggign & remove some runtime checks

    The expression is already long and confusing enough without the color
    stuff sprinkled in. Moving it to a dedicated file makes sense.
    
    I switched a bit of the color support code to pure Nix since there
    wasn't much point in doing that in bash while we can just do it in Nix.
    andir committed Dec 11, 2019
    Copy the full SHA
    50b2ef2 View commit details
  3. buildRustCrate: use tr instead of sed (it reads a bit nicer)

    I already have a few changes in here that will trigger rebuilds so I
    might as well do that substitution now.
    andir committed Dec 11, 2019
    Copy the full SHA
    db55d1f View commit details
  4. buildRustCrate: document and cleanup the symbol seeding

    That code had been in the derivation for a while but no explanation was
    given why that is needed. It might be helpful to our future selfs to
    document why things are done the way they are.
    andir committed Dec 11, 2019
    Copy the full SHA
    f4aeabd View commit details
  5. buildRustCrate: rename makeDeps function to mkRustcDepArgs

    This should carry the function better then `makeDeps` as it isn't
    producing deps but the rustc arguments required to link against those.
    andir committed Dec 11, 2019
    Copy the full SHA
    d37f001 View commit details
  6. buildRustCrate: reflow the way extraRustcOpts is constructed

    This should make it more obvious that we have three parts to it and not
    just one long gibberish string that makes up all of it.
    andir committed Dec 11, 2019
    Copy the full SHA
    5ad8326 View commit details

Commits on Dec 12, 2019

  1. buildRustCrate: use less bash for the build script

    We can get rid of a bunch of workarounds that were in the build script
    before by just passing on the `crateBin` attribute.
    
    Before we converted the list of attributes to a string only to convert
    it back in bash during the build phase. We can do the entire looping
    through builds in Nix and thus need no conversion and parsing of
    attributes over and over again.
    
    The big part that still remains bash is the heuristic that cargo
    introduced and that we can't do at eval time.
    andir committed Dec 12, 2019
    Copy the full SHA
    6ad22f5 View commit details
  2. buildRustCrate: deduplicate dependency override code

    The previous lines were only different in the kind of dependencies but
    otherwise exactly the same. It makes the entire thing a bit more
    readable by moving this into a function that takes care of this.
    andir committed Dec 12, 2019
    Copy the full SHA
    3f49d7a View commit details
  3. buildRustCrate: move common build functions to a dedicated file

    This means we aren't rebuilding hat file for each crate we are building
    and the buildPhase expression is a lot easier to comprehent.
    andir committed Dec 12, 2019
    Copy the full SHA
    2eaaf7a View commit details

Commits on Dec 18, 2019

  1. qemu: 4.1.0 -> 4.2.0

    risicle committed Dec 18, 2019
    Copy the full SHA
    8c3a97f View commit details

Commits on Dec 19, 2019

  1. Copy the full SHA
    f5c0d15 View commit details

Commits on Dec 21, 2019

  1. Copy the full SHA
    7753d58 View commit details

Commits on Dec 24, 2019

  1. Copy the full SHA
    a4ec22a View commit details
  2. qsampler: 0.6.0 -> 0.6.1

    r-ryantm committed Dec 24, 2019
    Copy the full SHA
    6701487 View commit details

Commits on Dec 25, 2019

  1. Copy the full SHA
    96d4f80 View commit details
  2. Copy the full SHA
    f3b68a7 View commit details

Commits on Dec 26, 2019

  1. nvidia: fix $ substitution in udev rules

    This fixes a harmless error from systemd-udevd that looks like:
    
      Dec 23 15:35:23 dellbook systemd-udevd[696]:
      /nix/store/iixya3ni5whybpq9zz1h7f4pyw7nhd19-udev-rules/99-local.rules:25
      Invalid value "..." for RUN (char 101: invalid substitution type),
      ignoring, but please fix it.
    
    Using $$ fixes it using the escaping documented at https://www.freedesktop.org/software/systemd/man/udev.html.
    matthewbauer committed Dec 26, 2019
    Copy the full SHA
    6689a38 View commit details

Commits on Dec 27, 2019

  1. nixosTests.kexec: port to python.

    The test did not succeed for me before this commit
    (the Perl test hung forever), and this translation exhibits
    the same problem.
    nh2 committed Dec 27, 2019
    Copy the full SHA
    12e3503 View commit details
  2. polybar: 3.4.1 -> 3.4.2

    Br1ght0ne committed Dec 27, 2019
    Copy the full SHA
    6c509b4 View commit details

Commits on Dec 28, 2019

  1. nixosTests.mysql: add missing () to start_all()

    Because mysql.wait_for_unit() starts the vm as well, we didn't notice
    that.
    flokli committed Dec 28, 2019
    Copy the full SHA
    7d64f7a View commit details
  2. nixosTests.mysql: add additional test{db,user}2

    Test that other users are not able to access the mysql database, and
    unix socket auth actually works.
    flokli committed Dec 28, 2019
    Copy the full SHA
    bf7841a View commit details

Commits on Dec 30, 2019

  1. Copy the full SHA
    2c19725 View commit details
  2. rx: 0.2.0 -> 0.3.0

    - Remove "--features" invocations
    - Refactor some meta attributes
    Br1ght0ne committed Dec 30, 2019
    Copy the full SHA
    9822497 View commit details
  3. Copy the full SHA
    d8623a2 View commit details
  4. Copy the full SHA
    ab63902 View commit details
  5. Copy the full SHA
    6777926 View commit details
  6. Copy the full SHA
    6885a05 View commit details
  7. Copy the full SHA
    b43479d View commit details

Commits on Dec 31, 2019

  1. atom, atom-beta: 1.36.1 -> 1.42.0, 1.37.0-beta0 -> 1.43.0-beta0

    Add shared libraries libuuid and libatk-bridge
    ysndr committed Dec 31, 2019
    Copy the full SHA
    9922a54 View commit details
  2. palemoon: use gcc7, remove build notification

    Changes as requested in #69206
    OPNA2608 committed Dec 31, 2019
    Copy the full SHA
    f7bd174 View commit details
  3. Adding passthru to ion shell to allow using it as a login shell as ad…

    …vised for a similar case in #45830
    mox committed Dec 31, 2019
    Copy the full SHA
    89c2324 View commit details
  4. Copy the full SHA
    36af8d3 View commit details
  5. Copy the full SHA
    b763746 View commit details
  6. python_openzwave: Fix broken and missing dependencies.

    Alex Whitt committed Dec 31, 2019
    Copy the full SHA
    2d00e8d View commit details
  7. Copy the full SHA
    a5689a2 View commit details
  8. Copy the full SHA
    9512e84 View commit details
  9. gitstatus: patch fewer lines

    The sed invocation was changing all lines matching "local daemon.*".
    This changed the line it was supposed to, but two other lines that also
    matched that pattern were being modified, which meant that the
    "daemon_pid_var" and "daemon_pid" variables were not defined when they
    should have been.
    bdesham committed Dec 31, 2019
    Copy the full SHA
    0542140 View commit details
  10. openzwave: 2018-11-13 -> 2019-12-08

    Alex Whitt committed Dec 31, 2019
    Copy the full SHA
    f435b1d View commit details
  11. ranger: 1.9.2 -> 1.9.3

    toonn committed Dec 31, 2019
    Copy the full SHA
    22b8a90 View commit details
  12. ranger: 1.9.2 -> 1.9.3 (#76748)

    ranger: 1.9.2 -> 1.9.3
    Mic92 authored Dec 31, 2019
    Copy the full SHA
    1736aff View commit details
  13. Merge pull request #76729 from mox-mox/master

    Adding passthru to ion shell to allow using it as a login shell as ad…
    matthewbauer authored Dec 31, 2019
    Copy the full SHA
    ddce47c View commit details
  14. powershell: set shellPath

    Fixes #45830
    matthewbauer authored Dec 31, 2019
    Copy the full SHA
    13b0141 View commit details
  15. Copy the full SHA
    62100c3 View commit details
Showing with 2,423 additions and 2,748 deletions.
  1. +5 −5 .github/CODEOWNERS
  2. +1 −1 lib/default.nix
  3. +25 −31 lib/modules.nix
  4. +18 −0 lib/tests/modules.sh
  5. +30 −0 lib/tests/modules/declare-submoduleWith-modules.nix
  6. +13 −0 lib/tests/modules/declare-submoduleWith-noshorthand.nix
  7. +12 −0 lib/tests/modules/declare-submoduleWith-path.nix
  8. +14 −0 lib/tests/modules/declare-submoduleWith-shorthand.nix
  9. +17 −0 lib/tests/modules/declare-submoduleWith-special.nix
  10. +3 −0 lib/tests/modules/define-submoduleWith-noshorthand.nix
  11. +3 −0 lib/tests/modules/define-submoduleWith-shorthand.nix
  12. +50 −16 lib/types.nix
  13. +18 −0 maintainers/maintainer-list.nix
  14. +57 −3 nixos/doc/manual/development/option-types.xml
  15. +5 −4 nixos/modules/hardware/video/nvidia.nix
  16. +1 −1 nixos/modules/services/misc/redmine.nix
  17. +26 −6 nixos/modules/services/networking/connman.nix
  18. +1 −0 nixos/modules/services/networking/networkmanager.nix
  19. +6 −6 nixos/modules/services/networking/syncthing.nix
  20. +1 −1 nixos/modules/services/web-servers/apache-httpd/default.nix
  21. +1 −1 nixos/modules/virtualisation/docker-containers.nix
  22. +40 −17 nixos/tests/3proxy.nix
  23. +5 −5 nixos/tests/haka.nix
  24. +12 −6 nixos/tests/kexec.nix
  25. +16 −2 nixos/tests/mysql.nix
  26. +1 −0 nixos/tests/netdata.nix
  27. +13 −4 pkgs/applications/audio/bitwig-studio/bitwig-studio3.nix
  28. +2 −2 pkgs/applications/audio/qsampler/default.nix
  29. +3 −2 pkgs/applications/audio/rosegarden/default.nix
  30. +3 −3 pkgs/applications/editors/android-studio/default.nix
  31. +4 −4 pkgs/applications/editors/atom/default.nix
  32. +2 −2 pkgs/applications/editors/atom/env.nix
  33. +40 −53 pkgs/applications/graphics/rx/default.nix
  34. +11 −5 pkgs/applications/misc/bemenu/default.nix
  35. +6 −3 pkgs/applications/misc/get_iplayer/default.nix
  36. +23 −0 pkgs/applications/misc/heimer/default.nix
  37. +3 −3 pkgs/applications/misc/joplin-desktop/default.nix
  38. +4 −3 pkgs/applications/misc/minder/default.nix
  39. +2 −2 pkgs/applications/misc/polybar/default.nix
  40. +2 −2 pkgs/applications/misc/ranger/default.nix
  41. +1 −0 pkgs/applications/networking/browsers/palemoon/default.nix
  42. +2 −2 pkgs/applications/networking/ssb/patchwork/default.nix
  43. +1 −1 pkgs/applications/version-management/git-and-tools/gitstatus/default.nix
  44. +2 −2 pkgs/applications/video/mpv/scripts/mpris.nix
  45. +9 −2 pkgs/applications/virtualization/qemu/default.nix
  46. +5 −6 pkgs/applications/virtualization/qemu/no-etc-install.patch
  47. +50 −125 pkgs/build-support/rust/build-rust-crate/build-crate.nix
  48. +7 −7 pkgs/build-support/rust/build-rust-crate/configure-crate.nix
  49. +51 −75 pkgs/build-support/rust/build-rust-crate/default.nix
  50. +7 −7 pkgs/build-support/rust/build-rust-crate/helpers.nix
  51. +117 −0 pkgs/build-support/rust/build-rust-crate/lib.sh
  52. +33 −0 pkgs/build-support/rust/build-rust-crate/log.nix
  53. +3 −4 pkgs/data/fonts/material-design-icons/default.nix
  54. +2 −2 pkgs/data/fonts/victor-mono/default.nix
  55. +2 −2 pkgs/development/interpreters/evcxr/default.nix
  56. +2 −2 pkgs/development/interpreters/quickjs/default.nix
  57. +19 −0 pkgs/development/libraries/gsmlib/default.nix
  58. +23 −0 pkgs/development/libraries/libctb/default.nix
  59. +13 −0 pkgs/development/libraries/libctb/include-kbhit.patch
  60. +3 −3 pkgs/development/libraries/openzwave/default.nix
  61. +1 −0 pkgs/development/libraries/prometheus-cpp/default.nix
  62. +7 −3 pkgs/development/libraries/science/biology/mirtk/default.nix
  63. +4 −4 pkgs/development/node-packages/default-v10.nix
  64. +1 −1 pkgs/development/node-packages/node-packages-v10.json
  65. +953 −565 pkgs/development/node-packages/node-packages-v10.nix
  66. +31 −31 pkgs/development/node-packages/node-packages-v12.nix
  67. +30 −30 pkgs/development/node-packages/node-packages-v13.nix
  68. +49 −0 pkgs/development/python-modules/django-postgresql-netfields/default.nix
  69. +1 −0 pkgs/development/python-modules/homeassistant-pyozw/default.nix
  70. +31 −0 pkgs/development/python-modules/junitparser/default.nix
  71. +50 −0 pkgs/development/python-modules/prox-tv/default.nix
  72. +11 −0 pkgs/development/python-modules/prox-tv/use-openblas.patch
  73. +20 −0 pkgs/development/python-modules/python_openzwave/cython.patch
  74. +4 −2 pkgs/development/python-modules/python_openzwave/default.nix
  75. +2 −2 pkgs/development/python-modules/stm32loader/default.nix
  76. +1 −0 pkgs/development/ruby-modules/with-packages/test.nix
  77. +7 −7 pkgs/development/tools/golangci-lint/default.nix
  78. +24 −0 pkgs/development/tools/kcli/default.nix
  79. +0 −31 pkgs/development/tools/misc/texlab/citeproc/package.json
  80. +0 −14 pkgs/development/tools/misc/texlab/citeproc/update-package.json.sh
  81. +5 −13 pkgs/development/tools/misc/texlab/default.nix
  82. +34 −15 pkgs/development/tools/rust/cargo-make/Cargo.lock
  83. +3 −3 pkgs/development/tools/rust/cargo-make/default.nix
  84. +4 −4 pkgs/games/empty-epsilon/default.nix
  85. +6 −6 pkgs/os-specific/linux/batman-adv/alfred.nix
  86. +6 −6 pkgs/os-specific/linux/batman-adv/batctl.nix
  87. +6 −5 pkgs/os-specific/linux/batman-adv/default.nix
  88. +9 −0 pkgs/os-specific/linux/batman-adv/version.nix
  89. +2 −2 pkgs/os-specific/linux/kernel/linux-4.14.nix
  90. +2 −2 pkgs/os-specific/linux/kernel/linux-4.19.nix
  91. +2 −2 pkgs/os-specific/linux/kernel/linux-5.4.nix
  92. +1 −1 pkgs/os-specific/linux/kernel/linux-libre.nix
  93. +2 −2 pkgs/os-specific/linux/power-calibrate/default.nix
  94. +2 −2 pkgs/servers/gotify/default.nix
  95. +2 −2 pkgs/servers/gotify/ui.nix
  96. +3 −0 pkgs/servers/http/unit/default.nix
  97. +2 −2 pkgs/servers/matrix-synapse/default.nix
  98. +31 −29 pkgs/servers/sip/freeswitch/default.nix
  99. +10 −1 pkgs/servers/sip/freeswitch/modules.nix
  100. +4 −0 pkgs/shells/ion/default.nix
  101. +4 −3 pkgs/shells/nushell/default.nix
  102. +4 −0 pkgs/shells/powershell/default.nix
  103. +3 −3 pkgs/shells/zsh/oh-my-zsh/default.nix
  104. +7 −2 pkgs/tools/misc/txr/default.nix
  105. +10 −4 pkgs/tools/networking/clash/default.nix
  106. +9 −1 pkgs/tools/networking/dhcpcd/default.nix
  107. +6 −6 pkgs/tools/networking/v2ray/default.nix
  108. +0 −18 pkgs/tools/security/bitwarden-cli/default.nix
  109. +0 −8 pkgs/tools/security/bitwarden-cli/generate.sh
  110. +0 −1,407 pkgs/tools/security/bitwarden-cli/node-packages-generated.nix
  111. +0 −3 pkgs/tools/security/bitwarden-cli/node-packages.json
  112. +0 −17 pkgs/tools/security/bitwarden-cli/node-packages.nix
  113. +4 −0 pkgs/tools/security/fail2ban/default.nix
  114. +50 −28 pkgs/tools/security/proxmark3/default.nix
  115. +7 −5 pkgs/tools/system/netdata/default.nix
  116. +80 −18 pkgs/tools/system/netdata/no-files-in-etc-and-var.patch
  117. +15 −5 pkgs/top-level/all-packages.nix
  118. +10 −0 pkgs/top-level/python-packages.nix
10 changes: 5 additions & 5 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
/.github/CODEOWNERS @edolstra

# Libraries
/lib @edolstra @nbp
/lib @edolstra @nbp @infinisil
/lib/systems @nbp @ericson2314 @matthewbauer
/lib/generators.nix @edolstra @nbp @Profpatsch
/lib/debug.nix @edolstra @nbp @Profpatsch
@@ -30,9 +30,9 @@
/pkgs/build-support/setup-hooks @Ericson2314

# NixOS Internals
/nixos/default.nix @nbp
/nixos/lib/from-env.nix @nbp
/nixos/lib/eval-config.nix @nbp
/nixos/default.nix @nbp @infinisil
/nixos/lib/from-env.nix @nbp @infinisil
/nixos/lib/eval-config.nix @nbp @infinisil
/nixos/doc/manual/configuration/abstractions.xml @nbp
/nixos/doc/manual/configuration/config-file.xml @nbp
/nixos/doc/manual/configuration/config-syntax.xml @nbp
@@ -62,7 +62,7 @@

# Haskell
/pkgs/development/compilers/ghc @basvandijk @cdepillabout
/pkgs/development/haskell-modules @basvandijk @cdepillabout
/pkgs/development/haskell-modules @basvandijk @cdepillabout @infinisil
/pkgs/development/haskell-modules/default.nix @basvandijk @cdepillabout
/pkgs/development/haskell-modules/generic-builder.nix @basvandijk @cdepillabout
/pkgs/development/haskell-modules/hoogle.nix @basvandijk @cdepillabout
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ let
commitIdFromGitRepo cleanSourceWith pathHasContext
canCleanSource;
inherit (modules) evalModules closeModules unifyModuleSyntax
applyIfFunction unpackSubmodule packSubmodule mergeModules
applyIfFunction mergeModules
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
pushDownProperties dischargeProperties filterOverrides
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
56 changes: 25 additions & 31 deletions lib/modules.nix
Original file line number Diff line number Diff line change
@@ -103,42 +103,42 @@ rec {
toClosureList = file: parentKey: imap1 (n: x:
if isAttrs x || isFunction x then
let key = "${parentKey}:anon-${toString n}"; in
unifyModuleSyntax file key (unpackSubmodule (applyIfFunction key) x args)
unifyModuleSyntax file key (applyIfFunction key x args)
else
let file = toString x; key = toString x; in
unifyModuleSyntax file key (applyIfFunction key (import x) args));
in
builtins.genericClosure {
startSet = toClosureList unknownModule "" modules;
operator = m: toClosureList m.file m.key m.imports;
operator = m: toClosureList m._file m.key m.imports;
};

/* Massage a module into canonical form, that is, a set consisting
of ‘options’, ‘config’ and ‘imports’ attributes. */
unifyModuleSyntax = file: key: m:
let metaSet = if m ? meta
then { meta = m.meta; }
else {};
let addMeta = config: if m ? meta
then mkMerge [ config { meta = m.meta; } ]
else config;
in
if m ? config || m ? options then
let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
if badAttrs != {} then
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
else
{ file = m._file or file;
{ _file = m._file or file;
key = toString m.key or key;
disabledModules = m.disabledModules or [];
imports = m.imports or [];
options = m.options or {};
config = mkMerge [ (m.config or {}) metaSet ];
config = addMeta (m.config or {});
}
else
{ file = m._file or file;
{ _file = m._file or file;
key = toString m.key or key;
disabledModules = m.disabledModules or [];
imports = m.require or [] ++ m.imports or [];
options = {};
config = mkMerge [ (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]) metaSet ];
config = addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]);
};

applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
@@ -171,25 +171,14 @@ rec {
else
f;

/* We have to pack and unpack submodules. We cannot wrap the expected
result of the function as we would no longer be able to list the arguments
of the submodule. (see applyIfFunction) */
unpackSubmodule = unpack: m: args:
if isType "submodule" m then
{ _file = m.file; } // (unpack m.submodule args)
else unpack m args;

packSubmodule = file: m:
{ _type = "submodule"; file = file; submodule = m; };

/* Merge a list of modules. This will recurse over the option
declarations in all modules, combining them into a single set.
At the same time, for each option declaration, it will merge the
corresponding option definitions in all machines, returning them
in the ‘value’ attribute of each option. */
mergeModules = prefix: modules:
mergeModules' prefix modules
(concatMap (m: map (config: { inherit (m) file; inherit config; }) (pushDownProperties m.config)) modules);
(concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);

mergeModules' = prefix: options: configs:
let
@@ -223,7 +212,7 @@ rec {
) {} modules;
# an attrset 'name' => list of submodules that declare ‘name’.
declsByName = byName "options" (module: option:
[{ inherit (module) file; options = option; }]
[{ inherit (module) _file; options = option; }]
) options;
# an attrset 'name' => list of submodules that define ‘name’.
defnsByName = byName "config" (module: value:
@@ -250,7 +239,7 @@ rec {
firstOption = findFirst (m: isOption m.options) "" decls;
firstNonOption = findFirst (m: !isOption m.options) "" decls;
in
throw "The option `${showOption loc}' in `${firstOption.file}' is a prefix of options in `${firstNonOption.file}'."
throw "The option `${showOption loc}' in `${firstOption._file}' is a prefix of options in `${firstNonOption._file}'."
else
mergeModules' loc decls defns
))
@@ -267,7 +256,14 @@ rec {
'opts' is a list of modules. Each module has an options attribute which
correspond to the definition of 'loc' in 'opt.file'. */
mergeOptionDecls = loc: opts:
mergeOptionDecls =
let
packSubmodule = file: m:
{ _file = file; imports = [ m ]; };
coerceOption = file: opt:
if isFunction opt then packSubmodule file opt
else packSubmodule file { options = opt; };
in loc: opts:
foldl' (res: opt:
let t = res.type;
t' = opt.options.type;
@@ -284,7 +280,7 @@ rec {
bothHave "apply" ||
(bothHave "type" && (! typesMergeable))
then
throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${showFiles res.declarations}."
throw "The option `${showOption loc}' in `${opt._file}' is already declared in ${showFiles res.declarations}."
else
let
/* Add the modules of the current option to the list of modules
@@ -293,16 +289,14 @@ rec {
current option declaration as the file use for the submodule. If the
submodule defines any filename, then we ignore the enclosing option file. */
options' = toList opt.options.options;
coerceOption = file: opt:
if isFunction opt then packSubmodule file opt
else packSubmodule file { options = opt; };

getSubModules = opt.options.type.getSubModules or null;
submodules =
if getSubModules != null then map (packSubmodule opt.file) getSubModules ++ res.options
else if opt.options ? options then map (coerceOption opt.file) options' ++ res.options
if getSubModules != null then map (packSubmodule opt._file) getSubModules ++ res.options
else if opt.options ? options then map (coerceOption opt._file) options' ++ res.options
else res.options;
in opt.options // res //
{ declarations = res.declarations ++ [opt.file];
{ declarations = res.declarations ++ [opt._file];
options = submodules;
} // typeSet
) { inherit loc; declarations = []; options = []; } opts;
18 changes: 18 additions & 0 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
@@ -164,6 +164,24 @@ checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix
checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
checkConfigOutput "false" config.enableAlias ./alias-with-priority-can-override.nix

# submoduleWith

## specialArgs should work
checkConfigOutput "foo" config.submodule.foo ./declare-submoduleWith-special.nix

## shorthandOnlyDefines config behaves as expected
checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nix
checkConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nix
checkConfigError 'value is a boolean while a set was expected' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix

## submoduleWith should merge all modules in one swoop
checkConfigOutput "true" config.submodule.inner ./declare-submoduleWith-modules.nix
checkConfigOutput "true" config.submodule.outer ./declare-submoduleWith-modules.nix

## Paths should be allowed as values and work as expected
checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix

cat <<EOF
====== module tests ======
$pass Pass
30 changes: 30 additions & 0 deletions lib/tests/modules/declare-submoduleWith-modules.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib, ... }: {
options.submodule = lib.mkOption {
type = lib.types.submoduleWith {
modules = [
{
options.inner = lib.mkOption {
type = lib.types.bool;
default = false;
};
}
{
outer = true;
}
];
};
default = {};
};

config.submodule = lib.mkMerge [
({ lib, ... }: {
options.outer = lib.mkOption {
type = lib.types.bool;
default = false;
};
})
{
inner = true;
}
];
}
13 changes: 13 additions & 0 deletions lib/tests/modules/declare-submoduleWith-noshorthand.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ lib, ... }: let
sub.options.config = lib.mkOption {
type = lib.types.bool;
default = false;
};
in {
options.submodule = lib.mkOption {
type = lib.types.submoduleWith {
modules = [ sub ];
};
default = {};
};
}
12 changes: 12 additions & 0 deletions lib/tests/modules/declare-submoduleWith-path.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ lib, ... }: {
options.submodule = lib.mkOption {
type = lib.types.submoduleWith {
modules = [
./declare-enable.nix
];
};
default = {};
};

config.submodule = ./define-enable.nix;
}
14 changes: 14 additions & 0 deletions lib/tests/modules/declare-submoduleWith-shorthand.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ lib, ... }: let
sub.options.config = lib.mkOption {
type = lib.types.bool;
default = false;
};
in {
options.submodule = lib.mkOption {
type = lib.types.submoduleWith {
modules = [ sub ];
shorthandOnlyDefinesConfig = true;
};
default = {};
};
}
17 changes: 17 additions & 0 deletions lib/tests/modules/declare-submoduleWith-special.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ lib, ... }: {
options.submodule = lib.mkOption {
type = lib.types.submoduleWith {
modules = [
({ lib, ... }: {
options.foo = lib.mkOption {
default = lib.foo;
};
})
];
specialArgs.lib = lib // {
foo = "foo";
};
};
default = {};
};
}
3 changes: 3 additions & 0 deletions lib/tests/modules/define-submoduleWith-noshorthand.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
submodule.config.config = true;
}
3 changes: 3 additions & 0 deletions lib/tests/modules/define-submoduleWith-shorthand.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
submodule.config = true;
}
66 changes: 50 additions & 16 deletions lib/types.nix
Original file line number Diff line number Diff line change
@@ -358,25 +358,43 @@ rec {
};

# A submodule (like typed attribute set). See NixOS manual.
submodule = opts:
submodule = modules: submoduleWith {
shorthandOnlyDefinesConfig = true;
modules = toList modules;
};

submoduleWith =
{ modules
, specialArgs ? {}
, shorthandOnlyDefinesConfig ? false
}@attrs:
let
opts' = toList opts;
inherit (lib.modules) evalModules;

coerce = unify: value: if isFunction value
then setFunctionArgs (args: unify (value args)) (functionArgs value)
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);

allModules = defs: modules ++ imap1 (n: { value, file }:
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:
let
coerce = def: if isFunction def then def else { config = def; };
modules = opts' ++ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs;
in (evalModules {
inherit modules;
(evalModules {
modules = allModules defs;
inherit specialArgs;
args.name = last loc;
prefix = loc;
}).config;
getSubOptions = prefix: (evalModules
{ modules = opts'; inherit prefix;
{ inherit modules prefix specialArgs;
# This is a work-around due to the fact that some sub-modules,
# such as the one included in an attribute set, expects a "args"
# attribute to be given to the sub-module. As the option
@@ -394,13 +412,29 @@ rec {
# It shouldn't cause an issue since this is cosmetic for the manual.
args.name = "‹name›";
}).options;
getSubModules = opts';
substSubModules = m: submodule m;
functor = (defaultFunctor name) // {
# Merging of submodules is done as part of mergeOptionDecls, as we have to annotate
# each submodule with its location.
payload = [];
binOp = lhs: rhs: [];
getSubModules = modules;
substSubModules = m: submoduleWith (attrs // {
modules = m;
});
functor = defaultFunctor name // {
type = types.submoduleWith;
payload = {
modules = modules;
specialArgs = specialArgs;
shorthandOnlyDefinesConfig = shorthandOnlyDefinesConfig;
};
binOp = lhs: rhs: {
modules = lhs.modules ++ rhs.modules;
specialArgs =
let intersecting = builtins.intersectAttrs lhs.specialArgs rhs.specialArgs;
in if intersecting == {}
then lhs.specialArgs // rhs.specialArgs
else throw "A submoduleWith option is declared multiple times with the same specialArgs \"${toString (attrNames intersecting)}\"";
shorthandOnlyDefinesConfig =
if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
then lhs.shorthandOnlyDefinesConfig
else throw "A submoduleWith option is declared multiple times with conflicting shorthandOnlyDefinesConfig values";
};
};
};

Loading