Skip to content

Commit

Permalink
Merge pull request #245388 from oxij/source-root-src
Browse files Browse the repository at this point in the history
treewide: mostly noop: refer to `src.name` or similar in `sourceRoot` where appropriate
  • Loading branch information
mweinelt authored Aug 3, 2023
2 parents 30392d5 + a0a909f commit 169e4c4
Show file tree
Hide file tree
Showing 232 changed files with 414 additions and 401 deletions.
2 changes: 1 addition & 1 deletion doc/languages-frameworks/rust.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ buildPythonPackage rec {
hash = "sha256-miW//pnOmww2i6SOGbkrAIdc/JMDT4FJLqdMFojZeoY=";
};
sourceRoot = "source/bindings/python";
sourceRoot = "${src.name}/bindings/python";
nativeBuildInputs = [
cargo
Expand Down
9 changes: 7 additions & 2 deletions doc/stdenv/stdenv.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,14 +614,19 @@ The list of source files or directories to be unpacked or copied. One of these m

##### `sourceRoot` {#var-stdenv-sourceRoot}

After running `unpackPhase`, the generic builder changes the current directory to the directory created by unpacking the sources. If there are multiple source directories, you should set `sourceRoot` to the name of the intended directory. Set `sourceRoot = ".";` if you use `srcs` and control the unpack phase yourself.
After unpacking all of `src` and `srcs`, if neither of `sourceRoot` and `setSourceRoot` are set, `unpackPhase` of the generic builder checks that the unpacking produced a single directory and moves the current working directory into it.

By default the `sourceRoot` is set to `"source"`. If you want to point to a sub-directory inside your project, you therefore need to set `sourceRoot = "source/my-sub-directory"`.
If `unpackPhase` produces multiple source directories, you should set `sourceRoot` to the name of the intended directory.
You can also set `sourceRoot = ".";` if you want to control it yourself in a later phase.

For example, if your want your build to start in a sub-directory inside your sources, and you are using `fetchzip`-derived `src` (like `fetchFromGitHub` or similar), you need to set `sourceRoot = "${src.name}/my-sub-directory"`.

##### `setSourceRoot` {#var-stdenv-setSourceRoot}

Alternatively to setting `sourceRoot`, you can set `setSourceRoot` to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set `sourceRoot`.

For example, if you are using `fetchurl` on an archive file that gets unpacked into a single directory the name of which changes between package versions, and you want your build to start in its sub-directory, you need to set `setSourceRoot = "sourceRoot=$(echo */my-sub-directory)";`, or in the case of multiple sources, you could use something more specific, like `setSourceRoot = "sourceRoot=$(echo ${pname}-*/my-sub-directory)";`.

##### `preUnpack` {#var-stdenv-preUnpack}

Hook executed at the start of the unpack phase.
Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2311.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ The module update takes care of the new config syntax and the data itself (user

## Nixpkgs internals {#sec-release-23.11-nixpkgs-internals}

- The use of `sourceRoot = "source";`, `sourceRoot = "source/subdir";`, and similar lines in package derivations using the default `unpackPhase` is deprecated as it requires `unpackPhase` to always produce a directory named "source". Use `sourceRoot = src.name`, `sourceRoot = "${src.name}/subdir";`, or `setSourceRoot = "sourceRoot=$(echo */subdir)";` or similar instead.

- The `qemu-vm.nix` module by default now identifies block devices via
persistent names available in `/dev/disk/by-*`. Because the rootDevice is
identfied by its filesystem label, it needs to be formatted before the VM is
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/alsa-scarlett-gui/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = [ "-Wno-error=deprecated-declarations" ];

makeFlags = [ "DESTDIR=\${out}" "PREFIX=''" ];
sourceRoot = "source/src";
sourceRoot = "${src.name}/src";
nativeBuildInputs = [ pkg-config wrapGAppsHook4 ];
buildInputs = [ gtk4 alsa-lib ];
postInstall = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/miniaudicle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stdenv.mkDerivation (finalAttrs: {
fetchSubmodules = true;
};

sourceRoot = "source/src";
sourceRoot = "${finalAttrs.src.name}/src";

postPatch = ''
echo '#define GIT_REVISION "${finalAttrs.version}-NixOS"' > git-rev.h
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/muse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
sha256 = "1rasp2v1ds2aw296lbf27rzw0l9fjl0cvbvw85d5ycvh6wkm301p";
};

sourceRoot = "source/muse3";
sourceRoot = "${src.name}/muse3";

patches = [ ./fix-parallel-building.patch ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/picoloop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
libjack2
];

sourceRoot = "source/picoloop";
sourceRoot = "${src.name}/picoloop";

makeFlags = [ "-f Makefile.PatternPlayer_debian_RtAudio_sdl20" ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/soundkonverter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mkDerivation rec {
buildInputs = [ taglib ] ++ runtimeDeps;
# encoder plugins go to ${out}/lib so they're found by kbuildsycoca5
cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=$out" ];
sourceRoot = "source/src";
sourceRoot = "${src.name}/src";
# add runt-time deps to PATH
postInstall = ''
wrapProgram $out/bin/soundkonverter --prefix PATH : ${lib.makeBinPath runtimeDeps }
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/speech-denoiser/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let
pname = "rnnoise-nu";
version = "unstable-07-10-2019";
src = speech-denoiser-src;
sourceRoot = "source/rnnoise";
sourceRoot = "${speech-denoiser-src.name}/rnnoise";
nativeBuildInputs = [ autoreconfHook ];
configureFlags = [ "--disable-examples" "--disable-doc" "--disable-shared" "--enable-static" ];
installTargets = [ "install-rnnoise-nu" ];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/tagutil/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
sha256 = "sha256-oY1aGl5CKVtpOfh8Wskio/huWYMiPuxWPqxlooTutcw=";
};

sourceRoot = "source/src";
sourceRoot = "${src.name}/src";

nativeBuildInputs = [
cmake
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/yoshimi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
hash = "sha256-zFwfKy8CVecGhgr48T+eDNHfMdctfrNGenc/XJctyw8=";
};

sourceRoot = "source/src";
sourceRoot = "${src.name}/src";

postPatch = ''
substituteInPlace Misc/Config.cpp --replace /usr $out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let
pname = "tsc";
commit = version;

sourceRoot = "source/core";
sourceRoot = "${src.name}/core";

recipe = writeText "recipe" ''
(tsc
Expand All @@ -44,7 +44,7 @@ let
pname = "tsc-dyn";

nativeBuildInputs = [ rustPlatform.bindgenHook ];
sourceRoot = "source/core";
sourceRoot = "${src.name}/core";

postInstall = ''
LIB=($out/lib/libtsc_dyn.*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def get_cargo_hash(drv_path: str):
drv_path = eval_drv(
nixpkgs,
"""
rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage rec {
pname = "tsc-dyn";
version = "%s";
nativeBuildInputs = [ clang ];
src = fetchFromGitHub (lib.importJSON %s);
sourceRoot = "source/core";
sourceRoot = "${src.name}/core";
cargoHash = lib.fakeHash;
}
"""
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/emulators/basiliskii/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, lib, fetchFromGitHub, autoconf, automake, pkg-config, SDL2, gtk2, mpfr }:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "basiliskii";
version = "unstable-2022-09-30";

Expand All @@ -9,7 +9,7 @@ stdenv.mkDerivation {
rev = "2fa17a0783cf36ae60b77b5ed930cda4dc1824af";
sha256 = "+jkns6H2YjlewbUzgoteGSQYWJL+OWVu178aM+BtABM=";
};
sourceRoot = "source/BasiliskII/src/Unix";
sourceRoot = "${finalAttrs.src.name}/BasiliskII/src/Unix";
patches = [ ./remove-redhat-6-workaround-for-scsi-sg.h.patch ];
nativeBuildInputs = [ autoconf automake pkg-config ];
buildInputs = [ SDL2 gtk2 mpfr ];
Expand All @@ -25,4 +25,4 @@ stdenv.mkDerivation {
maintainers = with maintainers; [ quag ];
platforms = platforms.linux;
};
}
})
2 changes: 1 addition & 1 deletion pkgs/applications/file-managers/xplorer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ in
rustPlatform.buildRustPackage {
inherit version src pname;

sourceRoot = "source/src-tauri";
sourceRoot = "${src.name}/src-tauri";

cargoLock = {
lockFile = ./Cargo.lock;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/graphics/djv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let

src = djvSrc;

sourceRoot = "source/etc/SuperBuild";
sourceRoot = "${src.name}/etc/SuperBuild";

nativeBuildInputs = [ cmake ];
buildInputs = [
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/graphics/imgbrd-grabber/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ stdenv.mkDerivation rec {
ln -s $out/share/Grabber/Grabber-cli $out/bin/Grabber-cli
'';

sourceRoot = "source/src";
sourceRoot = "${src.name}/src";

meta = with lib; {
description = "Very customizable imageboard/booru downloader with powerful filenaming features";
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/graphics/pixelnuke/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, fetchFromGitHub, libevent, glew, glfw }:

stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "pixelnuke";
version = "unstable-2019-05-19";

Expand All @@ -11,7 +11,7 @@ stdenv.mkDerivation {
sha256 = "03dp0p00chy00njl4w02ahxqiwqpjsrvwg8j4yi4dgckkc3gbh40";
};

sourceRoot = "source/pixelnuke";
sourceRoot = "${finalAttrs.src.name}/pixelnuke";

buildInputs = [ libevent glew glfw ];

Expand All @@ -26,4 +26,4 @@ stdenv.mkDerivation {
platforms = platforms.linux;
maintainers = with maintainers; [ mrVanDalo ];
};
}
})
6 changes: 3 additions & 3 deletions pkgs/applications/graphics/synfigstudio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let
pname = "ETL";
inherit version src;

sourceRoot = "source/ETL";
sourceRoot = "${src.name}/ETL";

nativeBuildInputs = [
pkg-config
Expand All @@ -54,7 +54,7 @@ let
pname = "synfig";
inherit version src;

sourceRoot = "source/synfig-core";
sourceRoot = "${src.name}/synfig-core";

configureFlags = [
"--with-boost=${boost.dev}"
Expand Down Expand Up @@ -89,7 +89,7 @@ stdenv.mkDerivation {
pname = "synfigstudio";
inherit version src;

sourceRoot = "source/synfig-studio";
sourceRoot = "${src.name}/synfig-studio";

postPatch = ''
patchShebangs images/splash_screen_development.sh
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/graphics/vpv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
cargoRoot = "src/fuzzy-finder";
cargoDeps = rustPlatform.fetchCargoTarball {
src = finalAttrs.src;
sourceRoot = "source/src/fuzzy-finder";
sourceRoot = "${finalAttrs.src.name}/src/fuzzy-finder";
hash = "sha256-CDKlmwA2Wj78xPaSiYPmIJ7xmiE5Co+oGGejZU3v1zI=";
};

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/candle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mkDerivation rec {

nativeBuildInputs = [ qmake ];

sourceRoot = "source/src";
sourceRoot = "${src.name}/src";

installPhase = ''
runHook preInstall
Expand Down
40 changes: 19 additions & 21 deletions pkgs/applications/misc/johnny-reborn/with-data.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@
, makeWrapper
}:


let
sounds = fetchFromGitHub {
owner = "nivs1978";
repo = "Johnny-Castaway-Open-Source";
rev = "be6afefd43a3334acc66fc9d777c162c8bfb9558";
hash = "sha256-rtZVCn4KbEBVwaSQ4HZhMoDEI5Q9IPj9SZywgAx0MPY=";
};

resources = fetchzip {
name = "scrantic-source";
url = "https://archive.org/download/johnny-castaway-screensaver/scrantic-run.zip";
hash = "sha256-Q9chCYReOQEmkTyIkYo+D+OXYUqxPNOOEEmiFh8yaw4=";
stripRoot = false;
};
in

stdenvNoCC.mkDerivation {
pname = "johnny-reborn";
inherit (johnny-reborn-engine) version;

srcs =
let
sounds = fetchFromGitHub {
owner = "nivs1978";
repo = "Johnny-Castaway-Open-Source";
rev = "be6afefd43a3334acc66fc9d777c162c8bfb9558";
hash = "sha256-rtZVCn4KbEBVwaSQ4HZhMoDEI5Q9IPj9SZywgAx0MPY=";
};

resources = fetchzip {
name = "scrantic-source";
url = "https://archive.org/download/johnny-castaway-screensaver/scrantic-run.zip";
hash = "sha256-Q9chCYReOQEmkTyIkYo+D+OXYUqxPNOOEEmiFh8yaw4=";
stripRoot = false;
};
in
[
sounds
resources
];
srcs = [ sounds resources ];

nativeBuildInputs = [ makeWrapper ];

sourceRoot = "source";
sourceRoot = sounds.name;

dontConfigure = true;
dontBuild = true;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/openbangla-keyboard/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
postPatch = ''
cp ${./Cargo.lock} Cargo.lock
'';
sourceRoot = "source/${cargoRoot}";
sourceRoot = "${src.name}/${cargoRoot}";
sha256 = "sha256-01MWuUUirsgpoprMArRp3qxKNayPHTkYWk31nXcIC34=";
};

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/pot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
hash = "sha256-v5yx8pE8+m+5CDy7X3CwitYhFQMX8Ynt8Y2k1lEZKpg=";
};

sourceRoot = "source/src-tauri";
sourceRoot = "${src.name}/src-tauri";

postPatch = ''
substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/qsudo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mkDerivation rec {
sha256 = "06kg057vwkvafnk69m9rar4wih3vq4h36wbzwbfc2kndsnn47lfl";
};

sourceRoot = "source/src-qt5";
sourceRoot = "${src.name}/src-qt5";

nativeBuildInputs = [
qmake
Expand Down
6 changes: 2 additions & 4 deletions pkgs/applications/misc/spacenav-cube-example/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

stdenv.mkDerivation {
pname = "spacenav-cube-example";
version = libspnav.version;
inherit (libspnav) version src;

src = libspnav.src;

sourceRoot = "source/examples/cube";
sourceRoot = "${libspnav.src.name}/examples/cube";

buildInputs = [ libX11 mesa_glu libspnav ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/subsurface/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let

src = subsurfaceSrc;

sourceRoot = "source/libdivecomputer";
sourceRoot = "${subsurfaceSrc.name}/libdivecomputer";

nativeBuildInputs = [ autoreconfHook pkg-config ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/yubioath-flutter/helper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildPythonApplication {
pname = "yubioath-flutter-helper";
inherit src version meta;

sourceRoot = "source/helper";
sourceRoot = "${src.name}/helper";
format = "pyproject";

postPatch = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/networking/browsers/browsh/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildGoModule rec {

pname = "browsh";

sourceRoot = "source/interfacer";
sourceRoot = "${src.name}/interfacer";

src = fetchFromGitHub {
owner = "browsh-org";
Expand Down
Loading

0 comments on commit 169e4c4

Please sign in to comment.