mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
packaging: Various improvements
Co-authored-by: Mic92 <Mic92@users.noreply.github.com>
This commit is contained in:
parent
c57e2486df
commit
1172e49a3a
3 changed files with 93 additions and 50 deletions
|
@ -156,6 +156,13 @@
|
||||||
inherit officialRelease;
|
inherit officialRelease;
|
||||||
pkgs = final;
|
pkgs = final;
|
||||||
src = self;
|
src = self;
|
||||||
|
maintainers = with lib.maintainers; [
|
||||||
|
edolstra
|
||||||
|
Ericson2314
|
||||||
|
Mic92
|
||||||
|
roberth
|
||||||
|
tomberek
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -173,9 +174,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);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,6 +211,7 @@ in
|
||||||
{
|
{
|
||||||
version = baseVersion + versionSuffix;
|
version = baseVersion + versionSuffix;
|
||||||
inherit versionSuffix;
|
inherit versionSuffix;
|
||||||
|
inherit maintainers;
|
||||||
|
|
||||||
inherit filesetToSource;
|
inherit filesetToSource;
|
||||||
|
|
||||||
|
@ -230,6 +247,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:
|
||||||
|
@ -258,6 +279,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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -274,14 +296,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
|
||||||
|
@ -290,7 +312,7 @@ in
|
||||||
scope.mesonComponentOverrides
|
scope.mesonComponentOverrides
|
||||||
];
|
];
|
||||||
mkMesonLibrary = mkPackageBuilder [
|
mkMesonLibrary = mkPackageBuilder [
|
||||||
miscGoodPractice
|
nixDefaultsLayer
|
||||||
bsdNoLinkAsNeeded
|
bsdNoLinkAsNeeded
|
||||||
scope.sourceLayer
|
scope.sourceLayer
|
||||||
mesonLayer
|
mesonLayer
|
||||||
|
@ -340,7 +362,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
|
||||||
|
@ -348,6 +370,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;
|
||||||
|
|
||||||
|
@ -356,6 +380,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;
|
||||||
|
|
||||||
|
@ -364,8 +392,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;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue