From b1fae11381766ea5afde57c69bfb566ca9a22808 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 26 Sep 2023 20:12:03 +0100 Subject: [PATCH 1/2] lib.removeAttrs: init alias --- lib/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index e4bf45aac3b6a..20d5518732e09 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -84,7 +84,7 @@ let mapAttrs' mapAttrsToList concatMapAttrs mapAttrsRecursive mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil - recursiveUpdate matchAttrs overrideExisting showAttrPath getOutput getBin + recursiveUpdate removeAttrs matchAttrs overrideExisting showAttrPath getOutput getBin getLib getDev getMan chooseDevOutputs zipWithNames zip recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets updateManyAttrsByPath; From c76510919e377ec42d0d80a2d33e77f94dcc0140 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 26 Sep 2023 22:55:15 +0100 Subject: [PATCH 2/2] WIP lib.types.{record,fix}, deconstructing submodule --- lib/tests/modules.sh | 29 +++++++ .../modules/declare-record-bad-default.nix | 25 ++++++ lib/tests/modules/declare-record-wildcard.nix | 24 ++++++ lib/tests/modules/declare-record.nix | 25 ++++++ .../modules/define-record-alice-prefs.nix | 9 ++ lib/tests/modules/define-record-alice.nix | 6 ++ lib/tests/modules/define-record-bob.nix | 6 ++ lib/tests/modules/define-record-mallory.nix | 6 ++ lib/tests/modules/fixpoint.nix | 27 ++++++ lib/types.nix | 4 +- lib/types/fix.nix | 29 +++++++ lib/types/record.nix | 86 +++++++++++++++++++ 12 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 lib/tests/modules/declare-record-bad-default.nix create mode 100644 lib/tests/modules/declare-record-wildcard.nix create mode 100644 lib/tests/modules/declare-record.nix create mode 100644 lib/tests/modules/define-record-alice-prefs.nix create mode 100644 lib/tests/modules/define-record-alice.nix create mode 100644 lib/tests/modules/define-record-bob.nix create mode 100644 lib/tests/modules/define-record-mallory.nix create mode 100644 lib/tests/modules/fixpoint.nix create mode 100644 lib/types/fix.nix create mode 100644 lib/types/record.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 93fb1df933276..03fdc2daf2549 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -64,6 +64,33 @@ checkConfigError() { fi } +# record field +checkConfigOutput '^"Alice"$' config.people.alice.name ./declare-record.nix ./define-record-alice.nix ./define-record-bob.nix +checkConfigOutput '^2019$' config.people.bob.nixerSince ./declare-record.nix ./define-record-alice.nix ./define-record-bob.nix + +# record field type error +checkConfigError 'A definition for option .people.mallory.nixerSince. is not of type .signed integer.. Definition values' config.people.mallory.nixerSince ./declare-record.nix ./define-record-mallory.nix +checkConfigError 'define-record-mallory.nix.: "beginning of time"' config.people.mallory.nixerSince ./declare-record.nix ./define-record-mallory.nix + +# record field default +checkConfigOutput '^true$' config.people.bob.isCool ./declare-record.nix ./define-record-alice.nix ./define-record-bob.nix + +# record field bad default definition +checkConfigError 'In .the default value of option people.mallory.: "yeah"' config.people.mallory.isCool ./declare-record-bad-default.nix ./define-record-mallory.nix +checkConfigError 'A definition for option .people.mallory.isCool. is not of type .boolean.. Definition values:' config.people.mallory.isCool ./declare-record-bad-default.nix ./define-record-mallory.nix + +# record field works in presence of wildcard +checkConfigOutput '^2016$' config.people.alice.nixerSince ./declare-record-wildcard.nix ./define-record-alice-prefs.nix + +# record wildcard field +checkConfigOutput '^true$' config.people.alice.mechKeyboard ./declare-record-wildcard.nix ./define-record-alice-prefs.nix + + +# fix +checkConfigOutput '"bobby"' config.people.lilbob.name ./fixpoint.nix + +if false; then + # Shorthand meta attribute does not duplicate the config checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix @@ -462,6 +489,8 @@ checkConfigOutput '^34|23$' options.submoduleLine34.declarationPositions.1.line # nested options work checkConfigOutput '^30$' options.nested.nestedLine30.declarationPositions.0.line ./declaration-positions.nix +fi + cat <