diff options
author | Alexander Vieth <aovieth@gmail.com> | 2022-08-24 21:57:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 20:57:52 -0500 |
commit | f28ab51b54ef2518345594a6baf45b9e25378912 (patch) | |
tree | 1ea4ef34eddb32d0f6b3d09d5cdb5446cfee0ee0 /pkgs/development/haskell-modules/make-package-set.nix | |
parent | 31c252e209d4a766b3f5d5267a8adc79dd7a3b35 (diff) | |
download | nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar.gz nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar.bz2 nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar.lz nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar.xz nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.tar.zst nixlib-f28ab51b54ef2518345594a6baf45b9e25378912.zip |
haskell.lib.makePackageSet: all-cabal-hashes can be a directory (#188203)
* all-cabal-hahses can be a directory Motivating problem: we want to use the flake.lock for all-cabal-hashes as a github repository as our revision pin, and then import that to pass as all-cabal-hashes. To do that we need it to accept a directory rather than a tarball. * all-cabal-hashes: add some comments
Diffstat (limited to 'pkgs/development/haskell-modules/make-package-set.nix')
-rw-r--r-- | pkgs/development/haskell-modules/make-package-set.nix | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 9d35d198825f..9bbfe4419286 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -21,6 +21,9 @@ , haskellLib , # hashes for downloading Hackage packages + # This is either a directory or a .tar.gz containing the cabal files and + # hashes of Hackage as exemplified by this repository: + # https://github.com/commercialhaskell/all-cabal-hashes/tree/hackage all-cabal-hashes , # compiler to use @@ -136,10 +139,20 @@ let cabal2nix --compiler=${self.ghc.haskellCompilerName} --system=${hostPlatform.config} ${sha256Arg} "${src}" ${extraCabal2nixOptions} > "$out/default.nix" ''; + # Given a package name and version, e.g. name = "async", version = "2.2.4", + # gives its cabal file and hashes (JSON file) as discovered from the + # all-cabal-hashes value. If that's a directory, it will copy the relevant + # files to $out; if it's a tarball, it will extract and move them to $out. all-cabal-hashes-component = name: version: buildPackages.runCommand "all-cabal-hashes-component-${name}-${version}" {} '' - tar --wildcards -xzvf ${all-cabal-hashes} \*/${name}/${version}/${name}.{json,cabal} mkdir -p $out - mv */${name}/${version}/${name}.{json,cabal} $out + if [ -d ${all-cabal-hashes} ] + then + cp ${all-cabal-hashes}/${name}/${version}/${name}.json $out + cp ${all-cabal-hashes}/${name}/${version}/${name}.cabal $out + else + tar --wildcards -xzvf ${all-cabal-hashes} \*/${name}/${version}/${name}.{json,cabal} + mv */${name}/${version}/${name}.{json,cabal} $out + fi ''; hackage2nix = name: version: let component = all-cabal-hashes-component name version; in self.haskellSrc2nix { |