Skip to content

Commit

Permalink
Merge pull request #93 from Mic92/manual-file
Browse files Browse the repository at this point in the history
allow to manually override filename that is patched
  • Loading branch information
Mic92 authored Jun 14, 2022
2 parents d74ad3f + 06dd722 commit 3143af0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions nix_update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -69,6 +75,7 @@ def parse_args() -> Options:
version_regex=args.version_regex,
review=args.review,
format=args.format,
override_filename=args.override_filename,
)


Expand Down
2 changes: 2 additions & 0 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions nix_update/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3143af0

Please sign in to comment.