bcachefs-unlock: respect x-systemd mount options
This will allow unlocking to take place *after* all of the devices have been probed, as indicated by the x-systemd.wants and x-systemd.requires options. This allows for multi-device bcachefs volumes to be reliably unlocked.
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
|
||||
- Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`.
|
||||
|
||||
- The systemd initrd will now respect `x-systemd.wants` and `x-systemd.requires` for reliably unlocking multi-disk bcachefs volumes.
|
||||
|
||||
- New hardening flags, `strictflexarrays1` and `strictflexarrays3` were made available, corresponding to the gcc/clang options `-fstrict-flex-arrays=1` and `-fstrict-flex-arrays=3` respectively.
|
||||
|
||||
- `gramps` has been updated to 6.0.0
|
||||
|
||||
@@ -93,19 +93,27 @@ let
|
||||
let
|
||||
mountUnit = "${utils.escapeSystemdPath (prefix + (lib.removeSuffix "/" fs.mountPoint))}.mount";
|
||||
device = firstDevice fs;
|
||||
deviceUnit = "${utils.escapeSystemdPath device}.device";
|
||||
mkDeviceUnit = device: "${utils.escapeSystemdPath device}.device";
|
||||
deviceUnit = mkDeviceUnit device;
|
||||
extractProperty =
|
||||
prop: options: (map (lib.removePrefix "${prop}=") (builtins.filter (lib.hasPrefix prop) options));
|
||||
normalizeUnits = unit: if lib.hasPrefix "/" unit then mkDeviceUnit unit else unit;
|
||||
requiredUnits = map normalizeUnits (extractProperty "x-systemd.requires" fs.options);
|
||||
wantedUnits = map normalizeUnits (extractProperty "x-systemd.wants" fs.options);
|
||||
in
|
||||
{
|
||||
name = "unlock-bcachefs-${utils.escapeSystemdPath fs.mountPoint}";
|
||||
value = {
|
||||
description = "Unlock bcachefs for ${fs.mountPoint}";
|
||||
requiredBy = [ mountUnit ];
|
||||
after = [ deviceUnit ];
|
||||
after = [ deviceUnit ] ++ requiredUnits ++ wantedUnits;
|
||||
before = [
|
||||
mountUnit
|
||||
"shutdown.target"
|
||||
];
|
||||
bindsTo = [ deviceUnit ];
|
||||
requires = requiredUnits;
|
||||
wants = wantedUnits;
|
||||
conflicts = [ "shutdown.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig = {
|
||||
|
||||
Reference in New Issue
Block a user