Merge pull request #10995 from NixOS/meson-remove-symlink-hack

Remove symlink hack from meson packaging
This commit is contained in:
John Ericson 2024-06-30 17:35:46 -04:00 committed by GitHub
commit 10ceb7d173
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 15 deletions

View file

@ -10,6 +10,33 @@
stdenv, stdenv,
versionSuffix, 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: { scope: {
inherit stdenv versionSuffix; inherit stdenv versionSuffix;
@ -55,4 +82,6 @@ scope: {
CONFIG_ASH_TEST y CONFIG_ASH_TEST y
''; '';
}); });
mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f);
} }

View file

@ -1,5 +1,6 @@
{ lib { lib
, stdenv , stdenv
, mkMesonDerivation
, releaseTools , releaseTools
, meson , meson
@ -38,13 +39,14 @@ let
else stdenv.mkDerivation; else stdenv.mkDerivation;
in in
mkDerivation (finalAttrs: { mkMesonDerivation (finalAttrs: {
pname = "nix-util"; pname = "nix-util";
inherit version; inherit version;
src = fileset.toSource { workDir = ./.;
root = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../.version
./.version
./meson.build ./meson.build
./meson.options ./meson.options
./linux/meson.build ./linux/meson.build
@ -53,7 +55,6 @@ mkDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "cc") ./.) (fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
};
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
@ -80,9 +81,10 @@ mkDerivation (finalAttrs: {
disallowedReferences = [ boost ]; disallowedReferences = [ boost ];
preConfigure = 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 # Copy some boost libraries so we don't get all of Boost in our
# closure. https://github.com/NixOS/nixpkgs/issues/45462 # closure. https://github.com/NixOS/nixpkgs/issues/45462