···299299 directly. The effect is that the package is built as if it were published
300300 on hackage. This can be used as a test for the source distribution,
301301 assuming the build fails when packaging mistakes are in the cabal file.
302302+303303+ A faster implementation using `cabal-install` is available as
304304+ `buildFromCabalSdist` in your Haskell package set.
302305 */
303306 buildFromSdist = pkg: overrideCabal (drv: {
304307 src = "${sdistTarball pkg}/${pkg.pname}-${pkg.version}.tar.gz";
···538538 withHoogle = self.ghcWithHoogle;
539539 };
540540541541+ /*
542542+ Run `cabal sdist` on a source.
543543+544544+ Unlike `haskell.lib.sdistTarball`, this does not require any dependencies
545545+ to be present, as it uses `cabal-install` instead of building `Setup.hs`.
546546+ This makes `cabalSdist` faster than `sdistTarball`.
547547+ */
548548+ cabalSdist = {
549549+ src,
550550+ name ? if src?name then "${src.name}-sdist.tar.gz" else "source.tar.gz"
551551+ }:
552552+ pkgs.runCommandNoCCLocal name
553553+ {
554554+ inherit src;
555555+ nativeBuildInputs = [ buildHaskellPackages.cabal-install ];
556556+ dontUnpack = false;
557557+ } ''
558558+ unpackPhase
559559+ cd "''${sourceRoot:-.}"
560560+ patchPhase
561561+ mkdir out
562562+ HOME=$PWD cabal sdist --output-directory out
563563+ mv out/*.tar.gz $out
564564+ '';
565565+566566+ /*
567567+ Like `haskell.lib.buildFromSdist`, but using `cabal sdist` instead of
568568+ building `./Setup`.
569569+570570+ Unlike `haskell.lib.buildFromSdist`, this does not require any dependencies
571571+ to be present. This makes `buildFromCabalSdist` faster than `haskell.lib.buildFromSdist`.
572572+ */
573573+ buildFromCabalSdist = pkg:
574574+ haskellLib.overrideSrc
575575+ {
576576+ src = self.cabalSdist { inherit (pkg) src; };
577577+ version = pkg.version;
578578+ }
579579+ pkg;
580580+541581 }
···11+# Revision history for local
22+33+## 0.1.0.0 -- YYYY-mm-dd
44+55+* First version. Released on an unsuspecting world.
+4
pkgs/test/haskell/cabalSdist/local/app/Main.hs
···11+module Main where
22+33+main :: IO ()
44+main = putStrLn "Hello, Haskell!"
+13
pkgs/test/haskell/cabalSdist/local/local.cabal
···11+cabal-version: 2.4
22+name: local
33+version: 0.1.0.0
44+55+synopsis: Nixpkgs test case
66+license: MIT
77+extra-source-files: CHANGELOG.md
88+99+executable local
1010+ main-is: Main.hs
1111+ build-depends: base
1212+ hs-source-dirs: app
1313+ default-language: Haskell2010