1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Merge pull request #12864 from NixOS/mergify/bp/2.26-maintenance/pr-12810

Packaging improvements from Nixpkgs (backport #12810)
This commit is contained in:
mergify[bot] 2025-04-01 18:19:38 +00:00 committed by GitHub
commit 06add7e551
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 95 additions and 52 deletions

View file

@ -167,6 +167,13 @@
inherit officialRelease; inherit officialRelease;
pkgs = final; pkgs = final;
src = self; src = self;
maintainers = with lib.maintainers; [
edolstra
Ericson2314
Mic92
roberth
tomberek
];
}; };
}; };

View file

@ -3,6 +3,7 @@
pkgs, pkgs,
src, src,
officialRelease, officialRelease,
maintainers,
}: }:
scope: scope:
@ -110,7 +111,7 @@ let
let let
n = lib.length finalScope.patches; n = lib.length finalScope.patches;
in in
if n == 0 then finalAttrs.version else finalAttrs.version + "+${toString n}"; if n == 0 then prevAttrs.version else prevAttrs.version + "+${toString n}";
# Clear what `derivation` can't/shouldn't serialize; see prevAttrs.workDir. # Clear what `derivation` can't/shouldn't serialize; see prevAttrs.workDir.
fileset = null; fileset = null;
@ -180,9 +181,24 @@ let
mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [ ]; mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [ ];
}; };
miscGoodPractice = finalAttrs: prevAttrs: { nixDefaultsLayer = finalAttrs: prevAttrs: {
strictDeps = prevAttrs.strictDeps or true; strictDeps = prevAttrs.strictDeps or true;
enableParallelBuilding = true; enableParallelBuilding = true;
pos = builtins.unsafeGetAttrPos "pname" prevAttrs;
meta = prevAttrs.meta or { } // {
homepage = prevAttrs.meta.homepage or "https://nixos.org/nix";
longDescription =
prevAttrs.longDescription or ''
Nix is a powerful package manager for mainly Linux and other Unix systems that
makes package management reliable and reproducible. It provides atomic
upgrades and rollbacks, side-by-side installation of multiple versions of
a package, multi-user package management and easy setup of build
environments.
'';
license = prevAttrs.meta.license or lib.licenses.lgpl21Plus;
maintainers = prevAttrs.meta.maintainers or [ ] ++ scope.maintainers;
platforms = prevAttrs.meta.platforms or (lib.platforms.unix ++ lib.platforms.windows);
};
}; };
/** /**
@ -202,6 +218,7 @@ in
{ {
version = baseVersion + versionSuffix; version = baseVersion + versionSuffix;
inherit versionSuffix; inherit versionSuffix;
inherit maintainers;
inherit filesetToSource; inherit filesetToSource;
@ -237,6 +254,10 @@ in
but it does make the build non-granular; all components will use a complete source. but it does make the build non-granular; all components will use a complete source.
Packaging expressions will be ignored. Packaging expressions will be ignored.
Single argument: the source to use.
See also `appendPatches`
*/ */
overrideSource = overrideSource =
src: src:
@ -265,6 +286,7 @@ in
} }
); );
resolvePath = p: finalScope.patchedSrc + "/${resolveRelPath p}"; resolvePath = p: finalScope.patchedSrc + "/${resolveRelPath p}";
filesetToSource = { root, fileset }: finalScope.resolvePath root;
appendPatches = appendPatches finalScope; appendPatches = appendPatches finalScope;
} }
); );
@ -281,14 +303,14 @@ in
(scope.overrideSource "${./..}").appendPatches patches; (scope.overrideSource "${./..}").appendPatches patches;
mkMesonDerivation = mkPackageBuilder [ mkMesonDerivation = mkPackageBuilder [
miscGoodPractice nixDefaultsLayer
scope.sourceLayer scope.sourceLayer
setVersionLayer setVersionLayer
mesonLayer mesonLayer
scope.mesonComponentOverrides scope.mesonComponentOverrides
]; ];
mkMesonExecutable = mkPackageBuilder [ mkMesonExecutable = mkPackageBuilder [
miscGoodPractice nixDefaultsLayer
bsdNoLinkAsNeeded bsdNoLinkAsNeeded
scope.sourceLayer scope.sourceLayer
setVersionLayer setVersionLayer
@ -297,7 +319,7 @@ in
scope.mesonComponentOverrides scope.mesonComponentOverrides
]; ];
mkMesonLibrary = mkPackageBuilder [ mkMesonLibrary = mkPackageBuilder [
miscGoodPractice nixDefaultsLayer
bsdNoLinkAsNeeded bsdNoLinkAsNeeded
scope.sourceLayer scope.sourceLayer
mesonLayer mesonLayer
@ -347,7 +369,7 @@ in
nix-perl-bindings = callPackage ../src/perl/package.nix { }; nix-perl-bindings = callPackage ../src/perl/package.nix { };
nix-everything = callPackage ../packaging/everything.nix { } // { nix-everything = callPackage ../packaging/everything.nix { } // {
# Note: no `passthru.overrideAllMesonComponents` # Note: no `passthru.overrideAllMesonComponents` etc
# This would propagate into `nix.overrideAttrs f`, but then discard # This would propagate into `nix.overrideAttrs f`, but then discard
# `f` when `.overrideAllMesonComponents` is used. # `f` when `.overrideAllMesonComponents` is used.
# Both "methods" should be views on the same fixpoint overriding mechanism # Both "methods" should be views on the same fixpoint overriding mechanism
@ -355,6 +377,8 @@ in
# two-fixpoint solution. # two-fixpoint solution.
/** /**
Apply an extension function (i.e. overlay-shaped) to all component derivations, and return the nix package. Apply an extension function (i.e. overlay-shaped) to all component derivations, and return the nix package.
Single argument: the extension function to apply (finalAttrs: prevAttrs: { ... })
*/ */
overrideAllMesonComponents = f: (scope.overrideAllMesonComponents f).nix-everything; overrideAllMesonComponents = f: (scope.overrideAllMesonComponents f).nix-everything;
@ -363,6 +387,10 @@ in
This affects all components. This affects all components.
Changes to the packaging expressions will be ignored. Changes to the packaging expressions will be ignored.
Single argument: list of patches to apply
See also `overrideSource`
*/ */
appendPatches = ps: (scope.appendPatches ps).nix-everything; appendPatches = ps: (scope.appendPatches ps).nix-everything;
@ -371,8 +399,26 @@ in
but it does make the build non-granular; all components will use a complete source. but it does make the build non-granular; all components will use a complete source.
Packaging expressions will be ignored. Packaging expressions will be ignored.
Filesets in the packaging expressions will be ignored.
Single argument: the source to use.
See also `appendPatches`
*/ */
overrideSource = src: (scope.overrideSource src).nix-everything; overrideSource = src: (scope.overrideSource src).nix-everything;
/**
Override any internals of the Nix package set.
Single argument: the extension function to apply to the package set (finalScope: prevScope: { ... })
Example:
```
overrideScope (finalScope: prevScope: { aws-sdk-cpp = null; })
```
*/
overrideScope = f: (scope.overrideScope f).nix-everything;
}; };
} }

