···299 directly. The effect is that the package is built as if it were published
300 on hackage. This can be used as a test for the source distribution,
301 assuming the build fails when packaging mistakes are in the cabal file.
000302 */
303 buildFromSdist = pkg: overrideCabal (drv: {
304 src = "${sdistTarball pkg}/${pkg.pname}-${pkg.version}.tar.gz";
···299 directly. The effect is that the package is built as if it were published
300 on hackage. This can be used as a test for the source distribution,
301 assuming the build fails when packaging mistakes are in the cabal file.
302+303+ A faster implementation using `cabal-install` is available as
304+ `buildFromCabalSdist` in your Haskell package set.
305 */
306 buildFromSdist = pkg: overrideCabal (drv: {
307 src = "${sdistTarball pkg}/${pkg.pname}-${pkg.version}.tar.gz";
···538 withHoogle = self.ghcWithHoogle;
539 };
540541+ /*
542+ Run `cabal sdist` on a source.
543+544+ Unlike `haskell.lib.sdistTarball`, this does not require any dependencies
545+ to be present, as it uses `cabal-install` instead of building `Setup.hs`.
546+ This makes `cabalSdist` faster than `sdistTarball`.
547+ */
548+ cabalSdist = {
549+ src,
550+ name ? if src?name then "${src.name}-sdist.tar.gz" else "source.tar.gz"
551+ }:
552+ pkgs.runCommandNoCCLocal name
553+ {
554+ inherit src;
555+ nativeBuildInputs = [ buildHaskellPackages.cabal-install ];
556+ dontUnpack = false;
557+ } ''
558+ unpackPhase
559+ cd "''${sourceRoot:-.}"
560+ patchPhase
561+ mkdir out
562+ HOME=$PWD cabal sdist --output-directory out
563+ mv out/*.tar.gz $out
564+ '';
565+566+ /*
567+ Like `haskell.lib.buildFromSdist`, but using `cabal sdist` instead of
568+ building `./Setup`.
569+570+ Unlike `haskell.lib.buildFromSdist`, this does not require any dependencies
571+ to be present. This makes `buildFromCabalSdist` faster than `haskell.lib.buildFromSdist`.
572+ */
573+ buildFromCabalSdist = pkg:
574+ haskellLib.overrideSrc
575+ {
576+ src = self.cabalSdist { inherit (pkg) src; };
577+ version = pkg.version;
578+ }
579+ pkg;
580+581 }
···1+# Revision history for local
2+3+## 0.1.0.0 -- YYYY-mm-dd
4+5+* First version. Released on an unsuspecting world.
+4
pkgs/test/haskell/cabalSdist/local/app/Main.hs
···0000
···1+module Main where
2+3+main :: IO ()
4+main = putStrLn "Hello, Haskell!"
+13
pkgs/test/haskell/cabalSdist/local/local.cabal
···0000000000000
···1+cabal-version: 2.4
2+name: local
3+version: 0.1.0.0
4+5+synopsis: Nixpkgs test case
6+license: MIT
7+extra-source-files: CHANGELOG.md
8+9+executable local
10+ main-is: Main.hs
11+ build-depends: base
12+ hs-source-dirs: app
13+ default-language: Haskell2010