git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #41425 from dasJ/luks-offset

nixos/luksroot: Support keyfile offsets

commit010504fbeb3a260c2de706d3efcf37e8ca73b7b2 authorSilvan Mosberger <infinisil@icloud.com> dateTue 7 Aug 2018, 18:10 (8 years ago) parent9e727bf690dac1
1 file changed+15−1
nixos/modules/system/boot/luksroot.nix+15−1
nixos/modules/system/boot/luksroot.nix+15−1
@@ -5,7 +5,7 @@ with lib;
55let
66 luks = config.boot.initrd.luks;
77
8− openCommand = name': { name, device, header, keyFile, keyFileSize, allowDiscards, yubikey, fallbackToPassword, ... }: assert name' == name; ''
8+ openCommand = name': { name, device, header, keyFile, keyFileSize, keyFileOffset, allowDiscards, yubikey, fallbackToPassword, ... }: assert name' == name; ''
99
1010 # Wait for a target (e.g. device, keyFile, header, ...) to appear.
1111 wait_target() {
@@ -47,6 +47,7 @@ let
4747 ${optionalString (keyFile != null) ''
4848 ${optionalString fallbackToPassword "if [ -e ${keyFile} ]; then"}
4949 echo " --key-file=${keyFile} ${optionalString (keyFileSize != null) "--keyfile-size=${toString keyFileSize}"}" \
50+ ${optionalString (keyFileOffset != null) "--keyfile-offset=${toString keyFileOffset}"}" \
5051 >> /.luksopen_args
5152 ${optionalString fallbackToPassword ''
5253 else
@@ -316,6 +317,19 @@ in
316317 '';
317318 };
318319
320+ keyFileOffset = mkOption {
321+ default = null;
322+ example = 4096;
323+ type = types.nullOr types.int;
324+ description = ''
325+ The offset of the key file. Use this in combination with
326+ <literal>keyFileSize</literal> to use part of a file as key file
327+ (often the case if a raw device or partition is used as a key file).
328+ If not specified, the key begins at the first byte of
329+ <literal>keyFile</literal>.
330+ '';
331+ };
332+
319333 # FIXME: get rid of this option.
320334 preLVM = mkOption {
321335 default = true;