View file

@ -4,6 +4,8 @@
lndir, lndir,
buildEnv, buildEnv,
maintainers,
nix-util, nix-util,
nix-util-c, nix-util-c,
nix-util-tests, nix-util-tests,
@ -39,6 +41,8 @@
nix-perl-bindings, nix-perl-bindings,
testers, testers,
patchedSrc ? null,
}: }:
let let
@ -68,48 +72,6 @@ let
; ;
}; };
dev = stdenv.mkDerivation (finalAttrs: {
name = "nix-${nix-cli.version}-dev";
pname = "nix";
version = nix-cli.version;
dontUnpack = true;
dontBuild = true;
libs = map lib.getDev (lib.attrValues libs);
installPhase = ''
mkdir -p $out/nix-support
echo $libs >> $out/nix-support/propagated-build-inputs
'';
passthru = {
tests = {
pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};
# If we were to fully emulate output selection here, we'd confuse the Nix CLIs,
# because they rely on `drvPath`.
dev = finalAttrs.finalPackage.out;
libs = throw "`nix.dev.libs` is not meant to be used; use `nix.libs` instead.";
};
meta = {
mainProgram = "nix";
pkgConfigModules = [
"nix-cmd"
"nix-expr"
"nix-expr-c"
"nix-fetchers"
"nix-flake"
"nix-flake-c"
"nix-main"
"nix-main-c"
"nix-store"
"nix-store-c"
"nix-util"
"nix-util-c"
];
};
});
devdoc = buildEnv { devdoc = buildEnv {
name = "nix-${nix-cli.version}-devdoc"; name = "nix-${nix-cli.version}-devdoc";
paths = [ paths = [
@ -192,10 +154,15 @@ stdenv.mkDerivation (finalAttrs: {
devPaths = lib.mapAttrsToList (_k: lib.getDev) finalAttrs.finalPackage.libs; devPaths = lib.mapAttrsToList (_k: lib.getDev) finalAttrs.finalPackage.libs;
in in
'' ''
mkdir -p $out $dev mkdir -p $out $dev/nix-support
# Custom files
echo $libs >> $dev/nix-support/propagated-build-inputs
echo ${nix-cli} ${lib.escapeShellArgs devPaths} >> $dev/nix-support/propagated-build-inputs
# Merged outputs # Merged outputs
lndir ${nix-cli} $out lndir ${nix-cli} $out
for lib in ${lib.escapeShellArgs devPaths}; do for lib in ${lib.escapeShellArgs devPaths}; do
lndir $lib $dev lndir $lib $dev
done done
@ -207,6 +174,7 @@ stdenv.mkDerivation (finalAttrs: {
passthru = { passthru = {
inherit (nix-cli) version; inherit (nix-cli) version;
src = patchedSrc;
/** /**
These are the libraries that are part of the Nix project. They are used These are the libraries that are part of the Nix project. They are used
@ -248,7 +216,29 @@ stdenv.mkDerivation (finalAttrs: {
meta = { meta = {
mainProgram = "nix"; mainProgram = "nix";
description = "The Nix package manager"; description = "The Nix package manager";
pkgConfigModules = dev.meta.pkgConfigModules; longDescription = nix-cli.meta.longDescription;
homepage = nix-cli.meta.homepage;
license = nix-cli.meta.license;
maintainers = maintainers;
platforms = nix-cli.meta.platforms;
outputsToInstall = [
"out"
"man"
];
pkgConfigModules = [
"nix-cmd"
"nix-expr"
"nix-expr-c"
"nix-fetchers"
"nix-flake"
"nix-flake-c"
"nix-main"
"nix-main-c"
"nix-store"
"nix-store-c"
"nix-util"
"nix-util-c"
];
}; };
}) })

View file

@ -31,7 +31,7 @@ perl.pkgs.toPerlModule (
./meson.build ./meson.build
./meson.options ./meson.options
] ]
++ lib.optionals finalAttrs.doCheck [ ++ lib.optionals finalAttrs.finalPackage.doCheck [
./.yath.rc.in ./.yath.rc.in
./t ./t
] ]
@ -70,7 +70,7 @@ perl.pkgs.toPerlModule (
mesonFlags = [ mesonFlags = [
(lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}") (lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}")
(lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}") (lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}")
(lib.mesonEnable "tests" finalAttrs.doCheck) (lib.mesonEnable "tests" finalAttrs.finalPackage.doCheck)
]; ];
mesonCheckFlags = [ mesonCheckFlags = [