mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge #219444: staging-next 2023-03-04
This commit is contained in:
commit
a86610144f
2398 changed files with 8459 additions and 5150 deletions
|
@ -158,6 +158,16 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
managerEnvironment = mkOption {
|
||||
type = with types; attrsOf (nullOr (oneOf [ str path package ]));
|
||||
default = {};
|
||||
example = { SYSTEMD_LOG_LEVEL = "debug"; };
|
||||
description = lib.mdDoc ''
|
||||
Environment variables of PID 1. These variables are
|
||||
*not* passed to started units.
|
||||
'';
|
||||
};
|
||||
|
||||
contents = mkOption {
|
||||
description = lib.mdDoc "Set of files that have to be linked into the initrd";
|
||||
example = literalExpression ''
|
||||
|
@ -355,8 +365,11 @@ in {
|
|||
less = "${pkgs.less}/bin/less";
|
||||
mount = "${cfg.package.util-linux}/bin/mount";
|
||||
umount = "${cfg.package.util-linux}/bin/umount";
|
||||
fsck = "${cfg.package.util-linux}/bin/fsck";
|
||||
};
|
||||
|
||||
managerEnvironment.PATH = "/bin:/sbin";
|
||||
|
||||
contents = {
|
||||
"/init".source = "${cfg.package}/lib/systemd/systemd";
|
||||
"/etc/systemd/system".source = stage1Units;
|
||||
|
@ -365,6 +378,7 @@ in {
|
|||
[Manager]
|
||||
DefaultEnvironment=PATH=/bin:/sbin ${optionalString (isBool cfg.emergencyAccess && cfg.emergencyAccess) "SYSTEMD_SULOGIN_FORCE=1"}
|
||||
${cfg.extraConfig}
|
||||
ManagerEnvironment=${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment)}
|
||||
'';
|
||||
|
||||
"/lib/modules".source = "${modulesClosure}/lib/modules";
|
||||
|
@ -444,21 +458,6 @@ in {
|
|||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
||||
|
||||
# The unit in /run/systemd/generator shadows the unit in
|
||||
# /etc/systemd/system, but will still apply drop-ins from
|
||||
# /etc/systemd/system/foo.service.d/
|
||||
#
|
||||
# We need IgnoreOnIsolate, otherwise the Requires dependency of
|
||||
# a mount unit on its makefs unit causes it to be unmounted when
|
||||
# we isolate for switch-root. Use a dummy package so that
|
||||
# generateUnits will generate drop-ins instead of unit files.
|
||||
packages = [(pkgs.runCommand "dummy" {} ''
|
||||
mkdir -p $out/etc/systemd/system
|
||||
touch $out/etc/systemd/system/systemd-{makefs,growfs}@.service
|
||||
'')];
|
||||
services."systemd-makefs@" = lib.mkIf needMakefs { unitConfig.IgnoreOnIsolate = true; };
|
||||
services."systemd-growfs@" = lib.mkIf needGrowfs { unitConfig.IgnoreOnIsolate = true; };
|
||||
|
||||
# make sure all the /dev nodes are set up
|
||||
services.systemd-tmpfiles-setup-dev.wantedBy = ["sysinit.target"];
|
||||
|
||||
|
|
|
@ -140,7 +140,10 @@ let
|
|||
else if config.fsType == "reiserfs" then "-q"
|
||||
else null;
|
||||
in {
|
||||
options = mkIf config.autoResize [ "x-nixos.autoresize" ];
|
||||
options = mkMerge [
|
||||
(mkIf config.autoResize [ "x-nixos.autoresize" ])
|
||||
(mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ])
|
||||
];
|
||||
formatOptions = mkIf (defaultFormatOptions != null) (mkDefault defaultFormatOptions);
|
||||
};
|
||||
|
||||
|
@ -155,27 +158,54 @@ let
|
|||
|
||||
makeFstabEntries =
|
||||
let
|
||||
fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "nfs4" "vboxsf" "glusterfs" "apfs" "9p" "cifs" "prl_fs" "vmhgfs" ];
|
||||
fsToSkipCheck = [
|
||||
"none"
|
||||
"auto"
|
||||
"overlay"
|
||||
"iso9660"
|
||||
"bindfs"
|
||||
"udf"
|
||||
"btrfs"
|
||||
"zfs"
|
||||
"tmpfs"
|
||||
"bcachefs"
|
||||
"nfs"
|
||||
"nfs4"
|
||||
"nilfs2"
|
||||
"vboxsf"
|
||||
"squashfs"
|
||||
"glusterfs"
|
||||
"apfs"
|
||||
"9p"
|
||||
"cifs"
|
||||
"prl_fs"
|
||||
"vmhgfs"
|
||||
] ++ lib.optionals (!config.boot.initrd.checkJournalingFS) [
|
||||
"ext3"
|
||||
"ext4"
|
||||
"reiserfs"
|
||||
"xfs"
|
||||
"jfs"
|
||||
"f2fs"
|
||||
];
|
||||
isBindMount = fs: builtins.elem "bind" fs.options;
|
||||
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck || isBindMount fs;
|
||||
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
||||
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
||||
in fstabFileSystems: { rootPrefix ? "", excludeChecks ? false, extraOpts ? (fs: []) }: concatMapStrings (fs:
|
||||
in fstabFileSystems: { rootPrefix ? "", extraOpts ? (fs: []) }: concatMapStrings (fs:
|
||||
(optionalString (isBindMount fs) (escape rootPrefix))
|
||||
+ (if fs.device != null then escape fs.device
|
||||
else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
|
||||
else throw "No device specified for mount point ‘${fs.mountPoint}’.")
|
||||
+ " " + escape (rootPrefix + fs.mountPoint)
|
||||
+ " " + escape fs.mountPoint
|
||||
+ " " + fs.fsType
|
||||
+ " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
|
||||
+ " " + (optionalString (!excludeChecks)
|
||||
("0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")))
|
||||
+ " 0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")
|
||||
+ "\n"
|
||||
) fstabFileSystems;
|
||||
|
||||
initrdFstab = pkgs.writeText "initrd-fstab" (makeFstabEntries (filter utils.fsNeededForBoot fileSystems) {
|
||||
rootPrefix = "/sysroot";
|
||||
excludeChecks = true;
|
||||
extraOpts = fs:
|
||||
(optional fs.autoResize "x-systemd.growfs")
|
||||
++ (optional fs.autoFormat "x-systemd.makefs");
|
||||
|
@ -328,7 +358,9 @@ in
|
|||
)}
|
||||
'';
|
||||
|
||||
boot.initrd.systemd.contents."/etc/fstab".source = initrdFstab;
|
||||
boot.initrd.systemd.storePaths = [initrdFstab];
|
||||
boot.initrd.systemd.managerEnvironment.SYSTEMD_SYSROOT_FSTAB = initrdFstab;
|
||||
boot.initrd.systemd.services.initrd-parse-etc.environment.SYSTEMD_SYSROOT_FSTAB = initrdFstab;
|
||||
|
||||
# Provide a target that pulls in all filesystems.
|
||||
systemd.targets.fs =
|
||||
|
|
|
@ -1101,15 +1101,17 @@ in
|
|||
what = "overlay";
|
||||
type = "overlay";
|
||||
options = "lowerdir=/sysroot/nix/.ro-store,upperdir=/sysroot/nix/.rw-store/store,workdir=/sysroot/nix/.rw-store/work";
|
||||
wantedBy = ["local-fs.target"];
|
||||
before = ["local-fs.target"];
|
||||
requires = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
||||
after = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
||||
unitConfig.IgnoreOnIsolate = true;
|
||||
wantedBy = ["initrd-fs.target"];
|
||||
before = ["initrd-fs.target"];
|
||||
requires = ["rw-store.service"];
|
||||
after = ["rw-store.service"];
|
||||
unitConfig.RequiresMountsFor = "/sysroot/nix/.ro-store";
|
||||
}];
|
||||
services.rw-store = {
|
||||
after = ["sysroot-nix-.rw\\x2dstore.mount"];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
unitConfig = {
|
||||
DefaultDependencies = false;
|
||||
RequiresMountsFor = "/sysroot/nix/.rw-store";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "/bin/mkdir -p -m 0755 /sysroot/nix/.rw-store/store /sysroot/nix/.rw-store/work /sysroot/nix/store";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue