Commit 5fba496d authored by K900's avatar K900
Browse files

Merge remote-tracking branch 'origin/staging-next' into staging

parents 523bbc86 7044a043
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ jobs:
  update:
    runs-on: ubuntu-24.04-arm
    if: github.event_name != 'schedule' || github.repository_owner == 'NixOS'
    env:
      # TODO: Remove after 2026-03-04, when Node 24 becomes the default.
      # https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
      FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
+6 −29
Original line number Diff line number Diff line
@@ -72,20 +72,7 @@ module.exports = async ({ github, context, core, dry }) => {
          exclude_pull_requests: true,
          head_sha: pull_request.head.sha,
        })
      ).data.workflow_runs[0] ??
      // TODO: Remove this after 2025-09-17, at which point all eval.yml artifacts will have expired.
      (
        await github.rest.actions.listWorkflowRuns({
          ...context.repo,
          // In older PRs, we need eval.yml instead of pr.yml.
          workflow_id: 'eval.yml',
          event: 'pull_request_target',
          status: 'success',
          exclude_pull_requests: true,
          head_sha: pull_request.head.sha,
        })
      ).data.workflow_runs[0] ??
      {}
      ).data.workflow_runs[0] ?? {}

    // Newer PRs might not have run Eval to completion, yet.
    // Older PRs might not have an eval.yml workflow, yet.
@@ -159,20 +146,10 @@ module.exports = async ({ github, context, core, dry }) => {
        await readFile(`${pull_number}/changed-paths.json`, 'utf-8'),
      ).labels

      Object.assign(
        prLabels,
        // Ignore `evalLabels` if it's an array.
        // This can happen for older eval runs, before we switched to objects.
        // The old eval labels would have been set by the eval run,
        // so now they'll be present in `before`.
        // TODO: Simplify once old eval results have expired (~2025-10)
        Array.isArray(evalLabels) ? undefined : evalLabels,
        {
          '12.approved-by: package-maintainer': Array.from(maintainers).some(
            (m) => approvals.has(m),
          ),
        },
      )
      Object.assign(prLabels, evalLabels, {
        '12.approved-by: package-maintainer':
          maintainers.intersection(approvals).size > 0,
      })
    }

    return prLabels
@@ -372,7 +349,7 @@ module.exports = async ({ github, context, core, dry }) => {
            `updated:>=${cutoff.toISOString()}`,
          ].join(' AND '),
          per_page: 100,
          // TODO: Remove in 2025-10, when it becomes the default.
          // TODO: Remove after 2025-11-04, when it becomes the default.
          advanced_search: true,
        },
      )
