Unverified Commit 7bc18b63 authored by K900's avatar K900 Committed by GitHub
Browse files

Merge pull request #227633 from ElvishJerricco/systemd-stage-1-fix-initrd-commands

Systemd stage 1 assert initrd commands are empty
parents 70f835f9 cca22054
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ in

    boot.kernelParams = mkIf (!config.networking.usePredictableInterfaceNames) [ "net.ifnames=0" ];

    boot.initrd.extraUdevRulesCommands = optionalString (!config.boot.initrd.systemd.enable && config.boot.initrd.services.udev.rules != "")
    boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable && config.boot.initrd.services.udev.rules != "")
      ''
        cat <<'EOF' > $out/99-local.rules
        ${config.boot.initrd.services.udev.rules}
+2 −1
Original line number Diff line number Diff line
@@ -546,8 +546,9 @@ in {
    # We do not have systemd in stage-1 boot so must invoke `multipathd`
    # with the `-1` argument which disables systemd calls. Invoke `multipath`
    # to display the multipath mappings in the output of `journalctl -b`.
    # TODO: Implement for systemd stage 1
    boot.initrd.kernelModules = [ "dm-multipath" "dm-service-time" ];
    boot.initrd.postDeviceCommands = ''
    boot.initrd.postDeviceCommands = mkIf (!config.boot.initrd.systemd.enable) ''
      modprobe -a dm-multipath dm-service-time
      multipathd -s
      (set -x && sleep 1 && multipath -ll)
+4 −4
Original line number Diff line number Diff line
@@ -116,11 +116,11 @@ in

    boot.initrd.kernelModules = [ "af_packet" ];

    boot.initrd.extraUtilsCommands = ''
    boot.initrd.extraUtilsCommands = mkIf (!config.boot.initrd.systemd.enable) ''
      copy_bin_and_libs ${pkgs.klibc}/lib/klibc/bin.static/ipconfig
    '';

    boot.initrd.preLVMCommands = mkBefore (
    boot.initrd.preLVMCommands = mkIf (!config.boot.initrd.systemd.enable) (mkBefore (
      # Search for interface definitions in command line.
      ''
        ifaces=""
@@ -148,9 +148,9 @@ in
        done
      ''

      + cfg.postCommands);
      + cfg.postCommands));

    boot.initrd.postMountCommands = mkIf cfg.flushBeforeStage2 ''
    boot.initrd.postMountCommands = mkIf (cfg.flushBeforeStage2 && !config.boot.initrd.systemd.enable) ''
      for iface in $ifaces; do
        ip address flush dev "$iface"
        ip link set dev "$iface" down
+21 −0
Original line number Diff line number Diff line
@@ -348,6 +348,27 @@ in {
  };

  config = mkIf (config.boot.initrd.enable && cfg.enable) {
    assertions = map (name: {
      assertion = lib.attrByPath name (throw "impossible") config.boot.initrd == "";
      message = ''
        systemd stage 1 does not support 'boot.initrd.${lib.concatStringsSep "." name}'. Please
          convert it to analogous systemd units in 'boot.initrd.systemd'.

            Definitions:
        ${lib.concatMapStringsSep "\n" ({ file, ... }: "    - ${file}") (lib.attrByPath name (throw "impossible") options.boot.initrd).definitionsWithLocations}
      '';
    }) [
      [ "preFailCommands" ]
      [ "preDeviceCommands" ]
      [ "preLVMCommands" ]
      [ "postDeviceCommands" ]
      [ "postMountCommands" ]
      [ "extraUdevRulesCommands" ]
      [ "extraUtilsCommands" ]
      [ "extraUtilsCommandsTest" ]
      [ "network" "postCommands" ]
    ];

    system.build = { inherit initialRamdisk; };

    boot.initrd.availableKernelModules = [
+4 −3
Original line number Diff line number Diff line
@@ -110,10 +110,11 @@ in
          }) earlyEncDevs);
        forceLuksSupportInInitrd = true;
      };
      postMountCommands =
        concatMapStrings (dev:
      # TODO: systemd stage 1
      postMountCommands = lib.mkIf (!config.boot.initrd.systemd.enable)
        (concatMapStrings (dev:
          "cryptsetup luksOpen --key-file ${dev.encrypted.keyFile} ${dev.encrypted.blkDev} ${dev.encrypted.label};\n"
        ) lateEncDevs;
        ) lateEncDevs);
    };
  };
}
Loading