@@ -4,7 +4,7 @@
44{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
55
66module Distribution.Nixpkgs.Haskell.Derivation
7− ( Derivation, nullDerivation, pkgid, revision, src, isLibrary, isExecutable
7+ ( Derivation, nullDerivation, pkgid, revision, src, subpath, isLibrary, isExecutable
88 , extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags
99 , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
1010 , enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection
@@ -36,6 +36,7 @@ data Derivation = MkDerivation
3636 { _pkgid :: PackageIdentifier
3737 , _revision :: Int
3838 , _src :: DerivationSource
39+ , _subpath :: FilePath
3940 , _isLibrary :: Bool
4041 , _isExecutable :: Bool
4142 , _extraFunctionArgs :: Set Binding
@@ -65,6 +66,7 @@ nullDerivation = MkDerivation
6566 { _pkgid = error "undefined Derivation.pkgid"
6667 , _revision = error "undefined Derivation.revision"
6768 , _src = error "undefined Derivation.src"
69+ , _subpath = error "undefined Derivation.subpath"
6870 , _isLibrary = error "undefined Derivation.isLibrary"
6971 , _isExecutable = error "undefined Derivation.isExecutable"
7072 , _extraFunctionArgs = error "undefined Derivation.extraFunctionArgs"
@@ -104,6 +106,7 @@ instance Pretty Derivation where
104106 [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
105107 , attr "version" $ doubleQuotes $ disp (packageVersion _pkgid)
106108 , sourceAttr _src
109+ , onlyIf (_subpath /= ".") $ attr "postUnpack" postUnpack
107110 , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision
108111 , onlyIf (not (null _editedCabalFile) && _revision > 0) $ attr "editedCabalFile" $ string _editedCabalFile
109112 , listattr "configureFlags" empty (map (show . show) renderedFlags)
@@ -149,3 +152,8 @@ instance Pretty Derivation where
149152 , rbrace <> semi
150153 ]
151154 | otherwise = attr "src" $ text derivUrl
155+
156+ postUnpack = doubleQuotes $ vcat
157+ [ text "sourceRoot=\\${sourceRoot}/" <> text _subpath
158+ , text "echo Source root reset to \\${sourceRoot}"
159+ ]