diff --git a/flake.nix b/flake.nix index 0c0ddfa47..e160cbfef 100644 --- a/flake.nix +++ b/flake.nix @@ -167,6 +167,13 @@ inherit officialRelease; pkgs = final; src = self; + maintainers = with lib.maintainers; [ + edolstra + Ericson2314 + Mic92 + roberth + tomberek + ]; }; }; diff --git a/packaging/components.nix b/packaging/components.nix index 991d54241..cd1d219b8 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -3,6 +3,7 @@ pkgs, src, officialRelease, + maintainers, }: scope: @@ -110,7 +111,7 @@ let let n = lib.length finalScope.patches; 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. fileset = null; @@ -180,9 +181,24 @@ let mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [ ]; }; - miscGoodPractice = finalAttrs: prevAttrs: { + nixDefaultsLayer = finalAttrs: prevAttrs: { strictDeps = prevAttrs.strictDeps or 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; inherit versionSuffix; + inherit maintainers; inherit filesetToSource; @@ -237,6 +254,10 @@ in but it does make the build non-granular; all components will use a complete source. Packaging expressions will be ignored. + + Single argument: the source to use. + + See also `appendPatches` */ overrideSource = src: @@ -265,6 +286,7 @@ in } ); resolvePath = p: finalScope.patchedSrc + "/${resolveRelPath p}"; + filesetToSource = { root, fileset }: finalScope.resolvePath root; appendPatches = appendPatches finalScope; } ); @@ -281,14 +303,14 @@ in (scope.overrideSource "${./..}").appendPatches patches; mkMesonDerivation = mkPackageBuilder [ - miscGoodPractice + nixDefaultsLayer scope.sourceLayer setVersionLayer mesonLayer scope.mesonComponentOverrides ]; mkMesonExecutable = mkPackageBuilder [ - miscGoodPractice + nixDefaultsLayer bsdNoLinkAsNeeded scope.sourceLayer setVersionLayer @@ -297,7 +319,7 @@ in scope.mesonComponentOverrides ]; mkMesonLibrary = mkPackageBuilder [ - miscGoodPractice + nixDefaultsLayer bsdNoLinkAsNeeded scope.sourceLayer mesonLayer @@ -347,7 +369,7 @@ in nix-perl-bindings = callPackage ../src/perl/package.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 # `f` when `.overrideAllMesonComponents` is used. # Both "methods" should be views on the same fixpoint overriding mechanism @@ -355,6 +377,8 @@ in # two-fixpoint solution. /** 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; @@ -363,6 +387,10 @@ in This affects all components. 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; @@ -371,8 +399,26 @@ in but it does make the build non-granular; all components will use a complete source. 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; + /** + 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; + }; } diff --git a/packaging/everything.nix b/packaging/everything.nix index 2c65f209f..1835eefb6 100644 --- a/packaging/everything.nix +++ b/packaging/everything.nix @@ -4,6 +4,8 @@ lndir, buildEnv, + maintainers, + nix-util, nix-util-c, nix-util-tests, @@ -39,6 +41,8 @@ nix-perl-bindings, testers, + + patchedSrc ? null, }: 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 { name = "nix-${nix-cli.version}-devdoc"; paths = [ @@ -192,10 +154,15 @@ stdenv.mkDerivation (finalAttrs: { devPaths = lib.mapAttrsToList (_k: lib.getDev) finalAttrs.finalPackage.libs; 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 lndir ${nix-cli} $out + for lib in ${lib.escapeShellArgs devPaths}; do lndir $lib $dev done @@ -207,6 +174,7 @@ stdenv.mkDerivation (finalAttrs: { passthru = { inherit (nix-cli) version; + src = patchedSrc; /** These are the libraries that are part of the Nix project. They are used @@ -248,7 +216,29 @@ stdenv.mkDerivation (finalAttrs: { meta = { mainProgram = "nix"; 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" + ]; }; })