+13 −7
Original line number Diff line number Diff line
@@ -7370,12 +7370,6 @@
    github = "eigengrau";
    githubId = 4939947;
  };
  eihqnh = {
    email = "eihqnh@outlook.com";
    github = "eihqnh";
    githubId = 40905037;
    name = "eihqnh";
  };
  eikek = {
    email = "eike.kettner@posteo.de";
    github = "eikek";
@@ -15845,7 +15839,7 @@
    githubId = 13599169;
  };
  marius851000 = {
    email = "mariusdavid@laposte.net";
    email = "nix@mariusdavid.fr";
    name = "Marius David";
    github = "marius851000";
    githubId = 22586596;
@@ -23217,6 +23211,12 @@
    githubId = 11320;
    name = "Sergiu Ivanov";
  };
  scottstephens = {
    email = "stephens.js@gmail.com";
    github = "scottstephens";
    githubId = 526260;
    name = "Scott Stephens";
  };
  scraptux = {
    email = "git@thomasjasny.de";
    github = "scraptux";
@@ -26206,6 +26206,12 @@
    githubId = 48209000;
    name = "Anna Gillert";
  };
  tlvince = {
    email = "nixos@tlvince.com";
    github = "tlvince";
    githubId = 323761;
    name = "Tom Vincent";
  };
  tm-drtina = {
    email = "tm.drtina@gmail.com";
    github = "tm-drtina";
+4 −1
Original line number Diff line number Diff line
@@ -388,5 +388,8 @@ in
  );

  meta.doc = ./tpm2.md;
  meta.maintainers = with lib.maintainers; [ lschuermann ];
  meta.maintainers = with lib.maintainers; [
    lschuermann
    scottstephens
  ];
}
+88 −63
Original line number Diff line number Diff line
@@ -16,6 +16,68 @@ let
        lib.concatMapStrings (s: "\n  ${lib.generators.mkValueStringDefault { } s}") l;
    mkKeyValue = lib.generators.mkKeyValueDefault { } ":";
  };
  firmwareSubmodule = lib.types.submodule (
    { name, ... }@local:
    let
      mcu = local.name;
      subcfg = local.config;
    in
    {
      options = {
        enable = lib.mkEnableOption ''
          building of firmware for manual flashing
        '';
        enableKlipperFlash = lib.mkEnableOption ''
          flashings scripts for firmware. This will add `klipper-flash-$mcu` scripts to your environment which can be called to flash the firmware.
          Please check the configs at [klipper](https://github.com/Klipper3d/klipper/tree/master/config) whether your board supports flashing via `make flash`
        '';
        serial = lib.mkOption {
          type = lib.types.nullOr lib.types.path;
          description = "Path to serial port this printer is connected to. Derived from `service.klipper.settings` by default.";
          defaultText = lib.literalExpression "config.services.klipper.settings.<name>.serial";
          default =
            if lib.hasAttrByPath [ "${mcu}" "serial" ] cfg.settings then cfg.settings."${mcu}".serial else null;
        };
        configFile = lib.mkOption {
          type = lib.types.path;
          description = "Path to firmware config which is generated using `klipper-genconf`";
        };
        package = lib.mkOption {
          type = lib.types.nullOr lib.types.package;
          readOnly = true;
          description = "Path to the built firmware package.";
        };
        klipperFlashPackage = lib.mkOption {
          type = lib.types.nullOr lib.types.package;
          readOnly = true;
          description = "Path to the built klipper-flash package.";
        };
      };
      config = {
        package =
          if subcfg.enable then
            pkgs.klipper-firmware.override {
              klipper = cfg.package;
              mcu = lib.strings.sanitizeDerivationName mcu;
              firmwareConfig = subcfg.configFile;
            }
          else
            null;

        klipperFlashPackage =
          if subcfg.enable && subcfg.enableKlipperFlash then
            pkgs.klipper-flash.override {
              klipper = cfg.package;
              klipper-firmware = subcfg.package;
              mcu = lib.strings.sanitizeDerivationName mcu;
              flashDevice = subcfg.serial;
              firmwareConfig = subcfg.configFile;
            }
          else
            null;
      };
    }
  );
in
{
  imports = [
@@ -119,30 +181,17 @@ in
      };

      firmwares = lib.mkOption {
        description = "Firmwares klipper should manage";
        description = "Firmwares Klipper should manage";
        default = { };
        type =
          with lib.types;
          attrsOf (submodule {
            options = {
              enable = lib.mkEnableOption ''
                building of firmware for manual flashing
              '';
              enableKlipperFlash = lib.mkEnableOption ''
                flashings scripts for firmware. This will add `klipper-flash-$mcu` scripts to your environment which can be called to flash the firmware.
                Please check the configs at [klipper](https://github.com/Klipper3d/klipper/tree/master/config) whether your board supports flashing via `make flash`
              '';
              serial = lib.mkOption {
                type = lib.types.nullOr path;
                default = null;
                description = "Path to serial port this printer is connected to. Leave `null` to derive it from `service.klipper.settings`.";
              };
              configFile = lib.mkOption {
                type = path;
                description = "Path to firmware config which is generated using `klipper-genconf`";
        type = lib.types.attrsOf firmwareSubmodule;
        example = {
          mcu = {
            enable = true;
            enableKlipperFlash = true;
            serial = "/dev/serial/by-id/usb-Klipper_123ABCDEF";
            configFile = lib.literalExpression "./klipper-firmware.cfg";
          };
        };
          });
      };
    };
  };
@@ -158,16 +207,6 @@ in
        assertion = cfg.user != null -> cfg.group != null;
        message = "Option services.klipper.group is not set when services.klipper.user is specified.";
      }
      {
        assertion =
          cfg.settings != null
          -> lib.foldl (a: b: a && b) true (
            lib.mapAttrsToList (
              mcu: _: mcu != null -> (lib.hasAttrByPath [ "${mcu}" "serial" ] cfg.settings)
            ) cfg.firmwares
          );
        message = "Option services.klipper.settings.$mcu.serial must be set when settings.klipper.firmware.$mcu is specified";
      }
      {
        assertion = (cfg.configFile != null) != (cfg.settings != null);
        message = "You need to either specify services.klipper.settings or services.klipper.configFile.";
@@ -176,7 +215,16 @@ in
        assertion = (cfg.configFile != null) -> (cfg.extraSettings == "");
        message = "You can't use services.klipper.extraSettings with services.klipper.configFile.";
      }
    ];
    ]
    ++ lib.mapAttrsToList (mcu: firmware: {
      assertion = firmware.enable -> firmware.serial != null;
      message = ''
        Unable to determine the serial connection for services.klipper.firmwares."${mcu}". Please set one of the following:

          - services.klipper.firmwares."${mcu}".serial
          - services.klipper.settings."${mcu}".serial
      '';
    }) cfg.firmwares;

    services.klipper = lib.mkIf cfg.octoprintIntegration {
      user = config.services.octoprint.user;
@@ -257,37 +305,14 @@ in
        genconf = pkgs.klipper-genconf.override {
          klipper = cfg.package;
        };
        firmwares = lib.filterAttrs (n: v: v != null) (
          lib.mapAttrs (
            mcu:
            {
              enable,
              enableKlipperFlash,
              configFile,
              serial,
            }:
            if enable then
              pkgs.klipper-firmware.override {
                klipper = cfg.package;
                mcu = lib.strings.sanitizeDerivationName mcu;
                firmwareConfig = configFile;
              }
            else
              null
          ) cfg.firmwares
        firmwares = lib.filter (v: v != null) (
          lib.mapAttrsToList (mcu: firmware: firmware.package) cfg.firmwares
        );
        firmwareFlashers = lib.filter (v: v != null) (
          lib.mapAttrsToList (mcu: firmware: firmware.klipperFlashPackage) cfg.firmwares
        );
        firmwareFlasher = lib.mapAttrsToList (
          mcu: firmware:
          pkgs.klipper-flash.override {
            klipper = cfg.package;
            klipper-firmware = firmware;
            mcu = lib.strings.sanitizeDerivationName mcu;
            flashDevice = default cfg.firmwares."${mcu}".serial cfg.settings."${mcu}".serial;
            firmwareConfig = cfg.firmwares."${mcu}".configFile;
          }
        ) (lib.filterAttrs (mcu: firmware: cfg.firmwares."${mcu}".enableKlipperFlash) firmwares);
      in
      [ genconf ] ++ firmwareFlasher ++ lib.attrValues firmwares;
      [ genconf ] ++ firmwares ++ firmwareFlashers;
  };
  meta.maintainers = [
    lib.maintainers.cab404
Loading