git.iko.soy/typeable/cabal2nix
on master help sign in
Remove the freaky IsString Binding instance and replace it by proper functions.
ff5ec31Peter Simons
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+33−19
@@ -2,14 +2,16 @@
2
2
3module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess ) where
3module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess ) where
4
4
5−import Control.Lens
5+import Internal.Lens
6import Data.Maybe
6import Data.Maybe
7+import Data.Set ( Set )
7import qualified Data.Set as Set
8import qualified Data.Set as Set
8import Distribution.Nixpkgs.Haskell
9import Distribution.Nixpkgs.Haskell
9import Distribution.Package
10import Distribution.Package
10import Distribution.Text
11import Distribution.Text
11import Distribution.Version
12import Distribution.Version
12−import Language.Nix ( ) -- IsString instance for Binding
13+import Language.Nix
14+import Data.List.Split
13
15
14postProcess :: Derivation -> Derivation
16postProcess :: Derivation -> Derivation
15postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
17postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
@@ -21,31 +23,43 @@ fixGtkBuilds drv = drv & dependencies . pkgconfig %~ (`Set.difference` buildDeps
21
23
22hooks :: [(Dependency, Derivation -> Derivation)]
24hooks :: [(Dependency, Derivation -> Derivation)]
23hooks = over (mapped._1) (\str -> fromMaybe (error ("invalid constraint: " ++ show str)) (simpleParse str))
25hooks = over (mapped._1) (\str -> fromMaybe (error ("invalid constraint: " ++ show str)) (simpleParse str))
24− [ ("Agda", set (executableDepends . tool . contains "emacs") True . set phaseOverrides agdaPostInstall)
26+ [ ("Agda", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agdaPostInstall)
25 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
27 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
26− , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList ["libXext", "libXfixes"])))
28+ , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [pkg "libXext", pkg "libXfixes"])))
27 , ("cabal-install", set phaseOverrides cabalInstallPostInstall)
29 , ("cabal-install", set phaseOverrides cabalInstallPostInstall)
28 , ("darcs", set phaseOverrides darcsInstallPostInstall)
30 , ("darcs", set phaseOverrides darcsInstallPostInstall)
29 , ("git-annex", gitAnnexHook)
31 , ("git-annex", gitAnnexHook)
30 , ("haddock", set phaseOverrides "preCheck = \"unset GHC_PACKAGE_PATH\";")
32 , ("haddock", set phaseOverrides "preCheck = \"unset GHC_PACKAGE_PATH\";")
31 , ("HFuse", set phaseOverrides hfusePreConfigure)
33 , ("HFuse", set phaseOverrides hfusePreConfigure)
32 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
34 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
33− , ("github-backup", set (executableDepends . tool . contains "git") True)
35+ , ("github-backup", set (executableDepends . tool . contains (pkg "git")) True)
34− , ("GlomeVec", set (libraryDepends . pkgconfig . contains "llvm") True)
36+ , ("GlomeVec", set (libraryDepends . pkgconfig . contains (bind "self.llvmPackages.llvm")) True)
35− , ("gtk3", set (libraryDepends . pkgconfig . contains "gtk3") True) -- https://github.com/NixOS/cabal2nix/issues/145
37+ , ("gtk3", set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True) -- https://github.com/NixOS/cabal2nix/issues/145
36− , ("imagemagick", set (libraryDepends . pkgconfig . contains "imagemagick") True) -- https://github.com/NixOS/cabal2nix/issues/136
38+ , ("imagemagick", set (libraryDepends . pkgconfig . contains (pkg "imagemagick")) True) -- https://github.com/NixOS/cabal2nix/issues/136
37− , ("jsaddle", set (dependencies . haskell . contains "ghcjs-base") False)
39+ , ("jsaddle", set (dependencies . haskell . contains (pkg "ghcjs-base")) False)
38− , ("mysql", set (libraryDepends . system . contains "mysql") True)
40+ , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True)
39− , ("pango", set (libraryDepends . haskell . contains "cairo") True)
41+ , ("pango", set (libraryDepends . haskell . contains (pkg "cairo")) True)
40− , ("readline", over (libraryDepends . system) (Set.union (Set.fromList ["readline", "ncurses"])))
42+ , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
41− , ("terminfo", set (libraryDepends . system . contains "ncurses") True)
43+ , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True)
42− , ("thyme", set (libraryDepends . tool . contains "cpphs") True) -- required on Darwin
44+ , ("thyme", set (libraryDepends . tool . contains (pkg "cpphs")) True) -- required on Darwin
43 , ("monad", set phaseOverrides xmonadPostInstall)
45 , ("monad", set phaseOverrides xmonadPostInstall)
44 , ("wxc", wxcHook)
46 , ("wxc", wxcHook)
45− , ("wxcore", set (libraryDepends . pkgconfig . contains "wxGTK") True)
47+ , ("wxcore", set (libraryDepends . pkgconfig . contains (pkg "wxGTK")) True)
46− , ("X11", over (libraryDepends . system) (Set.union (Set.fromList ["libXinerama","libXext","libXrender"])))
48+ , ("X11", over (libraryDepends . system) (Set.union (pkgs ["libXinerama","libXext","libXrender"])))
47 ]
49 ]
48
50
51+pkg :: Identifier -> Binding
52+pkg i = create binding (i, create path ["pkgs",i])
53+
54+pkgs :: [Identifier] -> Set Binding
55+pkgs = Set.fromList . map pkg
56+
57+bind :: String -> Binding
58+bind s = create binding (i, create path is)
59+ where
60+ is = map (create ident) (splitOn "." s)
61+ i = last is
62+
49gitAnnexHook :: Derivation -> Derivation
63gitAnnexHook :: Derivation -> Derivation
50gitAnnexHook = set phaseOverrides gitAnnexOverrides . over (executableDepends . system) (Set.union buildInputs)
64gitAnnexHook = set phaseOverrides gitAnnexOverrides . over (executableDepends . system) (Set.union buildInputs)
51 where
65 where
@@ -55,7 +69,7 @@ gitAnnexHook = set phaseOverrides gitAnnexOverrides . over (executableDepends .
55 , "installPhase = \"make PREFIX=$out CABAL=./Setup install\";"
69 , "installPhase = \"make PREFIX=$out CABAL=./Setup install\";"
56 , "checkPhase = \"./git-annex test\";"
70 , "checkPhase = \"./git-annex test\";"
57 ]
71 ]
58− buildInputs = Set.fromList ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
72+ buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
59
73
60hfusePreConfigure :: String
74hfusePreConfigure :: String
61hfusePreConfigure = unlines
75hfusePreConfigure = unlines
@@ -79,8 +93,8 @@ gfPhaseOverrides = unlines
79 ]
93 ]
80
94
81wxcHook :: Derivation -> Derivation
95wxcHook :: Derivation -> Derivation
82−wxcHook drv = drv & libraryDepends . system %~ Set.union (Set.fromList ["mesa", "libX11"])
96+wxcHook drv = drv & libraryDepends . system %~ Set.union (Set.fromList [pkg "mesa", pkg "libX11"])
83− & libraryDepends . pkgconfig . contains "wxGTK" .~ True
97+ & libraryDepends . pkgconfig . contains (pkg "wxGTK") .~ True
84 & phaseOverrides .~ wxcPostInstall (packageVersion drv)
98 & phaseOverrides .~ wxcPostInstall (packageVersion drv)
85 & runHaddock .~ False
99 & runHaddock .~ False
86 where
100 where
src/Language/Nix/Binding.hs−4
@@ -4,7 +4,6 @@
4module Language.Nix.Binding ( Binding, binding, localName, reference ) where
4module Language.Nix.Binding ( Binding, binding, localName, reference ) where
5
5
6import Control.DeepSeq.Generics
6import Control.DeepSeq.Generics
7−import Data.String
8import GHC.Generics ( Generic )
7import GHC.Generics ( Generic )
9import Internal.Lens
8import Internal.Lens
10import Internal.PrettyPrinting
9import Internal.PrettyPrinting
@@ -19,9 +18,6 @@ makeLenses ''Binding
19binding :: Lens' Binding (Identifier,Path)
18binding :: Lens' Binding (Identifier,Path)
20binding f (Bind l r) = uncurry Bind `fmap` f (l, r)
19binding f (Bind l r) = uncurry Bind `fmap` f (l, r)
21
20
22−instance IsString Binding where -- TODO: This instance feels dangerous!
23− fromString s = Bind i (create path [i]) where i = fromString s
24−
25instance NFData Binding where rnf = genericRnf
21instance NFData Binding where rnf = genericRnf
26
22
27instance Default Binding where
23instance Default Binding where