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

staging-nixos merge for 2026-02-16 (#490990)

parents 9a6db6bb db023774
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -62,6 +62,19 @@ in

  config = lib.mkIf cfg.enable {

    warnings = lib.optional (cfg.powerUpCommands != "") ''
      powerManagement.powerUpCommands is deprecated due to it having unclear ordering semantics.
      It will be removed in NixOS 26.11.
      It is recommended to create an explicit systemd oneshot service instead,
      that is pulled in at the right time during the boot process.
      See https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html
      for more information on possible targets that can be used for this.

      If you also want to run this service upon waking up from resume, the recommended
      method to do so is described here:
      https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#sleep.target
    '';

    systemd.targets.post-resume = {
      description = "Post-Resume Actions";
      requires = [ "post-resume.service" ];
@@ -81,14 +94,25 @@ in
      serviceConfig.Type = "oneshot";
    };

    systemd.services.post-boot = {
      description = "Post-boot Actions";
      # It's not well defined at what point in the bootup sequence this should run
      # we should eventually just remove this.
      wantedBy = [ "multi-user.target" ];
      restartIfChanged = false;
      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = true;
      };
      script = ''
        ${cfg.powerUpCommands}
      '';
    };

    systemd.services.post-resume = {
      description = "Post-Resume Actions";
      after = [
        "suspend.target"
        "hibernate.target"
        "hybrid-sleep.target"
        "suspend-then-hibernate.target"
      ];
      # Pulled in by post-resume.service above
      after = [ "sleep.target" ];
      script = ''
        /run/current-system/systemd/bin/systemctl try-restart --no-block post-resume.target
        ${cfg.resumeCommands}
+2 −0
Original line number Diff line number Diff line
@@ -742,6 +742,8 @@ in
      };

      systemd = {
        generatorPath = [ cfg.package ];

        sockets.sshd = lib.mkIf cfg.startWhenNeeded {
          description = "SSH Socket";
          wantedBy = [ "sockets.target" ];
+0 −4
Original line number Diff line number Diff line
@@ -58,10 +58,6 @@ in
          assertion = config.boot.postBootCommands == "";
          message = "nixos-init cannot be used with boot.postBootCommands";
        }
        {
          assertion = config.powerManagement.powerUpCommands == "";
          message = "nixos-init cannot be used with powerManagement.powerUpCommands";
        }
      ];
    })
  ];
+0 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ let
      );
      postBootCommands = pkgs.writeText "local-cmds" ''
        ${config.boot.postBootCommands}
        ${config.powerManagement.powerUpCommands}
      '';
    };
  };
+41 −6
Original line number Diff line number Diff line
@@ -233,6 +233,8 @@ let

  proxy_env = config.networking.proxy.envVars;

  json = pkgs.formats.json { };

in

{
@@ -356,6 +358,28 @@ in
      '';
    };

    generatorEnvironment = mkOption {
      type = types.attrsOf types.str;
      default = { };
      example = {
        MY_VAR = "my-value";
      };
      description = ''
        Environment variables for systemd generators.

        The `PATH` environment variable is populated via `systemd.generatorPath`.
      '';
    };

    generatorPath = mkOption {
      type = types.listOf types.package;
      default = [ ];
      example = lib.literalExpression "[ pkgs.hello ]";
      description = ''
        Packages added to the `PATH` environment variable of all systemd generators.
      '';
    };

    shutdown = mkOption {
      type = types.attrsOf types.path;
      default = { };
@@ -636,6 +660,12 @@ in
        "systemd/user-preset/00-nixos.preset".text = ''
          ignore *
        '';

        "systemd/generator-environment.json".source =
          json.generate "systemd-generator-environment.json" cfg.generatorEnvironment;

        "systemd/system-environment-generators/env-generator".source =
          "${config.system.nixos-init.package}/bin/env-generator";
      };

    services.dbus.enable = true;
@@ -683,12 +713,7 @@ in
    systemd.managerEnvironment = {
      # Doesn't contain systemd itself - everything works so it seems to use the compiled-in value for its tools
      # util-linux is needed for the main fsck utility wrapping the fs-specific ones
      PATH = lib.makeBinPath (
        config.system.fsPackages
        ++ [ cfg.package.util-linux ]
        # systemd-ssh-generator needs sshd in PATH
        ++ lib.optional config.services.openssh.enable config.services.openssh.package
      );
      PATH = lib.makeBinPath (config.system.fsPackages ++ [ cfg.package.util-linux ]);
      LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
      TZDIR = "/etc/zoneinfo";
      # If SYSTEMD_UNIT_PATH ends with an empty component (":"), the usual unit load path will be appended to the contents of the variable
@@ -704,6 +729,16 @@ in
      DefaultIPAccounting = lib.mkDefault true;
    };

    # These are needed for systemd-fstab-generator to schedule systemd-fsck@
    # units.
    systemd.generatorPath = config.system.fsPackages ++ [
      cfg.package.util-linux
    ];

    systemd.generatorEnvironment = {
      PATH = lib.makeBinPath cfg.generatorPath;
    };

    system.requiredKernelConfig = map config.lib.kernelConfig.isEnabled [
      "DEVTMPFS"
      "CGROUPS"
Loading