MCPcopy Index your code
hub / github.com/jetify-com/devbox / FixInstallableArgs

Function FixInstallableArgs

internal/nix/nix.go:269–287  ·  view source on GitHub ↗

FixInstallableArgs removes the narHash and lastModifiedDate query parameters from any args that are valid installables and the Nix version is <2.25. Otherwise it returns them unchanged. This fixes an issues with some older versions of Nix where specifying a narHash without a lastModifiedDate result

(args []string)

Source from the content-addressed store, hash-verified

267// This fixes an issues with some older versions of Nix where specifying a
268// narHash without a lastModifiedDate results in an error.
269func FixInstallableArgs(args []string) {
270 if AtLeast(Version2_25) {
271 return
272 }
273
274 for i := range args {
275 parsed, _ := flake.ParseInstallable(args[i])
276 if parsed.Ref.NARHash == "" && parsed.Ref.LastModified == 0 {
277 continue
278 }
279 if parsed.Ref.NARHash != "" && parsed.Ref.LastModified != 0 {
280 continue
281 }
282
283 parsed.Ref.NARHash = ""
284 parsed.Ref.LastModified = 0
285 args[i] = parsed.String()
286 }
287}
288
289// fixInstallableArg calls fixInstallableArgs with a single argument.
290func FixInstallableArg(arg string) string {

Callers 4

FixInstallableArgFunction · 0.85
BuildFunction · 0.85
ProfileInstallFunction · 0.85
ProfileRemoveFunction · 0.85

Calls 3

ParseInstallableFunction · 0.92
AtLeastFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected