git.iko.soy/typeable/cabal2nix
on master help sign in
47 files changed+1211−527
since splitsnapshots
unifiedsplit
.travis.yml+137−81 README.md+12−7 cabal2nix.cabal+138−192 hackage2nix/Main.hs+29−20 hackage2nix/README.md+3 src/Cabal2nix.hs+44−29 src/Distribution/Nixpkgs/Fetch.hs+46−8 src/Distribution/Nixpkgs/Haskell/Constraint.hs+1−1 src/Distribution/Nixpkgs/Haskell/Derivation.hs+8−17 src/Distribution/Nixpkgs/Haskell/FromCabal.hs+22−13 src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+28−32 src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+18−17 src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs+133−3 src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+23−9 src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+137−35 src/Distribution/Nixpkgs/Haskell/Hackage.hs+1−1 src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+28−3 src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+62−36 test/Main.hs+10−14 test/golden-test-cases/ede.nix.golden+1 test/golden-test-cases/gogol-adexchange-buyer.nix.golden+1 test/golden-test-cases/gogol-admin-emailmigration.nix.golden+1 test/golden-test-cases/gogol-affiliates.nix.golden+1 test/golden-test-cases/gogol-apps-tasks.nix.golden+1 test/golden-test-cases/gogol-appstate.nix.golden+1 test/golden-test-cases/gogol-blogger.nix.golden+1 test/golden-test-cases/gogol-datastore.nix.golden+1 test/golden-test-cases/gogol-dfareporting.nix.golden+1 test/golden-test-cases/gogol-firebase-rules.nix.golden+1 test/golden-test-cases/gogol-gmail.nix.golden+1 test/golden-test-cases/gogol-kgsearch.nix.golden+1 test/golden-test-cases/gogol-maps-engine.nix.golden+1 test/golden-test-cases/gogol-plus.nix.golden+1 test/golden-test-cases/gogol-resourceviews.nix.golden+1 test/golden-test-cases/gogol-translate.nix.golden+1 test/golden-test-cases/gogol-webmaster-tools.nix.golden+1 test/golden-test-cases/gogol-youtube.nix.golden+1 test/golden-test-cases/hxt-expat.nix.golden+1 test/golden-test-cases/hxt-tagsoup.nix.golden+1 test/golden-test-cases/nvim-hs.nix.golden+1 test/golden-test-cases/opencv.cabal+263 test/golden-test-cases/opencv.nix.golden+30 test/golden-test-cases/openpgp-asciiarmor.nix.golden+1 test/golden-test-cases/pinch.nix.golden+1 test/golden-test-cases/swagger.nix.golden+1 test/golden-test-cases/test-fixture.nix.golden+1 update-stackage.sh+13−9
.travis.yml+137−81
@@ -1,105 +1,161 @@
11# This Travis job script has been generated by a script via
22#
3−# runghc make_travis_yml_2.hs '--no-installed' '--doctest' '--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen' '--hlint' '-o' '.travis.yml' 'cabal2nix.cabal'
3+# haskell-ci '--installed=+all -Cabal' '--hlint' '--doctest' '--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen' '-o' '.travis.yml' 'cabal2nix.cabal' '--head-hackage' '--head-hackage-jobs' '> 8.8'
44#
5−# For more information, see https://github.com/hvr/multi-ghc-travis
5+# For more information, see https://github.com/haskell-CI/haskell-ci
66#
7+# version: 0.9.20200306
8+#
9+version: ~> 1.0
710language: c
8−sudo: false
9−
11+os: linux
12+dist: xenial
1013git:
11− submodules: false # whether to recursively clone submodules
12−
14+ # whether to recursively clone submodules
15+ submodules: false
1316cache:
1417 directories:
1518 - $HOME/.cabal/packages
1619 - $HOME/.cabal/store
17−
20+ - $HOME/.hlint
1821before_cache:
19− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
22+ - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
2023 # remove files that are regenerated by 'cabal update'
21− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
22− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
23− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
24− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
25− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
26−
27− - rm -rfv $HOME/.cabal/packages/head.hackage
28−
29−matrix:
24+ - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
25+ - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
26+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
27+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
28+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
29+ - rm -rfv $CABALHOME/packages/head.hackage
30+jobs:
3031 include:
31− - compiler: "ghc-8.4.3"
32− # env: TEST=--disable-tests BENCH=--disable-benchmarks
33− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
34− - compiler: "ghc-8.2.2"
35− # env: TEST=--disable-tests BENCH=--disable-benchmarks
36− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}
37−
32+ - compiler: ghc-8.10.1
33+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.1","cabal-install-3.2"]}}
34+ os: linux
35+ - compiler: ghc-8.8.3
36+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.3","cabal-install-3.0"]}}
37+ os: linux
38+ - compiler: ghc-8.6.5
39+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.0"]}}
40+ os: linux
41+ allow_failures:
42+ - compiler: ghc-8.8.3
43+ - compiler: ghc-8.10.1
3844before_install:
39− - HC=${CC}
40− - HCPKG=${HC/ghc/ghc-pkg}
45+ - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
46+ - WITHCOMPILER="-w $HC"
47+ - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
48+ - HCPKG="$HC-pkg"
4149 - unset CC
42− - ROOTDIR=$(pwd)
43− - mkdir -p $HOME/.local/bin
44− - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
45− - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
50+ - CABAL=/opt/ghc/bin/cabal
51+ - CABALHOME=$HOME/.cabal
52+ - export PATH="$CABALHOME/bin:$PATH"
53+ - TOP=$(pwd)
54+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
4655 - echo $HCNUMVER
47−
56+ - CABAL="$CABAL -vnormal+nowrap"
57+ - set -o pipefail
58+ - TEST=--enable-tests
59+ - BENCH=--enable-benchmarks
60+ - HEADHACKAGE=false
61+ - if [ $HCNUMVER -ge 80800 ] ; then HEADHACKAGE=true ; fi
62+ - rm -f $CABALHOME/config
63+ - |
64+ echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
65+ echo "remote-build-reporting: anonymous" >> $CABALHOME/config
66+ echo "write-ghc-environment-files: always" >> $CABALHOME/config
67+ echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
68+ echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
69+ echo "world-file: $CABALHOME/world" >> $CABALHOME/config
70+ echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
71+ echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
72+ echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
73+ echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
74+ echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
75+ echo "install-dirs user" >> $CABALHOME/config
76+ echo " prefix: $CABALHOME" >> $CABALHOME/config
77+ echo "repository hackage.haskell.org" >> $CABALHOME/config
78+ echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
79+ - |
80+ if $HEADHACKAGE; then
81+ echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config
82+ echo "repository head.hackage.ghc.haskell.org" >> $CABALHOME/config
83+ echo " url: https://ghc.gitlab.haskell.org/head.hackage/" >> $CABALHOME/config
84+ echo " secure: True" >> $CABALHOME/config
85+ echo " root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config
86+ echo " 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config
87+ echo " f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config
88+ echo " key-threshold: 3" >> $CABALHOME/config
89+ fi
4890install:
49− - cabal --version
91+ - ${CABAL} --version
5092 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
51− - BENCH=${BENCH---enable-benchmarks}
52− - TEST=${TEST---enable-tests}
53− - HADDOCK=${HADDOCK-true}
54− - INSTALLED=${INSTALLED-true}
55− - GHCHEAD=${GHCHEAD-false}
56− - travis_retry cabal update -v
57− - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
58− - rm -fv cabal.project cabal.project.local
59− - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
60− - if [ $HCNUMVER -ge 80000 ]; then cabal new-install -w ${HC} --symlink-bindir=$HOME/.local/bin doctest --constraint='doctest ==0.15.*'; fi
61− - if [ $HCNUMVER -eq 80202 ]; then cabal new-install -w ${HC} --symlink-bindir=$HOME/.local/bin hlint --constraint='hlint ==2.1.*'; fi
62− - "printf 'packages: \".\"\\n' > cabal.project"
63− - cat cabal.project
64− - if [ -f "./configure.ac" ]; then
65− (cd "." && autoreconf -i);
66− fi
67− - rm -f cabal.project.freeze
68− - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
69− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
70− - rm -rf .ghc.environment.* "."/dist
71− - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
72−
73−# Here starts the actual work to be performed for the package under test;
74−# any command which exits with a non-zero exit code causes the build to fail.
93+ - |
94+ echo "program-default-options" >> $CABALHOME/config
95+ echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
96+ - cat $CABALHOME/config
97+ - rm -fv cabal.project cabal.project.local cabal.project.freeze
98+ - travis_retry ${CABAL} v2-update -v
99+ - (cd /tmp && ${CABAL} v2-install $WITHCOMPILER -j2 doctest --constraint='doctest ==0.16.2.*')
100+ - if [ $HCNUMVER -lt 80800 ] ; then HLINTVER=$(cd /tmp && (${CABAL} v2-install -v $WITHCOMPILER --dry-run hlint --constraint='hlint ==2.2.*' | perl -ne 'if (/\bhlint-(\d+(\.\d+)*)\b/) { print "$1"; last; }')); echo "HLint version $HLINTVER" ; fi
101+ - "if [ $HCNUMVER -lt 80800 ] ; then if [ ! -e $HOME/.hlint/hlint-$HLINTVER/hlint ]; then echo \"Downloading HLint version $HLINTVER\"; mkdir -p $HOME/.hlint; curl --write-out 'Status Code: %{http_code} Redirects: %{num_redirects} Total time: %{time_total} Total Dsize: %{size_download}\\n' --silent --location --output $HOME/.hlint/hlint-$HLINTVER.tar.gz \"https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz\"; tar -xzv -f $HOME/.hlint/hlint-$HLINTVER.tar.gz -C $HOME/.hlint; fi ; fi"
102+ - if [ $HCNUMVER -lt 80800 ] ; then mkdir -p $CABALHOME/bin && ln -sf "$HOME/.hlint/hlint-$HLINTVER/hlint" $CABALHOME/bin/hlint ; fi
103+ - if [ $HCNUMVER -lt 80800 ] ; then hlint --version ; fi
104+ # Generate cabal.project
105+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
106+ - touch cabal.project
107+ - |
108+ echo "packages: ." >> cabal.project
109+ - |
110+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(Cabal|cabal2nix)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
111+ - cat cabal.project || true
112+ - cat cabal.project.local || true
113+ - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
114+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
115+ - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
116+ - rm cabal.project.freeze
117+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
118+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
75119script:
76− # test that source-distributions can be generated
77− - (cd "." && cabal sdist)
78− - mv "."/dist/cabal2nix-*.tar.gz ${DISTDIR}/
120+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
121+ # Packaging...
122+ - ${CABAL} v2-sdist all
123+ # Unpacking...
124+ - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
79125 - cd ${DISTDIR} || false
80− - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
81− - "printf 'packages: cabal2nix-*/*.cabal\\n' > cabal.project"
82− - cat cabal.project
126+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
127+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
128+ - PKGDIR_cabal2nix="$(find . -maxdepth 1 -type d -regex '.*/cabal2nix-[0-9.]*')"
129+ # Generate cabal.project
130+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
131+ - touch cabal.project
132+ - |
133+ echo "packages: ${PKGDIR_cabal2nix}" >> cabal.project
134+ - |
135+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(Cabal|cabal2nix)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
136+ - cat cabal.project || true
137+ - cat cabal.project.local || true
138+ # Building...
83139 # this builds all libraries and executables (without tests/benchmarks)
84− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
85−
86−
140+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
141+ # Building with tests and benchmarks...
87142 # build & run tests, build benchmarks
88− - cabal new-build -w ${HC} ${TEST} ${BENCH} all
89− - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
90−
91− # doctest
92− - if [ $HCNUMVER -ge 80000 ]; then (cd cabal2nix-* && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen src); fi
93−
94− # hlint
95− - if [ $HCNUMVER -eq 80202 ]; then (cd cabal2nix-* && hlint src); fi
96−
97− # cabal check
98− - (cd cabal2nix-* && cabal check)
99−
100− # haddock
101− - rm -rf ./dist-newstyle
102− - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
143+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
144+ # Testing...
145+ - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
146+ # Doctest...
147+ - (cd ${PKGDIR_cabal2nix} && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen src)
148+ # HLint..
149+ - if [ $HCNUMVER -lt 80800 ] ; then (cd ${PKGDIR_cabal2nix} && hlint src) ; fi
150+ - if [ $HCNUMVER -lt 80800 ] ; then (cd ${PKGDIR_cabal2nix} && hlint hackage2nix) ; fi
151+ - if [ $HCNUMVER -lt 80800 ] ; then (cd ${PKGDIR_cabal2nix} && hlint cabal2nix) ; fi
152+ # cabal check...
153+ - (cd ${PKGDIR_cabal2nix} && ${CABAL} -vnormal check)
154+ # haddock...
155+ - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
156+ # Building without installed constraints for packages in global-db...
157+ - rm -f cabal.project.local
158+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
103159
104−# REGENDATA ["--no-installed","--doctest","--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen","--hlint","-o",".travis.yml","cabal2nix.cabal"]
160+# REGENDATA ("0.9.20200306",["--installed=+all -Cabal","--hlint","--doctest","--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen","-o",".travis.yml","cabal2nix.cabal","--head-hackage","--head-hackage-jobs","> 8.8"])
105161# EOF
README.md+12−7
@@ -1,6 +1,11 @@
11Cabal2nix
22=========
33
4+[![hackage release](https://img.shields.io/hackage/v/cabal2nix.svg?label=hackage)](http://hackage.haskell.org/package/cabal2nix)
5+[![stackage LTS package](http://stackage.org/package/cabal2nix/badge/lts)](http://stackage.org/lts/package/cabal2nix)
6+[![stackage Nightly package](http://stackage.org/package/cabal2nix/badge/nightly)](http://stackage.org/nightly/package/cabal2nix)
7+[![travis build status](https://img.shields.io/travis/NixOS/cabal2nix/master.svg?label=travis+build)](https://travis-ci.org/NixOS/cabal2nix)
8+
49`cabal2nix` converts a single Cabal file into a single Nix build expression.
510For example:
611
@@ -22,16 +27,16 @@ direct `http://host/path/pkg.cabal` URL can be provided, as well as a
2227`file:///local/path/pkg.cabal` URI that doesn't depend on network access.
2328However, if the source hash is not already in `cabal2nix`'s cache or provided
2429using the `--sha256` option, `cabal2nix` still needs to download the source
25−code to compute the hash, which obviously still causes network traffic. Run the
26−utility with `--help` to see the complete list of supported command line flags.
30+code to compute the hash, which still causes network traffic. Run the utility
31+with `--help` to see the complete list of supported command-line flags.
2732
28−Detailed instructions how to use those generated files with Nix can be found at
29−http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure.
33+Detailed instructions on how to use those generated files with Nix can be found at
34+https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages.
3035
3136`cabal2nix` can also build derivations for projects from other sources than
32−hackage. You only need to provide an URI that points to a cabal project. The
33−most common usecase for this is probably to generate a derivation for a project
34−on the local file system:
37+Hackage. You only need to provide a URI that points to a cabal project. The
38+most common use-case for this is probably to generate a derivation for a
39+project on the local file system:
3540
3641 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
3742 $ cabal2nix .
cabal2nix.cabal+138−192
@@ -1,206 +1,152 @@
1−name: cabal2nix
2−version: 2.9.3
3−synopsis: Convert Cabal files into Nix build instructions.
4−category: Distribution, Nix
5−stability: stable
6−homepage: https://github.com/nixos/cabal2nix#readme
7−bug-reports: https://github.com/nixos/cabal2nix/issues
8−author: Peter Simons,
9− Andres Loeh,
10− Benno Fünfstück,
11− Mateusz Kowalczyk,
12− Michael Alan Dorman,
13− Tom Smalley,
14− Mathijs Kwik,
15− Shea Levy,
16− Dmitry Malikov,
17− Eric Seidel,
18− Jacob Mitchell,
19− Graham Christensen,
20− Hamish Mackenzie,
21− Nikolay Amiantov,
22− Aycan iRiCAN,
23− Bryan Gardiner,
24− Joe Hermaszewski,
25− John Wiegley,
26− Philipp Hausmann,
27− Spencer Janssen,
28− Tom Hunger,
29− William Casarin,
30− koral,
31− ksaric,
32− Adam Vogt,
33− Alexey Shmalko,
34− Corey O'Connor,
35− Cray Elliott,
36− David Johnson,
37− Dmitry Bushev,
38− Domen Kožar,
39− Felix Kunzmann,
40− Gabriel Ebner,
41− Gergely Risko,
42− Joachim Fasting,
43− John Albietz,
44− John Chee,
45− Jussi Maki,
46− Lisanna Dettwyler,
47− Mark Laws,
48− Mark Wotton,
49− Matthew Pickering,
50− Matthew Stewart,
51− Matvey Aksenov,
52− Nicholas Clarke,
53− Nicolas Rolland,
54− Oliver Charles,
55− Pascal Wittmann,
56− Patrick John Wheeler,
57− Phil de Joux,
58− Piotr Bogdan,
59− Profpatsch,
60− Raymond Gauthier,
61− Renzo Carbonara,
62− Rodney Lorrimar,
63− Sibi,
64− Sukant Hajra,
65− Tanner Doshier,
66− Vaibhav Sagar,
67− Viktar Basharymau,
68− danbst,
69− karsten gebbert,
70− laMudri,
71− Александр Цамутали
72−maintainer: Peter Simons <simons@cryp.to>
73−license: BSD3
74−license-file: LICENSE
75−tested-with: GHC == 8.2.2, GHC == 8.4.3
76−build-type: Simple
77−cabal-version: 1.24
78−
1+name: cabal2nix
2+version: 2.15.1
3+synopsis: Convert Cabal files into Nix build instructions.
794description:
80− Convert Cabal files into Nix build instructions. Users of Nix can install the
81− latest version by running:
5+ Convert Cabal files into Nix build instructions. Users of Nix can install the latest
6+ version by running:
827 .
838 > nix-env -i cabal2nix
84−
85−extra-source-files:
86− README.md
87− test/golden-test-cases/*.cabal
88− test/golden-test-cases/*.nix.golden
9+license: BSD3
10+license-file: LICENSE
11+author: Peter Simons, Andres Loeh, Benno Fünfstück, Mateusz Kowalczyk,
12+ Michael Alan Dorman, Tom Smalley, Mathijs Kwik, Shea Levy, Dmitry
13+ Malikov, Eric Seidel, Jacob Mitchell, Graham Christensen,
14+ Hamish Mackenzie, Nikolay Amiantov, Aycan iRiCAN, Bryan
15+ Gardiner, Joe Hermaszewski, John Wiegley, Philipp Hausmann,
16+ Spencer Janssen, Tom Hunger, William Casarin, koral,
17+ ksaric, Adam Vogt, Alexey Shmalko, Corey O'Connor, Cray
18+ Elliott, David Johnson, Dmitry Bushev, Domen Kožar, Felix
19+ Kunzmann, Gabriel Ebner, Gergely Risko, Joachim Fasting,
20+ John Albietz, John Chee, Jussi Maki, Lisanna Dettwyler,
21+ Mark Laws, Mark Wotton, Matthew Pickering, Matthew Stewart,
22+ Matvey Aksenov, Nicholas Clarke, Nicolas Rolland, Oliver
23+ Charles, Pascal Wittmann, Patrick John Wheeler, Phil de
24+ Joux, Piotr Bogdan, Profpatsch, Raymond Gauthier, Renzo
25+ Carbonara, Rodney Lorrimar, Sibi, Sukant Hajra, Tanner
26+ Doshier, Vaibhav Sagar, Viktar Basharymau, danbst, karsten
27+ gebbert, laMudri, Александр Цамутали
28+maintainer: Peter Simons <simons@cryp.to>
29+stability: stable
30+tested-with: GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1
31+category: Distribution, Nix
32+homepage: https://github.com/nixos/cabal2nix#readme
33+bug-reports: https://github.com/nixos/cabal2nix/issues
34+build-type: Simple
35+extra-source-files: README.md
36+ test/golden-test-cases/*.cabal
37+ test/golden-test-cases/*.nix.golden
38+cabal-version: 1.24
8939
9040source-repository head
91− type: git
41+ type: git
9242 location: https://github.com/nixos/cabal2nix
9343
9444library
95− hs-source-dirs: src
96− other-extensions: CPP DeriveGeneric FlexibleInstances MultiParamTypeClasses
97− OverloadedStrings RecordWildCards ScopedTypeVariables
98− StandaloneDeriving TemplateHaskell
99− default-extensions: MonadFailDesugaring
100− ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
101− -Wredundant-constraints
102− build-depends:
103− Cabal >2.2
104− , aeson
105− , ansi-wl-pprint
106− , base <5
107− , bytestring
108− , containers
109− , deepseq >=1.4
110− , directory
111− , distribution-nixpkgs >=1.1.1
112− , filepath
113− , hackage-db >=2.0.1
114− , hopenssl >=2
115− , hpack >= 0.26
116− , language-nix
117− , lens
118− , optparse-applicative
119− , pretty >=1.1.2
120− , process
121− , split
122− , text
123− , time
124− , transformers
125− , yaml
126− exposed-modules:
127− Cabal2nix
128− Distribution.Nixpkgs.Fetch
129− Distribution.Nixpkgs.Haskell
130− Distribution.Nixpkgs.Haskell.BuildInfo
131− Distribution.Nixpkgs.Haskell.Constraint
132− Distribution.Nixpkgs.Haskell.Derivation
133− Distribution.Nixpkgs.Haskell.FromCabal
134− Distribution.Nixpkgs.Haskell.FromCabal.Configuration
135− Distribution.Nixpkgs.Haskell.FromCabal.Flags
136− Distribution.Nixpkgs.Haskell.FromCabal.License
137− Distribution.Nixpkgs.Haskell.FromCabal.Name
138− Distribution.Nixpkgs.Haskell.FromCabal.Normalize
139− Distribution.Nixpkgs.Haskell.FromCabal.PostProcess
140− Distribution.Nixpkgs.Haskell.Hackage
141− Distribution.Nixpkgs.Haskell.OrphanInstances
142− Distribution.Nixpkgs.Haskell.PackageSourceSpec
143− other-modules:
144− Paths_cabal2nix
145− default-language: Haskell2010
45+ exposed-modules: Cabal2nix
46+ Distribution.Nixpkgs.Fetch
47+ Distribution.Nixpkgs.Haskell
48+ Distribution.Nixpkgs.Haskell.BuildInfo
49+ Distribution.Nixpkgs.Haskell.Constraint
50+ Distribution.Nixpkgs.Haskell.Derivation
51+ Distribution.Nixpkgs.Haskell.FromCabal
52+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration
53+ Distribution.Nixpkgs.Haskell.FromCabal.Flags
54+ Distribution.Nixpkgs.Haskell.FromCabal.License
55+ Distribution.Nixpkgs.Haskell.FromCabal.Name
56+ Distribution.Nixpkgs.Haskell.FromCabal.Normalize
57+ Distribution.Nixpkgs.Haskell.FromCabal.PostProcess
58+ Distribution.Nixpkgs.Haskell.Hackage
59+ Distribution.Nixpkgs.Haskell.OrphanInstances
60+ Distribution.Nixpkgs.Haskell.PackageSourceSpec
61+ other-modules: Paths_cabal2nix
62+ hs-source-dirs: src
63+ build-depends: base > 4.11
64+ , Cabal == 3.0.*
65+ , aeson > 1
66+ , ansi-wl-pprint
67+ , bytestring
68+ , containers >= 0.5.9
69+ , deepseq >= 1.4
70+ , directory
71+ , distribution-nixpkgs >= 1.3.1
72+ , filepath
73+ , hackage-db >= 2.0.1
74+ , hopenssl >= 2
75+ , hpack >= 0.29.6
76+ , language-nix
77+ , lens
78+ , optparse-applicative
79+ , pretty >= 1.1.2
80+ , process
81+ , split
82+ , text
83+ , time
84+ , transformers
85+ , yaml
86+ default-language: Haskell2010
87+ other-extensions: MultiParamTypeClasses
88+ ScopedTypeVariables
89+ FlexibleInstances
90+ CPP
91+ TemplateHaskell
92+ StandaloneDeriving
93+ RecordWildCards
94+ OverloadedStrings
95+ DeriveGeneric
96+ ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
97+ -Wredundant-constraints
14698
14799executable cabal2nix
148− main-is: Main.hs
149− hs-source-dirs: cabal2nix
150− default-extensions: MonadFailDesugaring
151− ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
152− -Wredundant-constraints
153− build-depends: base, cabal2nix
154− default-language: Haskell2010
100+ main-is: Main.hs
101+ hs-source-dirs: cabal2nix
102+ build-depends: base, cabal2nix
103+ default-language: Haskell2010
104+ ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
105+ -Wredundant-constraints
155106
156107executable hackage2nix
157− main-is: Main.hs
158− hs-source-dirs: hackage2nix
159− default-extensions: MonadFailDesugaring
160− ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
161− -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
162− build-depends:
163− Cabal >2.2
164− , aeson
165− , base <5
166− , bytestring
167− , cabal2nix
168− , containers
169− , directory
170− , distribution-nixpkgs >=1.1.1
171− , filepath
172− , hopenssl >=2
173− , language-nix
174− , lens
175− , monad-par
176− , monad-par-extras
177− , mtl
178− , optparse-applicative
179− , pretty >=1.1.2
180− other-modules:
181− Paths_cabal2nix
182− HackageGit
183− default-language: Haskell2010
108+ main-is: Main.hs
109+ other-modules: HackageGit
110+ Paths_cabal2nix
111+ hs-source-dirs: hackage2nix
112+ build-depends: base < 5
113+ , Cabal
114+ , aeson
115+ , bytestring
116+ , cabal2nix
117+ , containers
118+ , directory
119+ , distribution-nixpkgs >= 1.2
120+ , filepath
121+ , hopenssl >= 2
122+ , language-nix
123+ , lens
124+ , monad-par
125+ , monad-par-extras
126+ , mtl
127+ , optparse-applicative
128+ , pretty >= 1.1.2
129+ default-language: Haskell2010
130+ ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
131+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-maxN16
184132
185133test-suite regression-test
186− type: exitcode-stdio-1.0
187− main-is: Main.hs
188− hs-source-dirs: test
189− default-extensions: MonadFailDesugaring
190− ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
191− -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
192− -with-rtsopts=-K1K
193− build-depends: base
194− , Cabal >2.2
195− , cabal2nix
196− , containers
197− , directory
198− , filepath
199− , language-nix
200− , lens
201− , pretty
202− , process >1.2
203− , tasty
204− , tasty-golden
205− build-tools: cabal2nix
206− default-language: Haskell2010
134+ type: exitcode-stdio-1.0
135+ main-is: Main.hs
136+ hs-source-dirs: test
137+ build-depends: base
138+ , Cabal
139+ , cabal2nix
140+ , containers
141+ , directory
142+ , filepath
143+ , language-nix
144+ , lens
145+ , pretty
146+ , process > 1.2
147+ , tasty
148+ , tasty-golden
149+ default-language: Haskell2010
150+ build-tools: cabal2nix
151+ ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
152+ -Wredundant-constraints -threaded -with-rtsopts=-K64K
hackage2nix/Main.hs+29−20
@@ -1,6 +1,5 @@
11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE RecordWildCards #-}
3−{-# LANGUAGE CPP #-}
43
54module Main ( main ) where
65
@@ -11,13 +10,10 @@ import Control.Monad
1110import Control.Monad.Par.Combinator
1211import Control.Monad.Par.IO
1312import Control.Monad.Trans ( liftIO )
14−import Data.List
13+import Data.List ( intercalate )
1514import Data.Map.Strict ( Map )
1615import qualified Data.Map.Strict as Map
1716import Data.Maybe
18−#if !MIN_VERSION_base(4,11,0)
19−import Data.Monoid
20−#endif
2117import Data.Set ( Set )
2218import qualified Data.Set as Set
2319import Data.String
@@ -27,10 +23,11 @@ import Distribution.Nixpkgs.Haskell.Constraint
2723import Distribution.Nixpkgs.Haskell.FromCabal
2824import Distribution.Nixpkgs.Haskell.FromCabal.Configuration as Config
2925import Distribution.Nixpkgs.Haskell.FromCabal.Flags
26+import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
3027import Distribution.Nixpkgs.Meta
3128import Distribution.Nixpkgs.PackageMap
3229import Distribution.Package
33−import Distribution.PackageDescription hiding ( options, buildDepends, extraLibs, buildTools, homepage )
30+import Distribution.PackageDescription hiding ( options, extraLibs, buildTools, homepage )
3431import Distribution.System
3532import Distribution.Text
3633import Distribution.Version
@@ -66,7 +63,7 @@ main = do
6663 pinfo :: ParserInfo CLI
6764 pinfo = info
6865 ( helper
69− <*> infoOption ("hackage2nix " ++ display Main.version) (long "version" <> help "Show version number")
66+ <*> infoOption ("hackage2nix " ++ prettyShow Main.version) (long "version" <> help "Show version number")
7067 <*> cliOptions
7168 )
7269 ( fullDesc
@@ -75,13 +72,15 @@ main = do
7572 CLI {..} <- execParser pinfo
7673
7774 config <- readConfiguration (nixpkgsRepository </> configFile)
78− nixpkgs <- readNixpkgPackageMap nixpkgsRepository Nothing
75+ nixpkgs <- readNixpkgPackageMap ["-f", nixpkgsRepository, "--arg", "config", "{ allowAliases = false; }"]
7976 preferredVersions <- readPreferredVersions (fromMaybe (hackageRepository </> "preferred-versions") preferredVersionsFile)
8077 let fixup = Map.delete "acme-everything" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
8178 . Map.delete "som" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
8279 . Map.delete "type" -- TODO: https://github.com/NixOS/cabal2nix/issues/163
8380 . Map.delete "control-invariants" -- TODO: depends on "assert"
84− . over (at ("hermes")) ((fmap (set (contains "1.3.4.3") False))) -- TODO: https://github.com/haskell/hackage-server/issues/436
81+ . Map.delete "with" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
82+ . Map.delete "telega" -- TODO: depends on "with"
83+ . over (at "hermes") (fmap (set (contains "1.3.4.3") False)) -- TODO: https://github.com/haskell/hackage-server/issues/436
8584 hackage <- fixup <$> readHackage hackageRepository
8685 let
8786 hackagePackagesFile :: FilePath
@@ -94,7 +93,7 @@ main = do
9493 latestVersionSet = Map.map Set.findMax (Map.filter (not . Set.null) (Map.mapWithKey (enforcePreferredVersions preferredVersions) hackage))
9594
9695 defaultPackageOverridesSet :: PackageSet
97− defaultPackageOverridesSet = Map.fromList [ (name, resolveConstraint c hackage) | c@(Dependency name _) <- defaultPackageOverrides config ]
96+ defaultPackageOverridesSet = Map.fromList [ (name, resolveConstraint c hackage) | c@(Dependency name _ _) <- defaultPackageOverrides config ]
9897
9998 generatedDefaultPackageSet :: PackageSet
10099 generatedDefaultPackageSet = (defaultPackageOverridesSet `Map.union` latestVersionSet) `Map.difference` corePackageSet
@@ -107,7 +106,7 @@ main = do
107106
108107 extraPackageSet :: PackageMultiSet
109108 extraPackageSet = Map.unionsWith Set.union
110− [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _) <- extraPackages config ]
109+ [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _ _) <- extraPackages config ]
111110
112111 db :: PackageMultiSet
113112 db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
@@ -117,7 +116,7 @@ main = do
117116 ]
118117
119118 haskellResolver :: Dependency -> Bool
120− haskellResolver (Dependency name vrange)
119+ haskellResolver (Dependency name vrange _)
121120 | Just v <- Map.lookup name corePackageSet = v `withinRange` vrange
122121 | Just v <- Map.lookup name generatedDefaultPackageSet = v `withinRange` vrange
123122 | otherwise = False
@@ -136,8 +135,13 @@ main = do
136135 (descr, cabalSHA256) <- readPackage hackageRepository pkgId
137136 meta <- readPackageMeta hackageRepository pkgId
138137
139− let isInDefaultPackageSet :: Bool
140− isInDefaultPackageSet = maybe False (== v) (Map.lookup name generatedDefaultPackageSet)
138+ let isInDefaultPackageSet, isHydraEnabled, isBroken :: Bool
139+ isInDefaultPackageSet = (== Just v) (Map.lookup name generatedDefaultPackageSet)
140+ isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)
141+ isBroken = any (withinRange v) [ vr | Dependency pn vr _ <- brokenPackages config, pn == name ]
142+
143+ droppedPlatforms :: Set Platform
144+ droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)
141145
142146 tarballSHA256 :: SHA256Hash
143147 tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball"))
@@ -151,15 +155,17 @@ main = do
151155
152156 drv :: Derivation
153157 drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr
154− & src .~ DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256
158+ & src .~ urlDerivationSource ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") tarballSHA256
155159 & editedCabalFile .~ cabalSHA256
156− & metaSection.hydraPlatforms %~ (`Set.difference` Map.findWithDefault Set.empty name (dontDistributePackages config))
160+ & metaSection.platforms %~ (`Set.difference` Map.findWithDefault Set.empty name (unsupportedPlatforms config))
161+ & metaSection.hydraPlatforms %~ (if Set.null droppedPlatforms then id else (`Set.difference` droppedPlatforms))
162+ & metaSection.hydraPlatforms %~ (if isHydraEnabled then id else const Set.empty)
163+ & metaSection.broken ||~ isBroken
157164 & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers
158− & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty)
159165 & metaSection.homepage .~ ""
160166
161167 overrides :: Doc
162− overrides = fcat $ punctuate space [ disp b <> semi | b <- Set.toList ((view (dependencies . each) drv) `Set.union` view extraFunctionArgs drv), not (isFromHackage b) ]
168+ overrides = fcat $ punctuate space [ pPrint b <> semi | b <- Set.toList (view (dependencies . each) drv `Set.union` view extraFunctionArgs drv), not (isFromHackage b) ]
163169 return $ render $ nest 2 $
164170 hang (doubleQuotes (text attr) <+> equals <+> text "callPackage") 2 (parens (pPrint drv)) <+> (braces overrides <> semi)
165171
@@ -193,10 +199,13 @@ enforcePreferredVersions cs pkg = Set.filter (\v -> PackageIdentifier pkg v `sat
193199
194200resolveConstraint :: Constraint -> Hackage -> Version
195201resolveConstraint c = fromMaybe (error msg) . resolveConstraint' c
196− where msg = "constraint " ++ display c ++ " cannot be resolved in Hackage"
202+ where msg = unlines [ "constraint " ++ display c ++ " cannot be resolved in Hackage"
203+ , "This could be due the package being missing in the hackage directory"
204+ , "or the file system not being case sensitive."
205+ ]
197206
198207resolveConstraint' :: Constraint -> Hackage -> Maybe Version
199−resolveConstraint' (Dependency name vrange) hackage
208+resolveConstraint' (Dependency name vrange _) hackage
200209 | Just vset' <- Map.lookup name hackage
201210 , vset <- Set.filter (`withinRange` vrange) vset'
202211 , not (Set.null vset) = Just (Set.findMax vset)
hackage2nix/README.md+3
@@ -15,6 +15,9 @@ and we want to check that hackage-packages.nix will be updated correctly.
1515On macOS you can use [this](https://gist.github.com/dixson3/8360571) to create one
1616(you can replace 60g with 4g as that should be plenty).
1717
18+There is a [video on YouTube](https://www.youtube.com/watch?v=qX0mgtSm360)
19+that gives a thorough walk-through of these steps.
20+
1821#### Setup
1922Replace `git@github.com:NixOS/nixpkgs.git` with a fork you have access to.
2023```
src/Cabal2nix.hs+44−29
@@ -3,21 +3,20 @@
33{-# LANGUAGE RecordWildCards #-}
44
55module Cabal2nix
6− ( main, cabal2nix, cabal2nix', cabal2nixWithDB
6+ ( main, cabal2nix, cabal2nix', cabal2nixWithDB, parseArgs
7+ , Options(..)
78 )
89 where
910
1011import Control.Exception ( bracket )
1112import Control.Lens
1213import Control.Monad
13−import Data.List
14+import Data.List ( intercalate, isPrefixOf )
1415import Data.List.Split
1516import Data.Maybe ( fromMaybe, isJust, listToMaybe )
16−import Data.Monoid ( (<>) )
1717import qualified Data.Set as Set
1818import Data.String
1919import Data.Time
20−import qualified Distribution.Compat.ReadP as P
2120import Distribution.Compiler
2221import Distribution.Nixpkgs.Fetch
2322import Distribution.Nixpkgs.Haskell
@@ -25,13 +24,14 @@ import Distribution.Nixpkgs.Haskell.FromCabal
2524import Distribution.Nixpkgs.Haskell.FromCabal.Flags
2625import qualified Distribution.Nixpkgs.Haskell.FromCabal.PostProcess as PP (pkg)
2726import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
27+import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2828import Distribution.Nixpkgs.Haskell.PackageSourceSpec
2929import Distribution.Nixpkgs.Meta
30−import Distribution.PackageDescription ( mkFlagName, mkFlagAssignment, FlagAssignment )
3130import Distribution.Package ( packageId )
31+import Distribution.PackageDescription ( mkFlagName, mkFlagAssignment, FlagAssignment )
32+import Distribution.Parsec as P
3233import Distribution.Simple.Utils ( lowercase )
3334import Distribution.System
34−import Distribution.Text
3535import Language.Nix
3636import Options.Applicative
3737import Paths_cabal2nix ( version )
@@ -45,9 +45,10 @@ data Options = Options
4545 , optMaintainer :: [String]
4646--, optPlatform :: [String] -- TODO: fix command line handling of platforms
4747 , optHaddock :: Bool
48− , optHpack :: Bool
48+ , optHpack :: HpackUse
4949 , optDoCheck :: Bool
5050 , optJailbreak :: Bool
51+ , optDoBenchmark :: Bool
5152 , optRevision :: Maybe String
5253 , optHyperlinkSource :: Bool
5354 , optEnableLibraryProfiling :: Bool
@@ -61,9 +62,10 @@ data Options = Options
6162 , optSystem :: Platform
6263 , optSubpath :: Maybe FilePath
6364 , optHackageSnapshot :: Maybe UTCTime
65+ , optNixpkgsIdentifier :: NixpkgsResolver
6466 , optUrl :: String
67+ , optFetchSubmodules :: Bool
6568 }
66− deriving (Show)
6769
6870options :: Parser Options
6971options = Options
@@ -71,9 +73,17 @@ options = Options
7173 <*> many (strOption $ long "maintainer" <> metavar "MAINTAINER" <> help "maintainer of this package (may be specified multiple times)")
7274-- <*> many (strOption $ long "platform" <> metavar "PLATFORM" <> help "supported build platforms (may be specified multiple times)")
7375 <*> flag True False (long "no-haddock" <> help "don't run Haddock when building this package")
74− <*> switch (long "hpack" <> help "run hpack before configuring this package (only non-hackage packages)")
76+ <*>
77+ (
78+ flag' ForceHpack (long "hpack" <> help "run hpack before configuring this package (only non-hackage packages)")
79+ <|>
80+ flag' NoHpack (long "no-hpack" <> help "disable hpack run and use only cabal disregarding package.yaml existence")
81+ <|>
82+ pure PackageYamlHpack
83+ )
7584 <*> flag True False (long "no-check" <> help "don't run regression test suites of this package")
7685 <*> switch (long "jailbreak" <> help "disregard version restrictions on build inputs")
86+ <*> switch (long "benchmark" <> help "enable benchmarks for this package")
7787 <*> optional (strOption $ long "revision" <> help "revision to use when fetching from VCS")
7888 <*> flag True False (long "no-hyperlink-source" <> help "don't generate pretty-printed source code for the documentation")
7989 <*> switch (long "enable-library-profiling" <> help "enable library profiling in the generated build")
@@ -83,11 +93,13 @@ options = Options
8393 <*> optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
8494 <*> switch (long "shell" <> help "generate output suitable for nix-shell")
8595 <*> many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
86− <*> option (readP parse) (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith display)
87− <*> option (maybeReader parsePlatform) (long "system" <> help "host system (in either short Nix format or full LLVM style) to use when evaluating the Cabal file" <> value buildPlatform <> showDefaultWith display)
96+ <*> option parseCabal (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith prettyShow)
97+ <*> option (maybeReader parsePlatform) (long "system" <> help "host system (in either short Nix format or full LLVM style) to use when evaluating the Cabal file" <> value buildPlatform <> showDefaultWith prettyShow)
8898 <*> optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
8999 <*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
100+ <*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
90101 <*> strArgument (metavar "URI")
102+ <*> flag True False (long "dont-fetch-submodules" <> help "do not fetch git submodules from git sources")
91103
92104-- | A parser for the date. Hackage updates happen maybe once or twice a month.
93105-- Example: parseTime defaultTimeLocale "%FT%T%QZ" "2017-11-20T12:18:35Z" :: Maybe UTCTime
@@ -97,10 +109,8 @@ utcTimeReader = eitherReader $ \arg ->
97109 Nothing -> Left $ "Cannot parse date, ISO format used ('2017-11-20T12:18:35Z'): " ++ arg
98110 Just utcTime -> Right utcTime
99111
100−readP :: P.ReadP a a -> ReadM a
101−readP p = eitherReader $ \s -> case [ r' | (r',"") <- P.readP_to_S p s ] of
102− (r:_) -> Right r
103− _ -> Left ("invalid value " ++ show s)
112+parseCabal :: Parsec a => ReadM a
113+parseCabal = eitherReader eitherParsec
104114
105115-- | Replicate the normalization performed by GHC_CONVERT_CPU in GHC's aclocal.m4
106116-- since the output of that is what Cabal parses.
@@ -125,6 +135,7 @@ ghcConvertOS os = case os of
125135 "watchos" -> "ios"
126136 "tvos" -> "ios"
127137 "linux-android" -> "linux-android"
138+ "linux-androideabi" -> "linux-androideabi"
128139 _ | "linux-" `isPrefixOf` os -> "linux"
129140 _ -> fromMaybe os $ listToMaybe
130141 [prefix | prefix <- osPrefixes, prefix `isPrefixOf` os]
@@ -151,7 +162,7 @@ parsePlatformParts = \case
151162pinfo :: ParserInfo Options
152163pinfo = info
153164 ( helper
154− <*> infoOption ("cabal2nix " ++ display version) (long "version" <> help "Show version number")
165+ <*> infoOption ("cabal2nix " ++ prettyShow version) (long "version" <> help "Show version number")
155166 <*> options
156167 )
157168 ( fullDesc
@@ -180,23 +191,21 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() ->
180191 cabal2nix =<< getArgs
181192
182193hpackOverrides :: Derivation -> Derivation
183−hpackOverrides = over phaseOverrides (++ "preConfigure = \"hpack\";")
194+hpackOverrides = over phaseOverrides (++ "prePatch = \"hpack\";")
184195 . set (libraryDepends . tool . contains (PP.pkg "hpack")) True
185196
186−cabal2nix' :: [String] -> IO (Either Doc Derivation)
187−cabal2nix' args = do
188− opts@Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args
189−
190− pkg <- getPackage optHpack optHackageDb optHackageSnapshot $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
197+cabal2nix' :: Options -> IO (Either Doc Derivation)
198+cabal2nix' opts@Options{..} = do
199+ pkg <- getPackage optHpack optFetchSubmodules optHackageDb optHackageSnapshot $
200+ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
191201 processPackage opts pkg
192202
193−cabal2nixWithDB :: DB.HackageDB -> [String] -> IO (Either Doc Derivation)
194−cabal2nixWithDB db args = do
195− opts@Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args
203+cabal2nixWithDB :: DB.HackageDB -> Options -> IO (Either Doc Derivation)
204+cabal2nixWithDB db opts@Options{..} = do
196205 when (isJust optHackageDb) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-db"
197206 when (isJust optHackageSnapshot) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-snapshot"
198−
199− pkg <- getPackage' optHpack (return db) $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
207+ pkg <- getPackage' optHpack optFetchSubmodules (return db) $
208+ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
200209 processPackage opts pkg
201210
202211processPackage :: Options -> Package -> IO (Either Doc Derivation)
@@ -210,7 +219,7 @@ processPackage Options{..} pkg = do
210219
211220 deriv :: Derivation
212221 deriv = withHpackOverrides $ fromGenericPackageDescription (const True)
213− (\i -> Just (binding # (i, path # [i])))
222+ optNixpkgsIdentifier
214223 optSystem
215224 (unknownCompilerInfo optCompiler NoAbiTag)
216225 flags
@@ -226,6 +235,7 @@ processPackage Options{..} pkg = do
226235 & metaSection.maintainers .~ Set.fromList (map (review ident) optMaintainer)
227236-- & metaSection.platforms .~ Set.fromList optPlatform
228237 & doCheck &&~ optDoCheck
238+ & doBenchmark ||~ optDoBenchmark
229239 & extraFunctionArgs %~ Set.union (Set.fromList ("inherit stdenv":map (fromString . ("inherit " ++)) optExtraArgs))
230240
231241 shell :: Doc
@@ -253,7 +263,12 @@ processPackage Options{..} pkg = do
253263 pure $ if optNixShellOutput then Left shell else Right deriv
254264
255265cabal2nix :: [String] -> IO ()
256−cabal2nix = cabal2nix' >=> putStrLn . either render prettyShow
266+cabal2nix = parseArgs >=> cabal2nix' >=> putStrLn . either render prettyShow
267+
268+parseArgs :: [String] -> IO Options
269+parseArgs = handleParseResult . execParserPure defaultPrefs pinfo
270+
271+-- Utils
257272
258273readFlagList :: [String] -> FlagAssignment
259274readFlagList = mkFlagAssignment . map tagWithValue
src/Distribution/Nixpkgs/Fetch.hs+46−8
@@ -6,7 +6,7 @@
66module Distribution.Nixpkgs.Fetch
77 ( Source(..)
88 , Hash(..)
9− , DerivationSource(..), fromDerivationSource
9+ , DerivationSource(..), fromDerivationSource, urlDerivationSource
1010 , fetch
1111 , fetchWith
1212 ) where
@@ -18,7 +18,10 @@ import Control.Monad.IO.Class
1818import Control.Monad.Trans.Maybe
1919import Data.Aeson
2020import qualified Data.ByteString.Lazy.Char8 as BS
21+import qualified Data.List as L
22+import Data.Maybe
2123import GHC.Generics ( Generic )
24+import Language.Nix.PrettyPrinting as PP
2225import System.Directory
2326import System.Environment
2427import System.Exit
@@ -56,6 +59,7 @@ data DerivationSource = DerivationSource
5659 , derivUrl :: String -- ^ URL to fetch from.
5760 , derivRevision :: String -- ^ Revision to use. Leave empty if the fetcher doesn't support revisions.
5861 , derivHash :: String -- ^ The hash of the source.
62+ , derivSubmodule :: Maybe Bool -- ^ The fetchSubmodule setting (if any)
5963 }
6064 deriving (Show, Eq, Ord, Generic)
6165
@@ -66,22 +70,46 @@ instance FromJSON DerivationSource where
6670 <$> o .: "url"
6771 <*> o .: "rev"
6872 <*> o .: "sha256"
73+ <*> o .: "fetchSubmodules"
6974 parseJSON _ = error "invalid DerivationSource"
7075
76+instance PP.Pretty DerivationSource where
77+ pPrint DerivationSource {..} =
78+ let isHackagePackage = "mirror://hackage/" `L.isPrefixOf` derivUrl
79+ fetched = derivKind /= ""
80+ in if isHackagePackage then attr "sha256" $ string derivHash
81+ else if not fetched then attr "src" $ text derivUrl
82+ else vcat
83+ [ text "src" <+> equals <+> text ("fetch" ++ derivKind) <+> lbrace
84+ , nest 2 $ vcat
85+ [ attr "url" $ string derivUrl
86+ , attr "sha256" $ string derivHash
87+ , if derivRevision /= "" then attr "rev" (string derivRevision) else PP.empty
88+ , boolattr "fetchSubmodules" (isJust derivSubmodule) (fromJust derivSubmodule)
89+ ]
90+ , rbrace PP.<> semi
91+ ]
92+
93+
94+urlDerivationSource :: String -> String -> DerivationSource
95+urlDerivationSource url hash = DerivationSource "url" url "" hash Nothing
96+
7197fromDerivationSource :: DerivationSource -> Source
7298fromDerivationSource DerivationSource{..} = Source derivUrl derivRevision (Certain derivHash) "."
7399
74100-- | Fetch a source, trying any of the various nix-prefetch-* scripts.
75−fetch :: forall a. (String -> MaybeT IO a) -- ^ This function is passed the output path name as an argument.
101+fetch :: forall a.
102+ Bool -- ^ If True, fetch submodules when the source is a git repository
103+ -> (String -> MaybeT IO a) -- ^ This function is passed the output path name as an argument.
76104 -- It should return 'Nothing' if the file doesn't match the expected format.
77105 -- This is required, because we cannot always check if a download succeeded otherwise.
78106 -> Source -- ^ The source to fetch from.
79107 -> IO (Maybe (DerivationSource, a)) -- ^ The derivation source and the result of the processing function. Returns Nothing if the download failed.
80−fetch f = runMaybeT . fetchers where
108+fetch optSubModules f = runMaybeT . fetchers where
81109 fetchers :: Source -> MaybeT IO (DerivationSource, a)
82110 fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
83111 [ (False, "url", [])
84− , (True, "git", ["--fetch-submodules"])
112+ , (True, "git", ["--fetch-submodules" | optSubModules ])
85113 , (True, "hg", [])
86114 , (True, "svn", [])
87115 , (True, "bzr", [])
@@ -100,17 +128,19 @@ fetch f = runMaybeT . fetchers where
100128 guard $ existsDir || existsFile
101129 let path' | '/' `elem` path = path
102130 | otherwise = "./" ++ path
103− process (DerivationSource "" path' "" "", path') <|> localArchive path'
131+ process (localDerivationSource path', path') <|> localArchive path'
104132
105133 localArchive :: FilePath -> MaybeT IO (DerivationSource, a)
106134 localArchive path = do
107135 absolutePath <- liftIO $ canonicalizePath path
108136 unpacked <- snd <$> fetchWith (False, "url", ["--unpack"]) (Source ("file://" ++ absolutePath) "" UnknownHash ".")
109− process (DerivationSource "" absolutePath "" "", unpacked)
137+ process (localDerivationSource absolutePath, unpacked)
110138
111139 process :: (DerivationSource, FilePath) -> MaybeT IO (DerivationSource, a)
112140 process (derivSource, file) = (,) derivSource <$> f file
113141
142+ localDerivationSource p = DerivationSource "" p "" "" Nothing
143+
114144-- | Like 'fetch', but allows to specify which script to use.
115145fetchWith :: (Bool, String, [String]) -> Source -> MaybeT IO (DerivationSource, FilePath)
116146fetchWith (supportsRev, kind, addArgs) source = do
@@ -131,11 +161,19 @@ fetchWith (supportsRev, kind, addArgs) source = do
131161 ExitFailure _ -> return Nothing
132162 ExitSuccess -> do
133163 buf <- BS.hGetContents stdoutH
134− let (l:ls) = reverse (BS.lines buf)
164+ let (l,ls) = case reverse (BS.lines buf) of
165+ [] -> error "This can't happen, but GHC doesn't know that."
166+ (x:xs) -> (x,xs)
135167 buf' = BS.unlines (reverse ls)
136168 case length ls of
137169 0 -> return Nothing
138− 1 -> return (Just (DerivationSource kind (sourceUrl source) "" (BS.unpack (head ls)) , sourceUrl source))
170+ 1 -> return (Just (DerivationSource { derivKind = kind
171+ , derivUrl = sourceUrl source
172+ , derivRevision = ""
173+ , derivHash = BS.unpack (head ls)
174+ , derivSubmodule = Nothing
175+ }
176+ , sourceUrl source))
139177 _ -> case eitherDecode buf' of
140178 Left err -> error ("invalid JSON: " ++ err ++ " in " ++ show buf')
141179 Right ds -> return (Just (ds { derivKind = kind }, BS.unpack l))
src/Distribution/Nixpkgs/Haskell/Constraint.hs+1−1
@@ -9,7 +9,7 @@ import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
99type Constraint = Dependency
1010
1111satisfiesConstraint :: PackageIdentifier -> Constraint -> Bool
12−satisfiesConstraint (PackageIdentifier pn v) (Dependency cn vr) = (pn /= cn) || (v `withinRange` vr)
12+satisfiesConstraint (PackageIdentifier pn v) (Dependency cn vr _) = (pn /= cn) || (v `withinRange` vr)
1313
1414satisfiesConstraints :: PackageIdentifier -> [Constraint] -> Bool
1515satisfiesConstraints p = all (satisfiesConstraint p)
src/Distribution/Nixpkgs/Haskell/Derivation.hs+8−17
@@ -7,7 +7,7 @@
77module Distribution.Nixpkgs.Haskell.Derivation
88 ( Derivation, nullDerivation, pkgid, revision, src, subpath, isLibrary, isExecutable
99 , extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags
10− , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
10+ , cabalFlags, runHaddock, jailbreak, doCheck, doBenchmark, testTarget, hyperlinkSource, enableSplitObjs
1111 , enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection
1212 , dependencies, setupDepends, benchmarkDepends, enableSeparateDataOutput
1313 )
@@ -15,7 +15,7 @@ module Distribution.Nixpkgs.Haskell.Derivation
1515
1616import Control.DeepSeq
1717import Control.Lens
18−import Data.List
18+import Data.List ( isPrefixOf )
1919import Data.Set ( Set )
2020import qualified Data.Set as Set
2121import Data.Set.Lens
@@ -55,6 +55,7 @@ data Derivation = MkDerivation
5555 , _runHaddock :: Bool
5656 , _jailbreak :: Bool
5757 , _doCheck :: Bool
58+ , _doBenchmark :: Bool
5859 , _testTarget :: String
5960 , _hyperlinkSource :: Bool
6061 , _enableLibraryProfiling :: Bool
@@ -86,6 +87,7 @@ nullDerivation = MkDerivation
8687 , _runHaddock = error "undefined Derivation.runHaddock"
8788 , _jailbreak = error "undefined Derivation.jailbreak"
8889 , _doCheck = error "undefined Derivation.doCheck"
90+ , _doBenchmark = error "undefined Derivation.doBenchmark"
8991 , _testTarget = error "undefined Derivation.testTarget"
9092 , _hyperlinkSource = error "undefined Derivation.hyperlinkSource"
9193 , _enableLibraryProfiling = error "undefined Derivation.enableLibraryProfiling"
@@ -110,9 +112,9 @@ instance Pretty Derivation where
110112 pPrint drv@MkDerivation {..} = funargs (map text ("mkDerivation" : toAscList inputs)) $$ vcat
111113 [ text "mkDerivation" <+> lbrace
112114 , nest 2 $ vcat
113− [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
114− , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
115− , sourceAttr _src
115+ [ attr "pname" $ doubleQuotes $ pPrint (packageName _pkgid)
116+ , attr "version" $ doubleQuotes $ pPrint (packageVersion _pkgid)
117+ , pPrint _src
116118 , onlyIf (_subpath /= ".") $ attr "postUnpack" postUnpack
117119 , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision
118120 , onlyIf (not (null _editedCabalFile) && _revision > 0) $ attr "editedCabalFile" $ string _editedCabalFile
@@ -131,6 +133,7 @@ instance Pretty Derivation where
131133 , boolattr "doHaddock" (not _runHaddock) _runHaddock
132134 , boolattr "jailbreak" _jailbreak _jailbreak
133135 , boolattr "doCheck" (not _doCheck) _doCheck
136+ , boolattr "doBenchmark" _doBenchmark _doBenchmark
134137 , onlyIf (not (null _testTarget)) $ attr "testTarget" $ string _testTarget
135138 , boolattr "hyperlinkSource" (not _hyperlinkSource) _hyperlinkSource
136139 , onlyIf (not (null _phaseOverrides)) $ vcat ((map text . lines) _phaseOverrides)
@@ -148,17 +151,5 @@ instance Pretty Derivation where
148151 renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text (unFlagName f) | (f, enable) <- unFlagAssignment _cabalFlags ]
149152 ++ map text (toAscList _configureFlags)
150153 isHackagePackage = "mirror://hackage/" `isPrefixOf` derivUrl _src
151− sourceAttr DerivationSource {..}
152− | isHackagePackage = attr "sha256" $ string derivHash
153− | derivKind /= "" = vcat
154− [ text "src" <+> equals <+> text ("fetch" ++ derivKind) <+> lbrace
155− , nest 2 $ vcat
156− [ attr "url" $ string derivUrl
157− , attr "sha256" $ string derivHash
158− , if derivRevision /= "" then attr "rev" (string derivRevision) else empty
159− ]
160− , rbrace <> semi
161− ]
162− | otherwise = attr "src" $ text derivUrl
163154
164155 postUnpack = string $ "sourceRoot+=/" ++ _subpath ++ "; echo source root reset to $sourceRoot"
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+22−13
@@ -11,7 +11,6 @@ import Data.Maybe
1111import Data.Set ( Set )
1212import qualified Data.Set as Set
1313import Distribution.Compiler
14−import Distribution.License
1514import Distribution.Nixpkgs.Haskell
1615import qualified Distribution.Nixpkgs.Haskell as Nix
1716import Distribution.Nixpkgs.Haskell.Constraint
@@ -59,14 +58,14 @@ finalizeGenericPackageDescription haskellResolver arch compiler flags constraint
5958 }
6059
6160 jailbroken :: HaskellResolver -> HaskellResolver
62− jailbroken resolver (Dependency pkg _) = resolver (Dependency pkg anyVersion)
61+ jailbroken resolver (Dependency pkg _ _) = resolver (Dependency pkg anyVersion mempty)
6362
6463 withInternalLibs :: HaskellResolver -> HaskellResolver
6564 withInternalLibs resolver d = depPkgName d `elem` internalNames || resolver d
6665
6766 internalNames :: [PackageName]
6867 internalNames = [ unqualComponentNameToPackageName n | (n,_) <- condSubLibraries genDesc ]
69− ++ [ unqualComponentNameToPackageName n | Just n <- libName <$> subLibraries (packageDescription genDesc) ]
68+ ++ [ unqualComponentNameToPackageName n | LSubLibName n <- libName <$> subLibraries (packageDescription genDesc) ]
7069
7170 in case finalize (jailbroken (withInternalLibs haskellResolver)) of
7271 Left m -> case finalize (const True) of
@@ -92,6 +91,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
9291 & runHaddock .~ doHaddockPhase
9392 & jailbreak .~ False
9493 & doCheck .~ True
94+ & doBenchmark .~ False
9595 & testTarget .~ mempty
9696 & hyperlinkSource .~ True
9797 & enableSplitObjs .~ True
@@ -108,7 +108,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
108108 & Nix.description .~ synopsis
109109 & Nix.license .~ nixLicense
110110 & Nix.platforms .~ Nix.allKnownPlatforms
111− & Nix.hydraPlatforms .~ (if nixLicense == Nix.Known "stdenv.lib.licenses.unfree" then Set.empty else Nix.allKnownPlatforms)
111+ & Nix.hydraPlatforms .~ (if isFreeLicense nixLicense then Nix.allKnownPlatforms else Set.empty)
112112 & Nix.maintainers .~ mempty
113113 & Nix.broken .~ not (null missingDeps)
114114 )
@@ -116,30 +116,39 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
116116 xrev = maybe 0 read (lookup "x-revision" customFieldsPD)
117117
118118 nixLicense :: Nix.License
119− nixLicense = fromCabalLicense (either licenseFromSPDX id licenseRaw)
119+ nixLicense = either fromSPDXLicense fromCabalLicense licenseRaw
120120
121121 resolveInHackage :: Identifier -> Binding
122− resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _) <- missingDeps ] = bindNull i
122+ resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _ _) <- missingDeps ] = bindNull i
123123 | otherwise = binding # (i, path # ["self",i]) -- TODO: "self" shouldn't be hardcoded.
124124
125+ -- TODO: This is all very confusing. Haskell packages refer to the Nixpkgs
126+ -- derivation 'foo' as 'pkgs.foo', because they live in the 'haskellPackages'
127+ -- name space -- not on the top level. Therefore, we built our Nixpkgs lookup
128+ -- function so that top level names are returned as 'pkgs.foo'. As a result, we
129+ -- end up pre-pending that path to all kinds of names all over the place. I
130+ -- suppose the correct approach would be to assume that the lookup function
131+ -- returns names that live in the top-level and to adapt the code in
132+ -- PostProcess.hs et all to that fact.
125133 goodScopes :: Set [Identifier]
126134 goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome2"], ["gnome"], ["gnome3"], ["kde4"]])
127135
128136 resolveInNixpkgs :: Identifier -> Binding
129137 resolveInNixpkgs i
130138 | i `elem` ["clang","lldb","llvm"] = binding # (i, path # ["self","llvmPackages",i]) -- TODO: evil!
131− | i == "gtk2" = binding # (i, path # ["pkgs","gnome2","gtk"])
132− | i == "gtk3" = binding # (i, path # ["pkgs","gnome3","gtk"])
133− | i == "gtksourceview3" = binding # (i, path # ["pkgs","gnome3","gtksourceview"])
139+ | i == "gtk2" = binding # (i, path # ["pkgs","gtk2"]) -- TODO: these cases should not be necessary
140+ | i == "gtk3" = binding # (i, path # ["pkgs","gtk3"])
141+ | i == "gtksourceview3" = binding # (i, path # ["pkgs","gtksourceview3"])
142+ | i == "vte_291" = binding # (i, path # ["pkgs","vte"])
134143 | Just p <- nixpkgsResolver i, init (view (reference . path) p) `Set.member` goodScopes = p
135144 | otherwise = bindNull i
136145
137146 resolveInHackageThenNixpkgs :: Identifier -> Binding
138− resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i
147+ resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion mempty) = resolveInHackage i
139148 | otherwise = resolveInNixpkgs i
140149
141150 internalLibNames :: [PackageName]
142− internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
151+ internalLibNames = [ unqualComponentNameToPackageName n | LSubLibName n <- libName <$> subLibraries ]
143152
144153 doHaddockPhase :: Bool
145154 doHaddockPhase | not (null internalLibNames) = False
@@ -149,7 +158,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
149158 convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
150159 convertBuildInfo Cabal.BuildInfo {..} | not buildable = mempty
151160 convertBuildInfo Cabal.BuildInfo {..} = mempty
152− & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends, x `notElem` internalLibNames ]
161+ & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _ _) <- targetBuildDepends, x `notElem` internalLibNames ]
153162 & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]
154163 & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | PkgconfigDependency x _ <- pkgconfigDepends, y <- libNixName (unPkgconfigName x) ]
155164 & tool .~ Set.fromList (map resolveInHackageThenNixpkgs . concatMap buildToolNixName
@@ -157,7 +166,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
157166
158167 convertSetupBuildInfo :: Cabal.SetupBuildInfo -> Nix.BuildInfo
159168 convertSetupBuildInfo bi = mempty
160− & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- Cabal.setupDepends bi ]
169+ & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _ _) <- Cabal.setupDepends bi ]
161170
162171bindNull :: Identifier -> Binding
163172bindNull i = binding # (i, path # ["null"])
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+28−32
@@ -1,16 +1,21 @@
11{-# LANGUAGE RecordWildCards #-}
2−{-# LANGUAGE CPP #-}
32{-# LANGUAGE FlexibleInstances #-}
43{-# LANGUAGE OverloadedStrings #-}
54{-# LANGUAGE DeriveGeneric #-}
65{-# OPTIONS_GHC -fno-warn-orphans #-}
76
8−module Distribution.Nixpkgs.Haskell.FromCabal.Configuration ( Configuration(..), readConfiguration, assertConsistency ) where
7+module Distribution.Nixpkgs.Haskell.FromCabal.Configuration
8+ ( Configuration(..), readConfiguration, assertConsistency
9+ )
10+ where
11+
12+import Prelude hiding ( fail )
913
10−import Control.Exception ( throwIO )
1114import Control.DeepSeq
15+import Control.Exception ( throwIO )
1216import Control.Lens
13−import Control.Monad
17+import Control.Monad hiding ( fail )
18+import Control.Monad.Fail
1419import Data.Aeson
1520import Data.Map as Map
1621import Data.Set as Set
@@ -40,14 +45,22 @@ data Configuration = Configuration
4045 -- role during dependency resolution.
4146 , extraPackages :: [Constraint]
4247
43− -- |We know that these packages won't build, so we give them an empty
44− -- meta.hydraPlatforms attribute to avoid cluttering our Hydra output with
45− -- lots of failure messages.
46− , dontDistributePackages :: Map PackageName (Set Platform)
47−
4848 -- |This information is used by the @hackage2nix@ utility to determine the
4949 -- 'maintainers' for a given Haskell package.
5050 , packageMaintainers :: Map Identifier (Set PackageName)
51+
52+ -- |These packages (by design) don't support certain platforms.
53+ , unsupportedPlatforms :: Map PackageName (Set Platform)
54+
55+ -- |These packages cannot be distributed by Hydra, i.e. because they have an
56+ -- unfree license or depend on other tools that cannot be distributed for
57+ -- some reason.
58+ , dontDistributePackages :: Set PackageName
59+
60+ -- |We know that these packages won't compile, so we mark them as broken and
61+ -- also disable their meta.hydraPlatforms attribute to avoid cluttering our
62+ -- Hydra job with lots of failure messages.
63+ , brokenPackages :: [Constraint]
5164 }
5265 deriving (Show, Generic)
5366
@@ -59,50 +72,33 @@ instance FromJSON Configuration where
5972 <*> o .:? "core-packages" .!= mempty
6073 <*> o .:? "default-package-overrides" .!= mempty
6174 <*> o .:? "extra-packages" .!= mempty
62− <*> o .:? "dont-distribute-packages" .!= mempty
6375 <*> o .:? "package-maintainers" .!= mempty
76+ <*> o .:? "unsupported-platforms" .!= mempty
77+ <*> o .:? "dont-distribute-packages" .!= mempty
78+ <*> o .:? "broken-packages" .!= mempty
6479 parseJSON _ = error "invalid Configuration"
6580
6681instance FromJSON Identifier where
6782 parseJSON (String s) = pure (review ident (T.unpack s))
6883 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
6984
70−#if MIN_VERSION_aeson(1,0,0)
71−
7285instance FromJSONKey Identifier where
7386 fromJSONKey = FromJSONKeyText parseKey
7487
7588instance FromJSONKey PackageName where
7689 fromJSONKey = FromJSONKeyText parseKey
7790
78−#elif MIN_VERSION_aeson(0,11,0)
79−
80−instance (FromJSON v) => FromJSON (Map Identifier v) where
81− parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
82−
83−instance (FromJSON v) => FromJSON (Map PackageName v) where
84− parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
85−
86−#else
87−
88−instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
89− parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
90−
91−#endif
92−
9391parseKey :: FromJSON k => Text -> k
9492parseKey s = either error id (parseEither parseJSON (String s))
9593
9694readConfiguration :: FilePath -> IO Configuration
97−readConfiguration path =
98− decodeFileEither path >>= either throwIO assertConsistency
95+readConfiguration path = decodeFileEither path >>= either throwIO assertConsistency
9996
100−assertConsistency :: Monad m => Configuration -> m Configuration
97+assertConsistency :: MonadFail m => Configuration -> m Configuration
10198assertConsistency cfg@Configuration {..} = do
10299 let report msg = fail ("*** configuration error: " ++ msg)
103−
104100 maintainedPackages = Set.unions (Map.elems packageMaintainers)
105− disabledPackages = Map.keysSet dontDistributePackages
101+ disabledPackages = dontDistributePackages `Set.union` Set.fromList (depPkgName <$> brokenPackages)
106102 disabledMaintainedPackages = maintainedPackages `Set.intersection` disabledPackages
107103 unless (Set.null disabledMaintainedPackages) $
108104 report ("disabled packages that have a maintainer: " ++ show disabledMaintainedPackages)
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+18−17
@@ -4,6 +4,7 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Flags ( configureCabalFlags ) wher
44
55import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
66
7+import Data.Char
78import Distribution.Package
89import Distribution.PackageDescription
910import Distribution.Version
@@ -15,30 +16,25 @@ configureCabalFlags' :: PackageIdentifier -> [(FlagName,Bool)]
1516configureCabalFlags' (PackageIdentifier name version)
1617 | name == "accelerate-examples"= [disable "opencl"]
1718 | name == "arithmoi" = [disable "llvm"]
19+ | name == "bustle" = [disable "hgettext"] -- https://gitlab.freedesktop.org/bustle/bustle/issues/13
1820 | name == "cabal-plan" = [enable "exe"]
1921 | name == "cassava" = [disable "bytestring--lt-0_10_4"]
2022 | name == "darcs" = [enable "library", enable "force-char8-encoding"]
2123 | name == "diagrams-builder" = [enable "cairo", enable "svg", enable "ps", enable "rasterific"]
24+ | name == "fltkhs" = [enable "opengl"]
2225 | name == "folds" = [disable "test-hlint"]
2326 | name == "git-annex" = [ enable "assistant"
24− , enable "cryptonite"
27+ , disable "benchmark"
2528 , enable "dbus"
26− , enable "desktopnotify"
27− , enable "dns"
28− , enable "feed"
29− , enable "inotify"
29+ , disable "debuglocks"
30+ , enable "magicmime"
31+ , enable "networkbsd"
3032 , enable "pairing"
3133 , enable "production"
32− , enable "quvi"
33− , disable "s3"
34− , enable "tahoe"
35− , enable "tdfa"
36− , ("testsuite", version `withinRange` "< 6.20170925 || >= 6.20171214")
34+ , enable "s3"
3735 , enable "torrentparser"
38− , disable "webapp"
39− , disable "webapp-secure"
36+ , enable "webapp"
4037 , enable "webdav"
41− , enable "xmpp"
4238 ]
4339 | name == "haskeline" = [enable "terminfo"]
4440 | name == "haste-compiler" = [enable "portable"]
@@ -46,22 +42,27 @@ configureCabalFlags' (PackageIdentifier name version)
4642 | name == "hlibsass" && version >= mkVersion [0,1,5]
4743 = [enable "externalLibsass"]
4844 | name == "hmatrix" = [enable "openblas", enable "disable-default-paths"]
49− | name == "hslua" = [enable "system-lua"]
45+ | name == "hslua" = [enable "system-lua", disable "use-pkgconfig"]
5046 | name == "idris" = [enable "gmp", enable "ffi", enable "curses", ("execonly", version `withinRange` orLaterVersion (mkVersion [1,1,1])) ]
5147 | name == "io-streams" = [enable "NoInteractiveTests"]
5248 | name == "liquid-fixpoint" = [enable "build-external"]
5349 | name == "pandoc" = [enable "https", disable "trypandoc"]
50+ | name == "pandoc-placetable" = [enable "inlineMarkdown"]
5451 | name == "persistent-sqlite" = [enable "systemlib"]
5552 | name == "reactive-banana-wx" = [disable "buildExamples"]
5653 | name == "snap-server" = [enable "openssl"]
54+ | name == "stack" = [enable "disable-git-info", enable "hide-dependency-versions", enable "supported-build"]
5755 | name == "xmobar" = [enable "with_alsa", enable "with_conduit", enable "with_datezone", enable "with_dbus", enable "with_inotify", enable "with_iwlib", enable "with_mpd", enable "with_mpris", enable "with_rtsopts", enable "with_threaded", enable "with_utf8", enable "with_uvmeter", enable "with_weather", enable "with_xft", enable "with_xpm"]
5856 | name == "xmonad-extras" = [disable "with_hlist", enable "with_split", enable "with_parsec"]
59− | name == "yaml" = [enable "system-libyaml"]
57+ | name == "yaml" = [("system-libyaml", version >= "0.10.1.1")]
6058 | name == "yi" = [enable "pango", enable "vty"]
6159 | otherwise = []
6260
6361enable :: String -> (FlagName,Bool)
64−enable name = (mkFlagName name, True)
62+enable name = (mkFlagName' name, True)
6563
6664disable :: String -> (FlagName,Bool)
67−disable name = (mkFlagName name, False)
65+disable name = (mkFlagName' name, False)
66+
67+mkFlagName' :: String -> FlagName
68+mkFlagName' = mkFlagName . map toLower
src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs+133−3
@@ -1,11 +1,17 @@
11{-# LANGUAGE ViewPatterns #-}
22
3−module Distribution.Nixpkgs.Haskell.FromCabal.License ( fromCabalLicense ) where
3+module Distribution.Nixpkgs.Haskell.FromCabal.License
4+ ( fromCabalLicense
5+ , fromSPDXLicense
6+ , isFreeLicense
7+ ) where
48
5−import Distribution.Nixpkgs.License
9+import Data.List (intercalate)
610import Distribution.License ( License(..), knownLicenses )
11+import Distribution.Nixpkgs.License
12+import Distribution.Pretty (prettyShow)
13+import qualified Distribution.SPDX as SPDX
714import Distribution.Text (display)
8−import Data.List (intercalate)
915import Distribution.Version
1016
1117-- TODO: Programmatically strip trailing zeros from license version numbers.
@@ -36,5 +42,129 @@ fromCabalLicense (Apache (Just (versionNumbers -> [2,0]))) = Known "stdenv.lib.l
3642fromCabalLicense ISC = Known "stdenv.lib.licenses.isc"
3743fromCabalLicense OtherLicense = Unknown Nothing
3844fromCabalLicense (UnknownLicense "CC0-1.0") = Known "stdenv.lib.licenses.cc0"
45+fromCabalLicense (UnknownLicense "BSD3ClauseORApache20") = Known "stdenv.lib.licenses.bsd3"
3946fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"
4047 ++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)
48+
49+fromSPDXLicense :: SPDX.License -> Distribution.Nixpkgs.License.License
50+fromSPDXLicense SPDX.NONE = Unknown Nothing
51+fromSPDXLicense (SPDX.License expr) =
52+ case expr of
53+ SPDX.ELicense simpl Nothing ->
54+ -- Not handled: license exceptions
55+ case simpl of
56+ SPDX.ELicenseId lid ->
57+ case lid of
58+ SPDX.AFL_2_1 -> Known "stdenv.lib.licenses.afl21"
59+ SPDX.AFL_3_0 -> Known "stdenv.lib.licenses.afl3"
60+ SPDX.AGPL_3_0_only -> Known "stdenv.lib.licenses.agpl3"
61+ SPDX.AGPL_3_0_or_later -> Known "stdenv.lib.licenses.agpl3Plus"
62+ SPDX.APSL_2_0 -> Known "stdenv.lib.licenses.apsl20"
63+ SPDX.Artistic_1_0 -> Known "stdenv.lib.licenses.artistic1"
64+ SPDX.Artistic_2_0 -> Known "stdenv.lib.licenses.artistic2"
65+ SPDX.Apache_2_0 -> Known "stdenv.lib.licenses.asl20"
66+ SPDX.BSL_1_0 -> Known "stdenv.lib.licenses.boost"
67+ SPDX.Beerware -> Known "stdenv.lib.licenses.beerware"
68+ SPDX.NullBSD -> Known "stdenv.lib.licenses.bsd0"
69+ SPDX.BSD_2_Clause -> Known "stdenv.lib.licenses.bsd2"
70+ SPDX.BSD_3_Clause -> Known "stdenv.lib.licenses.bsd3"
71+ SPDX.BSD_4_Clause -> Known "stdenv.lib.licenses.bsdOriginal"
72+ SPDX.ClArtistic -> Known "stdenv.lib.licenses.clArtistic"
73+ SPDX.CC0_1_0 -> Known "stdenv.lib.licenses.cc0"
74+ SPDX.CC_BY_NC_SA_2_0 -> Known "stdenv.lib.licenses.cc-by-nc-sa-20"
75+ SPDX.CC_BY_NC_SA_2_5 -> Known "stdenv.lib.licenses.cc-by-nc-sa-25"
76+ SPDX.CC_BY_NC_SA_3_0 -> Known "stdenv.lib.licenses.cc-by-nc-sa-30"
77+ SPDX.CC_BY_NC_SA_4_0 -> Known "stdenv.lib.licenses.cc-by-nc-sa-40"
78+ SPDX.CC_BY_NC_4_0 -> Known "stdenv.lib.licenses.cc-by-nc-40"
79+ SPDX.CC_BY_ND_3_0 -> Known "stdenv.lib.licenses.cc-by-nd-30"
80+ SPDX.CC_BY_SA_2_5 -> Known "stdenv.lib.licenses.cc-by-sa-25"
81+ SPDX.CC_BY_3_0 -> Known "stdenv.lib.licenses.cc-by-30"
82+ SPDX.CC_BY_SA_3_0 -> Known "stdenv.lib.licenses.cc-by-sa-30"
83+ SPDX.CC_BY_4_0 -> Known "stdenv.lib.licenses.cc-by-40"
84+ SPDX.CC_BY_SA_4_0 -> Known "stdenv.lib.licenses.cc-by-sa-40"
85+ SPDX.CDDL_1_0 -> Known "stdenv.lib.licenses.cddl"
86+ SPDX.CECILL_2_0 -> Known "stdenv.lib.licenses.cecill20"
87+ SPDX.CECILL_B -> Known "stdenv.lib.licenses.cecill-b"
88+ SPDX.CECILL_C -> Known "stdenv.lib.licenses.cecill-c"
89+ SPDX.CPAL_1_0 -> Known "stdenv.lib.licenses.cpal10"
90+ SPDX.CPL_1_0 -> Known "stdenv.lib.licenses.cpl10"
91+ SPDX.Curl -> Known "stdenv.lib.licenses.curl"
92+ SPDX.DOC -> Known "stdenv.lib.licenses.doc"
93+ SPDX.EFL_1_0 -> Known "stdenv.lib.licenses.efl10"
94+ SPDX.EFL_2_0 -> Known "stdenv.lib.licenses.efl20"
95+ SPDX.EPL_1_0 -> Known "stdenv.lib.licenses.epl10"
96+ SPDX.EPL_2_0 -> Known "stdenv.lib.licenses.epl20"
97+ SPDX.EUPL_1_1 -> Known "stdenv.lib.licenses.eupl11"
98+ SPDX.GFDL_1_2_only -> Known "stdenv.lib.licenses.fdl12"
99+ SPDX.GFDL_1_3_only -> Known "stdenv.lib.licenses.fdl13"
100+ SPDX.GPL_1_0_only -> Known "stdenv.lib.licenses.gpl1"
101+ SPDX.GPL_1_0_or_later -> Known "stdenv.lib.licenses.gpl1Plus"
102+ SPDX.GPL_2_0_only -> Known "stdenv.lib.licenses.gpl2"
103+ SPDX.GPL_2_0_or_later -> Known "stdenv.lib.licenses.gpl2Plus"
104+ SPDX.GPL_3_0_only -> Known "stdenv.lib.licenses.gpl3"
105+ SPDX.GPL_3_0_or_later -> Known "stdenv.lib.licenses.gpl3Plus"
106+ SPDX.HPND -> Known "stdenv.lib.licenses.hpnd"
107+ SPDX.IJG -> Known "stdenv.lib.licenses.ijg"
108+ SPDX.ImageMagick -> Known "stdenv.lib.licenses.imagemagick"
109+ SPDX.IPA -> Known "stdenv.lib.licenses.ipa"
110+ SPDX.IPL_1_0 -> Known "stdenv.lib.licenses.ipl10"
111+ SPDX.ISC -> Known "stdenv.lib.licenses.isc"
112+ SPDX.JasPer_2_0 -> Known "stdenv.lib.licenses.jasper"
113+ SPDX.LGPL_2_0_only -> Known "stdenv.lib.licenses.lgpl2"
114+ SPDX.LGPL_2_0_or_later -> Known "stdenv.lib.licenses.lgpl2Plus"
115+ SPDX.LGPL_2_1_only -> Known "stdenv.lib.licenses.lgpl21"
116+ SPDX.LGPL_2_1_or_later -> Known "stdenv.lib.licenses.lgpl21Plus"
117+ SPDX.LGPL_3_0_only -> Known "stdenv.lib.licenses.lgpl3"
118+ SPDX.LGPL_3_0_or_later -> Known "stdenv.lib.licenses.lgpl3Plus"
119+ SPDX.Libpng -> Known "stdenv.lib.licenses.libpng"
120+ SPDX.Libtiff -> Known "stdenv.lib.licenses.libtiff"
121+ SPDX.LPPL_1_2 -> Known "stdenv.lib.licenses.lppl12"
122+ SPDX.LPPL_1_3c -> Known "stdenv.lib.licenses.lppl13c"
123+ SPDX.LPL_1_02 -> Known "stdenv.lib.licenses.lpl-102"
124+ SPDX.MIT -> Known "stdenv.lib.licenses.mit"
125+ SPDX.MPL_1_0 -> Known "stdenv.lib.licenses.mpl10"
126+ SPDX.MPL_1_1 -> Known "stdenv.lib.licenses.mpl11"
127+ SPDX.MPL_2_0 -> Known "stdenv.lib.licenses.mpl20"
128+ SPDX.MS_PL -> Known "stdenv.lib.licenses.mspl"
129+ SPDX.NCSA -> Known "stdenv.lib.licenses.ncsa"
130+ SPDX.NPOSL_3_0 -> Known "stdenv.lib.licenses.nposl3"
131+ SPDX.OFL_1_1 -> Known "stdenv.lib.licenses.ofl"
132+ SPDX.OLDAP_2_8 -> Known "stdenv.lib.licenses.openldap"
133+ SPDX.OpenSSL -> Known "stdenv.lib.licenses.openssl"
134+ SPDX.OSL_2_1 -> Known "stdenv.lib.licenses.osl21"
135+ SPDX.OSL_3_0 -> Known "stdenv.lib.licenses.osl3"
136+ SPDX.PHP_3_01 -> Known "stdenv.lib.licenses.php201"
137+ SPDX.PostgreSQL -> Known "stdenv.lib.licenses.postgresql"
138+ SPDX.Python_2_0 -> Known "stdenv.lib.licenses.psfl"
139+ SPDX.QPL_1_0 -> Known "stdenv.lib.licenses.qpl"
140+ SPDX.Ruby -> Known "stdenv.lib.licenses.ruby"
141+ SPDX.Sendmail -> Known "stdenv.lib.licenses.sendmail"
142+ SPDX.SGI_B_2_0 -> Known "stdenv.lib.licenses.sgi-b-0"
143+ SPDX.Sleepycat -> Known "stdenv.lib.licenses.sleepycat"
144+ SPDX.TCL -> Known "stdenv.lib.licenses.tcltx"
145+ SPDX.Unlicense -> Known "stdenv.lib.licenses.unlicense"
146+ SPDX.Vim -> Known "stdenv.lib.licenses.vim"
147+ SPDX.VSL_1_0 -> Known "stdenv.lib.licenses.vsl10"
148+ SPDX.Watcom_1_0 -> Known "stdenv.lib.licenses.watcom"
149+ SPDX.W3C -> Known "stdenv.lib.licenses.w3c"
150+ SPDX.WTFPL -> Known "stdenv.lib.licenses.wtfpl"
151+ SPDX.Zlib -> Known "stdenv.lib.licenses.zlib"
152+ SPDX.ZPL_2_0 -> Known "stdenv.lib.licenses.zpl20"
153+ SPDX.ZPL_2_1 -> Known "stdenv.lib.licenses.zpl21"
154+ _ ->
155+ -- Licence is not in Nixpkgs.
156+ -- Use the SPDX expression as a free-form license string.
157+ Unknown (Just $ prettyShow expr)
158+ _ ->
159+ -- Not handed: the '+' suffix and user-defined licences references.
160+ -- Use the SPDX expression as a free-form license string.
161+ Unknown (Just $ prettyShow expr)
162+ _ ->
163+ -- Not handled: compound expressions, not expressible in Nixpkgs.
164+ -- Use the SPDX expression as a free-form license string.
165+ Unknown (Just $ prettyShow expr)
166+
167+isFreeLicense :: Distribution.Nixpkgs.License.License -> Bool
168+isFreeLicense (Known "stdenv.lib.licenses.unfree") = False
169+isFreeLicense (Unknown Nothing) = False
170+isFreeLicense _ = True
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+23−9
@@ -29,6 +29,7 @@ libNixName "appindicator-0.1" = return "libappindicator-gtk2"
2929libNixName "appindicator3-0.1" = return "libappindicator-gtk3"
3030libNixName "asound" = return "alsaLib"
3131libNixName "b2" = return "libb2"
32+libNixName "boost_context" = return "boost"
3233libNixName "bz2" = return "bzip2"
3334libNixName "c++" = [] -- What is that?
3435libNixName "cairo-gobject" = return "cairo"
@@ -38,7 +39,7 @@ libNixName "cairo-svg" = return "cairo"
3839libNixName "crypt" = [] -- provided by glibc
3940libNixName "crypto" = return "openssl"
4041libNixName "curses" = return "ncurses"
41−libNixName "dbusmenu-glib-0.4" = return "libdbusmenu-glib"
42+libNixName "dbusmenu-glib-0.4" = return "libdbusmenu"
4243libNixName "dbusmenu-gtk3-0.4" = ["libdbusmenu-gtk3", "gtk3"]
4344libNixName "dl" = [] -- provided by glibc
4445libNixName "fftw3" = return "fftw"
@@ -47,7 +48,7 @@ libNixName "gconf" = return "GConf"
4748libNixName "gconf-2.0" = return "GConf"
4849libNixName "gdk-2.0" = return "gtk2"
4950libNixName "gdk-3.0" = return "gtk3"
50−libNixName "gdk-pixbuf-2.0" = return "gdk_pixbuf"
51+libNixName "gdk-pixbuf-2.0" = return "gdk-pixbuf"
5152libNixName "gdk-x11-2.0" = return "gdk_x11"
5253libNixName "gdk-x11-3.0" = return "gtk3"
5354libNixName "gio-2.0" = return "glib"
@@ -55,11 +56,11 @@ libNixName "GL" = return "libGL"
5556libNixName "GLU" = ["libGLU","libGL"]
5657libNixName "glut" = ["freeglut","libGLU","libGL"]
5758libNixName "gnome-keyring" = return "gnome-keyring"
58−libNixName "gnome-keyring-1" = return "gnome-keyring"
59+libNixName "gnome-keyring-1" = return "libgnome-keyring"
5960libNixName "gnome-vfs-2.0" = return "gnome-vfs"
6061libNixName "gnome-vfs-module-2.0" = return "gnome-vfs_module"
6162libNixName "gobject-2.0" = return "glib"
62−libNixName "gobject-introspection-1.0" = return "gobjectIntrospection"
63+libNixName "gobject-introspection-1.0" = return "gobject-introspection"
6364libNixName "gstreamer-audio-0.10" = return "gst-plugins-base"
6465libNixName "gstreamer-audio-1.0" = return "gst-plugins-base"
6566libNixName "gstreamer-base-0.10" = return "gst-plugins-base"
@@ -84,8 +85,8 @@ libNixName "ImageMagick" = return "imagemagick"
8485libNixName "Imlib2" = return "imlib2"
8586libNixName "iw" = return "wirelesstools"
8687libNixName "jack" = return "libjack2"
87−libNixName "javascriptcoregtk-3.0" = return "webkitgtk24x-gtk3" -- These are the old APIs, of which 2.4 is the last provider, so map directly to that.
88−libNixName "javascriptcoregtk-4.0" = return "webkitgtk" -- This is the current API, so let it reference an alias for the latest version.
88+libNixName "javascriptcoregtk-3.0" = return "webkitgtk24x-gtk3" -- These are the old APIs, of which 2.4 is the last provider, so map directly to that.
89+libNixName "javascriptcoregtk-4.0" = return "webkitgtk"
8990libNixName "jpeg" = return "libjpeg"
9091libNixName "jvm" = return "jdk"
9192libNixName "lapack" = return "liblapack"
@@ -94,18 +95,26 @@ libNixName "ldap" = return "openldap"
9495libNixName "libavutil" = return "ffmpeg"
9596libNixName "libgsasl" = return "gsasl"
9697libNixName "libpcre" = return "pcre"
98+libNixName "libpcre2" = return "pcre2"
99+libNixName "libpcre2-8" = libNixName "libpcre2"
100+libNixName "libqrencode" = return "qrencode"
97101libNixName "libR" = return "R"
98102libNixName "libsoup-gnome-2.4" = return "libsoup"
99103libNixName "libsystemd" = return "systemd"
104+libNixName "libudev" = return "systemd"
100105libNixName "libxml-2.0" = return "libxml2"
101106libNixName "libzip" = return "libzip"
102107libNixName "libzmq" = return "zeromq"
103108libNixName "m" = [] -- in stdenv
104109libNixName "magic" = return "file"
105110libNixName "MagickWand" = return "imagemagick"
111+libNixName "mnl" = return "libmnl"
106112libNixName "mpi" = return "openmpi"
107113libNixName "ncursesw" = return "ncurses"
108114libNixName "netsnmp" = return "net_snmp"
115+libNixName "nix-expr" = return "nix"
116+libNixName "nix-main" = return "nix"
117+libNixName "nix-store" = return "nix"
109118libNixName "notify" = return "libnotify"
110119libNixName "odbc" = return "unixODBC"
111120libNixName "openblas" = return "openblasCompat"
@@ -126,10 +135,10 @@ libNixName "Qt5Gui" = return "qt5"
126135libNixName "Qt5Qml" = return "qt5"
127136libNixName "Qt5Quick" = return "qt5"
128137libNixName "Qt5Widgets" = return "qt5"
138+libNixName "quadprog" = return "QuadProgpp"
129139libNixName "rt" = [] -- in glibc
130140libNixName "rtlsdr" = return "rtl-sdr"
131141libNixName "ruby1.8" = return "ruby"
132−libNixName "sane-backends" = return "saneBackends"
133142libNixName "sass" = return "libsass"
134143libNixName "sctp" = return "lksctp-tools" -- This is linux-specific, we should create a common attribute if we ever add sctp support for other systems.
135144libNixName "sdl2" = return "SDL2"
@@ -144,16 +153,20 @@ libNixName "stdc++.dll" = [] -- What is that?
144153libNixName "systemd-journal" = return "systemd"
145154libNixName "tag_c" = return "taglib"
146155libNixName "taglib_c" = return "taglib"
156+libNixName "tensorflow" = return "libtensorflow"
147157libNixName "udev" = return "systemd";
148158libNixName "uuid" = return "libossp_uuid";
159+libNixName "vte-2.91" = return "vte_291"
149160libNixName "wayland-client" = return "wayland"
150161libNixName "wayland-cursor" = return "wayland"
151162libNixName "wayland-egl" = return "libGL"
152163libNixName "wayland-server" = return "wayland"
153−libNixName "webkit2gtk-4.0" = return "webkitgtk" -- This is the current API, so let it reference an alias for the latest version.
154−libNixName "webkit2gtk-web-extension-4.0" = return "webkitgtk-web-extension" -- This package doesn't actually exist in nixpkgs at present.
164+libNixName "webkit2gtk" = return "webkitgtk"
165+libNixName "webkit2gtk-4.0" = return "webkitgtk"
166+libNixName "webkit2gtk-web-extension-4.0" = return "webkitgtk"
155167libNixName "webkitgtk-3.0" = return "webkitgtk24x-gtk3" -- These are the old APIs, of which 2.4 is the last provider, so map directly to that
156168libNixName "X11" = return "libX11"
169+libNixName "x11" = return "xlibsWrapper"
157170libNixName "xau" = return "libXau"
158171libNixName "Xcursor" = return "libXcursor"
159172libNixName "xerces-c" = return "xercesc"
@@ -169,6 +182,7 @@ libNixName "Xrender" = return "libXrender"
169182libNixName "Xss" = return "libXScrnSaver"
170183libNixName "Xtst" = return "libXtst"
171184libNixName "Xxf86vm" = return "libXxf86vm"
185+libNixName "yaml" = return "libyaml"
172186libNixName "yaml-0.1" = return "libyaml"
173187libNixName "z" = return "zlib"
174188libNixName "zmq" = return "zeromq"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+137−35
@@ -1,14 +1,19 @@
11{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
23
34module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess, pkg ) where
45
56import Control.Lens
7+import Control.Monad.Trans.State
68import Data.List.Split
9+import Data.Map ( Map )
10+import qualified Data.Map as Map
11+import Data.Map.Lens
712import Data.Set ( Set )
813import qualified Data.Set as Set
9−import Data.Set.Lens
1014import Distribution.Nixpkgs.Haskell
1115import Distribution.Nixpkgs.Meta
16+import Distribution.Nixpkgs.License
1217import Distribution.Package
1318import Distribution.System
1419import Distribution.Text
@@ -16,7 +21,11 @@ import Distribution.Version
1621import Language.Nix
1722
1823postProcess :: Derivation -> Derivation
19−postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
24+postProcess deriv =
25+ foldr (.) id [ f | (Dependency n vr _, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
26+ . fixGtkBuilds
27+ . fixBuildDependsForTools
28+ $ deriv
2029
2130fixGtkBuilds :: Derivation -> Derivation
2231fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesWithHaskellName)
@@ -24,42 +33,79 @@ fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesW
2433 & dependencies . tool %~ Set.filter (not . collidesWithHaskellName)
2534 where
2635 collidesWithHaskellName :: Binding -> Bool
27− collidesWithHaskellName b = view localName b `Set.member` buildDeps
36+ collidesWithHaskellName b = case buildDeps Map.!? view localName b of
37+ Nothing -> False -- totally uncollided
38+ Just p -> p /= view reference b -- identical is not collision, and important to preserve for cross
2839
2940 myName :: Identifier
3041 myName = ident # unPackageName (packageName drv)
3142
32− buildDeps :: Set Identifier
33− buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)
43+ buildDeps :: Map Identifier Path
44+ buildDeps = Map.delete myName (toMapOf (dependencies . haskell . to Set.toList . traverse . binding . ifolded) drv)
45+
46+-- Per https://github.com/haskell/cabal/issues/5412 hvr considers
47+-- `build-depends` providing executables an accident, and fragile one at that,
48+-- unworthy of any compatibility hacks. But while he and the other Hackage
49+-- maintainers is dedicated to fixing executables and libraries on Hackage, test
50+-- suites and benchmarks are not a priority, as it is trivial to skip building
51+-- test-suites with cabal-install. Nix however wishes to build test suites much
52+-- more widely, so skipping those components is not an option.
53+--
54+-- Between that, and Stack not changing behavior as of
55+-- https://github.com/commercialhaskell/stack/pull/4132, it seems likely that
56+-- for a while packages scraped from Hackage will continue to improperly use
57+-- `build-depends: package-for-tool` instead of `build-tool-depends` (which does
58+-- also work for Stack). Until that changes, we provide do this to work around
59+-- those package's brokenness.
60+fixBuildDependsForTools :: Derivation -> Derivation
61+fixBuildDependsForTools = foldr (.) id
62+ [ fmap snd $ runState $ do
63+ needs <- use $ cloneLens c . haskell . contains p
64+ cloneLens c . tool . contains p ||= needs
65+ | (c :: ALens' Derivation BuildInfo) <- [ testDepends, benchmarkDepends ]
66+ , p <- self <$> [ "hspec-discover"
67+ , "tasty-discover"
68+ , "hsx2hs"
69+ , "markdown-unlit"
70+ ]
71+ ]
3472
3573hooks :: [(Dependency, Derivation -> Derivation)]
3674hooks =
3775 [ ("Agda < 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agdaPostInstall)
3876 , ("Agda >= 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agda25PostInstall)
3977 , ("alex < 3.1.5", set (testDepends . tool . contains (pkg "perl")) True)
40− , ("alex", set (executableDepends . tool . contains (bind "self.happy")) True)
41− , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
78+ , ("alex", set (executableDepends . tool . contains (self "happy")) True)
79+ , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
4280 , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
43− , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
44− , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
81+ , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
82+ , ("bustle", bustleOverrides)
4583 , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
46− , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [bind "self.mtl", bind "self.parsec"]))) -- https://github.com/haskell/cabal/issues/5391
84+ , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
4785 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17
4886 , ("cabal-install", set doCheck False . set phaseOverrides cabalInstallPostInstall)
87+ , ("cabal2nix > 2", cabal2nixOverrides)
4988 , ("darcs", set phaseOverrides darcsInstallPostInstall . set doCheck False)
5089 , ("dbus", set doCheck False) -- don't execute tests that try to access the network
5190 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
5291 , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
5392 , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
93+ , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . over (libraryDepends . pkgconfig) (Set.union (pkgs ["libGLU", "libGL"]))) -- TODO: fltk14 belongs into the *setup* dependencies.
5494 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
5595 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
96+ , ("gi-gdk", set runHaddock True )
97+ , ("gi-gio", set runHaddock True )
98+ , ("gi-glib", set runHaddock True )
5699 , ("gi-gst", giGstLibOverrides "gstreamer") -- https://github.com/haskell-gi/haskell-gi/issues/36
57100 , ("gi-gstaudio", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
58101 , ("gi-gstbase", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
59102 , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
103+ , ("gi-gtk", set runHaddock True )
60104 , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
61105 , ("gi-pango", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
106+ , ("gi-pango", set runHaddock True )
62107 , ("gi-pangocairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
108+ , ("gi-vte", set runHaddock True )
63109 , ("gi-webkit", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
64110 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
65111 , ("git", set doCheck False) -- https://github.com/vincenthz/hit/issues/33
@@ -70,6 +116,7 @@ hooks =
70116 , ("GlomeVec", set (libraryDepends . pkgconfig . contains (bind "self.llvmPackages.llvm")) True)
71117 , ("graphviz", set (testDepends . system . contains (pkg "graphviz")) True)
72118 , ("gtk3", gtk3Hook)
119+ , ("gtkglext", gtkglextHook)
73120 , ("haddock", haddockHook) -- https://github.com/haskell/haddock/issues/511
74121 , ("hakyll", set (testDepends . tool . contains (pkg "utillinux")) True) -- test suite depends on "rev"
75122 , ("haskell-src-exts", set doCheck False)
@@ -80,31 +127,34 @@ hooks =
80127 , ("holy-project", set doCheck False) -- attempts to access the network
81128 , ("hoogle", set testTarget "--test-option=--no-net")
82129 , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1
83− , ("hslua < 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1")))
84− , ("hslua >= 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_3")))
130+ , ("hslua < 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_1")))
131+ , ("hslua >= 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
85132 , ("hspec-core >= 2.4.4", hspecCoreOverrides)
86133 , ("http-client", set doCheck False) -- attempts to access the network
87134 , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network
88135 , ("http-client-tls >= 0.2.2", set doCheck False) -- attempts to access the network
89136 , ("http-conduit", set doCheck False) -- attempts to access the network
90137 , ("imagemagick", set (libraryDepends . pkgconfig . contains (pkg "imagemagick")) True) -- https://github.com/NixOS/cabal2nix/issues/136
91− , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (bind "self.random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1
138+ , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (self "random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1
92139 , ("js-jquery", set doCheck False) -- attempts to access the network
93140 , ("libconfig", over (libraryDepends . system) (replace "config = null" (pkg "libconfig")))
94141 , ("libxml", set (configureFlags . contains "--extra-include-dir=${libxml2.dev}/include/libxml2") True)
95142 , ("liquid-fixpoint", set (executableDepends . system . contains (pkg "ocaml")) True . set (testDepends . system . contains (pkg "z3")) True . set (testDepends . system . contains (pkg "nettools")) True . set (testDepends . system . contains (pkg "git")) True . set doCheck False)
96143 , ("liquidhaskell", set (testDepends . system . contains (pkg "z3")) True)
97− , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (bind "self.only-buildable-on-windows")) False)
98− , ("MFlow < 4.6", set (libraryDepends . tool . contains (bind "self.cpphs")) True)
144+ , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (self "only-buildable-on-windows")) False)
145+ , ("MFlow < 4.6", set (libraryDepends . tool . contains (self "cpphs")) True)
99146 , ("mwc-random", set doCheck False)
100147 , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True)
101148 , ("network-attoparsec", set doCheck False) -- test suite requires network access
102149 , ("numeric-qq", set doCheck False) -- test suite doesn't finish even after 1+ days
103150 , ("opencv", opencvOverrides)
104− , ("pandoc >= 1.16.0.2", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332
105− , ("pandoc", set jailbreak False) -- jailbreak-cabal break the build
106− , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/172
151+ , ("pandoc >= 1.16.0.2 && < 2.5", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332
152+ , ("pandoc < 2.6", pandocPre26Overrides)
153+ , ("pandoc >= 2.6", pandocOverrides)
154+ , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/369
107155 , ("purescript", set doCheck False) -- test suite doesn't cope with Nix build env
156+ , ("proto-lens-protobuf-types", set (libraryDepends . tool . contains (pkg "protobuf")) True)
157+ , ("proto-lens-protoc", set (libraryDepends . tool . contains (pkg "protobuf")) True)
108158 , ("qtah-cpp-qt5", set (libraryDepends . system . contains (bind "pkgs.qt5.qtbase")) True)
109159 , ("qtah-qt5", set (libraryDepends . tool . contains (bind "pkgs.qt5.qtbase")) True)
110160 , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
@@ -118,10 +168,11 @@ hooks =
118168 , ("target", set (testDepends . system . contains (pkg "z3")) True)
119169 , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True)
120170 , ("text", set doCheck False) -- break infinite recursion
121− , ("thyme", set (libraryDepends . tool . contains (bind "self.cpphs")) True) -- required on Darwin
171+ , ("tensorflow-proto", set (libraryDepends . tool . contains (pkg "protobuf")) True)
172+ , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin
122173 , ("twilio", set doCheck False) -- attempts to access the network
123174 , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")
124− , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
175+ , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
125176 , ("webkitgtk3", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
126177 , ("webkitgtk3-javascriptcore", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
127178 , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104
@@ -130,14 +181,18 @@ hooks =
130181 , ("wxc", wxcHook)
131182 , ("wxcore", set (libraryDepends . pkgconfig . contains (pkg "wxGTK")) True)
132183 , ("X11", over (libraryDepends . system) (Set.union (Set.fromList $ map bind ["pkgs.xorg.libXinerama","pkgs.xorg.libXext","pkgs.xorg.libXrender","pkgs.xorg.libXScrnSaver"])))
133− , ("xmonad", set phaseOverrides xmonadPostInstall)
134− , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (bind "self.zip") (pkg "zip")))
184+ , ("xmonad >= 0.14.2", set phaseOverrides xmonadPostInstall)
185+ , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (self "zip") (pkg "zip")))
135186 , ("zip-archive >= 0.3.1 && < 0.3.2.3", over (testDepends . tool) (Set.union (Set.fromList [pkg "zip", pkg "unzip"]))) -- https://github.com/jgm/zip-archive/issues/35
187+ , ("zip-archive >= 0.4", set (testDepends . tool . contains (pkg "which")) True)
136188 ]
137189
138190pkg :: Identifier -> Binding
139191pkg i = binding # (i, path # ["pkgs",i])
140192
193+self :: Identifier -> Binding
194+self i = binding # (i, path # ["self",i])
195+
141196pkgs :: [Identifier] -> Set Binding
142197pkgs = Set.fromList . map pkg
143198
@@ -147,10 +202,18 @@ bind s = binding # (i, path # is)
147202 is = map (review ident) (splitOn "." s)
148203 i = last is
149204
205+-- | @replace old new bset@ replaces the Nix binding @old@ with @new@ in the
206+-- set of bindings @bset@. If @old@ is not found in @bset@, then the function
207+-- fails with an 'error'.
150208replace :: Binding -> Binding -> Set Binding -> Set Binding
151−replace old new bs = if old `Set.member` bs then Set.insert new (Set.delete old bs) else bs
209+replace old new bs
210+ | old `Set.member` bs = Set.insert new (Set.delete old bs)
211+ | otherwise = error (unwords [ "post-process: cannot replace name binding"
212+ , show old, "by", show new
213+ , "because it's not found in set"
214+ , show bs
215+ ])
152216
153−-- TODO: I need to figure out how to conveniently replace a binding in a set.
154217gtk3Hook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145
155218gtk3Hook = set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True
156219 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "gtk3"))
@@ -167,13 +230,12 @@ gitAnnexHook = set phaseOverrides gitAnnexOverrides
167230 where
168231 gitAnnexOverrides = unlines
169232 [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"
170− , "installPhase = \"make PREFIX=$out BUILDER=: install\";"
171− , "checkPhase = ''"
233+ , "postBuild = ''"
172234 , " ln -sf dist/build/git-annex/git-annex git-annex"
173235 , " ln -sf git-annex git-annex-shell"
174− , " export PATH+=\":$PWD\""
175− , " git-annex test"
176236 , "'';"
237+ , "installPhase = \"make PREFIX=$out BUILDER=: install install-completions\";"
238+ , "checkPhase = ''PATH+=\":$PWD\" git-annex test'';"
177239 , "enableSharedExecutables = false;"
178240 ]
179241 buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
@@ -194,7 +256,7 @@ gfPhaseOverrides = unlines
194256 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
195257 -- Parallel compilation fails. Disable it.
196258 , "'';"
197− , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build:$LD_LIBRARY_PATH'';"
259+ , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH'';"
198260 -- The build step itself, after having built the library, needs to be able
199261 -- to find the library it just built in order to compile grammar files.
200262 ]
@@ -230,10 +292,8 @@ darcsInstallPostInstall = unlines
230292xmonadPostInstall :: String
231293xmonadPostInstall = unlines
232294 [ "postInstall = ''"
233− , " shopt -s globstar"
234− , " mkdir -p $doc/share/man/man1"
235− , " mv \"$data/\"**\"/man/\"*[0-9] $doc/share/man/man1/"
236− , " rm \"$data/\"**\"/man/\"*"
295+ , " install -D man/xmonad.1 ''${!outputDoc}/share/man/man1/xmonad.1"
296+ , " install -D man/xmonad.hs ''${!outputDoc}/share/doc/$name/sample-xmonad.hs"
237297 , "'';"
238298 ]
239299
@@ -300,8 +360,50 @@ webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x
300360opencvOverrides :: Derivation -> Derivation
301361opencvOverrides = set phaseOverrides "hardeningDisable = [ \"bindnow\" ];"
302362 . over (libraryDepends . pkgconfig) (replace (pkg "opencv") (pkg "opencv3"))
303− . set (configureFlags . contains "--with-gcc=${stdenv.cc}/bin/c++") True
304− . set (configureFlags . contains "--with-ld=${stdenv.cc}/bin/c++") True
305363
306364hspecCoreOverrides :: Derivation -> Derivation -- https://github.com/hspec/hspec/issues/330
307365hspecCoreOverrides = set phaseOverrides "testTarget = \"--test-option=--skip --test-option='Test.Hspec.Core.Runner.hspecResult runs specs in parallel'\";"
366+
367+cabal2nixOverrides :: Derivation -> Derivation
368+cabal2nixOverrides = set phaseOverrides $ unlines
369+ [ "preCheck = ''"
370+ , " export PATH=\"$PWD/dist/build/cabal2nix:$PATH\""
371+ , " export HOME=\"$TMPDIR/home\""
372+ , "'';"
373+ ]
374+
375+gtkglextHook :: Derivation -> Derivation
376+gtkglextHook = over (libraryDepends . system) (Set.union (Set.fromList deps))
377+ where
378+ deps :: [Binding]
379+ deps = bind <$> [ "pkgs.gtk2"
380+ , "pkgs.libGLU"
381+ , "pkgs.xorg.libSM"
382+ , "pkgs.xorg.libICE"
383+ , "pkgs.xorg.libXt"
384+ , "pkgs.xorg.libXmu"
385+ ]
386+
387+pandocPre26Overrides :: Derivation -> Derivation
388+pandocPre26Overrides = set phaseOverrides postInstall
389+ where
390+ postInstall = unlines [ "postInstall = ''"
391+ , " mkdir -p $out/share"
392+ , " mv $data/*/*/man $out/share/"
393+ , "'';"
394+ ]
395+
396+pandocOverrides :: Derivation -> Derivation
397+pandocOverrides = set phaseOverrides postInstall
398+ where
399+ postInstall = unlines [ "postInstall = ''"
400+ , " mkdir -p $out/share/man/man1"
401+ , " mv \"man/\"*.1 $out/share/man/man1/"
402+ , "'';"
403+ ]
404+
405+bustleOverrides :: Derivation -> Derivation
406+bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True
407+ . set (executableDepends . pkgconfig . contains "gio-unix = null") False
408+ . set (metaSection . license) (Known "stdenv.lib.licenses.lgpl21Plus")
409+ . set (metaSection . hydraPlatforms) allKnownPlatforms
src/Distribution/Nixpkgs/Haskell/Hackage.hs+1−1
@@ -1,6 +1,6 @@
11module Distribution.Nixpkgs.Haskell.Hackage
22 ( HackageDB, PackageData, VersionData(..)
3− , hackageTarball, readTarball
3+ , hackageTarball, readTarball, parsePackageData
44 )
55 where
66
src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+28−3
@@ -9,9 +9,12 @@ import qualified Data.Text as T
99import Data.Yaml
1010import Distribution.Compiler
1111import Distribution.Package
12+import Distribution.Parsec
1213import Distribution.System
13−import Distribution.Text
14+import Distribution.Pretty as Cabal
15+import qualified Data.Version as Base
1416import Distribution.Version
17+import Language.Nix.PrettyPrinting as Nix
1518
1619instance NFData CompilerInfo
1720instance NFData AbiTag
@@ -49,6 +52,10 @@ instance FromJSON PackageIdentifier where
4952 parseJSON (String s) = return (fromString (T.unpack s))
5053 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell package identifier")
5154
55+instance FromJSON VersionRange where
56+ parseJSON (String s) = return (fromString (T.unpack s))
57+ parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Cabal VersionRange")
58+
5259instance FromJSON Dependency where
5360 parseJSON (String s) = return (fromString (T.unpack s))
5461 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell Dependency")
@@ -57,7 +64,25 @@ instance FromJSON CompilerInfo where
5764 parseJSON (String s) = return (unknownCompilerInfo (fromString (T.unpack s)) NoAbiTag)
5865 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell compiler")
5966
67+instance Nix.Pretty Version where
68+ pPrint = pretty
69+
70+instance Nix.Pretty PackageName where
71+ pPrint = pretty
72+
73+instance Nix.Pretty PackageIdentifier where
74+ pPrint = pretty
75+
76+instance Nix.Pretty CompilerId where
77+ pPrint = pretty
78+
79+instance Nix.Pretty Platform where
80+ pPrint = pretty
81+
82+instance Nix.Pretty Base.Version where
83+ pPrint = text . Base.showVersion
84+
6085-- parsing tools
6186
62−text2isString :: Text a => String -> String -> a
63−text2isString t s = fromMaybe (error ("fromString: " ++ show s ++ " is not a valid " ++ t)) (simpleParse s)
87+text2isString :: Parsec a => String -> String -> a
88+text2isString t s = fromMaybe (error ("fromString: " ++ show s ++ " is not a valid " ++ t)) (simpleParsec s)
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+62−36
@@ -1,5 +1,5 @@
11module Distribution.Nixpkgs.Haskell.PackageSourceSpec
2− ( Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
2+ ( HpackUse(..), Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
33 ) where
44
55import qualified Control.Exception as Exception
@@ -11,16 +11,18 @@ import qualified Data.ByteString.Char8 as BS
1111import Data.List ( isSuffixOf, isPrefixOf )
1212import qualified Data.Map as DB
1313import Data.Maybe
14+import qualified Data.Text as T
15+import qualified Data.Text.Encoding as T
1416import Data.Time
1517import Distribution.Nixpkgs.Fetch
1618import Distribution.Nixpkgs.Hashes
1719import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
20+import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
1821import qualified Distribution.Package as Cabal
1922import Distribution.PackageDescription
2023import qualified Distribution.PackageDescription as Cabal
2124import Distribution.PackageDescription.Parsec as Cabal
22−import Distribution.Parsec.Common (showPError)
23−import Distribution.Text ( simpleParse, display )
25+import Distribution.Parsec
2426import Distribution.Version
2527import qualified Hpack.Config as Hpack
2628import qualified Hpack.Render as Hpack
@@ -29,8 +31,12 @@ import System.Directory ( doesDirectoryExist, doesFileExist, createDirectoryIfMi
2931import System.Exit ( exitFailure )
3032import System.FilePath ( (</>), (<.>) )
3133import System.IO
32−import qualified Data.Text as T
33−import qualified Data.Text.Encoding as T
34+import Text.PrettyPrint.HughesPJClass hiding ( first )
35+
36+data HpackUse
37+ = ForceHpack
38+ | PackageYamlHpack
39+ | NoHpack
3440
3541data Package = Package
3642 { pkgSource :: DerivationSource
@@ -39,37 +45,43 @@ data Package = Package
3945 }
4046 deriving (Show)
4147
42−getPackage :: Bool
43− -- ^ Whether hpack should regenerate the cabal file.
48+getPackage :: HpackUse
49+ -- ^ the way hpack should be used.
50+ -> Bool
51+ -- ^ Whether to fetch submodules if fetching from git
4452 -> Maybe FilePath
4553 -- ^ The path to the Hackage database.
4654 -> Maybe UTCTime
4755 -- ^ If we have hackage-snapshot time.
4856 -> Source
4957 -> IO Package
50−getPackage optHpack optHackageDB optHackageSnapshot =
51− getPackage' optHpack (loadHackageDB optHackageDB optHackageSnapshot)
58+getPackage optHpack optSubmodules optHackageDB optHackageSnapshot =
59+ getPackage' optHpack optSubmodules (loadHackageDB optHackageDB optHackageSnapshot)
5260
53−getPackage' :: Bool
54− -- ^ Whether hpack should regenerate the cabal file.
61+getPackage' :: HpackUse
62+ -- ^ the way hpack should be used.
63+ -> Bool
64+ -- ^ Whether to fetch submodules if fetching from git
5565 -> IO DB.HackageDB
5666 -> Source
5767 -> IO Package
58−getPackage' optHpack hackageDB source = do
59− (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack hackageDB source
68+getPackage' optHpack optSubmodules hackageDB source = do
69+ (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack optSubmodules hackageDB source
6070 (\s -> Package s ranHpack pkgDesc) <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource
6171
62−fetchOrFromDB :: Bool
63− -- ^ Whether hpack should regenerate the cabal file
72+fetchOrFromDB :: HpackUse
73+ -- ^ the way hpack should be used
74+ -> Bool
75+ -- ^ Whether to fetch submodules if fetching from git
6476 -> IO DB.HackageDB
6577 -> Source
6678 -> IO (Maybe DerivationSource, Bool, Cabal.GenericPackageDescription)
67−fetchOrFromDB optHpack hackageDB src
79+fetchOrFromDB optHpack optSubmodules hackageDB src
6880 | "cabal://" `isPrefixOf` sourceUrl src = do
6981 (msrc, pkgDesc) <- fromDB hackageDB . drop (length "cabal://") $ sourceUrl src
7082 return (msrc, False, pkgDesc)
7183 | otherwise = do
72− r <- fetch (\dir -> cabalFromPath optHpack (dir </> sourceCabalDir src)) src
84+ r <- fetch optSubmodules (\dir -> cabalFromPath optHpack (dir </> sourceCabalDir src)) src
7385 case r of
7486 Nothing -> fail $ "Failed to fetch source. Does this source exist? " ++ show src
7587 Just (derivSource, (externalSource, ranHpack, pkgDesc)) ->
@@ -92,16 +104,16 @@ fromDB hackageDBIO pkg = do
92104 vd <- maybe unknownPackageError return (DB.lookup name hackageDB >>= lookupVersion)
93105 let ds = case DB.tarballSha256 vd of
94106 Nothing -> Nothing
95− Just hash -> Just (DerivationSource "url" url "" hash)
107+ Just hash -> Just (urlDerivationSource url hash)
96108 return (ds, setCabalFileHash (DB.cabalFileSha256 vd) (DB.cabalFile vd))
97109 where
98110 pkgId :: Cabal.PackageIdentifier
99− pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)
111+ pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParsec pkg)
100112 name = Cabal.packageName pkgId
101113
102− unknownPackageError = fail $ "No such package " ++ display pkgId ++ " in the cabal database. Did you run cabal update?"
114+ unknownPackageError = fail $ "No such package " ++ prettyShow pkgId ++ " in the cabal database. Did you run cabal update?"
103115
104− url = "mirror://hackage/" ++ display pkgId ++ ".tar.gz"
116+ url = "mirror://hackage/" ++ prettyShow pkgId ++ ".tar.gz"
105117
106118 version :: Version
107119 version = Cabal.packageVersion pkgId
@@ -138,20 +150,20 @@ sourceFromHackage optHash pkgId cabalDir = do
138150 -- Use the cached hash (either from cache file or given on cmdline via sha256 opt)
139151 -- if available, otherwise download from hackage to compute hash.
140152 case cachedHash of
141− Guess hash -> return $ DerivationSource "url" url "" hash
153+ Guess hash -> return $ urlDerivationSource url hash
142154 Certain hash ->
143155 -- We need to force the hash here. If we didn't do this, then when reading the
144156 -- hash from the cache file, the cache file will still be open for reading
145157 -- (because lazy io) when writeFile opens the file again for writing. By forcing
146158 -- the hash here, we ensure that the file is closed before opening it again.
147159 seq (length hash) $
148− DerivationSource "url" url "" hash <$ writeFile cacheFile hash
160+ urlDerivationSource url hash <$ writeFile cacheFile hash
149161 UnknownHash -> do
150162 maybeHash <- runMaybeT (derivHash . fst <$> fetchWith (False, "url", []) (Source url "" UnknownHash cabalDir))
151163 case maybeHash of
152164 Just hash ->
153165 seq (length hash) $
154− DerivationSource "url" url "" hash <$ writeFile cacheFile hash
166+ urlDerivationSource url hash <$ writeFile cacheFile hash
155167 Nothing -> do
156168 hPutStr stderr $ unlines
157169 [ "*** cannot compute hash. (Not a hackage project?)"
@@ -164,12 +176,12 @@ sourceFromHackage optHash pkgId cabalDir = do
164176 exitFailure
165177
166178showPackageIdentifier :: Cabal.GenericPackageDescription -> String
167−showPackageIdentifier pkgDesc = name ++ "-" ++ display version where
179+showPackageIdentifier pkgDesc = name ++ "-" ++ prettyShow version where
168180 pkgId = Cabal.package . Cabal.packageDescription $ pkgDesc
169181 name = Cabal.unPackageName (Cabal.packageName pkgId)
170182 version = Cabal.packageVersion pkgId
171183
172−cabalFromPath :: Bool -- ^ Whether hpack should regenerate the cabal file
184+cabalFromPath :: HpackUse -- ^ the way hpack should be used
173185 -> FilePath -> MaybeT IO (Bool, Bool, Cabal.GenericPackageDescription)
174186cabalFromPath optHpack path = do
175187 d <- liftIO $ doesDirectoryExist path
@@ -179,17 +191,25 @@ cabalFromPath optHpack path = do
179191 return (d, ranHpack, pkg)
180192 else (,,) d False <$> cabalFromFile False path
181193
182−cabalFromDirectory :: Bool -- ^ Whether hpack should regenerate the cabal file
194+cabalFromDirectory :: HpackUse -- ^ the way hpack should be used
183195 -> FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
184−cabalFromDirectory True dir = hpackDirectory dir
185−cabalFromDirectory False dir = do
196+cabalFromDirectory ForceHpack dir = hpackDirectory dir
197+cabalFromDirectory NoHpack dir = onlyCabalFromDirectory dir "*** No .cabal file was found. Exiting."
198+cabalFromDirectory PackageYamlHpack dir = do
199+ useHpack <- liftIO $ doesFileExist (dir </> "package.yaml")
200+ if useHpack
201+ then do
202+ liftIO $ hPutStrLn stderr "*** found package.yaml. Using hpack..."
203+ hpackDirectory dir
204+ else onlyCabalFromDirectory dir "*** Found neither a .cabal file nor package.yaml. Exiting."
205+
206+onlyCabalFromDirectory :: FilePath -> String -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
207+onlyCabalFromDirectory dir errMsg = do
186208 cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
187209 case cabals of
188− [] -> do
189− liftIO $ hPutStrLn stderr "*** found zero cabal files. Trying hpack..."
190− hpackDirectory dir
210+ [] -> fail errMsg
191211 [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
192− _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
212+ _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
193213
194214handleIO :: (Exception.IOException -> IO a) -> IO a -> IO a
195215handleIO = Exception.handle
@@ -199,11 +219,17 @@ encodeUtf8 = T.encodeUtf8 . T.pack
199219
200220hpackDirectory :: FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
201221hpackDirectory dir = do
202− mPackage <- liftIO $ Hpack.readPackageConfig Hpack.defaultDecodeOptions {Hpack.decodeOptionsTarget = dir </> Hpack.packageConfig}
222+ mPackage <- liftIO $ Hpack.readPackageConfig Hpack.defaultDecodeOptions {
223+ Hpack.decodeOptionsProgramName = Hpack.ProgramName "cabal2nix"
224+ , Hpack.decodeOptionsTarget = dir </> Hpack.packageConfig
225+ }
203226 case mPackage of
204227 Left err -> liftIO $ hPutStrLn stderr ("*** hpack error: " ++ show err ++ ". Exiting.") >> exitFailure
205− Right (Hpack.DecodeResult pkg' _ _) -> do
206− let hpackOutput = encodeUtf8 $ Hpack.renderPackage [] pkg'
228+ Right r -> do
229+ let hpackOutput =
230+ let body = Hpack.renderPackage [] (Hpack.decodeResultPackage r)
231+ cabalVersion = Hpack.decodeResultCabalVersion r
232+ in encodeUtf8 $ cabalVersion ++ body
207233 hash = printSHA256 $ digest (digestByName "sha256") hpackOutput
208234 case runParseGenericPackageDescription "<hpack output>" hpackOutput of
209235 Left msg -> liftIO $ do
test/Main.hs+10−14
@@ -46,7 +46,7 @@ testLibrary cabalFile = do
4646 cabal2nix :: GenericPackageDescription -> Derivation
4747 cabal2nix gpd = fromGenericPackageDescription
4848 (const True)
49− (\i -> Just (binding # (i, path # [i])))
49+ (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
5050 (Platform X86_64 Linux)
5151 (unknownCompilerInfo (CompilerId GHC (mkVersion [8,2])) NoAbiTag)
5252 (configureCabalFlags (packageId gpd))
@@ -57,6 +57,7 @@ testLibrary cabalFile = do
5757 , derivUrl = "mirror://hackage/foo.tar.gz"
5858 , derivRevision = ""
5959 , derivHash = "deadbeef"
60+ , derivSubmodule = Nothing
6061 }
6162 & extraFunctionArgs %~ Set.union (Set.singleton "inherit stdenv")
6263 goldenVsFileDiff
@@ -78,7 +79,10 @@ testLibrary cabalFile = do
7879-- some temporary location that is empty.
7980--
8081-- * Run this test with different kinds of encodings.
81−
82+--
83+-- * Run tests with a different target OS, like Darwin. The packages "iconv",
84+-- "crypt-sha512", "gl" might be worthwhile for testing since their output
85+-- differs on Darwin.
8286
8387testExecutable :: FilePath -> FilePath -> TestTree
8488testExecutable exe cabalFile = do
@@ -89,20 +93,12 @@ testExecutable exe cabalFile = do
8993 (\ref new -> ["diff", "-u", ref, new])
9094 goldenFile
9195 nixFile
92− (callCommand (unwords ["env LANG=en_US.UTF-8", exe, "--sha256=deadbeef", "--compiler=ghc-8.2", "--", cabalFile, ">"++nixFile]))
96+ (callCommand (unwords ["env LANG=en_US.UTF-8", exe, "--sha256=deadbeef", "--system=x86_64-linux", "--compiler=ghc-8.2", "--", cabalFile, ">"++nixFile]))
9397
9498-------------------------------------------------------------------------------
9599-- * Helper functions
96100-------------------------------------------------------------------------------
97101
98−-- | Find all *files* in the given directory. This function does not recurse,
99−-- nor does it include the special entries @'.'@ or @'..'@ in the result.
100−
101−listDirectoryFiles :: FilePath -> IO [FilePath]
102−listDirectoryFiles dirPath = do
103− entries <- listDirectory dirPath
104− filterM doesFileExist (map (dirPath </>) entries)
105−
106102-- | Find all *files* in the given directory that end with the given suffix.
107103-- This function does not recurse, nor does it include the special entries
108104-- @'.'@ or @'..'@ in the result.
@@ -115,9 +111,9 @@ listDirectoryFiles dirPath = do
115111-- we prefer our own simpler code.
116112
117113listDirectoryFilesBySuffix :: String -> FilePath -> IO [FilePath]
118−listDirectoryFilesBySuffix suff =
119− fmap (filter ((suff ==) . takeExtension)) . listDirectoryFiles
120−
114+listDirectoryFilesBySuffix suff dirPath = do
115+ entries <- listDirectory dirPath
116+ filterM doesFileExist [ dirPath </> e | e <- entries, takeExtension e == suff ]
121117
122118-- | A variant of 'writeFile' that appends a newline to the end of the buffer
123119-- before writing.
test/golden-test-cases/ede.nix.golden+1
@@ -21,4 +21,5 @@ mkDerivation {
2121 homepage = "http://github.com/brendanhay/ede";
2222 description = "Templating language with similar syntax and features to Liquid or Jinja2";
2323 license = "unknown";
24+ hydraPlatforms = stdenv.lib.platforms.none;
2425}
test/golden-test-cases/gogol-adexchange-buyer.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Ad Exchange Buyer SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-admin-emailmigration.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Email Migration API v2 SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-affiliates.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Affiliate Network SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-apps-tasks.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Tasks SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-appstate.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google App State SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-blogger.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Blogger SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-datastore.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Cloud Datastore SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-dfareporting.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google DCM/DFA Reporting And Trafficking SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-firebase-rules.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Firebase Rules SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-gmail.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Gmail SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-kgsearch.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Knowledge Graph Search SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-maps-engine.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Maps Engine SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-plus.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google + SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-resourceviews.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Compute Engine Instance Groups SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-translate.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Translate SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-webmaster-tools.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google Search Console SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/gogol-youtube.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "https://github.com/brendanhay/gogol";
88 description = "Google YouTube Data SDK";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/hxt-expat.nix.golden+1
@@ -7,4 +7,5 @@ mkDerivation {
77 homepage = "http://www.fh-wedel.de/~si/HXmlToolbox/index.html";
88 description = "Expat parser for HXT";
99 license = "unknown";
10+ hydraPlatforms = stdenv.lib.platforms.none;
1011}
test/golden-test-cases/hxt-tagsoup.nix.golden+1
@@ -11,4 +11,5 @@ mkDerivation {
1111 homepage = "https://github.com/UweSchmidt/hxt";
1212 description = "TagSoup parser for HXT";
1313 license = "unknown";
14+ hydraPlatforms = stdenv.lib.platforms.none;
1415}
test/golden-test-cases/nvim-hs.nix.golden+1
@@ -32,6 +32,7 @@ mkDerivation {
3232 template-haskell text time time-locale-compat transformers
3333 transformers-base utf8-string
3434 ];
35+ testToolDepends = [ hspec-discover ];
3536 homepage = "https://github.com/neovimhaskell/nvim-hs";
3637 description = "Haskell plugin backend for neovim";
3738 license = stdenv.lib.licenses.asl20;
test/golden-test-cases/opencv.cabalnew file+263
@@ -0,0 +1,263 @@
1+name: opencv
2+version: 0.0.2.1
3+homepage: https://github.com/LumiGuide/haskell-opencv
4+bug-reports: https://github.com/LumiGuide/haskell-opencv/issues
5+license: BSD3
6+license-file: LICENSE
7+author: Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
8+maintainer: Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
9+build-type: Custom
10+cabal-version: >=1.23
11+category: AI, Graphics
12+synopsis: Haskell binding to OpenCV-3.x
13+description: <<https://raw.githubusercontent.com/LumiGuide/haskell-opencv/master/data/haskell-opencv-logo-200x82.png>>
14+ .
15+ This is a Haskell library providing a binding to OpenCV-3.x.
16+ It binds directly with the C++ API using the @inline-c@ Haskell library.
17+ .
18+ The library is far from complete but the framework is there to easily
19+ bind missing functionality.
20+ .
21+ Note that the OpenCV contrib modules are provided by
22+ <http://hackage.haskell.org/package/opencv-extra opencv-extra>.
23+ .
24+ Make sure to checkout the
25+ <https://github.com/LumiGuide/haskell-opencv/tree/master/opencv-examples opencv-examples>.
26+
27+extra-source-files:
28+ CHANGELOG.md
29+ data/*.png
30+ data/*.jpg
31+ data/*.mp4
32+ data/*.xml
33+
34+extra-doc-files:
35+ doc/generated/*.png
36+ doc/generated/examples/*.png
37+ doc/generated/examples/*.gif
38+ doc/color_conversions.png
39+
40+source-repository head
41+ type: git
42+ location: git://github.com/LumiGuide/haskell-opencv.git
43+ subdir: opencv
44+
45+flag internal-documentation
46+ description: Enables documentation generation for internal modules.
47+ default: False
48+ manual: True
49+
50+custom-setup
51+ setup-depends: base, Cabal >= 1.23
52+
53+library
54+ hs-source-dirs: src
55+ include-dirs: include
56+ install-includes:
57+ haskell_opencv_matx_typedefs.hpp
58+ hsc_macros.hpp
59+ namespace.hpp
60+ orb.hpp
61+ simple_blob_detector.hpp
62+ termcriteria.hpp
63+ video_motion_analysis.hpp
64+
65+ cc-options: -Wall -std=c++11
66+ ghc-options: -Wall -fwarn-incomplete-patterns -funbox-strict-fields
67+ if flag(internal-documentation)
68+ cpp-options: -DENABLE_INTERNAL_DOCUMENTATION
69+
70+ build-depends:
71+ aeson >= 0.9.0.1
72+ , base >= 4.8 && <5
73+ , base64-bytestring >= 1.0.0.1
74+ , bindings-DSL >= 1.0.23
75+ , bytestring >= 0.10.6
76+ , containers >= 0.5.6.2
77+ , data-default >= 0.7.1.1
78+ , deepseq >= 1.4.1.1
79+ , inline-c >= 0.6
80+ , inline-c-cpp >= 0.2.1
81+ , JuicyPixels >= 3.2.8.1
82+ , linear >= 1.20.4
83+ , primitive >= 0.6.1
84+ , repa >= 3.4.0.2
85+ , template-haskell >= 2.10
86+ , text >= 1.2.2.1
87+ , transformers >= 0.4.2
88+ , vector >= 0.11
89+
90+ exposed-modules:
91+ OpenCV
92+ OpenCV.Calib3d
93+ OpenCV.Core.ArrayOps
94+ OpenCV.Core.Types
95+ OpenCV.Core.Types.Mat
96+ OpenCV.Core.Types.Mat.HMat
97+ OpenCV.Core.Types.Mat.Repa
98+ OpenCV.Core.Types.Matx
99+ OpenCV.Core.Types.Point
100+ OpenCV.Core.Types.Rect
101+ OpenCV.Core.Types.Size
102+ OpenCV.Core.Types.Vec
103+ OpenCV.Exception
104+ OpenCV.Features2d
105+ OpenCV.HighGui
106+ OpenCV.ImgCodecs
107+ OpenCV.ImgProc.ColorMaps
108+ OpenCV.ImgProc.Drawing
109+ OpenCV.ImgProc.FeatureDetection
110+ OpenCV.ImgProc.GeometricImgTransform
111+ OpenCV.ImgProc.ImgFiltering
112+ OpenCV.ImgProc.MiscImgTransform
113+ OpenCV.ImgProc.MiscImgTransform.ColorCodes
114+ OpenCV.ImgProc.ObjectDetection
115+ OpenCV.ImgProc.StructuralAnalysis
116+ OpenCV.ImgProc.Types
117+ OpenCV.ImgProc.CascadeClassifier
118+ OpenCV.JSON
119+ OpenCV.Photo
120+ OpenCV.TypeLevel
121+ OpenCV.Unsafe
122+ OpenCV.Video
123+ OpenCV.Video.MotionAnalysis
124+ OpenCV.VideoIO.Types
125+ OpenCV.VideoIO.VideoCapture
126+ OpenCV.VideoIO.VideoWriter
127+
128+ OpenCV.Internal
129+ OpenCV.Internal.Mutable
130+ OpenCV.Internal.C.Inline
131+ OpenCV.Internal.C.PlacementNew
132+ OpenCV.Internal.C.PlacementNew.TH
133+ OpenCV.Internal.C.Types
134+ OpenCV.Internal.Calib3d.Constants
135+ OpenCV.Internal.Core.ArrayOps
136+ OpenCV.Internal.Core.Types
137+ OpenCV.Internal.Core.Types.Constants
138+ OpenCV.Internal.Core.Types.Mat
139+ OpenCV.Internal.Core.Types.Mat.Depth
140+ OpenCV.Internal.Core.Types.Mat.HMat
141+ OpenCV.Internal.Core.Types.Mat.Marshal
142+ OpenCV.Internal.Core.Types.Mat.ToFrom
143+ OpenCV.Internal.Core.Types.Matx
144+ OpenCV.Internal.Core.Types.Matx.TH
145+ OpenCV.Internal.Core.Types.Point
146+ OpenCV.Internal.Core.Types.Point.TH
147+ OpenCV.Internal.Core.Types.Rect
148+ OpenCV.Internal.Core.Types.Rect.TH
149+ OpenCV.Internal.Core.Types.Size
150+ OpenCV.Internal.Core.Types.Size.TH
151+ OpenCV.Internal.Core.Types.Vec
152+ OpenCV.Internal.Core.Types.Vec.TH
153+ OpenCV.Internal.Exception
154+ OpenCV.Internal.ImgCodecs
155+ OpenCV.Internal.ImgProc.MiscImgTransform
156+ OpenCV.Internal.ImgProc.MiscImgTransform.TypeLevel
157+ OpenCV.Internal.ImgProc.MiscImgTransform.ColorCodes
158+ OpenCV.Internal.ImgProc.Types
159+ OpenCV.Internal.Photo.Constants
160+ OpenCV.Internal.VideoIO.Constants
161+ OpenCV.Internal.VideoIO.Types
162+ OpenCV.Juicy
163+
164+ default-extensions:
165+ BangPatterns
166+ DataKinds
167+ FlexibleContexts
168+ FlexibleInstances
169+ LambdaCase
170+ OverloadedStrings
171+ PackageImports
172+ PolyKinds
173+ ScopedTypeVariables
174+ TupleSections
175+ TypeFamilies
176+ TypeOperators
177+
178+ default-language: Haskell2010
179+ pkgconfig-depends: opencv >= 3.0.0
180+ extra-libraries: stdc++
181+
182+test-suite doc-images-opencv
183+ type: exitcode-stdio-1.0
184+ hs-source-dirs: doc
185+ main-is: images.hs
186+ other-modules:
187+ ExampleExtractor
188+ Language.Haskell.Meta.Syntax.Translate
189+ default-language: Haskell2010
190+ ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
191+ build-depends:
192+ base >= 4.8 && < 5
193+ , bytestring >= 0.10.6
194+ , containers >= 0.5.6.2
195+ , data-default >= 0.7.1.1
196+ , directory >= 1.2.2
197+ , Glob >= 0.9
198+ , haskell-src-exts >= 1.18.2
199+ , JuicyPixels >= 3.2.8.1
200+ , linear >= 1.20.4
201+ , opencv
202+ , primitive >= 0.6.1
203+ , template-haskell >= 2.10
204+ , text >= 1.2.2.1
205+ , transformers >= 0.4.2
206+ , vector >= 0.11
207+
208+ default-extensions:
209+ BangPatterns
210+ DataKinds
211+ LambdaCase
212+ OverloadedStrings
213+ PackageImports
214+ PolyKinds
215+ ScopedTypeVariables
216+ TupleSections
217+ TypeFamilies
218+ TypeOperators
219+
220+test-suite test-opencv
221+ type: exitcode-stdio-1.0
222+ hs-source-dirs: test
223+ main-is: test.hs
224+ default-language: Haskell2010
225+ ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
226+ build-depends:
227+ base >= 4.8 && < 5
228+ , bytestring >= 0.10.6
229+ , lens >= 4.13
230+ , linear >= 1.20.4
231+ , opencv
232+ , QuickCheck >= 2.10.1
233+ , repa >= 3.4.0.2
234+ , tasty >= 0.11.0.2
235+ , tasty-hunit >= 0.9.2
236+ , tasty-quickcheck >= 0.8.4
237+ , transformers >= 0.4.2
238+ , vector >= 0.11
239+
240+ default-extensions:
241+ DataKinds
242+ FlexibleContexts
243+ PackageImports
244+ RankNTypes
245+ ScopedTypeVariables
246+ TypeOperators
247+
248+benchmark bench-opencv
249+ type: exitcode-stdio-1.0
250+ hs-source-dirs: bench
251+ main-is: bench.hs
252+ default-language: Haskell2010
253+ ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
254+ build-depends:
255+ base >= 4.8 && < 5
256+ , bytestring >= 0.10.6
257+ , criterion >= 1.1.1
258+ , opencv
259+ , repa >= 3.4.0.2
260+
261+ default-extensions:
262+ DataKinds
263+ PackageImports
test/golden-test-cases/opencv.nix.goldennew file+30
@@ -0,0 +1,30 @@
1+{ mkDerivation, aeson, base, base64-bytestring, bindings-DSL
2+, bytestring, Cabal, containers, criterion, data-default, deepseq
3+, directory, Glob, haskell-src-exts, inline-c, inline-c-cpp
4+, JuicyPixels, lens, linear, opencv3, primitive, QuickCheck, repa
5+, stdenv, tasty, tasty-hunit, tasty-quickcheck, template-haskell
6+, text, transformers, vector
7+}:
8+mkDerivation {
9+ pname = "opencv";
10+ version = "0.0.2.1";
11+ sha256 = "deadbeef";
12+ setupHaskellDepends = [ base Cabal ];
13+ libraryHaskellDepends = [
14+ aeson base base64-bytestring bindings-DSL bytestring containers
15+ data-default deepseq inline-c inline-c-cpp JuicyPixels linear
16+ primitive repa template-haskell text transformers vector
17+ ];
18+ libraryPkgconfigDepends = [ opencv3 ];
19+ testHaskellDepends = [
20+ base bytestring containers data-default directory Glob
21+ haskell-src-exts JuicyPixels lens linear primitive QuickCheck repa
22+ tasty tasty-hunit tasty-quickcheck template-haskell text
23+ transformers vector
24+ ];
25+ benchmarkHaskellDepends = [ base bytestring criterion repa ];
26+ hardeningDisable = [ "bindnow" ];
27+ homepage = "https://github.com/LumiGuide/haskell-opencv";
28+ description = "Haskell binding to OpenCV-3.x";
29+ license = stdenv.lib.licenses.bsd3;
30+}
test/golden-test-cases/openpgp-asciiarmor.nix.golden+1
@@ -15,4 +15,5 @@ mkDerivation {
1515 homepage = "http://floss.scru.org/openpgp-asciiarmor";
1616 description = "OpenPGP (RFC4880) ASCII Armor codec";
1717 license = "unknown";
18+ hydraPlatforms = stdenv.lib.platforms.none;
1819}
test/golden-test-cases/pinch.nix.golden+1
@@ -14,6 +14,7 @@ mkDerivation {
1414 base bytestring containers hspec hspec-discover QuickCheck text
1515 unordered-containers vector
1616 ];
17+ testToolDepends = [ hspec-discover ];
1718 homepage = "https://github.com/abhinav/pinch#readme";
1819 description = "An alternative implementation of Thrift for Haskell";
1920 license = stdenv.lib.licenses.bsd3;
test/golden-test-cases/swagger.nix.golden+1
@@ -11,4 +11,5 @@ mkDerivation {
1111 testHaskellDepends = [ aeson base bytestring tasty tasty-hunit ];
1212 description = "Implementation of swagger data model";
1313 license = "unknown";
14+ hydraPlatforms = stdenv.lib.platforms.none;
1415}
test/golden-test-cases/test-fixture.nix.golden+1
@@ -13,6 +13,7 @@ mkDerivation {
1313 testHaskellDepends = [
1414 base hspec hspec-discover mtl template-haskell transformers
1515 ];
16+ testToolDepends = [ hspec-discover ];
1617 homepage = "http://github.com/cjdev/test-fixture#readme";
1718 description = "Test monadic side-effects";
1819 license = stdenv.lib.licenses.bsd3;
update-stackage.sh+13−9
@@ -2,11 +2,14 @@
22
33set -eu -o pipefail
44
5−tmpfile=$(mktemp "stackage-update.XXXXXXX")
6−trap "rm $tmpfile" 0
5+cd "$(dirname "$0")"
76
8−curl -L -s "https://www.stackage.org/lts/cabal.config" >"$tmpfile"
9−version=$(sed -n "s/^--.*http:..www.stackage.org.snapshot.lts-//p" "$tmpfile")
7+tmpfile=$(mktemp "update-stackage.XXXXXXX")
8+# shellcheck disable=SC2064
9+trap "rm ${tmpfile} ${tmpfile}.new" 0
10+
11+curl -L -s "https://stackage.org/lts/cabal.config" >"$tmpfile"
12+version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.lts-//p" "$tmpfile")
1013
1114# Create a simple yaml version of the file.
1215sed -r \
@@ -16,12 +19,13 @@ sed -r \
1619 -e 's|,$||' \
1720 -e '/installed$/d' \
1821 -e '/^$/d' \
19− -i "$tmpfile"
22+ < "${tmpfile}" | sort --ignore-case >"${tmpfile}.new"
2023
2124# Drop restrictions on some tools where we always want the latest version.
2225sed -r \
2326 -e '/ cabal-install /d' \
2427 -e '/ cabal2nix /d' \
28+ -e '/ cabal2spec /d' \
2529 -e '/ distribution-nixpkgs /d' \
2630 -e '/ git-annex /d' \
2731 -e '/ hindent /d' \
@@ -31,16 +35,16 @@ sed -r \
3135 -e '/ hopenssl /d' \
3236 -e '/ jailbreak-cabal /d' \
3337 -e '/ json-autotype/d' \
34− -e '/ lambdabot-core /d' \
35− -e '/ lambdabot-irc-plugins /d' \
3638 -e '/ language-nix /d' \
39+ -e '/ shake /d' \
3740 -e '/ ShellCheck /d' \
3841 -e '/ stack /d' \
3942 -e '/ weeder /d' \
40− -i "$tmpfile"
43+ < "${tmpfile}.new" > "${tmpfile}"
4144
4245# Drop the previous configuration ...
43−sed -e '/# LTS Haskell/,/^$/c \TODO\
46+# shellcheck disable=SC1004
47+sed -e '/ # LTS Haskell/,/^$/c \TODO\
4448' -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml
4549
4650# ... and replace it with the new one.