!PSmBFWNKoXmlQBzUQf:helsinki-systems.de

Stage 1 systemd

81 Members
systemd in NixOs's stage 1, replacing the current bash tooling https://github.com/NixOS/nixpkgs/projects/5127 Servers

Load older messages


SenderMessageTime
29 May 2023
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgwell01:28:42
@elvishjerricco:matrix.org@elvishjerricco:matrix.org the best thing to do is have After= on the specific device you want 01:28:55
@elvishjerricco:matrix.org@elvishjerricco:matrix.org in an ideal world we'd have Lily Foster's patch and you could do After=initrd-root-device.target to wait for whatever the root fs's device is 01:29:21
@winterqt:nixos.devWinter (she/her)ah, okay01:29:30
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgbut that's still not "all devices" since that's not really a thing in udev01:29:34
@winterqt:nixos.devWinter (she/her)
In reply to @elvishjerricco:matrix.org
the best thing to do is have After= on the specific device you want
how do I find that?
01:29:44
@elvishjerricco:matrix.org@elvishjerricco:matrix.org Winter (she/her): What specifically are you trying to do? We may have an X Y problem here 01:30:05
@winterqt:nixos.devWinter (she/her)ephemeral rootfs, so I kind of need that ordering01:30:39
@winterqt:nixos.devWinter (she/her)not ZFS though, so I can't rely on the ZFS import services01:30:56
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgso how are you achieving ephemeral rootfs then?01:31:16
@winterqt:nixos.devWinter (she/her)

btrfs:

    mkdir /scratch
    mount /dev/mapper/nixos /scratch

    btrfs subvolume delete /scratch/root/srv
    btrfs subvolume delete /scratch/root/var/lib/portables
    btrfs subvolume delete /scratch/root/var/lib/machines
    btrfs subvolume delete /scratch/root

    btrfs subvolume snapshot /scratch/root-blank /scratch/root

    umount /scratch
    rm -r /scratch
01:32:26
@winterqt:nixos.devWinter (she/her)oh, i could use cryptsetup.target01:32:46
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgI se01:32:55
@elvishjerricco:matrix.org@elvishjerricco:matrix.org * I see01:32:56
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgno,01:32:57
@elvishjerricco:matrix.org@elvishjerricco:matrix.org You probably just want to do After=dev-mapper-nixos.device 01:33:20
@winterqt:nixos.devWinter (she/her)ah, yeah, that'd be better01:33:29
@elvishjerricco:matrix.org@elvishjerricco:matrix.org and BindsTo=dev-mapper-nixos.device 01:33:34
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgwith that combination, that's how systemd does the "waiting for device blabla..." thing01:33:53
@winterqt:nixos.devWinter (she/her)

so like this?

  boot.initrd.systemd.services.wipe-root = {
    wantedBy = [ "initrd.target" ];
    before = [ "sysroot.target" ];
    after = [ "dev-mapper-nixos.device" ];
    bindsTo = [ "dev-mapper-nixos.device" ];
    path = [ pkgs.coreutils pkgs.btrfs-progs ];
    serviceConfig.Type = "oneshot";
    script = ''
      mkdir /scratch
      mount /dev/mapper/nixos /scratch

      btrfs subvolume delete /scratch/root/srv
      btrfs subvolume delete /scratch/root/var/lib/portables
      btrfs subvolume delete /scratch/root/var/lib/machines
      btrfs subvolume delete /scratch/root

      btrfs subvolume snapshot /scratch/root-blank /scratch/root

      umount /scratch
      rm -r /scratch
    '';
  };
01:36:19
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgs/sysroot.target/sysroot.mount/01:37:04
@elvishjerricco:matrix.org@elvishjerricco:matrix.org * s/sysroot.target/sysroot.mount/ 01:37:06
@winterqt:nixos.devWinter (she/her)thanks.01:37:28
@elvishjerricco:matrix.org@elvishjerricco:matrix.org and it might be technically more correct to say requiredBy = ["sysroot.mount"]; rather than wantedBy = ["initrd.target"];? Which unit probably doesn't matter in all practicality, but wantedBy vs requiredBy just dictates whether you want failure to turn into a total stage 1 failure 01:38:10
@winterqt:nixos.devWinter (she/her)
    requiredBy = [ "sysroot.mount" ];
    # before = [ "sysroot.mount" ];
01:38:41
@winterqt:nixos.devWinter (she/her) do I need to keep before then? 01:38:46
@elvishjerricco:matrix.org@elvishjerricco:matrix.org still need the before. Requires dependencies don't cause runtime ordering 01:39:07
@winterqt:nixos.devWinter (she/her)got it, wasn't 100% sure01:39:29
@elvishjerricco:matrix.org@elvishjerricco:matrix.organd only lead to failure if the required unit fails before the requiring unit has even started01:39:31
@winterqt:nixos.devWinter (she/her)interesting01:39:49

Show newer messages


Back to Room ListRoom Version: 6