swap: allow randomEncryption to take an attrset for extra config - #1285
Open
yottanami wants to merge 2 commits into
Open
swap: allow randomEncryption to take an attrset for extra config#1285yottanami wants to merge 2 commits into
yottanami wants to merge 2 commits into
Conversation
randomEncryption was typed as a plain bool, which just passed enable/allowDiscards down to NixOS's swapDevices.*.randomEncryption submodule, with no way to reach its other options (cipher, sectorSize, etc). Widen the type to bool or an attrset. A bool keeps the old behavior unchanged. An attrset enables encryption by default (overridable via its own enable key) and is merged over the enable/allowDiscards defaults, so extra NixOS randomEncryption options pass through. Fixes nix-community#438
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
randomEncryptionon theswappartition type was typed as a plainbool, which only ever built{ enable = ...; allowDiscards = ...; }for NixOS'sswapDevices.*.randomEncryptionsubmodule — there was no way to reach its other options (cipher,sectorSize, etc.), as noted in the issue.Per the maintainer's suggestion in the issue thread, this widens the type to
lib.types.either lib.types.bool (lib.types.attrsOf lib.types.anything):true/falsekeeps the exact old behavior (backwards compatible — verified both existing in-repo usages,example/swap.nixandtests/mdadm-btrfs-wipe.nix, still use a bare bool and are unaffected).enable = true, overridable by settingenablein the attrset), and is merged over theenable/allowDiscardsdefaults so any extra NixOSrandomEncryptionoptions (cipher, sectorSize, ...) pass straight through.Also introduced a
randomEncryptionEnabledderived boolean (config.randomEncryptionwhen it's a bool, else.enable or true) since the rest of the module (_create/_mount/_unmount) branches on whether random encryption is active at all, and!doesn't work on an attrset.I don't have a local Nix environment to run
nix flake check/ the test suite against this change — flagging that so a maintainer/CI can verify directly.Fixes #438