@@ -19,10 +19,11 @@ module Distribution.NixOS.Derivation.Cabal
22import Distribution.NixOS.Derivation.Meta
23import Distribution.NixOS.Derivation.Meta
23import Distribution.NixOS.PrettyPrinting
24import Distribution.NixOS.PrettyPrinting
24−import Distribution.Text
25import Distribution.Package
25import Distribution.Package
26+import Distribution.Text
26#ifdef __HADDOCK__
27#ifdef __HADDOCK__
27import Distribution.PackageDescription ( PackageDescription )
28import Distribution.PackageDescription ( PackageDescription )
@@ -43,7 +44,8 @@ import Text.Regex.Posix hiding ( empty )
43data Derivation = MkDerivation
44data Derivation = MkDerivation
44 { pname :: String
45 { pname :: String
45 , version :: Version
46 , version :: Version
47+ , sha256 :: Maybe String
46− , sha256 :: String
48+ , src :: Maybe String
47 , isLibrary :: Bool
49 , isLibrary :: Bool
48 , isExecutable :: Bool
50 , isExecutable :: Bool
49 , buildDepends :: [String]
51 , buildDepends :: [String]
@@ -73,11 +75,13 @@ renderDerivation :: Derivation -> Doc
73renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
75renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
75 , text "cabal.mkDerivation" <+> lparen <> text "self" <> colon <+> lbrace
77 , text "cabal.mkDerivation" <+> lparen <> text "self" <> colon <+> lbrace
76− , nest 2 $ vcat
78+ , nest 2 $ vcat $
77 [ attr "pname" $ string (pname deriv)
79 [ attr "pname" $ string (pname deriv)
78 , attr "version" $ doubleQuotes (disp (version deriv))
80 , attr "version" $ doubleQuotes (disp (version deriv))
79− , attr "sha256" $ string (sha256 deriv)
81+ ] ++ maybeToList (fmap (attr "sha256" . string) $ sha256 deriv)
82+ ++ maybeToList (fmap (attr "src" . string) $ src deriv)
80− , boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)
84+ [ boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)
81 , boolattr "isExecutable" (not (isLibrary deriv) || isExecutable deriv) (isExecutable deriv)
85 , boolattr "isExecutable" (not (isLibrary deriv) || isExecutable deriv) (isExecutable deriv)
82 , listattr "buildDepends" (buildDepends deriv)
86 , listattr "buildDepends" (buildDepends deriv)
83 , listattr "testDepends" (testDepends deriv)
87 , listattr "testDepends" (testDepends deriv)
@@ -111,7 +115,8 @@ parseDerivation buf
111 , [name] <- buf `regsubmatch` "pname *= *\"([^\"]+)\""
115 , [name] <- buf `regsubmatch` "pname *= *\"([^\"]+)\""
112 , [vers'] <- buf `regsubmatch` "version *= *\"([^\"]+)\""
116 , [vers'] <- buf `regsubmatch` "version *= *\"([^\"]+)\""
113 , Just vers <- simpleParse vers'
117 , Just vers <- simpleParse vers'
114− , [sha] <- buf `regsubmatch` "sha256 *= *\"([^\"]+)\""
118+ , sha <- buf `regsubmatch` "sha256 *= *\"([^\"]+)\""
119+ , sr <- buf `regsubmatch` "src *= *([^;]+);"
115 , plats <- buf `regsubmatch` "platforms *= *([^;]+);"
120 , plats <- buf `regsubmatch` "platforms *= *([^;]+);"
116 , hplats <- buf `regsubmatch` "hydraPlatforms *= *([^;]+);"
121 , hplats <- buf `regsubmatch` "hydraPlatforms *= *([^;]+);"
117 , maint <- buf `regsubmatch` "maintainers *= *\\[([^\"]+)]"
122 , maint <- buf `regsubmatch` "maintainers *= *\\[([^\"]+)]"
@@ -121,7 +126,8 @@ parseDerivation buf
121 = Just MkDerivation
126 = Just MkDerivation
122 { pname = name
127 { pname = name
123 , version = vers
128 , version = vers
124− , sha256 = sha
129+ , sha256 = listToMaybe sha
130+ , src = listToMaybe sr
125 , isLibrary = False
131 , isLibrary = False
126 , isExecutable = False
132 , isExecutable = False
127 , buildDepends = []
133 , buildDepends = []