@@ -19,10 +19,11 @@ module Distribution.NixOS.Derivation.Cabal
1919 )
2020 where
2121
22+import Data.Maybe
2223import Distribution.NixOS.Derivation.Meta
2324import Distribution.NixOS.PrettyPrinting
24−import Distribution.Text
2525import Distribution.Package
26+import Distribution.Text
2627#ifdef __HADDOCK__
2728import Distribution.PackageDescription ( PackageDescription )
2829#endif
@@ -43,7 +44,8 @@ import Text.Regex.Posix hiding ( empty )
4344data Derivation = MkDerivation
4445 { pname :: String
4546 , version :: Version
46− , sha256 :: String
47+ , sha256 :: Maybe String
48+ , src :: Maybe String
4749 , isLibrary :: Bool
4850 , isExecutable :: Bool
4951 , buildDepends :: [String]
@@ -73,11 +75,13 @@ renderDerivation :: Derivation -> Doc
7375renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
7476 [ text ""
7577 , text "cabal.mkDerivation" <+> lparen <> text "self" <> colon <+> lbrace
76− , nest 2 $ vcat
78+ , nest 2 $ vcat $
7779 [ attr "pname" $ string (pname deriv)
7880 , attr "version" $ doubleQuotes (disp (version deriv))
79− , attr "sha256" $ string (sha256 deriv)
80− , boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)
81+ ] ++ maybeToList (fmap (attr "sha256" . string) $ sha256 deriv)
82+ ++ maybeToList (fmap (attr "src" . string) $ src deriv)
83+ ++
84+ [ boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)
8185 , boolattr "isExecutable" (not (isLibrary deriv) || isExecutable deriv) (isExecutable deriv)
8286 , listattr "buildDepends" (buildDepends deriv)
8387 , listattr "testDepends" (testDepends deriv)
@@ -111,7 +115,8 @@ parseDerivation buf
111115 , [name] <- buf `regsubmatch` "pname *= *\"([^\"]+)\""
112116 , [vers'] <- buf `regsubmatch` "version *= *\"([^\"]+)\""
113117 , Just vers <- simpleParse vers'
114− , [sha] <- buf `regsubmatch` "sha256 *= *\"([^\"]+)\""
118+ , sha <- buf `regsubmatch` "sha256 *= *\"([^\"]+)\""
119+ , sr <- buf `regsubmatch` "src *= *([^;]+);"
115120 , plats <- buf `regsubmatch` "platforms *= *([^;]+);"
116121 , hplats <- buf `regsubmatch` "hydraPlatforms *= *([^;]+);"
117122 , maint <- buf `regsubmatch` "maintainers *= *\\[([^\"]+)]"
@@ -121,7 +126,8 @@ parseDerivation buf
121126 = Just MkDerivation
122127 { pname = name
123128 , version = vers
124− , sha256 = sha
129+ , sha256 = listToMaybe sha
130+ , src = listToMaybe sr
125131 , isLibrary = False
126132 , isExecutable = False
127133 , buildDepends = []