mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-29 23:52:55 +00:00
nixos: Use systemd-makefs for autoFormat
This commit is contained in:
parent
3f697e808b
commit
5176a4f113
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
- `util-linux` is now supported on Darwin and is no longer an alias to `unixtools`. Use the `unixtools.util-linux` package for access to the Apple variants of the utilities.
|
- `util-linux` is now supported on Darwin and is no longer an alias to `unixtools`. Use the `unixtools.util-linux` package for access to the Apple variants of the utilities.
|
||||||
|
|
||||||
|
- `fileSystems.<name>.autoFormat` now uses `systemd-makefs`, which does not accept formatting options. Therefore, `fileSystems.<name>.formatOptions` has been removed.
|
||||||
|
|
||||||
## Other Notable Changes {#sec-release-23.11-notable-changes}
|
## Other Notable Changes {#sec-release-23.11-notable-changes}
|
||||||
|
|
||||||
- The Cinnamon module now enables XDG desktop integration by default. If you are experiencing collisions related to xdg-desktop-portal-gtk you can safely remove `xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];` from your NixOS configuration.
|
- The Cinnamon module now enables XDG desktop integration by default. If you are experiencing collisions related to xdg-desktop-portal-gtk you can safely remove `xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];` from your NixOS configuration.
|
||||||
|
@ -588,6 +588,15 @@ in
|
|||||||
systemd.services."systemd-backlight@".restartIfChanged = false;
|
systemd.services."systemd-backlight@".restartIfChanged = false;
|
||||||
systemd.services."systemd-fsck@".restartIfChanged = false;
|
systemd.services."systemd-fsck@".restartIfChanged = false;
|
||||||
systemd.services."systemd-fsck@".path = [ config.system.path ];
|
systemd.services."systemd-fsck@".path = [ config.system.path ];
|
||||||
|
systemd.services."systemd-makefs@" = {
|
||||||
|
restartIfChanged = false;
|
||||||
|
path = [ pkgs.util-linux ] ++ config.system.fsPackages;
|
||||||
|
# Since there is no /etc/systemd/system/systemd-makefs@.service
|
||||||
|
# file, the units generated in /run/systemd/generator would
|
||||||
|
# override anything we put here. But by forcing the use of a
|
||||||
|
# drop-in in /etc, it does apply.
|
||||||
|
overrideStrategy = "asDropin";
|
||||||
|
};
|
||||||
systemd.services.systemd-random-seed.restartIfChanged = false;
|
systemd.services.systemd-random-seed.restartIfChanged = false;
|
||||||
systemd.services.systemd-remount-fs.restartIfChanged = false;
|
systemd.services.systemd-remount-fs.restartIfChanged = false;
|
||||||
systemd.services.systemd-update-utmp.restartIfChanged = false;
|
systemd.services.systemd-update-utmp.restartIfChanged = false;
|
||||||
|
@ -112,12 +112,9 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
formatOptions = mkOption {
|
formatOptions = mkOption {
|
||||||
default = "";
|
visible = false;
|
||||||
type = types.str;
|
type = types.unspecified;
|
||||||
description = lib.mdDoc ''
|
default = null;
|
||||||
If {option}`autoFormat` option is set specifies
|
|
||||||
extra options passed to mkfs.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
autoResize = mkOption {
|
autoResize = mkOption {
|
||||||
@ -139,22 +136,11 @@ let
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
config.options = mkMerge [
|
||||||
defaultFormatOptions =
|
(mkIf config.autoResize [ "x-nixos.autoresize" ])
|
||||||
# -F needed to allow bare block device without partitions
|
(mkIf config.autoFormat [ "x-systemd.makefs" ])
|
||||||
if (builtins.substring 0 3 config.fsType) == "ext" then "-F"
|
(mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ])
|
||||||
# -q needed for non-interactive operations
|
];
|
||||||
else if config.fsType == "jfs" then "-q"
|
|
||||||
# (same here)
|
|
||||||
else if config.fsType == "reiserfs" then "-q"
|
|
||||||
else null;
|
|
||||||
in {
|
|
||||||
options = mkMerge [
|
|
||||||
(mkIf config.autoResize [ "x-nixos.autoresize" ])
|
|
||||||
(mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ])
|
|
||||||
];
|
|
||||||
formatOptions = mkIf (defaultFormatOptions != null) (mkDefault defaultFormatOptions);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,8 +202,7 @@ let
|
|||||||
initrdFstab = pkgs.writeText "initrd-fstab" (makeFstabEntries (filter utils.fsNeededForBoot fileSystems) {
|
initrdFstab = pkgs.writeText "initrd-fstab" (makeFstabEntries (filter utils.fsNeededForBoot fileSystems) {
|
||||||
rootPrefix = "/sysroot";
|
rootPrefix = "/sysroot";
|
||||||
extraOpts = fs:
|
extraOpts = fs:
|
||||||
(optional fs.autoResize "x-systemd.growfs")
|
(optional fs.autoResize "x-systemd.growfs");
|
||||||
++ (optional fs.autoFormat "x-systemd.makefs");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -330,6 +315,16 @@ in
|
|||||||
in
|
in
|
||||||
"Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${optionalString (fs.fsType == "auto") " fsType has to be explicitly set and"} only the ext filesystems and f2fs support it.";
|
"Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${optionalString (fs.fsType == "auto") " fsType has to be explicitly set and"} only the ext filesystems and f2fs support it.";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
assertion = ! (any (fs: fs.formatOptions != null) fileSystems);
|
||||||
|
message = let
|
||||||
|
fs = head (filter (fs: fs.formatOptions != null) fileSystems);
|
||||||
|
in ''
|
||||||
|
'fileSystems.<name>.formatOptions' has been removed, since
|
||||||
|
systemd-makefs does not support any way to provide formatting
|
||||||
|
options.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
# Export for use in other modules
|
# Export for use in other modules
|
||||||
@ -377,37 +372,7 @@ in
|
|||||||
wants = [ "local-fs.target" "remote-fs.target" ];
|
wants = [ "local-fs.target" "remote-fs.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services =
|
systemd.services = {
|
||||||
|
|
||||||
# Emit systemd services to format requested filesystems.
|
|
||||||
let
|
|
||||||
formatDevice = fs:
|
|
||||||
let
|
|
||||||
mountPoint' = "${escapeSystemdPath fs.mountPoint}.mount";
|
|
||||||
device' = escapeSystemdPath fs.device;
|
|
||||||
device'' = "${device'}.device";
|
|
||||||
in nameValuePair "mkfs-${device'}"
|
|
||||||
{ description = "Initialisation of Filesystem ${fs.device}";
|
|
||||||
wantedBy = [ mountPoint' ];
|
|
||||||
before = [ mountPoint' "systemd-fsck@${device'}.service" ];
|
|
||||||
requires = [ device'' ];
|
|
||||||
after = [ device'' ];
|
|
||||||
path = [ pkgs.util-linux ] ++ config.system.fsPackages;
|
|
||||||
script =
|
|
||||||
''
|
|
||||||
if ! [ -e "${fs.device}" ]; then exit 1; fi
|
|
||||||
# FIXME: this is scary. The test could be more robust.
|
|
||||||
type=$(blkid -p -s TYPE -o value "${fs.device}" || true)
|
|
||||||
if [ -z "$type" ]; then
|
|
||||||
echo "creating ${fs.fsType} filesystem on ${fs.device}..."
|
|
||||||
mkfs.${fs.fsType} ${fs.formatOptions} "${fs.device}"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
unitConfig.RequiresMountsFor = [ "${dirOf fs.device}" ];
|
|
||||||
unitConfig.DefaultDependencies = false; # needed to prevent a cycle
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
};
|
|
||||||
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat && !(utils.fsNeededForBoot fs)) fileSystems)) // {
|
|
||||||
# Mount /sys/fs/pstore for evacuating panic logs and crashdumps from persistent storage onto the disk using systemd-pstore.
|
# Mount /sys/fs/pstore for evacuating panic logs and crashdumps from persistent storage onto the disk using systemd-pstore.
|
||||||
# This cannot be done with the other special filesystems because the pstore module (which creates the mount point) is not loaded then.
|
# This cannot be done with the other special filesystems because the pstore module (which creates the mount point) is not loaded then.
|
||||||
"mount-pstore" = {
|
"mount-pstore" = {
|
||||||
|
@ -30,7 +30,7 @@ import ./make-test-python.nix {
|
|||||||
else "fsck.ext4.*/dev/vda"}'")
|
else "fsck.ext4.*/dev/vda"}'")
|
||||||
|
|
||||||
with subtest("mnt fs is fsckd"):
|
with subtest("mnt fs is fsckd"):
|
||||||
machine.succeed("journalctl -b | grep 'fsck.*/dev/vdb.*clean'")
|
machine.succeed("journalctl -b | grep 'fsck.*vdb.*clean'")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"grep 'Requires=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
"grep 'Requires=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user