diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-07-12 21:54:57 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-07-12 21:54:57 +0200 |
commit | 72f2c8d6c681590d8c973bb79bdd21060aec9c53 (patch) | |
tree | e837801a8c2663027afbcdb3f669d6b0aec90fe0 /lib/tests/modules.sh | |
parent | bf226bd766f25975d759976471941c941ebb581a (diff) | |
download | nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar.gz nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar.bz2 nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar.lz nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar.xz nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.tar.zst nixlib-72f2c8d6c681590d8c973bb79bdd21060aec9c53.zip |
lib/tests/modules: Test that _module.args works when a default argument is set
Diffstat (limited to 'lib/tests/modules.sh')
-rwxr-xr-x | lib/tests/modules.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 50f24c09ca40..c5f42cc08510 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -63,6 +63,28 @@ checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix +# Check that a module argument is passed, also when a default is available +# (but not needed) +# +# When the default is needed, we currently fail to do what the users expect, as +# we pass our own argument anyway, even if it *turns out* not to exist. +# +# The reason for this is that we don't know at invocation time what is in the +# _module.args option. That value is only available *after* all modules have been +# invoked. +# +# Hypothetically, Nix could help support this by giving access to the default +# values, through a new built-in function. +# However the default values are allowed to depend on other arguments, so those +# would have to be passed in somehow, making this not just a getter but +# something more complicated. +# +# At that point we have to wonder whether the extra complexity is worth the cost. +# Another - subjective - reason not to support it is that default values +# contradict the notion that an option has a single value, where _module.args +# is the option. +checkConfigOutput '^true$' config.result ./module-argument-default.nix + # types.pathInStore checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix |