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)
| 267 | // This fixes an issues with some older versions of Nix where specifying a |
| 268 | // narHash without a lastModifiedDate results in an error. |
| 269 | func 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. |
| 290 | func FixInstallableArg(arg string) string { |
no test coverage detected