git.iko.soy/typeable/cabal2nix
on master help sign in
17 files changed+198−190
since splitsnapshots
unifiedsplit
.travis.yml+70−53 README.md+6−6 cabal2nix.cabal+24−75 hackage2nix/Main.hs+9−8 hackage2nix/README.md+3 src/Cabal2nix.hs+10−12 src/Distribution/Nixpkgs/Fetch.hs+3−1 src/Distribution/Nixpkgs/Haskell/Constraint.hs+1−1 src/Distribution/Nixpkgs/Haskell/Derivation.hs+3−3 src/Distribution/Nixpkgs/Haskell/FromCabal.hs+7−7 src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+5−2 src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+8−3 src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+3−1 src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+11−4 src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+24−3 src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+9−8 update-stackage.sh+2−3
.travis.yml+70−53
@@ -1,12 +1,14 @@
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'
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#
55# For more information, see https://github.com/haskell-CI/haskell-ci
66#
7−# version: 0.3.20190413
7+# version: 0.9.20200306
88#
9+version: ~> 1.0
910language: c
11+os: linux
1012dist: xenial
1113git:
1214 # whether to recursively clone submodules
@@ -15,6 +17,7 @@ cache:
1517 directories:
1618 - $HOME/.cabal/packages
1719 - $HOME/.cabal/store
20+ - $HOME/.hlint
1821before_cache:
1922 - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
2023 # remove files that are regenerated by 'cabal update'
@@ -24,121 +27,135 @@ before_cache:
2427 - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
2528 - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
2629 - rm -rfv $CABALHOME/packages/head.hackage
27−matrix:
30+jobs:
2831 include:
29− - compiler: ghc-8.6.4
30− addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.4","cabal-install-2.4"]}}
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
3144before_install:
3245 - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
46+ - WITHCOMPILER="-w $HC"
47+ - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
3348 - HCPKG="$HC-pkg"
3449 - unset CC
3550 - CABAL=/opt/ghc/bin/cabal
3651 - CABALHOME=$HOME/.cabal
3752 - export PATH="$CABALHOME/bin:$PATH"
3853 - TOP=$(pwd)
39− - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
54+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
4055 - echo $HCNUMVER
41− - CABAL="$CABAL -vnormal+nowrap+markoutput"
56+ - CABAL="$CABAL -vnormal+nowrap"
4257 - set -o pipefail
43− - |
44− echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
45− echo 'BEGIN { state = "output"; }' >> .colorful.awk
46− echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
47− echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
48− echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
49− echo ' if (state == "cabal") {' >> .colorful.awk
50− echo ' print blue($0)' >> .colorful.awk
51− echo ' } else {' >> .colorful.awk
52− echo ' print $0' >> .colorful.awk
53− echo ' }' >> .colorful.awk
54− echo '}' >> .colorful.awk
55− - cat .colorful.awk
56− - |
57− color_cabal_output () {
58− awk -f $TOP/.colorful.awk
59− }
60− - echo text | color_cabal_output
61−install:
62− - ${CABAL} --version
63− - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
6458 - TEST=--enable-tests
6559 - BENCH=--enable-benchmarks
66− - GHCHEAD=${GHCHEAD-false}
60+ - HEADHACKAGE=false
61+ - if [ $HCNUMVER -ge 80800 ] ; then HEADHACKAGE=true ; fi
6762 - rm -f $CABALHOME/config
6863 - |
6964 echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
7065 echo "remote-build-reporting: anonymous" >> $CABALHOME/config
66+ echo "write-ghc-environment-files: always" >> $CABALHOME/config
7167 echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
7268 echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
7369 echo "world-file: $CABALHOME/world" >> $CABALHOME/config
7470 echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
7571 echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
72+ echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
7673 echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
7774 echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
7875 echo "install-dirs user" >> $CABALHOME/config
7976 echo " prefix: $CABALHOME" >> $CABALHOME/config
8077 echo "repository hackage.haskell.org" >> $CABALHOME/config
8178 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
90+install:
91+ - ${CABAL} --version
92+ - 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
8296 - cat $CABALHOME/config
8397 - rm -fv cabal.project cabal.project.local cabal.project.freeze
8498 - travis_retry ${CABAL} v2-update -v
85− - ${CABAL} v2-install -w ${HC} -j2 doctest --constraint='doctest ==0.16.*' | color_cabal_output
86− - ${CABAL} v2-install -w ${HC} -j2 hlint --constraint='hlint ==2.1.*' | color_cabal_output
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
87104 # Generate cabal.project
88105 - rm -rf cabal.project cabal.project.local cabal.project.freeze
89106 - touch cabal.project
90107 - |
91− echo 'packages: "."' >> cabal.project
108+ echo "packages: ." >> cabal.project
92109 - |
93− echo "write-ghc-environment-files: always" >> cabal.project
94− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(Cabal|cabal2nix)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
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"
95111 - cat cabal.project || true
96112 - cat cabal.project.local || true
97113 - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
98− - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output
114+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
99115 - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
100116 - rm cabal.project.freeze
101− - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
102− - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
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
103119script:
104120 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
105121 # Packaging...
106− - ${CABAL} v2-sdist all | color_cabal_output
122+ - ${CABAL} v2-sdist all
107123 # Unpacking...
108124 - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
109125 - cd ${DISTDIR} || false
110− - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
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.]*')"
111129 # Generate cabal.project
112130 - rm -rf cabal.project cabal.project.local cabal.project.freeze
113131 - touch cabal.project
114132 - |
115− echo 'packages: "cabal2nix-*/*.cabal"' >> cabal.project
133+ echo "packages: ${PKGDIR_cabal2nix}" >> cabal.project
116134 - |
117− echo "write-ghc-environment-files: always" >> cabal.project
118− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(Cabal|cabal2nix)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
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"
119136 - cat cabal.project || true
120137 - cat cabal.project.local || true
121138 # Building...
122139 # this builds all libraries and executables (without tests/benchmarks)
123− - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
140+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
124141 # Building with tests and benchmarks...
125142 # build & run tests, build benchmarks
126− - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
143+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
127144 # Testing...
128− - ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
145+ - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
129146 # Doctest...
130− - (cd cabal2nix-* && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen -XMonadFailDesugaring src)
147+ - (cd ${PKGDIR_cabal2nix} && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen src)
131148 # HLint..
132− - (cd cabal2nix-* && hlint -XMonadFailDesugaring src)
133− - (cd cabal2nix-* && hlint -XMonadFailDesugaring hackage2nix)
134− - (cd cabal2nix-* && hlint -XMonadFailDesugaring cabal2nix)
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
135152 # cabal check...
136− - (cd cabal2nix-* && ${CABAL} -vnormal check)
153+ - (cd ${PKGDIR_cabal2nix} && ${CABAL} -vnormal check)
137154 # haddock...
138− - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
155+ - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
139156 # Building without installed constraints for packages in global-db...
140157 - rm -f cabal.project.local
141− - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
158+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
142159
143−# REGENDATA ["--installed=+all -Cabal","--hlint","--doctest","--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen","-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"])
144161# EOF
README.md+6−6
@@ -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 obviously still causes network traffic. Run the
31−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.
3232
33−Detailed instructions how to use those generated files with Nix can be found at
33+Detailed instructions on how to use those generated files with Nix can be found at
3434https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages.
3535
3636`cabal2nix` can also build derivations for projects from other sources than
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:
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:
4040
4141 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
4242 $ cabal2nix .
cabal2nix.cabal+24−75
@@ -1,5 +1,5 @@
11name: cabal2nix
2−version: 2.14.4
2+version: 2.15.1
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,73 +8,26 @@ description:
88 > nix-env -i cabal2nix
99license: BSD3
1010license-file: LICENSE
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− Александр Цамутали
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, Александр Цамутали
7528maintainer: Peter Simons <simons@cryp.to>
7629stability: stable
77−tested-with: GHC == 8.6.4
30+tested-with: GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1
7831category: Distribution, Nix
7932homepage: https://github.com/nixos/cabal2nix#readme
8033bug-reports: https://github.com/nixos/cabal2nix/issues
@@ -108,14 +61,14 @@ library
10861 other-modules: Paths_cabal2nix
10962 hs-source-dirs: src
11063 build-depends: base > 4.11
111− , Cabal > 2.4
64+ , Cabal == 3.0.*
11265 , aeson > 1
11366 , ansi-wl-pprint
11467 , bytestring
11568 , containers >= 0.5.9
11669 , deepseq >= 1.4
11770 , directory
118− , distribution-nixpkgs >= 1.2
71+ , distribution-nixpkgs >= 1.3.1
11972 , filepath
12073 , hackage-db >= 2.0.1
12174 , hopenssl >= 2
@@ -131,7 +84,6 @@ library
13184 , transformers
13285 , yaml
13386 default-language: Haskell2010
134− default-extensions: MonadFailDesugaring
13587 other-extensions: MultiParamTypeClasses
13688 ScopedTypeVariables
13789 FlexibleInstances
@@ -149,7 +101,6 @@ executable cabal2nix
149101 hs-source-dirs: cabal2nix
150102 build-depends: base, cabal2nix
151103 default-language: Haskell2010
152− default-extensions: MonadFailDesugaring
153104 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
154105 -Wredundant-constraints
155106
@@ -159,7 +110,7 @@ executable hackage2nix
159110 Paths_cabal2nix
160111 hs-source-dirs: hackage2nix
161112 build-depends: base < 5
162− , Cabal > 2.4
113+ , Cabal
163114 , aeson
164115 , bytestring
165116 , cabal2nix
@@ -176,16 +127,15 @@ executable hackage2nix
176127 , optparse-applicative
177128 , pretty >= 1.1.2
178129 default-language: Haskell2010
179− default-extensions: MonadFailDesugaring
180130 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
181− -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
131+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-maxN16
182132
183133test-suite regression-test
184134 type: exitcode-stdio-1.0
185135 main-is: Main.hs
186136 hs-source-dirs: test
187137 build-depends: base
188− , Cabal > 2.4
138+ , Cabal
189139 , cabal2nix
190140 , containers
191141 , directory
@@ -197,7 +147,6 @@ test-suite regression-test
197147 , tasty
198148 , tasty-golden
199149 default-language: Haskell2010
200− default-extensions: MonadFailDesugaring
201150 build-tools: cabal2nix
202151 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
203152 -Wredundant-constraints -threaded -with-rtsopts=-K64K
hackage2nix/Main.hs+9−8
@@ -10,7 +10,7 @@ import Control.Monad
1010import Control.Monad.Par.Combinator
1111import Control.Monad.Par.IO
1212import Control.Monad.Trans ( liftIO )
13−import Data.List
13+import Data.List ( intercalate )
1414import Data.Map.Strict ( Map )
1515import qualified Data.Map.Strict as Map
1616import Data.Maybe
@@ -23,6 +23,7 @@ import Distribution.Nixpkgs.Haskell.Constraint
2323import Distribution.Nixpkgs.Haskell.FromCabal
2424import Distribution.Nixpkgs.Haskell.FromCabal.Configuration as Config
2525import Distribution.Nixpkgs.Haskell.FromCabal.Flags
26+import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2627import Distribution.Nixpkgs.Meta
2728import Distribution.Nixpkgs.PackageMap
2829import Distribution.Package
@@ -62,7 +63,7 @@ main = do
6263 pinfo :: ParserInfo CLI
6364 pinfo = info
6465 ( helper
65− <*> infoOption ("hackage2nix " ++ display Main.version) (long "version" <> help "Show version number")
66+ <*> infoOption ("hackage2nix " ++ prettyShow Main.version) (long "version" <> help "Show version number")
6667 <*> cliOptions
6768 )
6869 ( fullDesc
@@ -92,7 +93,7 @@ main = do
9293 latestVersionSet = Map.map Set.findMax (Map.filter (not . Set.null) (Map.mapWithKey (enforcePreferredVersions preferredVersions) hackage))
9394
9495 defaultPackageOverridesSet :: PackageSet
95− 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 ]
9697
9798 generatedDefaultPackageSet :: PackageSet
9899 generatedDefaultPackageSet = (defaultPackageOverridesSet `Map.union` latestVersionSet) `Map.difference` corePackageSet
@@ -105,7 +106,7 @@ main = do
105106
106107 extraPackageSet :: PackageMultiSet
107108 extraPackageSet = Map.unionsWith Set.union
108− [ 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 ]
109110
110111 db :: PackageMultiSet
111112 db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
@@ -115,7 +116,7 @@ main = do
115116 ]
116117
117118 haskellResolver :: Dependency -> Bool
118− haskellResolver (Dependency name vrange)
119+ haskellResolver (Dependency name vrange _)
119120 | Just v <- Map.lookup name corePackageSet = v `withinRange` vrange
120121 | Just v <- Map.lookup name generatedDefaultPackageSet = v `withinRange` vrange
121122 | otherwise = False
@@ -137,7 +138,7 @@ main = do
137138 let isInDefaultPackageSet, isHydraEnabled, isBroken :: Bool
138139 isInDefaultPackageSet = (== Just v) (Map.lookup name generatedDefaultPackageSet)
139140 isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)
140− isBroken = any (withinRange v) [ vr | Dependency pn vr <- brokenPackages config, pn == name ]
141+ isBroken = any (withinRange v) [ vr | Dependency pn vr _ <- brokenPackages config, pn == name ]
141142
142143 droppedPlatforms :: Set Platform
143144 droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)
@@ -164,7 +165,7 @@ main = do
164165 & metaSection.homepage .~ ""
165166
166167 overrides :: Doc
167− 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) ]
168169 return $ render $ nest 2 $
169170 hang (doubleQuotes (text attr) <+> equals <+> text "callPackage") 2 (parens (pPrint drv)) <+> (braces overrides <> semi)
170171
@@ -204,7 +205,7 @@ resolveConstraint c = fromMaybe (error msg) . resolveConstraint' c
204205 ]
205206
206207resolveConstraint' :: Constraint -> Hackage -> Maybe Version
207−resolveConstraint' (Dependency name vrange) hackage
208+resolveConstraint' (Dependency name vrange _) hackage
208209 | Just vset' <- Map.lookup name hackage
209210 , vset <- Set.filter (`withinRange` vrange) vset'
210211 , 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+10−12
@@ -11,14 +11,12 @@ module Cabal2nix
1111import Control.Exception ( bracket )
1212import Control.Lens
1313import Control.Monad
14−import Data.List
14+import Data.List ( intercalate, isPrefixOf )
1515import Data.List.Split
1616import Data.Maybe ( fromMaybe, isJust, listToMaybe )
17−import Data.Monoid ( (<>) )
1817import qualified Data.Set as Set
1918import Data.String
2019import Data.Time
21−import qualified Distribution.Compat.ReadP as P
2220import Distribution.Compiler
2321import Distribution.Nixpkgs.Fetch
2422import Distribution.Nixpkgs.Haskell
@@ -26,13 +24,14 @@ import Distribution.Nixpkgs.Haskell.FromCabal
2624import Distribution.Nixpkgs.Haskell.FromCabal.Flags
2725import qualified Distribution.Nixpkgs.Haskell.FromCabal.PostProcess as PP (pkg)
2826import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
27+import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2928import Distribution.Nixpkgs.Haskell.PackageSourceSpec
3029import Distribution.Nixpkgs.Meta
31−import Distribution.PackageDescription ( mkFlagName, mkFlagAssignment, FlagAssignment )
3230import Distribution.Package ( packageId )
31+import Distribution.PackageDescription ( mkFlagName, mkFlagAssignment, FlagAssignment )
32+import Distribution.Parsec as P
3333import Distribution.Simple.Utils ( lowercase )
3434import Distribution.System
35−import Distribution.Text
3635import Language.Nix
3736import Options.Applicative
3837import Paths_cabal2nix ( version )
@@ -94,8 +93,8 @@ options = Options
9493 <*> optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
9594 <*> switch (long "shell" <> help "generate output suitable for nix-shell")
9695 <*> many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
97− <*> option (readP parse) (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith display)
98− <*> 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)
9998 <*> optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
10099 <*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
101100 <*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
@@ -110,10 +109,8 @@ utcTimeReader = eitherReader $ \arg ->
110109 Nothing -> Left $ "Cannot parse date, ISO format used ('2017-11-20T12:18:35Z'): " ++ arg
111110 Just utcTime -> Right utcTime
112111
113−readP :: P.ReadP a a -> ReadM a
114−readP p = eitherReader $ \s -> case [ r' | (r',"") <- P.readP_to_S p s ] of
115− (r:_) -> Right r
116− _ -> Left ("invalid value " ++ show s)
112+parseCabal :: Parsec a => ReadM a
113+parseCabal = eitherReader eitherParsec
117114
118115-- | Replicate the normalization performed by GHC_CONVERT_CPU in GHC's aclocal.m4
119116-- since the output of that is what Cabal parses.
@@ -138,6 +135,7 @@ ghcConvertOS os = case os of
138135 "watchos" -> "ios"
139136 "tvos" -> "ios"
140137 "linux-android" -> "linux-android"
138+ "linux-androideabi" -> "linux-androideabi"
141139 _ | "linux-" `isPrefixOf` os -> "linux"
142140 _ -> fromMaybe os $ listToMaybe
143141 [prefix | prefix <- osPrefixes, prefix `isPrefixOf` os]
@@ -164,7 +162,7 @@ parsePlatformParts = \case
164162pinfo :: ParserInfo Options
165163pinfo = info
166164 ( helper
167− <*> infoOption ("cabal2nix " ++ display version) (long "version" <> help "Show version number")
165+ <*> infoOption ("cabal2nix " ++ prettyShow version) (long "version" <> help "Show version number")
168166 <*> options
169167 )
170168 ( fullDesc
src/Distribution/Nixpkgs/Fetch.hs+3−1
@@ -161,7 +161,9 @@ fetchWith (supportsRev, kind, addArgs) source = do
161161 ExitFailure _ -> return Nothing
162162 ExitSuccess -> do
163163 buf <- BS.hGetContents stdoutH
164− 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)
165167 buf' = BS.unlines (reverse ls)
166168 case length ls of
167169 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
18+import Data.List ( isPrefixOf )
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 $ disp (packageName _pkgid)
116− , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
115+ [ attr "pname" $ doubleQuotes $ pPrint (packageName _pkgid)
116+ , attr "version" $ doubleQuotes $ pPrint (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+7−7
@@ -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)
61+ jailbroken resolver (Dependency pkg _ _) = resolver (Dependency pkg anyVersion mempty)
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 | Just n <- libName <$> subLibraries (packageDescription genDesc) ]
68+ ++ [ unqualComponentNameToPackageName n | LSubLibName 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
@@ -144,11 +144,11 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
144144 | otherwise = bindNull i
145145
146146 resolveInHackageThenNixpkgs :: Identifier -> Binding
147− resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i
147+ resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion mempty) = resolveInHackage i
148148 | otherwise = resolveInNixpkgs i
149149
150150 internalLibNames :: [PackageName]
151− internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
151+ internalLibNames = [ unqualComponentNameToPackageName n | LSubLibName n <- 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+5−2
@@ -9,10 +9,13 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Configuration
99 )
1010 where
1111
12+import Prelude hiding ( fail )
13+
1214import Control.DeepSeq
1315import Control.Exception ( throwIO )
1416import Control.Lens
15−import Control.Monad
17+import Control.Monad hiding ( fail )
18+import Control.Monad.Fail
1619import Data.Aeson
1720import Data.Map as Map
1821import Data.Set as Set
@@ -91,7 +94,7 @@ parseKey s = either error id (parseEither parseJSON (String s))
9194readConfiguration :: FilePath -> IO Configuration
9295readConfiguration path = decodeFileEither path >>= either throwIO assertConsistency
9396
94−assertConsistency :: Monad m => Configuration -> m Configuration
97+assertConsistency :: MonadFail m => Configuration -> m Configuration
9598assertConsistency cfg@Configuration {..} = do
9699 let report msg = fail ("*** configuration error: " ++ msg)
97100 maintainedPackages = Set.unions (Map.elems packageMaintainers)
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+8−3
@@ -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,6 +16,7 @@ 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"]
@@ -26,7 +28,7 @@ configureCabalFlags' (PackageIdentifier name version)
2628 , enable "dbus"
2729 , disable "debuglocks"
2830 , enable "magicmime"
29− , disable "networkbsd"
31+ , enable "networkbsd"
3032 , enable "pairing"
3133 , enable "production"
3234 , enable "s3"
@@ -57,7 +59,10 @@ configureCabalFlags' (PackageIdentifier name version)
5759 | otherwise = []
5860
5961enable :: String -> (FlagName,Bool)
60−enable name = (mkFlagName name, True)
62+enable name = (mkFlagName' name, True)
6163
6264disable :: String -> (FlagName,Bool)
63−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/Name.hs+3−1
@@ -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"
@@ -94,6 +95,8 @@ 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"
97100libNixName "libqrencode" = return "qrencode"
98101libNixName "libR" = return "R"
99102libNixName "libsoup-gnome-2.4" = return "libsoup"
@@ -200,7 +203,6 @@ buildToolNixName "nix-env" = return "nix"
200203buildToolNixName "nix-hash" = return "nix"
201204buildToolNixName "nix-instantiate" = return "nix"
202205buildToolNixName "nix-store" = return "nix"
203−buildToolNixName "pkg-config" = return "pkgconfig"
204206buildToolNixName x = return (fromString x)
205207
206208-- | Helper function to extract the package name from a String that may or may
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+11−4
@@ -13,6 +13,7 @@ import Data.Set ( Set )
1313import qualified Data.Set as Set
1414import Distribution.Nixpkgs.Haskell
1515import Distribution.Nixpkgs.Meta
16+import Distribution.Nixpkgs.License
1617import Distribution.Package
1718import Distribution.System
1819import Distribution.Text
@@ -21,7 +22,7 @@ import Language.Nix
2122
2223postProcess :: Derivation -> Derivation
2324postProcess deriv =
24− foldr (.) id [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
25+ foldr (.) id [ f | (Dependency n vr _, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
2526 . fixGtkBuilds
2627 . fixBuildDependsForTools
2728 $ deriv
@@ -78,7 +79,7 @@ hooks =
7879 , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
7980 , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
8081 , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
81− , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
82+ , ("bustle", bustleOverrides)
8283 , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
8384 , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
8485 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17
@@ -89,7 +90,7 @@ hooks =
8990 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
9091 , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
9192 , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
92− , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . set (libraryDepends . pkgconfig . contains (pkg "libGLU_combined")) True) -- TODO: fltk14 belongs into the *setup* dependencies.
93+ , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . over (libraryDepends . pkgconfig) (Set.union (pkgs ["libGLU", "libGL"]))) -- TODO: fltk14 belongs into the *setup* dependencies.
9394 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
9495 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
9596 , ("gi-gdk", set runHaddock True )
@@ -255,7 +256,7 @@ gfPhaseOverrides = unlines
255256 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
256257 -- Parallel compilation fails. Disable it.
257258 , "'';"
258− , "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'';"
259260 -- The build step itself, after having built the library, needs to be able
260261 -- to find the library it just built in order to compile grammar files.
261262 ]
@@ -400,3 +401,9 @@ pandocOverrides = set phaseOverrides postInstall
400401 , " mv \"man/\"*.1 $out/share/man/man1/"
401402 , "'';"
402403 ]
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+24−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
@@ -61,7 +64,25 @@ instance FromJSON CompilerInfo where
6164 parseJSON (String s) = return (unknownCompilerInfo (fromString (T.unpack s)) NoAbiTag)
6265 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell compiler")
6366
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+
6485-- parsing tools
6586
66−text2isString :: Text a => String -> String -> a
67−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+9−8
@@ -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,7 @@ 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 )
3435
3536data HpackUse
3637 = ForceHpack
@@ -107,12 +108,12 @@ fromDB hackageDBIO pkg = do
107108 return (ds, setCabalFileHash (DB.cabalFileSha256 vd) (DB.cabalFile vd))
108109 where
109110 pkgId :: Cabal.PackageIdentifier
110− pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)
111+ pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParsec pkg)
111112 name = Cabal.packageName pkgId
112113
113− 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?"
114115
115− url = "mirror://hackage/" ++ display pkgId ++ ".tar.gz"
116+ url = "mirror://hackage/" ++ prettyShow pkgId ++ ".tar.gz"
116117
117118 version :: Version
118119 version = Cabal.packageVersion pkgId
@@ -175,7 +176,7 @@ sourceFromHackage optHash pkgId cabalDir = do
175176 exitFailure
176177
177178showPackageIdentifier :: Cabal.GenericPackageDescription -> String
178−showPackageIdentifier pkgDesc = name ++ "-" ++ display version where
179+showPackageIdentifier pkgDesc = name ++ "-" ++ prettyShow version where
179180 pkgId = Cabal.package . Cabal.packageDescription $ pkgDesc
180181 name = Cabal.unPackageName (Cabal.packageName pkgId)
181182 version = Cabal.packageVersion pkgId
update-stackage.sh+2−3
@@ -25,6 +25,7 @@ sed -r \
2525sed -r \
2626 -e '/ cabal-install /d' \
2727 -e '/ cabal2nix /d' \
28+ -e '/ cabal2spec /d' \
2829 -e '/ distribution-nixpkgs /d' \
2930 -e '/ git-annex /d' \
3031 -e '/ hindent /d' \
@@ -34,8 +35,6 @@ sed -r \
3435 -e '/ hopenssl /d' \
3536 -e '/ jailbreak-cabal /d' \
3637 -e '/ json-autotype/d' \
37− -e '/ lambdabot-core /d' \
38− -e '/ lambdabot-irc-plugins /d' \
3938 -e '/ language-nix /d' \
4039 -e '/ shake /d' \
4140 -e '/ ShellCheck /d' \
@@ -45,7 +44,7 @@ sed -r \
4544
4645# Drop the previous configuration ...
4746# shellcheck disable=SC1004
48−sed -e '/# LTS Haskell/,/^$/c \TODO\
47+sed -e '/ # LTS Haskell/,/^$/c \TODO\
4948' -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml
5049
5150# ... and replace it with the new one.