mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
62 lines
1.8 KiB
Nix
62 lines
1.8 KiB
Nix
# This module automatically grows the root partition.
|
|
# This allows an instance to be created with a bigger root filesystem
|
|
# than provided by the machine image.
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
with lib;
|
|
|
|
{
|
|
imports = [
|
|
(mkRenamedOptionModule [ "virtualisation" "growPartition" ] [ "boot" "growPartition" ])
|
|
];
|
|
|
|
options = {
|
|
boot.growPartition = mkEnableOption "growing the root partition on boot";
|
|
};
|
|
|
|
config = mkIf config.boot.growPartition {
|
|
assertions = [
|
|
{
|
|
assertion = !config.boot.initrd.systemd.repart.enable && !config.systemd.repart.enable;
|
|
message = "systemd-repart already grows the root partition and thus you should not use boot.growPartition";
|
|
}
|
|
];
|
|
systemd.services.growpart = {
|
|
wantedBy = [ "-.mount" ];
|
|
after = [ "-.mount" ];
|
|
before = [
|
|
"systemd-growfs-root.service"
|
|
"shutdown.target"
|
|
];
|
|
conflicts = [ "shutdown.target" ];
|
|
unitConfig.DefaultDependencies = false;
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
TimeoutSec = "infinity";
|
|
# growpart returns 1 if the partition is already grown
|
|
SuccessExitStatus = "0 1";
|
|
};
|
|
|
|
script = ''
|
|
rootDevice="${config.fileSystems."/".device}"
|
|
rootDevice="$(readlink -f "$rootDevice")"
|
|
parentDevice="$rootDevice"
|
|
while [ "''${parentDevice%[0-9]}" != "''${parentDevice}" ]; do
|
|
parentDevice="''${parentDevice%[0-9]}";
|
|
done
|
|
partNum="''${rootDevice#"''${parentDevice}"}"
|
|
if [ "''${parentDevice%[0-9]p}" != "''${parentDevice}" ] && [ -b "''${parentDevice%p}" ]; then
|
|
parentDevice="''${parentDevice%p}"
|
|
fi
|
|
"${pkgs.cloud-utils.guest}/bin/growpart" "$parentDevice" "$partNum"
|
|
'';
|
|
};
|
|
};
|
|
}
|