srcOnly: Some improvements (#345198)

This commit is contained in:
Philip Taron 2024-10-07 10:20:51 -07:00 committed by GitHub
commit 9f186c2632
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 19 deletions

View File

@ -42,6 +42,8 @@
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.

View File

@ -1,4 +1,5 @@
{ stdenv
, stdenvNoCC
, lib
, callPackage
, fetchurl
@ -70,6 +71,7 @@ in
url = "https://update.code.visualstudio.com/commit:${rev}/server-linux-x64/stable";
sha256 = "1iqglh4wx4wc80ihzcw4is7hd49s6kxpg9fz357r57a2679q0qw6";
};
stdenv = stdenvNoCC;
};
tests = { inherit (nixosTests) vscode-remote-ssh; };

View File

@ -1,22 +1,62 @@
{ 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

View File

@ -10,6 +10,7 @@
{ lib
, stdenv
, stdenvNoCC
, pkgsBuildTarget
, pkgsHostTarget
, buildPackages
@ -218,6 +219,8 @@
++ 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

View File

@ -1,6 +1,7 @@
{ lib
, runtimeShell
, srcOnly
, stdenvNoCC
, writeTextFile
, writeShellScript
, path
@ -38,6 +39,8 @@ let
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;