Skip to content

Commit

Permalink
libSrc: introduce a derivation which is the nixpkgs lib source
Browse files Browse the repository at this point in the history
  • Loading branch information
philiptaron committed Sep 2, 2024
1 parent 4f40c77 commit 1dc205b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkgs/pkgs-lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# pkgs-lib is for functions and values that can't be in lib because
# they depend on some packages. This notably is *not* for supporting package
# building, instead pkgs/build-support is the place for that.
{ lib, pkgs }: {
{ lib, pkgs }:

{
# setting format types and generators. These do not fit in lib/types.nix,
# because they depend on pkgs for rendering some formats
formats = import ./formats.nix {
inherit lib pkgs;
};

libSrc = pkgs.callPackage ./lib-src.nix { };
}

22 changes: 22 additions & 0 deletions pkgs/pkgs-lib/lib-src.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, stdenvNoCC }:

# Produces a derivation which contains **just** the top-level `lib` directory in `nixpkgs`,
# but maintains the same structure, so it's in the `$out/lib` == `./lib`.
#
# This allows Nix-using derivations inside Nixpkgs to be rebuilt when `lib` changes but not
# for other changes in the tree.
stdenvNoCC.mkDerivation {
name = "nixpkgs-lib";

src = lib.fileset.toSource {
root = ../..;
fileset = ../../lib;
};

installPhase = ''
runHook preInstall
mkdir $out
cp -ar $src/* $out
runHook postInstall
'';
}
3 changes: 3 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22418,6 +22418,9 @@ with pkgs;

libzdb = callPackage ../development/libraries/libzdb { };

# The Nixpkgs `lib` as a derivation
libSrc = pkgsLib.libSrc;

lightlocker = callPackage ../misc/screensavers/light-locker { };

lightspark = callPackage ../misc/lightspark { };
Expand Down

0 comments on commit 1dc205b

Please sign in to comment.