on master help sign in
Move path functions into utils module
31b5c01Alexandre Esteves
lib/command/src/Obelisk/Command/Thunk.hs+2−3
@@ -58,7 +58,6 @@ import System.FilePath
58import System.IO.Error
58import System.IO.Error
59import System.IO.Temp
59import System.IO.Temp
60import System.PosixCompat.Files (getSymbolicLinkStatus, modificationTime)
60import System.PosixCompat.Files (getSymbolicLinkStatus, modificationTime)
61−import System.Which (staticWhich)
62import qualified Text.URI as URI
61import qualified Text.URI as URI
63
62
64import Obelisk.App (MonadObelisk)
63import Obelisk.App (MonadObelisk)
@@ -180,14 +179,14 @@ getNixSha256ForUriUnpacked
180getNixSha256ForUriUnpacked uri =
179getNixSha256ForUriUnpacked uri =
181 withExitFailMessage ("nix-prefetch-url: Failed to determine sha256 hash of URL " <> gitUriToText uri) $ do
180 withExitFailMessage ("nix-prefetch-url: Failed to determine sha256 hash of URL " <> gitUriToText uri) $ do
182 [hash] <- fmap T.lines $ readProcessAndLogOutput (Debug, Debug) $
181 [hash] <- fmap T.lines $ readProcessAndLogOutput (Debug, Debug) $
183− proc $(staticWhich "nix-prefetch-url") ["--unpack", "--type", "sha256", T.unpack $ gitUriToText uri]
182+ proc nixPrefetchUrlPath ["--unpack", "--type", "sha256", T.unpack $ gitUriToText uri]
184 pure hash
183 pure hash
185
184
186nixPrefetchGit :: MonadObelisk m => GitUri -> Text -> Bool -> m NixSha256
185nixPrefetchGit :: MonadObelisk m => GitUri -> Text -> Bool -> m NixSha256
187nixPrefetchGit uri rev fetchSubmodules =
186nixPrefetchGit uri rev fetchSubmodules =
188 withExitFailMessage ("nix-prefetch-git: Failed to determine sha256 hash of Git repo " <> gitUriToText uri <> " at " <> rev) $ do
187 withExitFailMessage ("nix-prefetch-git: Failed to determine sha256 hash of Git repo " <> gitUriToText uri <> " at " <> rev) $ do
189 out <- readProcessAndLogStderr Debug $
188 out <- readProcessAndLogStderr Debug $
190− proc $(staticWhich "nix-prefetch-git") $ filter (/="")
189+ proc nixPrefetchGitPath $ filter (/="")
191 [ "--url", T.unpack $ gitUriToText uri
190 [ "--url", T.unpack $ gitUriToText uri
192 , "--rev", T.unpack rev
191 , "--rev", T.unpack rev
193 , if fetchSubmodules then "--fetch-submodules" else ""
192 , if fetchSubmodules then "--fetch-submodules" else ""
lib/command/src/Obelisk/Command/Utils.hs+6
@@ -54,6 +54,12 @@ nixBuildExePath = $(staticWhich "nix-build")
54jreKeyToolPath :: FilePath
54jreKeyToolPath :: FilePath
55jreKeyToolPath = $(staticWhich "keytool")
55jreKeyToolPath = $(staticWhich "keytool")
56
56
57+nixPrefetchGitPath :: FilePath
58+nixPrefetchGitPath = $(staticWhich "nix-prefetch-git")
59+
60+nixPrefetchUrlPath :: FilePath
61+nixPrefetchUrlPath = $(staticWhich "nix-prefetch-url")
62+
57-- | Nix syntax requires relative paths to be prefixed by @./@ or
63-- | Nix syntax requires relative paths to be prefixed by @./@ or
58-- @../@. This will make a 'FilePath' that can be embedded in a Nix
64-- @../@. This will make a 'FilePath' that can be embedded in a Nix
59-- expression.
65-- expression.