!coeAONBrWyDJnYMbMi:nixos.org

NixOS System Operations

629 Members
About system administration for running NixOS systems in production. Declaratively manage your operations. | Room recommendations: #networking:nixos.org170 Servers

Load older messages


SenderMessageTime
18 Apr 2026
@sss:matrix.dark-alexandr.netsssmaybe some better way exist to mount key beofre decryption and unmount after ?01:20:24
@hexa:lossy.networkhexapost open is probably wants/after cryptsetup.target01:20:33
@sss:matrix.dark-alexandr.netsssdifferent keys for different devices01:20:38
@hexa:lossy.networkhexapre open could be wantedBy cryptsetup-pre.target, before cryptsetup.target01:21:08
@sss:matrix.dark-alexandr.netsssok, but what about different code for pre/post per device ?01:21:53
@hexa:lossy.networkhexaRedacted or Malformed Event01:22:08
@hexa:lossy.networkhexawell they're going to be two systemd units01:22:32
@sss:matrix.dark-alexandr.netsssdevices you mean ?01:22:49
@hexa:lossy.networkhexayou can use the script attribute to port the script01:22:53
@hexa:lossy.networkhexaah, these were per device before01:23:06
@hexa:lossy.networkhexawhat are your hooks ding?01:23:16
@sss:matrix.dark-alexandr.netsssmounting external devices with keys01:23:46
@sss:matrix.dark-alexandr.netsssfew devices01:23:55
@elvishjerricco:matrix.orgElvishJerricco

The thing most strictly similar to postOpenCommands is just a service ordered with after = [ "systemd-cryptsetup@foo.service" ]; and before = [ "systemd-hibernate-resume.service" ];. If that seems obscure to you, that's because it is, and that's because scripted initrd was the one doing it weirdly before :P

The orderings that make the most sense depend on what you're actually trying to do

01:24:16
@sss:matrix.dark-alexandr.netsssok, so each device does have their own service ?01:25:13
@elvishjerricco:matrix.orgElvishJerricco

For this purpose specifically, I could tell you how to craft a systemd service that does this nicely, but systemd actually already has a feature that does that automatically

boot.initrd.luks.keyFile = "/foo:UUID=asdf";`

This means that a drive with UUID asdf will have a key file at the /foo path in the contained file system

01:26:29
@elvishjerricco:matrix.orgElvishJerricco *

For this purpose specifically, I could tell you how to craft a systemd service that does this nicely, but systemd actually already has a feature that does that automatically

boot.initrd.luks.devices.<name>.keyFile = "/foo:UUID=asdf";`

This means that a drive with UUID asdf will have a key file at the /foo path in the contained file system

01:26:44
@sss:matrix.dark-alexandr.netsssinteresting, thx for info01:27:16
@elvishjerricco:matrix.orgElvishJerriccothat said, this makes me suspicious: Are these actually for your root fs? Or some extra file system?01:27:22
@elvishjerricco:matrix.orgElvishJerriccoIf the latter, don't do it in initrd at all01:27:26
@sss:matrix.dark-alexandr.netsssit's partitions for lvm which contains root01:28:07
@sss:matrix.dark-alexandr.netssssounds weird, but it's legacy01:28:27
@sss:matrix.dark-alexandr.netsssfrom even before nixos )01:28:36
@elvishjerricco:matrix.orgElvishJerriccoso like, you have drive A with a keyfile on it, drive A is unencrypted, and that keyfile is used to decrypt drives B, C, D...?01:29:01
@elvishjerricco:matrix.orgElvishJerriccoand B, C, D constitute the LVM that has the root fs?01:29:12
@sss:matrix.dark-alexandr.netssslike i have drive a,b,c lvm for root with different keys on d,e,f01:29:52
@elvishjerricco:matrix.orgElvishJerriccook sure; but the basic idea of "root is on encrypted drives, the key is on these different unencrypted drives" is right, yea?01:30:37
@sss:matrix.dark-alexandr.netsssyes01:30:49
@elvishjerricco:matrix.orgElvishJerriccocool, just making sure I understand your use case right01:30:59
@sss:matrix.dark-alexandr.netsssand it is complicated yes, but to to a long history of data storage01:31:31

Show newer messages


Back to Room ListRoom Version: 10