treewide: fix sourceRoot for fetchgit-based src

According to Nixpkgs manual[1] and NixOS 23.11 Release Note[2], the
`sourceRoot` attribute passed to `stdenv.mkDerivation` should be
specified as `"${src.name}"` or `"${src.name}/subdir"` when `src` is
produced using `fetchgit`-based fetchers.

`sourceRoot = "source"` or `sourceRoot = "source/subdir"` is based on
the assumption that the `name` attribute of these pre-unpacked fetchers
are always `"source"`, which is not the case. Expecting constant `name`
also makes the source FODs prone to irrelevent hashes during version
bumps.

[1]: https://nixos.org/manual/nixpkgs/unstable/#var-stdenv-sourceRoot
[2]: https://nixos.org/manual/nixos/stable/release-notes#sec-release-23.11
This commit is contained in:
Yueh-Shun Li 2024-03-09 01:04:40 +08:00
parent 89d56ddd5b
commit 91b3db1309
44 changed files with 64 additions and 61 deletions

View file

@ -996,7 +996,7 @@
spectre_oxi = rustPlatform.buildRustPackage {
pname = "spectre_oxi";
inherit (old) version src;
sourceRoot = "source/spectre_oxi";
sourceRoot = "${old.src.name}/spectre_oxi";
cargoHash = "sha256-gCGuD5kipgfR0Le8npNmyBxNsUq0PavXvKkxkiPx13E=";

View file

@ -14,7 +14,7 @@ let
qtnproperty = mkDerivation {
name = "qtnproperty";
inherit src;
sourceRoot = "AwesomeBump/Sources/utils/QtnProperty";
sourceRoot = "${src.name}/Sources/utils/QtnProperty";
patches = [ ./qtnproperty-parallel-building.patch ];
buildInputs = [ qtscript qtbase qtdeclarative ];
nativeBuildInputs = [ qmake flex bison ];

View file

@ -64,7 +64,7 @@ in
pname = "${pname}-pnpm-deps";
inherit src version;
sourceRoot = "source/gephgui-wry/gephgui";
sourceRoot = "${src.name}/gephgui-wry/gephgui";
nativeBuildInputs = [
jq
@ -95,7 +95,7 @@ in
pname = "gephgui-wry";
inherit version src;
sourceRoot = "source/gephgui-wry";
sourceRoot = "${src.name}/gephgui-wry";
cargoLock = {
lockFile = ./Cargo.lock;

View file

@ -13,7 +13,7 @@ let
pname = "localsend";
version = "1.14.0";
linux = flutter313.buildFlutterApplication {
linux = flutter313.buildFlutterApplication rec {
inherit pname version;
src = fetchFromGitHub {
@ -23,7 +23,7 @@ let
hash = "sha256-CO0uFcZnOfE31EZxRUpgtod3+1lyXPpbytHB45DEM98=";
};
sourceRoot = "source/app";
sourceRoot = "${src.name}/app";
pubspecLock = lib.importJSON ./pubspec.lock.json;
@ -59,7 +59,7 @@ let
passthru.updateScript = ./update.sh;
meta = meta // {
meta = metaCommon // {
mainProgram = "localsend_app";
};
};
@ -81,13 +81,13 @@ let
cp -r *.app $out/Applications
'';
meta = meta // {
meta = metaCommon // {
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
platforms = [ "x86_64-darwin" "aarch64-darwin" ];
};
};
meta = with lib; {
metaCommon = with lib; {
description = "An open source cross-platform alternative to AirDrop";
homepage = "https://localsend.org/";
license = licenses.mit;

View file

@ -20,10 +20,10 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-yguUMEX0tn75wKrPKyqlCYbBFaEwC5b1s3k9xept1Fw=";
};
sourceRoot =
if stdenv.isDarwin
then "source/build/mac/release"
else "source/build/linux/release";
sourceRoot = "${finalAttrs.src.name}/build/${
if stdenv.hostPlatform.isDarwin then "mac"
else "linux"
}/release";
buildInputs = [
boost'

View file

@ -27,7 +27,7 @@ let
inherit src version;
pname = "openrefine-npm";
sourceRoot = "source/main/webapp";
sourceRoot = "${src.name}/main/webapp";
npmDepsHash = "sha256-8GhcL4tohQ5u2HeYN6JyTMMobUOqAL8ETCLiP1SoDSk=";

View file

@ -25,7 +25,7 @@ mkDerivation rec {
sha256 = "sha256-G4KlYAjOT1UV29vcX7Q8dMTj0BX0rsJcLtK2MQag5nU=";
};
sourceRoot = "source/src";
sourceRoot = "${src.name}/src";
qmakeFlags = [ "PREFIX=${placeholder "out"}" "CONFIG+=unixvlc" ];

View file

@ -17,7 +17,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
sourceRoot = "source/c2FmZQ";
sourceRoot = "${src.name}/c2FmZQ";
vendorHash = "sha256-cTXSFwWGHV2QJM4mX/Z+ZxCXKwr+59lEPvJa/PTA1wU=";

View file

@ -35,7 +35,7 @@ in buildGoModule rec {
hash = "sha256-tQ35GZuw7Ag1YfmOUarVY45yk4yugNLJetEV4m2w3GE=";
};
sourceRoot = "source/caddy";
sourceRoot = "${src.name}/caddy";
# frankenphp requires C code that would be removed with `go mod tidy`
# https://github.com/golang/go/issues/26366

View file

@ -27,7 +27,7 @@ flutter.buildFlutterApplication rec {
cargoDeps = rustPlatform.fetchCargoTarball {
name = "${pname}-${version}-cargo-deps";
inherit src;
sourceRoot = "source/intiface-engine-flutter-bridge";
sourceRoot = "${src.name}/intiface-engine-flutter-bridge";
hash = "sha256-0sCHa3rMaLYaUG3E3fmsLi0dSdb9vGyv7qNR3JQkXuU=";
};
cargoRoot = "intiface-engine-flutter-bridge";

View file

@ -18,7 +18,7 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-Fb5TeRTdvUlo/5Yi2d+FC8a6KoRLk2h1VE0/peMhWPs=";
};
sourceRoot = "source/rust/tool";
sourceRoot = "${src.name}/rust/tool";
cargoHash = "sha256-g4WzqfH6DZVUuNb0jV3MFdm3h7zy2bQ6d3agrXesWgc=";
env.TEST_SYSTEMD = systemd;

View file

@ -61,7 +61,7 @@ rustPlatform.buildRustPackage rec {
systemd
];
sourceRoot = "source/gui";
sourceRoot = "${src.name}/gui";
postInstall = ''
install -Dm0644 ./ui/static/logos/liana-app-icon.svg $out/share/icons/hicolor/scalable/apps/liana.svg

View file

@ -9,7 +9,7 @@ python3.pkgs.buildPythonApplication rec {
inherit (python3.pkgs.linien-common) src version;
sourceRoot = "source/linien-gui";
sourceRoot = "${src.name}/linien-gui";
nativeBuildInputs = with python3.pkgs; [
setuptools

View file

@ -17,7 +17,7 @@ buildGoModule rec {
hash = "sha256-4Y+yZSZrBDLPbQXaOCSKk/EY20Ka8CS4ivUg1TEaqXo=";
};
sourceRoot = "source/caddy";
sourceRoot = "${src.name}/caddy";
vendorHash = "sha256-N0RmvhBlTiWmBb4TzLmaThD9jVkKgcIO9vPWxJAvLRQ=";

View file

@ -15,7 +15,7 @@ python3Packages.buildPythonApplication rec {
version = "2.7.0";
format = "other";
sourceRoot = "source/source";
sourceRoot = "${src.name}/source";
src = fetchFromGitLab {
owner = "zehkira";
repo = "monophony";

View file

@ -39,7 +39,7 @@
sharedLibraryExt = rustc.stdenv.hostPlatform.extensions.sharedLibrary;
in flutter316.buildFlutterApplication {
in flutter316.buildFlutterApplication rec {
pname = "rustdesk";
version = "1.2.3-unstable-2024-02-11";
src = fetchFromGitHub {
@ -52,7 +52,7 @@ in flutter316.buildFlutterApplication {
strictDeps = true;
# Configure the Flutter/Dart build
sourceRoot = "source/flutter";
sourceRoot = "${src.name}/flutter";
# curl https://raw.githubusercontent.com/rustdesk/rustdesk/16db977fd81e14af62ec5ac7760a7661a5c24be8/flutter/pubspec.lock | yq
pubspecLock = lib.importJSON ./pubspec.lock.json;
gitHashes = {

View file

@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
pname = "snippetexpanderx";
sourceRoot = "source/cmd/snippetexpanderx";
sourceRoot = "${src.name}/cmd/snippetexpanderx";
nativeBuildInputs = [
pkg-config

View file

@ -12,7 +12,7 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-6758ej7bTvwZPWifl239rQMazM8uw+Y4+3EbjE8XsTg=";
};
sourceRoot = "source/server";
sourceRoot = "${src.name}/server";
cargoLock = {
lockFile = ./Cargo.lock;

View file

@ -14,7 +14,7 @@ buildNpmPackage rec {
hash = "sha256-DPGigs6DifTRa7VQVHgizZ3BUy3FPX3YhZi++yoBFBA=";
};
sourceRoot = "source/tools/syn2mas";
sourceRoot = "${src.name}/tools/syn2mas";
npmDepsHash = "sha256-HvBFuRyP1APg5V+yhvlODAJ02MEkdpuLfNjWB/UT2vg=";

View file

@ -16,7 +16,7 @@ buildDotnetModule rec {
hash = "sha256-41zlzrQ+YGY2wEvq4Su/lp6lOmGW4u0F37ub2a3z+7o=";
};
sourceRoot = "source/src";
sourceRoot = "${src.name}/src";
projectFile = "TorrentStream.sln";
nugetDeps = ./deps.nix;

View file

@ -18,7 +18,7 @@ buildDartApplication.override { inherit dart; } rec {
dartOutputType = "jit-snapshot";
src = flutterSrc;
sourceRoot = "source/packages/flutter_tools";
sourceRoot = "${src.name}/packages/flutter_tools";
postUnpack = ''chmod -R u+w "$NIX_BUILD_TOP/source"'';
inherit patches;

View file

@ -1,10 +1,10 @@
{ lib, mkCoqDerivation, coq, interval, compcert, flocq, bignums, version ? null }:
with lib; mkCoqDerivation {
let self = with lib; mkCoqDerivation {
pname = "vcfloat";
owner = "VeriNum";
inherit version;
sourceRoot = "source/vcfloat";
sourceRoot = "${self.src.name}/vcfloat";
postPatch = ''
coq_makefile -o Makefile -f _CoqProject *.v
'';
@ -21,4 +21,5 @@ with lib; mkCoqDerivation {
maintainers = with maintainers; [ quinn-dougherty ];
license = licenses.lgpl3Plus;
};
}
};
in self

View file

@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
sha256 = "sha256-aj/QmJ38ifsW36JFQcbp55aIQRvOpiqLHwEh/aFXsgo=";
};
sourceRoot = "source/mpfi";
sourceRoot = "${src.name}/mpfi";
nativeBuildInputs = [ autoreconfHook texinfo ];
buildInputs = [ mpfr ];

View file

@ -2,7 +2,7 @@
let
version = "1.0.1";
in buildPecl {
in buildPecl rec {
inherit version;
pname = "opentelemetry";
@ -13,7 +13,7 @@ in buildPecl {
hash = "sha256-VHUzRhTtHygHoW+poItaphV+mxe4rmmSfGgesUgPz8Q=";
};
sourceRoot = "source/ext";
sourceRoot = "${src.name}/ext";
doCheck = true;

View file

@ -4,11 +4,11 @@
, flit-core
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
pname = "${python.libPrefix}-bootstrap-${flit-core.pname}";
inherit (flit-core) version src patches meta;
sourceRoot = "source/flit_core";
sourceRoot = "${src.name}/flit_core";
buildPhase = ''
runHook preBuild

View file

@ -13,11 +13,11 @@
, wheel
}:
buildPythonPackage {
buildPythonPackage rec {
inherit (catboost) pname version src meta;
format = "pyproject";
sourceRoot = "source/catboost/python-package";
sourceRoot = "${src.name}/catboost/python-package";
nativeBuildInputs = [
setuptools

View file

@ -8,7 +8,7 @@
, wheel
, numpy
}:
buildPythonPackage {
buildPythonPackage rec {
pname = "daqp";
version = "0.5.1";
format = "pyproject";
@ -20,7 +20,7 @@ buildPythonPackage {
hash = "sha256-in7Ci/wM7i0csJ4XVfo1lboWOyfuuU+8E+TzGmMV3x0=";
};
sourceRoot = "source/interfaces/daqp-python";
sourceRoot = "${src.name}/interfaces/daqp-python";
postPatch = ''
sed -i 's|../../../daqp|../..|' setup.py

View file

@ -10,7 +10,7 @@ buildPythonPackage rec {
inherit (flit) src patches;
sourceRoot = "source/flit_core";
sourceRoot = "${src.name}/flit_core";
# Tests are run in the "flit" package.
doCheck = false;

View file

@ -22,7 +22,7 @@ let
pname = "kanidm";
version = "0.0.3-unstable-2023-08-23";
in
buildPythonPackage {
buildPythonPackage rec {
inherit pname version;
pyproject = true;
@ -35,7 +35,7 @@ buildPythonPackage {
hash = "sha256-5qQb+Itguw2v1Wdvc2vp00zglfvNd3LFEDvaweRJcOc=";
};
sourceRoot = "source/pykanidm";
sourceRoot = "${src.name}/pykanidm";
nativeBuildInputs = [
poetry-core

View file

@ -14,7 +14,7 @@ buildPythonPackage rec {
inherit (linien-common) src version;
sourceRoot = "source/linien-client";
sourceRoot = "${src.name}/linien-client";
preBuild = ''
export HOME=$(mktemp -d)

View file

@ -22,7 +22,7 @@ buildPythonPackage rec {
hash = "sha256-ZgAp1SEiHijyjK74VZyRLYY3Hzfc3BQ6cnoO3hZzvbE=";
};
sourceRoot = "source/linien-common";
sourceRoot = "${src.name}/linien-common";
preBuild = ''
export HOME=$(mktemp -d)

View file

@ -21,7 +21,7 @@ buildPythonPackage rec {
disabled = pythonOlder "3.8";
sourceRoot = "source/openllm-client";
sourceRoot = "${src.name}/openllm-client";
postPatch = ''
substituteInPlace pyproject.toml \

View file

@ -36,7 +36,7 @@ buildPythonPackage rec {
hash = "sha256-kRR715Vnt9ZAmxuWvtH0z093crH0JFrEKPtbjO3QMRc=";
};
sourceRoot = "source/openllm-core";
sourceRoot = "${src.name}/openllm-core";
nativeBuildInputs = [
pythonRelaxDepsHook

View file

@ -51,7 +51,7 @@ buildPythonPackage rec {
disabled = pythonOlder "3.8";
sourceRoot = "source/openllm-python";
sourceRoot = "${src.name}/openllm-python";
nativeBuildInputs = [
pythonRelaxDepsHook

View file

@ -44,7 +44,7 @@ buildPythonPackage rec {
cargoRoot = "rust";
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
sourceRoot = "source/rust";
sourceRoot = "${src.name}/rust";
name = "${pname}-${version}";
hash = "sha256-6fw0KgnPIMfdseWcunsGjvjVB+lJNoG3pLDqkORPJ0I=";
postPatch = ''

View file

@ -32,7 +32,7 @@ buildPythonPackage rec {
hash = "sha256-liTg5Hm+FPpRQajBnnJKBh3JPGyu0Hflntf0isj1FiQ=";
};
sourceRoot = "source/python";
sourceRoot = "${src.name}/python";
env.PROPHET_REPACKAGE_CMDSTAN = "false";

View file

@ -17,7 +17,7 @@ buildPythonPackage rec {
hash = "sha256-xJ/iPywOZA2kzHaVU43Bc8TUboj3OpDg1kLFMIc/T90=";
};
sourceRoot = "source/python";
sourceRoot = "${src.name}/python";
# setup script tries to get data from the network but we use the nixpkgs' one
postPatch = ''

View file

@ -34,9 +34,11 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
yarnLock = (fetchdep info.deps."src/electron") + "/yarn.lock";
sha256 = info.electron_yarn_hash;
};
npmDeps = fetchNpmDeps {
npmDeps = fetchNpmDeps rec {
src = fetchdep info.deps."src";
sourceRoot = "source/third_party/node";
# Assume that the fetcher always unpack the source,
# based on update.py
sourceRoot = "${src.name}/third_party/node";
hash = info.chromium_npm_hash;
};

View file

@ -10,7 +10,7 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-0vbAHSN+uwxoXXZtbuycP67PxjcB8Ftxd/Oij1gqE3Y=";
};
sourceRoot = "mingw-w64/mingw-w64-tools/gendef";
sourceRoot = "${finalAttrs.src.name}/mingw-w64-tools/gendef";
meta = {
description = "A tool which generate def files from DLLs";

View file

@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
inherit (opensnitch) src;
sourceRoot = "source/ebpf_prog";
sourceRoot = "${src.name}/ebpf_prog";
nativeBuildInputs = with llvmPackages; [
bc

View file

@ -15,7 +15,7 @@
}:
let
src = tuxedo-rs.src;
sourceRoot = "source/tailor_gui";
sourceRoot = "${src.name}/tailor_gui";
pname = "tailor_gui";
version = "0.2.3";
in

View file

@ -27,7 +27,7 @@ let
inherit src version;
pname = "openobserve-ui";
sourceRoot = "source/web";
sourceRoot = "${src.name}/web";
npmDepsHash = "sha256-RNUCR80ewFt9F/VHv7kXLa87h0fz0YBp+9gSOUhtrdU=";

View file

@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
--replace "-march=native" ""
'';
sourceRoot = "source/cpp";
sourceRoot = "${src.name}/cpp";
makeFlags = [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"

View file

@ -17,7 +17,7 @@ buildPythonApplication rec {
rev = "refs/tags/v${version}";
hash = "sha256-67CAR34VrMOzvNkukDeGRnUfoOLO66R37wsrRHjpp5E=";
};
sourceRoot = "source/tools/mpremote";
sourceRoot = "${src.name}/tools/mpremote";
format = "pyproject";
nativeBuildInputs = [