Skip to content

Commit 7d24526

Browse files
authored
Merge pull request #497 from nix-community/go-rust
drop cargoSha256, vendorSha256, match buildGo
2 parents 5270bf9 + b64e4f6 commit 7d24526

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Nix.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ getDerivationFile attrPath = do
138138
& fmapRT (fst >>> T.strip >>> T.stripPrefix (T.pack npDir <> "/") >>> fromJust)
139139

140140
-- Get an attribute that can be evaluated off a derivation, as in:
141-
-- getAttr "cargoSha256" "ripgrep" -> 0lwz661rbm7kwkd6mallxym1pz8ynda5f03ynjfd16vrazy2dj21
141+
-- getAttr "cargoHash" "ripgrep" -> 0lwz661rbm7kwkd6mallxym1pz8ynda5f03ynjfd16vrazy2dj21
142142
getAttr :: MonadIO m => Text -> Text -> ExceptT Text m Text
143143
getAttr attr = srcOrMain (nixEvalApply ("p: p." <> attr))
144144

@@ -204,7 +204,7 @@ numberOfFetchers derivationContents =
204204
-- Sum the number of things that look like fixed-output derivation hashes
205205
numberOfHashes :: Text -> Int
206206
numberOfHashes derivationContents =
207-
sum $ map countUp ["sha256 =", "sha256=", "cargoSha256 =", "cargoHash =", "vendorSha256 =", "vendorHash =", "hash =", "npmDepsHash ="]
207+
sum $ map countUp ["sha256 =", "sha256=", "cargoHash =", "vendorHash =", "hash =", "npmDepsHash ="]
208208
where
209209
countUp x = T.count x derivationContents
210210

src/Rewrite.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,17 @@ redirectedUrls log Args {..} = do
126126
--------------------------------------------------------------------------------
127127
-- Rewrite Rust on rustPlatform.buildRustPackage
128128
-- This is basically `version` above, but with a second pass to also update the
129-
-- cargoSha256 vendor hash.
129+
-- cargoHash vendor hash.
130130
rustCrateVersion :: MonadIO m => (Text -> m ()) -> Args -> ExceptT Text m (Maybe Text)
131131
rustCrateVersion log args@Args {..} = do
132132
if
133-
| and [(not (T.isInfixOf "cargoSha256" derivationContents)), (not (T.isInfixOf "cargoHash" derivationContents))] -> do
134-
lift $ log "No cargoSha256 or cargoHash found"
133+
| (not (T.isInfixOf "cargoHash" derivationContents)) -> do
134+
lift $ log "No cargoHash found"
135135
return Nothing
136136
| hasUpdateScript -> do
137137
lift $ log "skipping because derivation has updateScript"
138138
return Nothing
139139
| otherwise -> do
140-
_ <- lift $ File.replaceIO "cargoSha256 =" "cargoHash =" derivationFile
141140
-- This starts the same way `version` does, minus the assert
142141
srcVersionFix args
143142
-- But then from there we need to do this a second time for the cargoHash!
@@ -160,14 +159,13 @@ rustCrateVersion log args@Args {..} = do
160159
golangModuleVersion :: MonadIO m => (Text -> m ()) -> Args -> ExceptT Text m (Maybe Text)
161160
golangModuleVersion log args@Args {..} = do
162161
if
163-
| and [not (T.isInfixOf "buildGoModule" derivationContents && T.isInfixOf "vendorSha256" derivationContents), not (T.isInfixOf "buildGoModule" derivationContents && T.isInfixOf "vendorHash" derivationContents)] -> do
164-
lift $ log "Not a buildGoModule package with vendorSha256 or vendorHash"
162+
| not (T.isInfixOf "buildGo" derivationContents && T.isInfixOf "vendorHash" derivationContents) -> do
163+
lift $ log "Not a buildGoModule package with vendorHash"
165164
return Nothing
166165
| hasUpdateScript -> do
167166
lift $ log "skipping because derivation has updateScript"
168167
return Nothing
169168
| otherwise -> do
170-
_ <- lift $ File.replaceIO "vendorSha256 =" "vendorHash =" derivationFile
171169
-- This starts the same way `version` does, minus the assert
172170
srcVersionFix args
173171
-- But then from there we need to do this a second time for the vendorHash!
@@ -197,7 +195,7 @@ golangModuleVersion log args@Args {..} = do
197195
--------------------------------------------------------------------------------
198196
-- Rewrite NPM packages with buildNpmPackage
199197
-- This is basically `version` above, but with a second pass to also update the
200-
-- cargoSha256 vendor hash.
198+
-- npmDepsHash vendor hash.
201199
npmDepsVersion :: MonadIO m => (Text -> m ()) -> Args -> ExceptT Text m (Maybe Text)
202200
npmDepsVersion log args@Args {..} = do
203201
if

0 commit comments

Comments
 (0)