allow to manually override filename that is patched

This commit is contained in:
Jörg Thalheim 2022-06-14 11:10:13 +02:00
parent 438badbb01
commit 06dd722d36
5 changed files with 17 additions and 1 deletions

View File

@ -91,6 +91,13 @@ a regex can be used
$ nix-update jq --version-regex 'jq-(.*)'
```
By default `nix-update` will locate the file that needs to be patched using the `src` attribute of a derivation.
In some cases this heurestic is wrong. One can override the behavior like that:
``` console
$ nix-update hello --override-filename pkgs/applications/misc/hello/default.nix
```
With the `--shell`, `--build`, `--test` and `--run` flags the update can be
tested. Additionally, the `--review` flag can be used to
initiate a run of [nixpkgs-review](https://github.com/Mic92/nixpkgs-review), which will ensure all

View File

@ -53,6 +53,12 @@ def parse_args() -> Options:
parser.add_argument(
"--version", nargs="?", help="Version to update to", default="stable"
)
parser.add_argument(
"--override-filename",
nargs="?",
help="Set filename where nix-update will update version/hash",
default=None,
)
parser.add_argument("attribute", help="Attribute name within the file evaluated")
args = parser.parse_args()
return Options(
@ -69,6 +75,7 @@ def parse_args() -> Options:
version_regex=args.version_regex,
review=args.review,
format=args.format,
override_filename=args.override_filename,
)

View File

@ -89,6 +89,8 @@ def eval_attr(opts: Options) -> Package:
res = run(cmd)
out = json.loads(res.stdout)
package = Package(attribute=opts.attribute, **out)
if opts.override_filename is not None:
package.filename = opts.override_filename
if opts.version_preference != VersionPreference.SKIP and package.old_version == "":
raise UpdateError(
f"Nix's builtins.parseDrvName could not parse the version from {package.name}"

View File

@ -10,6 +10,7 @@ class Options:
version_preference: VersionPreference = VersionPreference.STABLE
version_regex: str = "(.*)"
import_path: str = "./."
override_filename: Optional[str] = None
commit: bool = False
write_commit_message: Optional[str] = None
shell: bool = False

View File

@ -122,7 +122,6 @@ def update_version(
raise UpdateError(
"Could not find a url in the derivations src attribute"
)
version
new_version = fetch_latest_version(package.url, preference, version_regex)
package.new_version = new_version
position = package.version_position