git.iko.soy/typeable/cabal2nix
on af7cf68 help sign in
18 files changed+326−392
since splitsnapshots
unifiedsplit
.travis.yml+86−131 README.md+7−7 cabal2nix.cabal+82−29 hackage2nix/Main.hs+18−24 hackage2nix/README.md−3 src/Cabal2nix.hs+15−20 src/Distribution/Nixpkgs/Fetch.hs+1−3 src/Distribution/Nixpkgs/Haskell/Constraint.hs+1−1 src/Distribution/Nixpkgs/Haskell/Derivation.hs+3−3 src/Distribution/Nixpkgs/Haskell/FromCabal.hs+11−11 src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+32−28 src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+2−9 src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+7−15 src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+13−30 src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+3−28 src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+25−35 test/Main.hs+11−3 update-stackage.sh+9−12
.travis.yml+86−131
@@ -1,161 +1,116 @@
11# This Travis job script has been generated by a script via
22#
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'
3+# runghc make_travis_yml_2.hs '--doctest' '--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen' '--hlint' '-o' '.travis.yml' 'cabal2nix.cabal'
44#
55# For more information, see https://github.com/haskell-CI/haskell-ci
66#
7−# version: 0.9.20200306
8−#
9−version: ~> 1.0
107language: c
11−os: linux
12−dist: xenial
8+sudo: false
9+
1310git:
14− # whether to recursively clone submodules
15− submodules: false
11+ submodules: false # whether to recursively clone submodules
12+
1613cache:
1714 directories:
1815 - $HOME/.cabal/packages
1916 - $HOME/.cabal/store
20− - $HOME/.hlint
17+
2118before_cache:
22− - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
19+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
2320 # remove files that are regenerated by 'cabal update'
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:
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:
3130 include:
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
31+ - compiler: "ghc-8.6.3"
32+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
33+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.6.3], sources: [hvr-ghc]}}
34+ - compiler: "ghc-8.4.4"
35+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
36+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.4.4], sources: [hvr-ghc]}}
37+
4438before_install:
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"
39+ - HC=${CC}
40+ - HCPKG=${HC/ghc/ghc-pkg}
4941 - unset CC
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))')"
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/') ))
5546 - echo $HCNUMVER
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
47+
9048install:
91− - ${CABAL} --version
49+ - cabal --version
9250 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
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"
51+ - BENCH=${BENCH---enable-benchmarks}
52+ - TEST=${TEST---enable-tests}
53+ - HADDOCK=${HADDOCK-true}
54+ - UNCONSTRAINED=${UNCONSTRAINED-true}
55+ - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}
56+ - GHCHEAD=${GHCHEAD-false}
57+ - travis_retry cabal update -v
58+ - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
59+ - rm -fv cabal.project cabal.project.local
60+ - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
61+ - (cd /tmp && echo '' | cabal new-repl -w ${HC} --build-dep fail)
62+ - if [ $HCNUMVER -ge 80000 ]; then cabal new-install -w ${HC} -j2 --symlink-bindir=$HOME/.local/bin doctest --constraint='doctest ==0.16.*'; fi
63+ - if [ $HCNUMVER -eq 80603 ]; then cabal new-install -w ${HC} -j2 --symlink-bindir=$HOME/.local/bin hlint --constraint='hlint ==2.1.*'; fi
64+ - "printf 'packages: \".\"\\n' > cabal.project"
65+ - "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
66+ - touch cabal.project.local
67+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- cabal2nix | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
11168 - cat cabal.project || true
11269 - 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
119−script:
70+ - if [ -f "./configure.ac" ]; then
71+ (cd "." && autoreconf -i);
72+ fi
73+ - rm -f cabal.project.freeze
74+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
75+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
76+ - rm -rf .ghc.environment.* "."/dist
12077 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
121− # Packaging...
122− - ${CABAL} v2-sdist all
123− # Unpacking...
78+
79+# Here starts the actual work to be performed for the package under test;
80+# any command which exits with a non-zero exit code causes the build to fail.
81+script:
82+ # test that source-distributions can be generated
83+ - cabal new-sdist all
12484 - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
12585 - cd ${DISTDIR} || false
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"
86+ - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
87+ - "printf 'packages: cabal2nix-*/*.cabal\\n' > cabal.project"
88+ - "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
89+ - touch cabal.project.local
90+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- cabal2nix | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
13691 - cat cabal.project || true
13792 - cat cabal.project.local || true
138− # Building...
13993 # this builds all libraries and executables (without tests/benchmarks)
140− - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
141− # Building with tests and benchmarks...
94+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
95+
14296 # build & run tests, build benchmarks
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
97+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
98+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
99+
100+ # doctest
101+ - if [ $HCNUMVER -ge 80000 ]; then (cd cabal2nix-* && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen -XMonadFailDesugaring src); fi
102+
103+ # hlint
104+ - if [ $HCNUMVER -eq 80603 ]; then (cd cabal2nix-* && hlint -XMonadFailDesugaring src); fi
105+
106+ # cabal check
107+ - (cd cabal2nix-* && cabal check)
108+
109+ # haddock
110+ - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
111+
112+ # Build without installed constraints for packages in global-db
113+ - if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi
159114
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"])
115+# REGENDATA ["--doctest","--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen","--hlint","-o",".travis.yml","cabal2nix.cabal"]
161116# EOF
README.md+7−7
@@ -27,16 +27,16 @@ direct `http://host/path/pkg.cabal` URL can be provided, as well as a
2727`file:///local/path/pkg.cabal` URI that doesn't depend on network access.
2828However, if the source hash is not already in `cabal2nix`'s cache or provided
2929using the `--sha256` option, `cabal2nix` still needs to download the source
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.
30+code to compute the hash, which obviously still causes network traffic. Run the
31+utility with `--help` to see the complete list of supported command line flags.
3232
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.
33+Detailed instructions how to use those generated files with Nix can be found at
34+http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure.
3535
3636`cabal2nix` can also build derivations for projects from other sources than
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:
37+hackage. You only need to provide an URI that points to a cabal project. The
38+most common usecase for this is probably to generate a derivation for a project
39+on the local file system:
4040
4141 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
4242 $ cabal2nix .
cabal2nix.cabal+82−29
@@ -1,5 +1,5 @@
11name: cabal2nix
2−version: 2.15.1
2+version: 2.12
33synopsis: Convert Cabal files into Nix build instructions.
44description:
55 Convert Cabal files into Nix build instructions. Users of Nix can install the latest
@@ -8,26 +8,73 @@ description:
88 > nix-env -i cabal2nix
99license: BSD3
1010license-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, Александр Цамутали
11+author: Peter Simons,
12+ Andres Loeh,
13+ Benno Fünfstück,
14+ Mateusz Kowalczyk,
15+ Michael Alan Dorman,
16+ Tom Smalley,
17+ Mathijs Kwik,
18+ Shea Levy,
19+ Dmitry Malikov,
20+ Eric Seidel,
21+ Jacob Mitchell,
22+ Graham Christensen,
23+ Hamish Mackenzie,
24+ Nikolay Amiantov,
25+ Aycan iRiCAN,
26+ Bryan Gardiner,
27+ Joe Hermaszewski,
28+ John Wiegley,
29+ Philipp Hausmann,
30+ Spencer Janssen,
31+ Tom Hunger,
32+ William Casarin,
33+ koral,
34+ ksaric,
35+ Adam Vogt,
36+ Alexey Shmalko,
37+ Corey O'Connor,
38+ Cray Elliott,
39+ David Johnson,
40+ Dmitry Bushev,
41+ Domen Kožar,
42+ Felix Kunzmann,
43+ Gabriel Ebner,
44+ Gergely Risko,
45+ Joachim Fasting,
46+ John Albietz,
47+ John Chee,
48+ Jussi Maki,
49+ Lisanna Dettwyler,
50+ Mark Laws,
51+ Mark Wotton,
52+ Matthew Pickering,
53+ Matthew Stewart,
54+ Matvey Aksenov,
55+ Nicholas Clarke,
56+ Nicolas Rolland,
57+ Oliver Charles,
58+ Pascal Wittmann,
59+ Patrick John Wheeler,
60+ Phil de Joux,
61+ Piotr Bogdan,
62+ Profpatsch,
63+ Raymond Gauthier,
64+ Renzo Carbonara,
65+ Rodney Lorrimar,
66+ Sibi,
67+ Sukant Hajra,
68+ Tanner Doshier,
69+ Vaibhav Sagar,
70+ Viktar Basharymau,
71+ danbst,
72+ karsten gebbert,
73+ laMudri,
74+ Александр Цамутали
2875maintainer: Peter Simons <simons@cryp.to>
2976stability: stable
30−tested-with: GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1
77+tested-with: GHC == 8.4.4, GHC == 8.6.3
3178category: Distribution, Nix
3279homepage: https://github.com/nixos/cabal2nix#readme
3380bug-reports: https://github.com/nixos/cabal2nix/issues
@@ -60,15 +107,15 @@ library
60107 Distribution.Nixpkgs.Haskell.PackageSourceSpec
61108 other-modules: Paths_cabal2nix
62109 hs-source-dirs: src
63− build-depends: base > 4.11
64− , Cabal == 3.0.*
65− , aeson > 1
110+ build-depends: base < 5
111+ , Cabal > 2.2
112+ , aeson
66113 , ansi-wl-pprint
67114 , bytestring
68− , containers >= 0.5.9
115+ , containers
69116 , deepseq >= 1.4
70117 , directory
71− , distribution-nixpkgs >= 1.3.1
118+ , distribution-nixpkgs >= 1.1.1
72119 , filepath
73120 , hackage-db >= 2.0.1
74121 , hopenssl >= 2
@@ -84,6 +131,7 @@ library
84131 , transformers
85132 , yaml
86133 default-language: Haskell2010
134+ default-extensions: MonadFailDesugaring
87135 other-extensions: MultiParamTypeClasses
88136 ScopedTypeVariables
89137 FlexibleInstances
@@ -101,6 +149,7 @@ executable cabal2nix
101149 hs-source-dirs: cabal2nix
102150 build-depends: base, cabal2nix
103151 default-language: Haskell2010
152+ default-extensions: MonadFailDesugaring
104153 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
105154 -Wredundant-constraints
106155
@@ -110,13 +159,13 @@ executable hackage2nix
110159 Paths_cabal2nix
111160 hs-source-dirs: hackage2nix
112161 build-depends: base < 5
113− , Cabal
162+ , Cabal > 2.2
114163 , aeson
115164 , bytestring
116165 , cabal2nix
117166 , containers
118167 , directory
119− , distribution-nixpkgs >= 1.2
168+ , distribution-nixpkgs >= 1.1.1
120169 , filepath
121170 , hopenssl >= 2
122171 , language-nix
@@ -127,15 +176,16 @@ executable hackage2nix
127176 , optparse-applicative
128177 , pretty >= 1.1.2
129178 default-language: Haskell2010
179+ default-extensions: MonadFailDesugaring
130180 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
131− -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-maxN16
181+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
132182
133183test-suite regression-test
134184 type: exitcode-stdio-1.0
135185 main-is: Main.hs
136186 hs-source-dirs: test
137187 build-depends: base
138− , Cabal
188+ , Cabal > 2.2
139189 , cabal2nix
140190 , containers
141191 , directory
@@ -147,6 +197,9 @@ test-suite regression-test
147197 , tasty
148198 , tasty-golden
149199 default-language: Haskell2010
200+ default-extensions: MonadFailDesugaring
150201 build-tools: cabal2nix
151202 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
152− -Wredundant-constraints -threaded -with-rtsopts=-K64K
203+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
204+ -with-rtsopts=-K64K
205+ -- TODO: this must be 1K!
hackage2nix/Main.hs+18−24
@@ -1,5 +1,6 @@
11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE RecordWildCards #-}
3+{-# LANGUAGE CPP #-}
34
45module Main ( main ) where
56
@@ -10,10 +11,13 @@ import Control.Monad
1011import Control.Monad.Par.Combinator
1112import Control.Monad.Par.IO
1213import Control.Monad.Trans ( liftIO )
13−import Data.List ( intercalate )
14+import Data.List
1415import Data.Map.Strict ( Map )
1516import qualified Data.Map.Strict as Map
1617import Data.Maybe
18+#if !MIN_VERSION_base(4,11,0)
19+import Data.Monoid
20+#endif
1721import Data.Set ( Set )
1822import qualified Data.Set as Set
1923import Data.String
@@ -23,11 +27,10 @@ import Distribution.Nixpkgs.Haskell.Constraint
2327import Distribution.Nixpkgs.Haskell.FromCabal
2428import Distribution.Nixpkgs.Haskell.FromCabal.Configuration as Config
2529import Distribution.Nixpkgs.Haskell.FromCabal.Flags
26−import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2730import Distribution.Nixpkgs.Meta
2831import Distribution.Nixpkgs.PackageMap
2932import Distribution.Package
30−import Distribution.PackageDescription hiding ( options, extraLibs, buildTools, homepage )
33+import Distribution.PackageDescription hiding ( options, buildDepends, extraLibs, buildTools, homepage )
3134import Distribution.System
3235import Distribution.Text
3336import Distribution.Version
@@ -63,7 +66,7 @@ main = do
6366 pinfo :: ParserInfo CLI
6467 pinfo = info
6568 ( helper
66− <*> infoOption ("hackage2nix " ++ prettyShow Main.version) (long "version" <> help "Show version number")
69+ <*> infoOption ("hackage2nix " ++ display Main.version) (long "version" <> help "Show version number")
6770 <*> cliOptions
6871 )
6972 ( fullDesc
@@ -72,15 +75,13 @@ main = do
7275 CLI {..} <- execParser pinfo
7376
7477 config <- readConfiguration (nixpkgsRepository </> configFile)
75− nixpkgs <- readNixpkgPackageMap ["-f", nixpkgsRepository, "--arg", "config", "{ allowAliases = false; }"]
78+ nixpkgs <- readNixpkgPackageMap nixpkgsRepository Nothing
7679 preferredVersions <- readPreferredVersions (fromMaybe (hackageRepository </> "preferred-versions") preferredVersionsFile)
7780 let fixup = Map.delete "acme-everything" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
7881 . Map.delete "som" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
7982 . Map.delete "type" -- TODO: https://github.com/NixOS/cabal2nix/issues/163
8083 . Map.delete "control-invariants" -- TODO: depends on "assert"
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
84+ . over (at ("hermes")) ((fmap (set (contains "1.3.4.3") False))) -- TODO: https://github.com/haskell/hackage-server/issues/436
8485 hackage <- fixup <$> readHackage hackageRepository
8586 let
8687 hackagePackagesFile :: FilePath
@@ -93,7 +94,7 @@ main = do
9394 latestVersionSet = Map.map Set.findMax (Map.filter (not . Set.null) (Map.mapWithKey (enforcePreferredVersions preferredVersions) hackage))
9495
9596 defaultPackageOverridesSet :: PackageSet
96− defaultPackageOverridesSet = Map.fromList [ (name, resolveConstraint c hackage) | c@(Dependency name _ _) <- defaultPackageOverrides config ]
97+ defaultPackageOverridesSet = Map.fromList [ (name, resolveConstraint c hackage) | c@(Dependency name _) <- defaultPackageOverrides config ]
9798
9899 generatedDefaultPackageSet :: PackageSet
99100 generatedDefaultPackageSet = (defaultPackageOverridesSet `Map.union` latestVersionSet) `Map.difference` corePackageSet
@@ -106,7 +107,7 @@ main = do
106107
107108 extraPackageSet :: PackageMultiSet
108109 extraPackageSet = Map.unionsWith Set.union
109− [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _ _) <- extraPackages config ]
110+ [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _) <- extraPackages config ]
110111
111112 db :: PackageMultiSet
112113 db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
@@ -116,7 +117,7 @@ main = do
116117 ]
117118
118119 haskellResolver :: Dependency -> Bool
119− haskellResolver (Dependency name vrange _)
120+ haskellResolver (Dependency name vrange)
120121 | Just v <- Map.lookup name corePackageSet = v `withinRange` vrange
121122 | Just v <- Map.lookup name generatedDefaultPackageSet = v `withinRange` vrange
122123 | otherwise = False
@@ -135,13 +136,8 @@ main = do
135136 (descr, cabalSHA256) <- readPackage hackageRepository pkgId
136137 meta <- readPackageMeta hackageRepository pkgId
137138
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)
139+ let isInDefaultPackageSet :: Bool
140+ isInDefaultPackageSet = maybe False (== v) (Map.lookup name generatedDefaultPackageSet)
145141
146142 tarballSHA256 :: SHA256Hash
147143 tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball"))
@@ -157,15 +153,13 @@ main = do
157153 drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr
158154 & src .~ urlDerivationSource ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") tarballSHA256
159155 & editedCabalFile .~ cabalSHA256
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
156+ & metaSection.hydraPlatforms %~ (`Set.difference` Map.findWithDefault Set.empty name (dontDistributePackages config))
164157 & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers
158+ & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty)
165159 & metaSection.homepage .~ ""
166160
167161 overrides :: Doc
168− overrides = fcat $ punctuate space [ pPrint b <> semi | b <- Set.toList (view (dependencies . each) drv `Set.union` view extraFunctionArgs drv), not (isFromHackage b) ]
162+ overrides = fcat $ punctuate space [ disp b <> semi | b <- Set.toList ((view (dependencies . each) drv) `Set.union` view extraFunctionArgs drv), not (isFromHackage b) ]
169163 return $ render $ nest 2 $
170164 hang (doubleQuotes (text attr) <+> equals <+> text "callPackage") 2 (parens (pPrint drv)) <+> (braces overrides <> semi)
171165
@@ -205,7 +199,7 @@ resolveConstraint c = fromMaybe (error msg) . resolveConstraint' c
205199 ]
206200
207201resolveConstraint' :: Constraint -> Hackage -> Maybe Version
208−resolveConstraint' (Dependency name vrange _) hackage
202+resolveConstraint' (Dependency name vrange) hackage
209203 | Just vset' <- Map.lookup name hackage
210204 , vset <- Set.filter (`withinRange` vrange) vset'
211205 , not (Set.null vset) = Just (Set.findMax vset)
hackage2nix/README.md−3
@@ -15,9 +15,6 @@ 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−
2118#### Setup
2219Replace `git@github.com:NixOS/nixpkgs.git` with a fork you have access to.
2320```
src/Cabal2nix.hs+15−20
@@ -11,12 +11,14 @@ module Cabal2nix
1111import Control.Exception ( bracket )
1212import Control.Lens
1313import Control.Monad
14−import Data.List ( intercalate, isPrefixOf )
14+import Data.List
1515import Data.List.Split
1616import Data.Maybe ( fromMaybe, isJust, listToMaybe )
17+import Data.Monoid ( (<>) )
1718import qualified Data.Set as Set
1819import Data.String
1920import Data.Time
21+import qualified Distribution.Compat.ReadP as P
2022import Distribution.Compiler
2123import Distribution.Nixpkgs.Fetch
2224import Distribution.Nixpkgs.Haskell
@@ -24,14 +26,13 @@ import Distribution.Nixpkgs.Haskell.FromCabal
2426import Distribution.Nixpkgs.Haskell.FromCabal.Flags
2527import qualified Distribution.Nixpkgs.Haskell.FromCabal.PostProcess as PP (pkg)
2628import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
27−import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2829import Distribution.Nixpkgs.Haskell.PackageSourceSpec
2930import Distribution.Nixpkgs.Meta
30−import Distribution.Package ( packageId )
3131import Distribution.PackageDescription ( mkFlagName, mkFlagAssignment, FlagAssignment )
32−import Distribution.Parsec as P
32+import Distribution.Package ( packageId )
3333import Distribution.Simple.Utils ( lowercase )
3434import Distribution.System
35+import Distribution.Text
3536import Language.Nix
3637import Options.Applicative
3738import Paths_cabal2nix ( version )
@@ -45,7 +46,7 @@ data Options = Options
4546 , optMaintainer :: [String]
4647--, optPlatform :: [String] -- TODO: fix command line handling of platforms
4748 , optHaddock :: Bool
48− , optHpack :: HpackUse
49+ , optHpack :: Bool
4950 , optDoCheck :: Bool
5051 , optJailbreak :: Bool
5152 , optDoBenchmark :: Bool
@@ -73,14 +74,7 @@ options = Options
7374 <*> many (strOption $ long "maintainer" <> metavar "MAINTAINER" <> help "maintainer of this package (may be specified multiple times)")
7475-- <*> many (strOption $ long "platform" <> metavar "PLATFORM" <> help "supported build platforms (may be specified multiple times)")
7576 <*> flag True False (long "no-haddock" <> help "don't run Haddock when building this package")
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− )
77+ <*> switch (long "hpack" <> help "run hpack before configuring this package (only non-hackage packages)")
8478 <*> flag True False (long "no-check" <> help "don't run regression test suites of this package")
8579 <*> switch (long "jailbreak" <> help "disregard version restrictions on build inputs")
8680 <*> switch (long "benchmark" <> help "enable benchmarks for this package")
@@ -93,8 +87,8 @@ options = Options
9387 <*> optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
9488 <*> switch (long "shell" <> help "generate output suitable for nix-shell")
9589 <*> many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
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)
90+ <*> option (readP parse) (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith display)
91+ <*> 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)
9892 <*> optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
9993 <*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
10094 <*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
@@ -109,8 +103,10 @@ utcTimeReader = eitherReader $ \arg ->
109103 Nothing -> Left $ "Cannot parse date, ISO format used ('2017-11-20T12:18:35Z'): " ++ arg
110104 Just utcTime -> Right utcTime
111105
112−parseCabal :: Parsec a => ReadM a
113−parseCabal = eitherReader eitherParsec
106+readP :: P.ReadP a a -> ReadM a
107+readP p = eitherReader $ \s -> case [ r' | (r',"") <- P.readP_to_S p s ] of
108+ (r:_) -> Right r
109+ _ -> Left ("invalid value " ++ show s)
114110
115111-- | Replicate the normalization performed by GHC_CONVERT_CPU in GHC's aclocal.m4
116112-- since the output of that is what Cabal parses.
@@ -135,7 +131,6 @@ ghcConvertOS os = case os of
135131 "watchos" -> "ios"
136132 "tvos" -> "ios"
137133 "linux-android" -> "linux-android"
138− "linux-androideabi" -> "linux-androideabi"
139134 _ | "linux-" `isPrefixOf` os -> "linux"
140135 _ -> fromMaybe os $ listToMaybe
141136 [prefix | prefix <- osPrefixes, prefix `isPrefixOf` os]
@@ -162,7 +157,7 @@ parsePlatformParts = \case
162157pinfo :: ParserInfo Options
163158pinfo = info
164159 ( helper
165− <*> infoOption ("cabal2nix " ++ prettyShow version) (long "version" <> help "Show version number")
160+ <*> infoOption ("cabal2nix " ++ display version) (long "version" <> help "Show version number")
166161 <*> options
167162 )
168163 ( fullDesc
@@ -191,7 +186,7 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() ->
191186 cabal2nix =<< getArgs
192187
193188hpackOverrides :: Derivation -> Derivation
194−hpackOverrides = over phaseOverrides (++ "prePatch = \"hpack\";")
189+hpackOverrides = over phaseOverrides (++ "preConfigure = \"hpack\";")
195190 . set (libraryDepends . tool . contains (PP.pkg "hpack")) True
196191
197192cabal2nix' :: Options -> IO (Either Doc Derivation)
src/Distribution/Nixpkgs/Fetch.hs+1−3
@@ -161,9 +161,7 @@ fetchWith (supportsRev, kind, addArgs) source = do
161161 ExitFailure _ -> return Nothing
162162 ExitSuccess -> do
163163 buf <- BS.hGetContents stdoutH
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)
164+ let (l:ls) = reverse (BS.lines buf)
167165 buf' = BS.unlines (reverse ls)
168166 case length ls of
169167 0 -> return Nothing
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+3−3
@@ -15,7 +15,7 @@ module Distribution.Nixpkgs.Haskell.Derivation
1515
1616import Control.DeepSeq
1717import Control.Lens
18−import Data.List ( isPrefixOf )
18+import Data.List
1919import Data.Set ( Set )
2020import qualified Data.Set as Set
2121import Data.Set.Lens
@@ -112,8 +112,8 @@ instance Pretty Derivation where
112112 pPrint drv@MkDerivation {..} = funargs (map text ("mkDerivation" : toAscList inputs)) $$ vcat
113113 [ text "mkDerivation" <+> lbrace
114114 , nest 2 $ vcat
115− [ attr "pname" $ doubleQuotes $ pPrint (packageName _pkgid)
116− , attr "version" $ doubleQuotes $ pPrint (packageVersion _pkgid)
115+ [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
116+ , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
117117 , pPrint _src
118118 , onlyIf (_subpath /= ".") $ attr "postUnpack" postUnpack
119119 , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+11−11
@@ -58,14 +58,14 @@ finalizeGenericPackageDescription haskellResolver arch compiler flags constraint
5858 }
5959
6060 jailbroken :: HaskellResolver -> HaskellResolver
61− jailbroken resolver (Dependency pkg _ _) = resolver (Dependency pkg anyVersion mempty)
61+ jailbroken resolver (Dependency pkg _) = resolver (Dependency pkg anyVersion)
6262
6363 withInternalLibs :: HaskellResolver -> HaskellResolver
6464 withInternalLibs resolver d = depPkgName d `elem` internalNames || resolver d
6565
6666 internalNames :: [PackageName]
6767 internalNames = [ unqualComponentNameToPackageName n | (n,_) <- condSubLibraries genDesc ]
68− ++ [ unqualComponentNameToPackageName n | LSubLibName n <- libName <$> subLibraries (packageDescription genDesc) ]
68+ ++ [ unqualComponentNameToPackageName n | Just n <- libName <$> subLibraries (packageDescription genDesc) ]
6969
7070 in case finalize (jailbroken (withInternalLibs haskellResolver)) of
7171 Left m -> case finalize (const True) of
@@ -119,7 +119,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
119119 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
125125 -- TODO: This is all very confusing. Haskell packages refer to the Nixpkgs
@@ -136,19 +136,19 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
136136 resolveInNixpkgs :: Identifier -> Binding
137137 resolveInNixpkgs i
138138 | i `elem` ["clang","lldb","llvm"] = binding # (i, path # ["self","llvmPackages",i]) -- TODO: evil!
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"])
139+ | i == "gtk2" = binding # (i, path # ["pkgs","gnome2","gtk"])
140+ | i == "gtk3" = binding # (i, path # ["pkgs","gnome3","gtk"])
141+ | i == "gtksourceview3" = binding # (i, path # ["pkgs","gnome3","gtksourceview"])
142+ | i == "vte_291" = binding # (i, path # ["pkgs","gnome3","vte"])
143143 | Just p <- nixpkgsResolver i, init (view (reference . path) p) `Set.member` goodScopes = p
144144 | otherwise = bindNull i
145145
146146 resolveInHackageThenNixpkgs :: Identifier -> Binding
147− resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion mempty) = resolveInHackage i
147+ resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i
148148 | otherwise = resolveInNixpkgs i
149149
150150 internalLibNames :: [PackageName]
151− internalLibNames = [ unqualComponentNameToPackageName n | LSubLibName n <- libName <$> subLibraries ]
151+ internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
152152
153153 doHaddockPhase :: Bool
154154 doHaddockPhase | not (null internalLibNames) = False
@@ -158,7 +158,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
158158 convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
159159 convertBuildInfo Cabal.BuildInfo {..} | not buildable = mempty
160160 convertBuildInfo Cabal.BuildInfo {..} = mempty
161− & 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 ]
162162 & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]
163163 & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | PkgconfigDependency x _ <- pkgconfigDepends, y <- libNixName (unPkgconfigName x) ]
164164 & tool .~ Set.fromList (map resolveInHackageThenNixpkgs . concatMap buildToolNixName
@@ -166,7 +166,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
166166
167167 convertSetupBuildInfo :: Cabal.SetupBuildInfo -> Nix.BuildInfo
168168 convertSetupBuildInfo bi = mempty
169− & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _ _) <- Cabal.setupDepends bi ]
169+ & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- Cabal.setupDepends bi ]
170170
171171bindNull :: Identifier -> Binding
172172bindNull i = binding # (i, path # ["null"])
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+32−28
@@ -1,21 +1,16 @@
11{-# LANGUAGE RecordWildCards #-}
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE FlexibleInstances #-}
34{-# LANGUAGE OverloadedStrings #-}
45{-# LANGUAGE DeriveGeneric #-}
56{-# OPTIONS_GHC -fno-warn-orphans #-}
67
7−module Distribution.Nixpkgs.Haskell.FromCabal.Configuration
8− ( Configuration(..), readConfiguration, assertConsistency
9− )
10− where
8+module Distribution.Nixpkgs.Haskell.FromCabal.Configuration ( Configuration(..), readConfiguration, assertConsistency ) where
119
12−import Prelude hiding ( fail )
13−
14−import Control.DeepSeq
1510import Control.Exception ( throwIO )
11+import Control.DeepSeq
1612import Control.Lens
17−import Control.Monad hiding ( fail )
18−import Control.Monad.Fail
13+import Control.Monad
1914import Data.Aeson
2015import Data.Map as Map
2116import Data.Set as Set
@@ -45,22 +40,14 @@ data Configuration = Configuration
4540 -- role during dependency resolution.
4641 , extraPackages :: [Constraint]
4742
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]
6451 }
6552 deriving (Show, Generic)
6653
@@ -72,33 +59,50 @@ instance FromJSON Configuration where
7259 <*> o .:? "core-packages" .!= mempty
7360 <*> o .:? "default-package-overrides" .!= mempty
7461 <*> o .:? "extra-packages" .!= mempty
75− <*> o .:? "package-maintainers" .!= mempty
76− <*> o .:? "unsupported-platforms" .!= mempty
7762 <*> o .:? "dont-distribute-packages" .!= mempty
78− <*> o .:? "broken-packages" .!= mempty
63+ <*> o .:? "package-maintainers" .!= mempty
7964 parseJSON _ = error "invalid Configuration"
8065
8166instance FromJSON Identifier where
8267 parseJSON (String s) = pure (review ident (T.unpack s))
8368 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
8469
70+#if MIN_VERSION_aeson(1,0,0)
71+
8572instance FromJSONKey Identifier where
8673 fromJSONKey = FromJSONKeyText parseKey
8774
8875instance FromJSONKey PackageName where
8976 fromJSONKey = FromJSONKeyText parseKey
9077
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+
9193parseKey :: FromJSON k => Text -> k
9294parseKey s = either error id (parseEither parseJSON (String s))
9395
9496readConfiguration :: FilePath -> IO Configuration
95−readConfiguration path = decodeFileEither path >>= either throwIO assertConsistency
97+readConfiguration path =
98+ decodeFileEither path >>= either throwIO assertConsistency
9699
97−assertConsistency :: MonadFail m => Configuration -> m Configuration
100+assertConsistency :: Monad m => Configuration -> m Configuration
98101assertConsistency cfg@Configuration {..} = do
99102 let report msg = fail ("*** configuration error: " ++ msg)
103+
100104 maintainedPackages = Set.unions (Map.elems packageMaintainers)
101− disabledPackages = dontDistributePackages `Set.union` Set.fromList (depPkgName <$> brokenPackages)
105+ disabledPackages = Map.keysSet dontDistributePackages
102106 disabledMaintainedPackages = maintainedPackages `Set.intersection` disabledPackages
103107 unless (Set.null disabledMaintainedPackages) $
104108 report ("disabled packages that have a maintainer: " ++ show disabledMaintainedPackages)
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+2−9
@@ -4,7 +4,6 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Flags ( configureCabalFlags ) wher
44
55import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
66
7−import Data.Char
87import Distribution.Package
98import Distribution.PackageDescription
109import Distribution.Version
@@ -16,7 +15,6 @@ configureCabalFlags' :: PackageIdentifier -> [(FlagName,Bool)]
1615configureCabalFlags' (PackageIdentifier name version)
1716 | name == "accelerate-examples"= [disable "opencl"]
1817 | name == "arithmoi" = [disable "llvm"]
19− | name == "bustle" = [disable "hgettext"] -- https://gitlab.freedesktop.org/bustle/bustle/issues/13
2018 | name == "cabal-plan" = [enable "exe"]
2119 | name == "cassava" = [disable "bytestring--lt-0_10_4"]
2220 | name == "darcs" = [enable "library", enable "force-char8-encoding"]
@@ -28,7 +26,6 @@ configureCabalFlags' (PackageIdentifier name version)
2826 , enable "dbus"
2927 , disable "debuglocks"
3028 , enable "magicmime"
31− , enable "networkbsd"
3229 , enable "pairing"
3330 , enable "production"
3431 , enable "s3"
@@ -47,7 +44,6 @@ configureCabalFlags' (PackageIdentifier name version)
4744 | name == "io-streams" = [enable "NoInteractiveTests"]
4845 | name == "liquid-fixpoint" = [enable "build-external"]
4946 | name == "pandoc" = [enable "https", disable "trypandoc"]
50− | name == "pandoc-placetable" = [enable "inlineMarkdown"]
5147 | name == "persistent-sqlite" = [enable "systemlib"]
5248 | name == "reactive-banana-wx" = [disable "buildExamples"]
5349 | name == "snap-server" = [enable "openssl"]
@@ -59,10 +55,7 @@ configureCabalFlags' (PackageIdentifier name version)
5955 | otherwise = []
6056
6157enable :: String -> (FlagName,Bool)
62−enable name = (mkFlagName' name, True)
58+enable name = (mkFlagName name, True)
6359
6460disable :: String -> (FlagName,Bool)
65−disable name = (mkFlagName' name, False)
66−
67−mkFlagName' :: String -> FlagName
68−mkFlagName' = mkFlagName . map toLower
61+disable name = (mkFlagName name, False)
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+7−15
@@ -29,7 +29,6 @@ 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"
3332libNixName "bz2" = return "bzip2"
3433libNixName "c++" = [] -- What is that?
3534libNixName "cairo-gobject" = return "cairo"
@@ -48,7 +47,7 @@ libNixName "gconf" = return "GConf"
4847libNixName "gconf-2.0" = return "GConf"
4948libNixName "gdk-2.0" = return "gtk2"
5049libNixName "gdk-3.0" = return "gtk3"
51−libNixName "gdk-pixbuf-2.0" = return "gdk-pixbuf"
50+libNixName "gdk-pixbuf-2.0" = return "gdk_pixbuf"
5251libNixName "gdk-x11-2.0" = return "gdk_x11"
5352libNixName "gdk-x11-3.0" = return "gtk3"
5453libNixName "gio-2.0" = return "glib"
@@ -56,7 +55,7 @@ libNixName "GL" = return "libGL"
5655libNixName "GLU" = ["libGLU","libGL"]
5756libNixName "glut" = ["freeglut","libGLU","libGL"]
5857libNixName "gnome-keyring" = return "gnome-keyring"
59−libNixName "gnome-keyring-1" = return "libgnome-keyring"
58+libNixName "gnome-keyring-1" = return "libgnome_keyring"
6059libNixName "gnome-vfs-2.0" = return "gnome-vfs"
6160libNixName "gnome-vfs-module-2.0" = return "gnome-vfs_module"
6261libNixName "gobject-2.0" = return "glib"
@@ -85,8 +84,8 @@ libNixName "ImageMagick" = return "imagemagick"
8584libNixName "Imlib2" = return "imlib2"
8685libNixName "iw" = return "wirelesstools"
8786libNixName "jack" = return "libjack2"
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"
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.
9089libNixName "jpeg" = return "libjpeg"
9190libNixName "jvm" = return "jdk"
9291libNixName "lapack" = return "liblapack"
@@ -95,9 +94,6 @@ libNixName "ldap" = return "openldap"
9594libNixName "libavutil" = return "ffmpeg"
9695libNixName "libgsasl" = return "gsasl"
9796libNixName "libpcre" = return "pcre"
98−libNixName "libpcre2" = return "pcre2"
99−libNixName "libpcre2-8" = libNixName "libpcre2"
100−libNixName "libqrencode" = return "qrencode"
10197libNixName "libR" = return "R"
10298libNixName "libsoup-gnome-2.4" = return "libsoup"
10399libNixName "libsystemd" = return "systemd"
@@ -108,13 +104,9 @@ libNixName "libzmq" = return "zeromq"
108104libNixName "m" = [] -- in stdenv
109105libNixName "magic" = return "file"
110106libNixName "MagickWand" = return "imagemagick"
111−libNixName "mnl" = return "libmnl"
112107libNixName "mpi" = return "openmpi"
113108libNixName "ncursesw" = return "ncurses"
114109libNixName "netsnmp" = return "net_snmp"
115−libNixName "nix-expr" = return "nix"
116−libNixName "nix-main" = return "nix"
117−libNixName "nix-store" = return "nix"
118110libNixName "notify" = return "libnotify"
119111libNixName "odbc" = return "unixODBC"
120112libNixName "openblas" = return "openblasCompat"
@@ -161,9 +153,8 @@ libNixName "wayland-client" = return "wayland"
161153libNixName "wayland-cursor" = return "wayland"
162154libNixName "wayland-egl" = return "libGL"
163155libNixName "wayland-server" = return "wayland"
164−libNixName "webkit2gtk" = return "webkitgtk"
165−libNixName "webkit2gtk-4.0" = return "webkitgtk"
166−libNixName "webkit2gtk-web-extension-4.0" = return "webkitgtk"
156+libNixName "webkit2gtk-4.0" = return "webkitgtk" -- This is the current API, so let it reference an alias for the latest version.
157+libNixName "webkit2gtk-web-extension-4.0" = return "webkitgtk-web-extension" -- This package doesn't actually exist in nixpkgs at present.
167158libNixName "webkitgtk-3.0" = return "webkitgtk24x-gtk3" -- These are the old APIs, of which 2.4 is the last provider, so map directly to that
168159libNixName "X11" = return "libX11"
169160libNixName "x11" = return "xlibsWrapper"
@@ -203,6 +194,7 @@ buildToolNixName "nix-env" = return "nix"
203194buildToolNixName "nix-hash" = return "nix"
204195buildToolNixName "nix-instantiate" = return "nix"
205196buildToolNixName "nix-store" = return "nix"
197+buildToolNixName "pkg-config" = return "pkgconfig"
206198buildToolNixName x = return (fromString x)
207199
208200-- | Helper function to extract the package name from a String that may or may
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+13−30
@@ -13,7 +13,6 @@ import Data.Set ( Set )
1313import qualified Data.Set as Set
1414import Distribution.Nixpkgs.Haskell
1515import Distribution.Nixpkgs.Meta
16−import Distribution.Nixpkgs.License
1716import Distribution.Package
1817import Distribution.System
1918import Distribution.Text
@@ -22,7 +21,7 @@ import Language.Nix
2221
2322postProcess :: Derivation -> Derivation
2423postProcess deriv =
25− foldr (.) id [ f | (Dependency n vr _, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
24+ foldr (.) id [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
2625 . fixGtkBuilds
2726 . fixBuildDependsForTools
2827 $ deriv
@@ -79,7 +78,7 @@ hooks =
7978 , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
8079 , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
8180 , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
82− , ("bustle", bustleOverrides)
81+ , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
8382 , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
8483 , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
8584 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17
@@ -90,7 +89,7 @@ hooks =
9089 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
9190 , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
9291 , ("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.
92+ , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . set (libraryDepends . pkgconfig . contains (pkg "libGLU_combined")) True) -- TODO: fltk14 belongs into the *setup* dependencies.
9493 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
9594 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
9695 , ("gi-gdk", set runHaddock True )
@@ -149,8 +148,7 @@ hooks =
149148 , ("numeric-qq", set doCheck False) -- test suite doesn't finish even after 1+ days
150149 , ("opencv", opencvOverrides)
151150 , ("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)
151+ , ("pandoc", pandocOverrides)
154152 , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/369
155153 , ("purescript", set doCheck False) -- test suite doesn't cope with Nix build env
156154 , ("proto-lens-protobuf-types", set (libraryDepends . tool . contains (pkg "protobuf")) True)
@@ -184,7 +182,6 @@ hooks =
184182 , ("xmonad >= 0.14.2", set phaseOverrides xmonadPostInstall)
185183 , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (self "zip") (pkg "zip")))
186184 , ("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)
188185 ]
189186
190187pkg :: Identifier -> Binding
@@ -230,12 +227,13 @@ gitAnnexHook = set phaseOverrides gitAnnexOverrides
230227 where
231228 gitAnnexOverrides = unlines
232229 [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"
233− , "postBuild = ''"
230+ , "installPhase = \"make PREFIX=$out BUILDER=: install\";"
231+ , "checkPhase = ''"
234232 , " ln -sf dist/build/git-annex/git-annex git-annex"
235233 , " ln -sf git-annex git-annex-shell"
234+ , " export PATH+=\":$PWD\""
235+ , " git-annex test"
236236 , "'';"
237− , "installPhase = \"make PREFIX=$out BUILDER=: install install-completions\";"
238− , "checkPhase = ''PATH+=\":$PWD\" git-annex test'';"
239237 , "enableSharedExecutables = false;"
240238 ]
241239 buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
@@ -256,7 +254,7 @@ gfPhaseOverrides = unlines
256254 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
257255 -- Parallel compilation fails. Disable it.
258256 , "'';"
259− , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH'';"
257+ , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build:$LD_LIBRARY_PATH'';"
260258 -- The build step itself, after having built the library, needs to be able
261259 -- to find the library it just built in order to compile grammar files.
262260 ]
@@ -292,8 +290,8 @@ darcsInstallPostInstall = unlines
292290xmonadPostInstall :: String
293291xmonadPostInstall = unlines
294292 [ "postInstall = ''"
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"
293+ , " install -D man/xmonad.1 $doc/share/man/man1/xmonad.1"
294+ , " install -D man/xmonad.hs $doc/share/doc/$name/sample-xmonad.hs"
297295 , "'';"
298296 ]
299297
@@ -384,26 +382,11 @@ gtkglextHook = over (libraryDepends . system) (Set.union (Set.fromList deps))
384382 , "pkgs.xorg.libXmu"
385383 ]
386384
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−
396385pandocOverrides :: Derivation -> Derivation
397386pandocOverrides = set phaseOverrides postInstall
398387 where
399388 postInstall = unlines [ "postInstall = ''"
400− , " mkdir -p $out/share/man/man1"
401− , " mv \"man/\"*.1 $out/share/man/man1/"
389+ , " mkdir -p $out/share"
390+ , " mv $data/*/*/man $out/share/"
402391 , "'';"
403392 ]
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/OrphanInstances.hs+3−28
@@ -9,12 +9,9 @@ import qualified Data.Text as T
99import Data.Yaml
1010import Distribution.Compiler
1111import Distribution.Package
12−import Distribution.Parsec
1312import Distribution.System
14−import Distribution.Pretty as Cabal
15−import qualified Data.Version as Base
13+import Distribution.Text
1614import Distribution.Version
17−import Language.Nix.PrettyPrinting as Nix
1815
1916instance NFData CompilerInfo
2017instance NFData AbiTag
@@ -52,10 +49,6 @@ instance FromJSON PackageIdentifier where
5249 parseJSON (String s) = return (fromString (T.unpack s))
5350 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell package identifier")
5451
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−
5952instance FromJSON Dependency where
6053 parseJSON (String s) = return (fromString (T.unpack s))
6154 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell Dependency")
@@ -64,25 +57,7 @@ instance FromJSON CompilerInfo where
6457 parseJSON (String s) = return (unknownCompilerInfo (fromString (T.unpack s)) NoAbiTag)
6558 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell compiler")
6659
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−
8560-- parsing tools
8661
87−text2isString :: Parsec a => String -> String -> a
88−text2isString t s = fromMaybe (error ("fromString: " ++ show s ++ " is not a valid " ++ t)) (simpleParsec s)
62+text2isString :: Text a => String -> String -> a
63+text2isString t s = fromMaybe (error ("fromString: " ++ show s ++ " is not a valid " ++ t)) (simpleParse s)
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+25−35
@@ -1,5 +1,5 @@
11module Distribution.Nixpkgs.Haskell.PackageSourceSpec
2− ( HpackUse(..), Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
2+ ( Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
33 ) where
44
55import qualified Control.Exception as Exception
@@ -11,18 +11,16 @@ 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
1614import Data.Time
1715import Distribution.Nixpkgs.Fetch
1816import Distribution.Nixpkgs.Hashes
1917import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
20−import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2118import qualified Distribution.Package as Cabal
2219import Distribution.PackageDescription
2320import qualified Distribution.PackageDescription as Cabal
2421import Distribution.PackageDescription.Parsec as Cabal
25−import Distribution.Parsec
22+import Distribution.Parsec.Common (showPError)
23+import Distribution.Text ( simpleParse, display )
2624import Distribution.Version
2725import qualified Hpack.Config as Hpack
2826import qualified Hpack.Render as Hpack
@@ -31,12 +29,8 @@ import System.Directory ( doesDirectoryExist, doesFileExist, createDirectoryIfMi
3129import System.Exit ( exitFailure )
3230import System.FilePath ( (</>), (<.>) )
3331import System.IO
34−import Text.PrettyPrint.HughesPJClass hiding ( first )
35−
36−data HpackUse
37− = ForceHpack
38− | PackageYamlHpack
39− | NoHpack
32+import qualified Data.Text as T
33+import qualified Data.Text.Encoding as T
4034
4135data Package = Package
4236 { pkgSource :: DerivationSource
@@ -45,8 +39,8 @@ data Package = Package
4539 }
4640 deriving (Show)
4741
48−getPackage :: HpackUse
49− -- ^ the way hpack should be used.
42+getPackage :: Bool
43+ -- ^ Whether hpack should regenerate the cabal file.
5044 -> Bool
5145 -- ^ Whether to fetch submodules if fetching from git
5246 -> Maybe FilePath
@@ -58,8 +52,8 @@ getPackage :: HpackUse
5852getPackage optHpack optSubmodules optHackageDB optHackageSnapshot =
5953 getPackage' optHpack optSubmodules (loadHackageDB optHackageDB optHackageSnapshot)
6054
61−getPackage' :: HpackUse
62− -- ^ the way hpack should be used.
55+getPackage' :: Bool
56+ -- ^ Whether hpack should regenerate the cabal file.
6357 -> Bool
6458 -- ^ Whether to fetch submodules if fetching from git
6559 -> IO DB.HackageDB
@@ -69,8 +63,8 @@ getPackage' optHpack optSubmodules hackageDB source = do
6963 (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack optSubmodules hackageDB source
7064 (\s -> Package s ranHpack pkgDesc) <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource
7165
72−fetchOrFromDB :: HpackUse
73− -- ^ the way hpack should be used
66+fetchOrFromDB :: Bool
67+ -- ^ Whether hpack should regenerate the cabal file
7468 -> Bool
7569 -- ^ Whether to fetch submodules if fetching from git
7670 -> IO DB.HackageDB
@@ -108,12 +102,12 @@ fromDB hackageDBIO pkg = do
108102 return (ds, setCabalFileHash (DB.cabalFileSha256 vd) (DB.cabalFile vd))
109103 where
110104 pkgId :: Cabal.PackageIdentifier
111− pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParsec pkg)
105+ pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)
112106 name = Cabal.packageName pkgId
113107
114− unknownPackageError = fail $ "No such package " ++ prettyShow pkgId ++ " in the cabal database. Did you run cabal update?"
108+ unknownPackageError = fail $ "No such package " ++ display pkgId ++ " in the cabal database. Did you run cabal update?"
115109
116− url = "mirror://hackage/" ++ prettyShow pkgId ++ ".tar.gz"
110+ url = "mirror://hackage/" ++ display pkgId ++ ".tar.gz"
117111
118112 version :: Version
119113 version = Cabal.packageVersion pkgId
@@ -176,12 +170,12 @@ sourceFromHackage optHash pkgId cabalDir = do
176170 exitFailure
177171
178172showPackageIdentifier :: Cabal.GenericPackageDescription -> String
179−showPackageIdentifier pkgDesc = name ++ "-" ++ prettyShow version where
173+showPackageIdentifier pkgDesc = name ++ "-" ++ display version where
180174 pkgId = Cabal.package . Cabal.packageDescription $ pkgDesc
181175 name = Cabal.unPackageName (Cabal.packageName pkgId)
182176 version = Cabal.packageVersion pkgId
183177
184−cabalFromPath :: HpackUse -- ^ the way hpack should be used
178+cabalFromPath :: Bool -- ^ Whether hpack should regenerate the cabal file
185179 -> FilePath -> MaybeT IO (Bool, Bool, Cabal.GenericPackageDescription)
186180cabalFromPath optHpack path = do
187181 d <- liftIO $ doesDirectoryExist path
@@ -191,25 +185,21 @@ cabalFromPath optHpack path = do
191185 return (d, ranHpack, pkg)
192186 else (,,) d False <$> cabalFromFile False path
193187
194−cabalFromDirectory :: HpackUse -- ^ the way hpack should be used
188+cabalFromDirectory :: Bool -- ^ Whether hpack should regenerate the cabal file
195189 -> FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
196−cabalFromDirectory ForceHpack dir = hpackDirectory dir
197−cabalFromDirectory NoHpack dir = onlyCabalFromDirectory dir "*** No .cabal file was found. Exiting."
198−cabalFromDirectory PackageYamlHpack dir = do
190+cabalFromDirectory True dir = hpackDirectory dir
191+cabalFromDirectory False dir = do
199192 useHpack <- liftIO $ doesFileExist (dir </> "package.yaml")
200193 if useHpack
201194 then do
202195 liftIO $ hPutStrLn stderr "*** found package.yaml. Using hpack..."
203196 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
208− cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
209− case cabals of
210− [] -> fail errMsg
211− [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
212− _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
197+ else do
198+ cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
199+ case cabals of
200+ [] -> fail "*** Found neither a .cabal file nor package.yaml. Exiting."
201+ [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
202+ _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
213203
214204handleIO :: (Exception.IOException -> IO a) -> IO a -> IO a
215205handleIO = Exception.handle
test/Main.hs+11−3
@@ -99,6 +99,14 @@ testExecutable exe cabalFile = do
9999-- * Helper functions
100100-------------------------------------------------------------------------------
101101
102+-- | Find all *files* in the given directory. This function does not recurse,
103+-- nor does it include the special entries @'.'@ or @'..'@ in the result.
104+
105+listDirectoryFiles :: FilePath -> IO [FilePath]
106+listDirectoryFiles dirPath = do
107+ entries <- listDirectory dirPath
108+ filterM doesFileExist (map (dirPath </>) entries)
109+
102110-- | Find all *files* in the given directory that end with the given suffix.
103111-- This function does not recurse, nor does it include the special entries
104112-- @'.'@ or @'..'@ in the result.
@@ -111,9 +119,9 @@ testExecutable exe cabalFile = do
111119-- we prefer our own simpler code.
112120
113121listDirectoryFilesBySuffix :: String -> FilePath -> IO [FilePath]
114−listDirectoryFilesBySuffix suff dirPath = do
115− entries <- listDirectory dirPath
116− filterM doesFileExist [ dirPath </> e | e <- entries, takeExtension e == suff ]
122+listDirectoryFilesBySuffix suff =
123+ fmap (filter ((suff ==) . takeExtension)) . listDirectoryFiles
124+
117125
118126-- | A variant of 'writeFile' that appends a newline to the end of the buffer
119127-- before writing.
update-stackage.sh+9−12
@@ -2,14 +2,11 @@
22
33set -eu -o pipefail
44
5−cd "$(dirname "$0")"
5+tmpfile=$(mktemp "stackage-update.XXXXXXX")
6+trap "rm $tmpfile" 0
67
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")
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")
1310
1411# Create a simple yaml version of the file.
1512sed -r \
@@ -19,13 +16,12 @@ sed -r \
1916 -e 's|,$||' \
2017 -e '/installed$/d' \
2118 -e '/^$/d' \
22− < "${tmpfile}" | sort --ignore-case >"${tmpfile}.new"
19+ -i "$tmpfile"
2320
2421# Drop restrictions on some tools where we always want the latest version.
2522sed -r \
2623 -e '/ cabal-install /d' \
2724 -e '/ cabal2nix /d' \
28− -e '/ cabal2spec /d' \
2925 -e '/ distribution-nixpkgs /d' \
3026 -e '/ git-annex /d' \
3127 -e '/ hindent /d' \
@@ -35,16 +31,17 @@ sed -r \
3531 -e '/ hopenssl /d' \
3632 -e '/ jailbreak-cabal /d' \
3733 -e '/ json-autotype/d' \
34+ -e '/ lambdabot-core /d' \
35+ -e '/ lambdabot-irc-plugins /d' \
3836 -e '/ language-nix /d' \
3937 -e '/ shake /d' \
4038 -e '/ ShellCheck /d' \
4139 -e '/ stack /d' \
4240 -e '/ weeder /d' \
43− < "${tmpfile}.new" > "${tmpfile}"
41+ -i "$tmpfile"
4442
4543# Drop the previous configuration ...
46−# shellcheck disable=SC1004
47−sed -e '/ # LTS Haskell/,/^$/c \TODO\
44+sed -e '/# LTS Haskell/,/^$/c \TODO\
4845' -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml
4946
5047# ... and replace it with the new one.