From 7e4456af3ebded53c6d0164ba1af419e7340a3ab Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Mon, 2 Nov 2026 19:53:17 +0100 Subject: pkgs/*: Use a `stable`/`unstable` marker in the filename --- pkgs/by-name/fe/fetchmail-common-name/package.nix | 12 ---- .../fe/fetchmail-common-name/package.stable.nix | 12 ++++ pkgs/by-name/st/stalwart-mail-patched/package.nix | 72 ---------------------- .../st/stalwart-mail-patched/package.stable.nix | 72 ++++++++++++++++++++++ pkgs/default.nix | 18 +++--- 5 files changed, 95 insertions(+), 91 deletions(-) delete mode 100644 pkgs/by-name/fe/fetchmail-common-name/package.nix create mode 100644 pkgs/by-name/fe/fetchmail-common-name/package.stable.nix delete mode 100644 pkgs/by-name/st/stalwart-mail-patched/package.nix create mode 100644 pkgs/by-name/st/stalwart-mail-patched/package.stable.nix (limited to 'pkgs') diff --git a/pkgs/by-name/fe/fetchmail-common-name/package.nix b/pkgs/by-name/fe/fetchmail-common-name/package.nix deleted file mode 100644 index 7c03e2e..0000000 --- a/pkgs/by-name/fe/fetchmail-common-name/package.nix +++ /dev/null @@ -1,12 +0,0 @@ -{fetchmail}: -fetchmail.overrideAttrs (final: prev: { - pname = "fetchmail-common-name"; - - patches = - (prev.patches or []) - ++ [ - ./patches/0001-fix-socket.c-Correctly-check-the-common-name-even-if.patch - ]; - - meta.mainProgram = prev.meta.mainProgram or "fetchmail"; -}) diff --git a/pkgs/by-name/fe/fetchmail-common-name/package.stable.nix b/pkgs/by-name/fe/fetchmail-common-name/package.stable.nix new file mode 100644 index 0000000..7c03e2e --- /dev/null +++ b/pkgs/by-name/fe/fetchmail-common-name/package.stable.nix @@ -0,0 +1,12 @@ +{fetchmail}: +fetchmail.overrideAttrs (final: prev: { + pname = "fetchmail-common-name"; + + patches = + (prev.patches or []) + ++ [ + ./patches/0001-fix-socket.c-Correctly-check-the-common-name-even-if.patch + ]; + + meta.mainProgram = prev.meta.mainProgram or "fetchmail"; +}) diff --git a/pkgs/by-name/st/stalwart-mail-patched/package.nix b/pkgs/by-name/st/stalwart-mail-patched/package.nix deleted file mode 100644 index f9bcdaa..0000000 --- a/pkgs/by-name/st/stalwart-mail-patched/package.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ - stalwart-mail, - callPackage, - nixLib, - rustPlatform, - lib, -}: let - spamfilter = callPackage ./spam-filter.nix {}; -in - stalwart-mail.override { - rustPlatform = - rustPlatform - // { - buildRustPackage = prev_base: let - prev = lib.fix prev_base; - in - rustPlatform.buildRustPackage ( - lib.attrsets.recursiveUpdate - prev - { - pname = "stalwart-mail-patched"; - - passthru = nixLib.warnMerge (prev.passthru or {}) { - # Use a reproducible source for the spamfilter - # instead of fetching it at runtime from GitHub. - inherit spamfilter; - } "stalwart-mail passthru"; - - cargoHash = "sha256-Rq18JumjKYt97WKIqnLakS+FQwsjt70irlYBYAYm3H8="; - - # The NixOS build tests should check if this works. - # And this shaves of around 50% of the build time. - doCheck = false; - - # We are already overriding it, so shaving of some unused features is okay. - buildNoDefaultFeatures = true; - buildFeatures = [ - # "sqlite" - # "postgres" - # "mysql" - "rocks" - # "elastic" - # "s3" - "redis" - "tls-native-roots" - ]; - - cargoPatches = - (prev.cargoPatches or []) - ++ [ - # `stalwart-mail` uses their bundled store, which makes it impossible to use our - # own CA certificate (e.g., for tests). Thus use a native version. - ./patches/0001-Allow-to-switch-to-operating-system-CA-root-store.patch - ]; - - # Check that the enterprise feature is really disabled. - postCheck = - (prev.postCheck or "") - + - # bash - '' - if grep "enterprise" ./target/*/release/stalwart-mail.d; then - echo "ERROR: Proprietary 'enterprise' feature active." - exit 1 - fi - ''; - - meta.mainProgram = prev.meta.mainProgram or "stalwart-mail"; - } - ); - }; - } diff --git a/pkgs/by-name/st/stalwart-mail-patched/package.stable.nix b/pkgs/by-name/st/stalwart-mail-patched/package.stable.nix new file mode 100644 index 0000000..f9bcdaa --- /dev/null +++ b/pkgs/by-name/st/stalwart-mail-patched/package.stable.nix @@ -0,0 +1,72 @@ +{ + stalwart-mail, + callPackage, + nixLib, + rustPlatform, + lib, +}: let + spamfilter = callPackage ./spam-filter.nix {}; +in + stalwart-mail.override { + rustPlatform = + rustPlatform + // { + buildRustPackage = prev_base: let + prev = lib.fix prev_base; + in + rustPlatform.buildRustPackage ( + lib.attrsets.recursiveUpdate + prev + { + pname = "stalwart-mail-patched"; + + passthru = nixLib.warnMerge (prev.passthru or {}) { + # Use a reproducible source for the spamfilter + # instead of fetching it at runtime from GitHub. + inherit spamfilter; + } "stalwart-mail passthru"; + + cargoHash = "sha256-Rq18JumjKYt97WKIqnLakS+FQwsjt70irlYBYAYm3H8="; + + # The NixOS build tests should check if this works. + # And this shaves of around 50% of the build time. + doCheck = false; + + # We are already overriding it, so shaving of some unused features is okay. + buildNoDefaultFeatures = true; + buildFeatures = [ + # "sqlite" + # "postgres" + # "mysql" + "rocks" + # "elastic" + # "s3" + "redis" + "tls-native-roots" + ]; + + cargoPatches = + (prev.cargoPatches or []) + ++ [ + # `stalwart-mail` uses their bundled store, which makes it impossible to use our + # own CA certificate (e.g., for tests). Thus use a native version. + ./patches/0001-Allow-to-switch-to-operating-system-CA-root-store.patch + ]; + + # Check that the enterprise feature is really disabled. + postCheck = + (prev.postCheck or "") + + + # bash + '' + if grep "enterprise" ./target/*/release/stalwart-mail.d; then + echo "ERROR: Proprietary 'enterprise' feature active." + exit 1 + fi + ''; + + meta.mainProgram = prev.meta.mainProgram or "stalwart-mail"; + } + ); + }; + } diff --git a/pkgs/default.nix b/pkgs/default.nix index 4fdb94f..bc7d70e 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -6,16 +6,20 @@ inherit (unstable_pkgs) lib; mergePkgs = pkgs: lib.callPackageWith (extra_lib.warnMerge pkgs in_tree_pkgs "the ./pkgs/by-name set"); - callPackageStable = lib.callPackageWith (mergePkgs stable_pkgs); - callPackageUnstable = lib.callPackageWith (mergePkgs unstable_pkgs); + callPackageStable = mergePkgs stable_pkgs; + callPackageUnstable = mergePkgs unstable_pkgs; in_tree_pkgs = extra_lib.mkByName { baseDirectory = ./by-name; - fileName = "package.nix"; - finalizeFunction = name: value: - if value.stable - then callPackageStable value.pkg {} - else callPackageUnstable value.pkg {}; + fileRegex = "package.(stable|unstable).nix"; + finalizeFunction = name: pkgPathList: let + # When specifying a regex `mkByName` returns a list of candidates. + # But we know, that there can only be one. + pkgPath = builtins.head pkgPathList; + in + if (builtins.match "(stable)" (builtins.baseNameOf pkgPath)) == ["stable"] + then callPackageStable pkgPath {} + else callPackageUnstable pkgPath {}; }; in in_tree_pkgs -- cgit v1.3.1