- Notifications
You must be signed in to change notification settings - Fork85
Swiss-knife for updating nix packages.
License
Mic92/nix-update
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Nix-update updates versions/source hashes of nix packages. It is designed towork with nixpkgs but also other package sets.
- automatically figure out the latest version of packages from:
- BitBucket
- Codeberg
- crates.io
- Gitea
- GitHub
- GitLab
- PyPi
- RubyGems.org
- Sourcehut
- Savannah
- update buildRustPackage's cargoHash/cargoSha256/cargoLock and cargoSetupHook'scargoDeps
- update buildGoModule's vendorHash/vendorSha256
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
- update buildComposerProject's vendorHash
- update buildMavenPackage's mvnHash
- update mixRelease's mixFodDeps
- update fetchYarnDeps offlineCache output hash
- update flake outputs (see
--flake) - generate the following lockfile, Cargo.lock, package-lock.json (see
--generate-lockfileand--lockfile-metadata-path) - build and run the resulting package (see
--build,--runor--shell - commit updated files (see
--commitflag) - run update scripts (
passthru.updateScript, see--use-update-scriptflag) - run package tests (see
--testflag) - specify the system to use (see
--systemflag)
nix-update is included in nixpkgs.
To run without installing it, use:
$nix-shell -p nix-updateTo install it:
$nix-env -f'<nixpkgs>' -iA nix-updateTo run it from the git repository:
$nix-build$./result/bin/nix-update
If you have nix flakes enabled you can also do:
$nix run github:Mic92/nix-updateFirst change to your directory containing the nix expression (Could be a nixpkgsor your own repository). Then runnix-update as follows
$nix-update attribute [--version version]If your package is defined in a flake use the--flake flag instead:
$nix-update attribute --flake [--version version]nix-update will then try to update either thepackages.{currentSystem}.{attribute} or{attribute} output attribute of thegiven flake. To update a package inlegacyPackages, pass the full path to thatpackage including the platform:legacyPackages.{platform}.{attribute}.
This example will fetch the latest github release:
$nix-update nixpkgs-reviewIt is also possible to specify the version manually
$nix-update --version=2.1.1 nixpkgs-reviewTo update an unstable package to the latest commit of the default branch:
$nix-update --version=branch nixpkgs-reviewTo update an unstable package to the latest commit from a certain branch:
$nix-update --version=branch=develop nixpkgs-reviewTo only update sources hashes without updating the version:
$nix-update --version=skip nixpkgs-reviewTo extract version information from versions with prefixes or suffixes, a regexcan be used
$nix-update jq --version-regex'jq-(.*)'By defaultnix-update will locate the file that needs to be patched using thesrc attribute of a derivation. In some cases this heuristic is wrong. One canoverride the behavior like that:
$nix-update hello --override-filename pkgs/applications/misc/hello/default.nixThenix-update command checks for new releases of a package using thesrcattribute. However, in some cases a package may use a non-standard release URLthat is not supported bynix-update, but still has a repository with releaseinformation. For example, the Signal Desktop package in Nixpkgs fetches updatesfromhttps://updates.signal.org/, but also publishes release information on itsGitHub page. In such cases, use the--url parameter to direct nix-update tothe correct repository:
nix-update --url https://github.com/signalapp/Signal-Desktop --override-filename pkgs/applications/networking/instant-messengers/signal-desktop/default.nix signal-desktopWith the--shell,--build,--test and--run flags the update can betested. Additionally, the--review flag can be used to initiate a run ofnixpkgs-review, which will ensure alldependent packages can be built.
In order to ensure consistent formatting, the--format flag will invokenixfmt (nixfmt-rfc-style in nixpkgs).
#Also runs nix-build$nix-update --build nixpkgs-review#Also runs nix-build nixpkgs-review.tests$nix-update --test nixpkgs-review#Also runs nix-shell$nix-update --shell nixpkgs-review#Also runs nix run$nix-update --run nixpkgs-review#Run`nixpkgs-review wip` to validate dependent packages$nix-update --review nixpkgs-review#Format file$nix-update --format nixpkgs-review
Nix-update also can optionally generate a commit message in the formattribute: old_version -> new_version with the applied version update:
$nix-update --commit bitcoin-abc...[master 53d68a6a5a9] bitcoin-abc: 0.21.1 -> 0.21.21 file changed, 2 insertions(+), 2 deletions(-)
By default, nix-update will attempt to update to the next stable version of apackage. Alphas, betas, release candidates and similar unstable releases will beignored. This can be affected by changing the parameterversion from itsdefault valuestable tounstable.
$nix-update sbtNot updating version, already 1.4.6$nix-update sbt --version=unstableUpdate 1.4.6 -> 1.5.0-M1 in sbt
Nix-update can also run thepassthru.updateScript defined by the package.
$nix-update sbt --use-update-scriptArguments can be passed tonix-shell maintainers/scripts/update.nix like so
$nix-update sbt --use-update-script --update-script-args"--argstr skip-prompt true"Some packages consist of multiple fixed-output derivations derived from the sameupstream source. For example, a Go project with Go module dependencies mightalso include a JavaScript project with npm dependencies.
To support such use cases,nix-update allows specifying subpackages directlyin the command line. Consider a package accessible via thesome-packageattribute, which also provides a second fixed-output derivation as a subpackagenamedweb-ui:
{buildGoModule,fetchFromGitHub,buildNpmPackage,}:letpname="some-package";version="1.0.0";src=fetchFromGitHub{owner="owner";repo="repo";rev="v${version}";hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";};web-ui=buildNpmPackagerec{ ...npmDepsHash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";};inbuildGoModulerec{inheritweb-uipnameversionsrc;vendorHash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";preBuild='' cp -r${web-ui}/* web/dist '';}
You can update the package and its subpackage usingnix-update as follows:
nix-update --subpackage web-ui some-packageThe--subpackage option can be repeated to update multiple subpackages in thesame derivation.
First clone the repo to your preferred location (in the following, we assume~/ - your home):
$git clone https://github.com/Mic92/nix-update/~/git/nix-updateThen enter the dev shell:
$cd~/nix-update$nix develop
Change to the repository that contains the nix files you want to update, i.e.nixpkgs:
$cd nixpkgsNow you can runnix-update just by specifying the full path to its executablewrapper:
$~/git/nix-update/bin/nix-update --commit helloThis project usestreefmt-nix forformatting. It can be run on the repository like that:
$ nix fmt- create pull requests
nix-update might not work correctly if a file contains multiple packages as itperforms naive search and replace to update version numbers. This might be aproblem if:
nameis used instead ofpnameand/or${version}is injected intoname.
Related discussions:
- nixpkgs-update is optimized formass-updates in nixpkgs while nix-update is better suited for interactiveusage that might require user-intervention i.e. fixing the build and testingthe result. nix-update is also not limited to nixpkgs.
About
Swiss-knife for updating nix packages.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.