srcOnly: Some improvements (#345198)

Changed files
+69 -19
nixos
doc
manual
release-notes
pkgs
applications
editors
vscode
build-support
src-only
development
compilers
tools
build-managers
+2
nixos/doc/manual/release-notes/rl-2411.section.md
···
Users can use it by `services.displayManager.ly.enable` and config it by
`services.displayManager.ly.settings` to generate `/etc/ly/config.ini`
+
- `srcOnly` was rewritten to be more readable, have additional warnings in the event that something is probably wrong, use the `stdenv` provided by the derivation, and Noogle-compatible documentation was added.
+
- The default sound server for most graphical sessions has been switched from PulseAudio to PipeWire.
Users that want to keep PulseAudio will want to set `services.pipewire.enable = false;` and `hardware.pulseaudio.enable = true;`.
There is currently no plan to fully deprecate and remove PulseAudio, however, PipeWire should generally be preferred for new installs.
+2
pkgs/applications/editors/vscode/vscode.nix
···
{ stdenv
+
, stdenvNoCC
, lib
, callPackage
, fetchurl
···
url = "https://update.code.visualstudio.com/commit:${rev}/server-linux-x64/stable";
sha256 = "1iqglh4wx4wc80ihzcw4is7hd49s6kxpg9fz357r57a2679q0qw6";
};
+
stdenv = stdenvNoCC;
};
tests = { inherit (nixosTests) vscode-remote-ssh; };
+59 -19
pkgs/build-support/src-only/default.nix
···
-
{ stdenv }:
-
# srcOnly is a utility builder that only fetches and unpacks the given `src`,
-
# and optionally patching with `patches` or adding build inputs.
-
#
-
# It can be invoked directly, or be used to wrap an existing derivation. Eg:
-
#
-
# > srcOnly pkgs.hello
-
#
+
{ lib, stdenvNoCC }:
+
+
/**
+
A utility builder to get the source code of the input derivation, with any patches applied.
+
+
# Examples
+
+
```nix
+
srcOnly pkgs.hello
+
=> «derivation /nix/store/gyfk2jg9079ga5g5gfms5i4h0k9jhf0f-hello-2.12.1-source.drv»
+
+
srcOnly {
+
inherit (pkgs.hello) name version src stdenv;
+
}
+
=> «derivation /nix/store/vf9hdhz38z7rfhzhrk0vi70h755fnsw7-hello-2.12.1-source.drv»
+
```
+
+
# Type
+
+
```
+
srcOnly :: (Derivation | AttrSet) -> Derivation
+
```
+
+
# Input
+
+
`attrs`
+
+
: One of the following:
+
+
- A derivation with (at minimum) an unpackPhase and a patchPhase.
+
- A set of attributes that would be passed to a `stdenv.mkDerivation` or `stdenvNoCC.mkDerivation` call.
+
+
# Output
+
+
A derivation that runs a derivation's `unpackPhase` and `patchPhase`, and then copies the result to the output path.
+
*/
+
attrs:
let
-
args = if builtins.hasAttr "drvAttrs" attrs then attrs.drvAttrs else attrs;
-
name = if builtins.hasAttr "name" args then args.name else "${args.pname}-${args.version}";
+
args = attrs.drvAttrs or attrs;
+
name = args.name or "${args.pname}-${args.version}";
+
stdenv = args.stdenv or (lib.warn "srcOnly: stdenv not provided, using stdenvNoCC" stdenvNoCC);
+
drv = stdenv.mkDerivation (
+
args
+
// {
+
name = "${name}-source";
+
+
phases = [
+
"unpackPhase"
+
"patchPhase"
+
"installPhase"
+
];
+
separateDebugInfo = false;
+
+
dontUnpack = false;
+
+
dontInstall = false;
+
installPhase = "cp -pr --reflink=auto -- . $out";
+
}
+
);
in
-
stdenv.mkDerivation (args // {
-
name = "${name}-source";
-
installPhase = "cp -pr --reflink=auto -- . $out";
-
outputs = [ "out" ];
-
separateDebugInfo = false;
-
dontUnpack = false;
-
dontInstall = false;
-
phases = ["unpackPhase" "patchPhase" "installPhase"];
-
})
+
lib.warnIf (args.dontUnpack or false) "srcOnly: derivation has dontUnpack set, overriding" drv
+3
pkgs/development/compilers/ghc/common-hadrian.nix
···
{ lib
, stdenv
+
, stdenvNoCC
, pkgsBuildTarget
, pkgsHostTarget
, buildPackages
···
++ lib.optionals (lib.elem version [ "9.8.1" "9.8.2" ]) [
../../tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
];
+
+
stdenv = stdenvNoCC;
}
# GHC's build system hadrian built from the GHC-to-build's source tree
+3
pkgs/development/tools/build-managers/gradle/update-deps.nix
···
{ lib
, runtimeShell
, srcOnly
+
, stdenvNoCC
, writeTextFile
, writeShellScript
, path
···
source = srcOnly (pkg.overrideAttrs (old: {
mitmCache = "";
gradleInitScript = ./init-deps.gradle;
+
+
stdenv = old.stdenv or stdenvNoCC;
}));
sourceDrvPath = builtins.unsafeDiscardOutputDependency source.drvPath;
nixShellKeep = lib.concatMapStringsSep " " (x: "--keep ${x}") keep;