nix-update: add url parameter to override the repository discovery

This commit is contained in:
Jörg Thalheim 2023-01-26 09:56:16 +01:00
parent 0bfc4701aa
commit ab45f140f6
4 changed files with 20 additions and 0 deletions

View File

@ -118,6 +118,18 @@ In some cases this heurestic is wrong. One can override the behavior like that:
$ nix-update hello --override-filename pkgs/applications/misc/hello/default.nix
```
The `nix-update` command checks for new releases of a package using the `src`
attribute. However, in some cases a package may use a non-standard release URL
that is not supported by `nix-update`, but still has a repository with release
information. For example, the Signal Desktop package in Nixpkgs fetches updates
from https://updates.signal.org/, but also publishes release information on its
GitHub page. In such cases, use the `--url` parameter to direct nix-update to
the correct repository:
``` console
nix-update --url https://github.com/signalapp/Signal-Desktop --override-filename pkgs/applications/networking/instant-messengers/signal-desktop/default.nix signal-desktop
```
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

@ -40,6 +40,10 @@ def parse_args(args: list[str]) -> Options:
action="store_true",
help="Use passthru.updateScript instead if possible",
)
parser.add_argument(
"--url",
help="URL to the repository to check for a release instead of using the URL in the src attribute of the package",
)
parser.add_argument(
"--write-commit-message",
metavar="FILE",
@ -89,6 +93,7 @@ def parse_args(args: list[str]) -> Options:
build=a.build,
commit=a.commit,
use_update_script=a.use_update_script,
url=a.url,
write_commit_message=a.write_commit_message,
run=a.run,
shell=a.shell,

View File

@ -132,6 +132,8 @@ def eval_attr(opts: Options) -> Package:
package = Package(attribute=opts.attribute, **out)
if opts.override_filename is not None:
package.filename = opts.override_filename
if opts.url is not None:
package.parsed_url = urlparse(opts.url)
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

@ -14,6 +14,7 @@ class Options:
version_regex: str = "(.*)"
import_path: str = os.getcwd()
override_filename: Optional[str] = None
url: Optional[str] = None
commit: bool = False
use_update_script: bool = False
write_commit_message: Optional[str] = None