Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@
stdenv,
versionSuffix,
}:
let
inherit (pkgs) lib;

localSourceLayer = finalAttrs: prevAttrs:
let
root = ../.;
workDirPath =
# Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has
# the requirement that everything except passthru and meta must be
# serialized by mkDerivation, which doesn't work for this.
prevAttrs.workDir;

workDirSubpath = lib.path.removePrefix root workDirPath;
sources = assert prevAttrs.fileset._type == "fileset"; prevAttrs.fileset;
src = lib.fileset.toSource { fileset = sources; inherit root; };

in
{
sourceRoot = "${src.name}/" + workDirSubpath;
inherit src;

# Clear what `derivation` can't/shouldn't serialize; see prevAttrs.workDir.
fileset = null;
workDir = null;
};

in
scope: {
inherit stdenv versionSuffix;

Expand Down Expand Up @@ -55,4 +82,6 @@ scope: {
CONFIG_ASH_TEST y
'';
});

mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f);
Copy link
Member Author

@roberth roberth Jun 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No meson-specific stuff here yet, but I'm sure we'll want to make use of it that way, or we could rename to mkLocalDerivation.

}
32 changes: 17 additions & 15 deletions src/libutil/package.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools

, meson
Expand Down Expand Up @@ -38,22 +39,22 @@ let
else stdenv.mkDerivation;
in

mkDerivation (finalAttrs: {
mkMesonDerivation (finalAttrs: {
pname = "nix-util";
inherit version;

src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./meson.build
./meson.options
./linux/meson.build
./unix/meson.build
./windows/meson.build
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
};
workDir = ./.;
fileset = fileset.unions [
../../.version
./.version
./meson.build
./meson.options
./linux/meson.build
./unix/meson.build
./windows/meson.build
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];

outputs = [ "out" "dev" ];

Expand All @@ -80,9 +81,10 @@ mkDerivation (finalAttrs: {
disallowedReferences = [ boost ];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix
# TODO: change release process to add `pre` in `.version`, remove it before tagging, and restore after.
''
echo ${version} > .version
chmod u+w ./.version
echo ${version} > ../../.version
''
# Copy some boost libraries so we don't get all of Boost in our
# closure. https://github.com/NixOS/nixpkgs/issues/45462
Expand Down