!coeAONBrWyDJnYMbMi:nixos.org

NixOS System Operations

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

Load older messages


SenderMessageTime
17 Apr 2026
@c4lliope:matrix.orgc4lliope changed their profile picture.08:41:46
@pyrox:pyrox.devdish [Fox/It/She] changed their profile picture.16:58:37
18 Apr 2026
@sss:matrix.dark-alexandr.netsss
 Failed assertions:
       - boot.initrd.luks.devices.<name>.preOpenCommands and postOpenCommands is not supported by systemd stage 1. Please bind a service to cryptsetup.target or cryptsetup-pre.target instead.

how to do it nowdays ?

01:09:54
@hexa:lossy.networkhexawrite a systemd unit in initrd instead01:11:17
@hexa:lossy.networkhexa boot.inird.systemd.services.<yourunit> = { ... } 01:12:20
@hexa:lossy.networkhexa I would interpret binding as using BindsTo 01:12:58
@elvishjerricco:matrix.orgElvishJerriccoOh uhh "bind to" is probably a bad choice of words for the assertion message then :P01:16:17
@sss:matrix.dark-alexandr.netsss so i need to create 2 services, one with BindsTo and second which depends on cryptsetup.target ? 01:16:32
@elvishjerricco:matrix.orgElvishJerriccoIt's only meant to tell you to make a systemd service relative to the cryptsetup target that's relevant to you01:17:01
@hexa:lossy.networkhexawas gonna say this feels not correct, but got distracted01:18:38
@sss:matrix.dark-alexandr.netsssso.... ?01:19:35
@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

Show newer messages


Back to Room ListRoom Version: 10