@@ -4,7 +4,7 @@
4{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
4{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
6module Distribution.Nixpkgs.Haskell.Derivation
6module Distribution.Nixpkgs.Haskell.Derivation
7− ( Derivation, nullDerivation, pkgid, revision, src, isLibrary, isExecutable
7+ ( Derivation, nullDerivation, pkgid, revision, src, subpath, isLibrary, isExecutable
8 , extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags
8 , extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags
9 , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
9 , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
10 , enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection
10 , enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection
@@ -36,6 +36,7 @@ data Derivation = MkDerivation
36 { _pkgid :: PackageIdentifier
36 { _pkgid :: PackageIdentifier
37 , _revision :: Int
37 , _revision :: Int
38 , _src :: DerivationSource
38 , _src :: DerivationSource
39+ , _subpath :: FilePath
39 , _isLibrary :: Bool
40 , _isLibrary :: Bool
40 , _isExecutable :: Bool
41 , _isExecutable :: Bool
41 , _extraFunctionArgs :: Set Binding
42 , _extraFunctionArgs :: Set Binding
@@ -65,6 +66,7 @@ nullDerivation = MkDerivation
65 { _pkgid = error "undefined Derivation.pkgid"
66 { _pkgid = error "undefined Derivation.pkgid"
66 , _revision = error "undefined Derivation.revision"
67 , _revision = error "undefined Derivation.revision"
67 , _src = error "undefined Derivation.src"
68 , _src = error "undefined Derivation.src"
69+ , _subpath = error "undefined Derivation.subpath"
68 , _isLibrary = error "undefined Derivation.isLibrary"
70 , _isLibrary = error "undefined Derivation.isLibrary"
69 , _isExecutable = error "undefined Derivation.isExecutable"
71 , _isExecutable = error "undefined Derivation.isExecutable"
70 , _extraFunctionArgs = error "undefined Derivation.extraFunctionArgs"
72 , _extraFunctionArgs = error "undefined Derivation.extraFunctionArgs"
@@ -104,6 +106,7 @@ instance Pretty Derivation where
104 [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
106 [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
105 , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
107 , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
106 , sourceAttr _src
108 , sourceAttr _src
109+ , onlyIf (_subpath /= ".") $ attr "postUnpack" postUnpack
107 , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision
110 , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision
108 , onlyIf (not (null _editedCabalFile) && _revision > 0) $ attr "editedCabalFile" $ string _editedCabalFile
111 , onlyIf (not (null _editedCabalFile) && _revision > 0) $ attr "editedCabalFile" $ string _editedCabalFile
109 , listattr "configureFlags" empty (map (show . show) renderedFlags)
112 , listattr "configureFlags" empty (map (show . show) renderedFlags)
@@ -149,3 +152,8 @@ instance Pretty Derivation where
149 , rbrace <> semi
152 , rbrace <> semi
151 | otherwise = attr "src" $ text derivUrl
154 | otherwise = attr "src" $ text derivUrl
156+ postUnpack = doubleQuotes $ vcat
157+ [ text "sourceRoot=\\${sourceRoot}/" <> text _subpath
158+ , text "echo Source root reset to \\${sourceRoot}"