From 8e937729aa423b2bd2608ab3abb7fd02b64f17fc Mon Sep 17 00:00:00 2001 From: Daniel Gorin Date: Fri, 11 Jan 2019 13:28:29 +0000 Subject: [PATCH 1/3] Use configureCabalFlags from cabal2nix The function `configureCabalFlags` has a list of packages that should be called with certain flags when passing them to `cabal2nix`. For example, for `hslua`, it specifies that it is to used the "system" version of lua (the one provided by nix) and not the version of lua that comes embedded in the package. Notice that cabal2nix assumes assumes this flag in newer versions of its `postProcess` method, and if the flag is not given, it will fail attempting to replace package "lua" by "lua_5_3". --- src/Distribution/Nixpkgs/Haskell/FromStack.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Distribution/Nixpkgs/Haskell/FromStack.hs b/src/Distribution/Nixpkgs/Haskell/FromStack.hs index e16859a..ad2857f 100644 --- a/src/Distribution/Nixpkgs/Haskell/FromStack.hs +++ b/src/Distribution/Nixpkgs/Haskell/FromStack.hs @@ -5,11 +5,12 @@ import Control.Lens import Data.Set.Lens import Distribution.Compiler (CompilerInfo(..)) import Distribution.System (Platform(..)) -import Distribution.Package (PackageName, PackageIdentifier(..), Dependency(..)) +import Distribution.Package (PackageName, PackageIdentifier(..), Dependency(..), packageId) import Distribution.PackageDescription import Distribution.Nixpkgs.Haskell.FromStack.Package import Distribution.Nixpkgs.Haskell.PackageSourceSpec import Distribution.Nixpkgs.Haskell.FromCabal +import Distribution.Nixpkgs.Haskell.FromCabal.Flags (configureCabalFlags) import Distribution.Nixpkgs.Haskell.Derivation import Stackage.BuildPlan import Stackage.Types (CabalFileInfo(..),PackageConstraints(..), DepInfo(..), SimpleDesc(..), TestState(..)) @@ -63,19 +64,20 @@ fromPackage conf pconf plan pkg = configureBenches | pcBenches constraints == Don'tBuild = removeBenches | otherwise = id - flags = Map.toList (pcFlagOverrides constraints) + defaultFlags = configureCabalFlags (packageId (pkgCabal pkg)) + flags = defaultFlags <> mkFlagAssignment (Map.toList $ pcFlagOverrides constraints) (descr, missingDeps) = finalizeGenericPackageDescription (haskellResolver conf) (targetPlatform conf) (targetCompiler conf) - (mkFlagAssignment flags) + flags (planDependencies plan) (configureBenches . configureTests $ pkgCabal pkg) genericDrv = fromPackageDescription (haskellResolver conf) (nixpkgsResolver conf) missingDeps - (mkFlagAssignment flags) + flags descr depName (Dependency name _) = name testDeps = setOf From 3c87cb9be30c7ebb3b109c094c0251228f0c3379 Mon Sep 17 00:00:00 2001 From: Daniel Gorin Date: Thu, 10 Jan 2019 17:50:42 +0000 Subject: [PATCH 2/3] Use a newer version of cabal2nix --- src/Distribution/Nixpkgs/Haskell/Stack.hs | 1 + src/LtsHaskell.hs | 2 +- stack.yaml | 5 ++++- stackage2nix.cabal | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Distribution/Nixpkgs/Haskell/Stack.hs b/src/Distribution/Nixpkgs/Haskell/Stack.hs index 1585d7b..82dca0f 100644 --- a/src/Distribution/Nixpkgs/Haskell/Stack.hs +++ b/src/Distribution/Nixpkgs/Haskell/Stack.hs @@ -32,6 +32,7 @@ makeLenses ''StackPackagesConfig getStackPackageFromDb :: DB.HackageDB -> StackPackage -> IO Package getStackPackageFromDb hackageDb stackPackage = do PackageSourceSpec.getPackage' + False False (pure hackageDb) (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir)) diff --git a/src/LtsHaskell.hs b/src/LtsHaskell.hs index 21f2676..84d4431 100644 --- a/src/LtsHaskell.hs +++ b/src/LtsHaskell.hs @@ -46,7 +46,7 @@ getPackageFromRepo allCabalHashesPath mSha1Hash pkgId = do tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no SHA256 hash for the tarball")) (view (mHashes . at "SHA256") meta) - source = DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256 + source = DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256 Nothing return $ Package source False pkgDesc getPackageFromDb :: DB.HackageDB -> PackageIdentifier -> IO Package diff --git a/stack.yaml b/stack.yaml index 4ba6f65..eafcb3f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,9 @@ resolver: lts-12.2 extra-deps: - - yaml-0.8.31.1 + - cabal2nix-2.13 + - hpack-0.31.1 + - infer-license-0.2.0 + - yaml-0.10.0 - git: https://github.com/fpco/stackage-curator.git commit: 73c5ed06602990c33d3fec1711e27875f283b6bf - git: https://github.com/jwiegley/gitlib.git diff --git a/stackage2nix.cabal b/stackage2nix.cabal index ad6aa37..0d1d2f4 100644 --- a/stackage2nix.cabal +++ b/stackage2nix.cabal @@ -35,7 +35,7 @@ library , QuickCheck , aeson , bytestring - , cabal2nix >= 2.7.2 + , cabal2nix >= 2.11 , containers , deepseq , distribution-nixpkgs >= 1.1 From 22e5e1f29cb83be00b67b0f3dbf8346b67d1af61 Mon Sep 17 00:00:00 2001 From: Daniel Gorin Date: Fri, 11 Jan 2019 13:41:44 +0000 Subject: [PATCH 3/3] Add support for building using nix Adds a `nix` section in the stack.yaml, as an `opt-in`, so it shouldn't break previous behaviour. --- stack.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index eafcb3f..08b88a0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-12.2 +resolver: lts-12.16 extra-deps: - cabal2nix-2.13 - hpack-0.31.1 @@ -12,3 +12,6 @@ extra-deps: - gitlib - gitlib-libgit2 +nix: + enable: false # run stack with --nix to enable + packages: [ icu, openssl, zlib ]