haskell.mkDerivation: Support sourceRoot, setSourceRoot

Allow setting `sourceRoot` and `setSourceRoot` in the arguments to
`haskellPackages.mkDerivation`. These arguments are passed directly to
`stdenv.mkDerivation`.

It may be worth reading over `pkgs/stdenv/generic/setup.sh` and checking
if there's other unsupported variables which may be useful. It may also
be worth adding an argument like `extraAttrs` to be passed to
`stdenv.mkDerivation` directly, as an escape hatch.
This commit is contained in:
Rebecca Turner 2024-10-25 09:41:50 -07:00
parent 95ee0b6830
commit ff9e35236c
No known key found for this signature in database
2 changed files with 8 additions and 0 deletions

View File

@ -191,6 +191,10 @@ and `version` from Hackage.
`sha256` `sha256`
: Hash to use for the default case of `src`. : Hash to use for the default case of `src`.
`sourceRoot`, `setSourceRoot`
: Passed to `stdenv.mkDerivation`; see [“Variables controlling the unpack
phase”](#variables-controlling-the-unpack-phase).
`revision` `revision`
: Revision number of the updated cabal file to fetch from Hackage. : Revision number of the updated cabal file to fetch from Hackage.
If `null` (which is the default value), the one included in `src` is used. If `null` (which is the default value), the one included in `src` is used.

View File

@ -34,6 +34,8 @@ in
, version, revision ? null , version, revision ? null
, sha256 ? null , sha256 ? null
, src ? fetchurl { url = "mirror://hackage/${pname}-${version}.tar.gz"; inherit sha256; } , src ? fetchurl { url = "mirror://hackage/${pname}-${version}.tar.gz"; inherit sha256; }
, sourceRoot ? null
, setSourceRoot ? null
, buildDepends ? [], setupHaskellDepends ? [], libraryHaskellDepends ? [], executableHaskellDepends ? [] , buildDepends ? [], setupHaskellDepends ? [], libraryHaskellDepends ? [], executableHaskellDepends ? []
, buildTarget ? "" , buildTarget ? ""
, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? [] , buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
@ -825,6 +827,8 @@ stdenv.mkDerivation ({
; ;
} }
// optionalAttrs (args ? sourceRoot) { inherit sourceRoot; }
// optionalAttrs (args ? setSourceRoot) { inherit setSourceRoot; }
// optionalAttrs (args ? preCompileBuildDriver) { inherit preCompileBuildDriver; } // optionalAttrs (args ? preCompileBuildDriver) { inherit preCompileBuildDriver; }
// optionalAttrs (args ? postCompileBuildDriver) { inherit postCompileBuildDriver; } // optionalAttrs (args ? postCompileBuildDriver) { inherit postCompileBuildDriver; }
// optionalAttrs (args ? preUnpack) { inherit preUnpack; } // optionalAttrs (args ? preUnpack) { inherit preUnpack; }