Update git references in Nix flake files and Nix expressions.
nix-update-git detects outdated version tags in flake inputs and fetcher calls, then updates them in place.
- Detect and update flake input refs (
ref = "v1.0.0"→ref = "v2.0.0") - Detect and update inline refs (
url = "github:owner/repo?ref=v1.0.0") - Supports
github:,gitlab:,sourcehut:,git+https://,git+ssh://,git+file://URLs - Pin inputs with
# pin— they will be skipped entirely - Check mode (default) shows what would change without modifying files
- Update mode applies changes in place
- Interactive mode prompts before each change
nix run github:yuxqiu/nix-update-gitOr add to your flake inputs:
inputs.nix-update-git.url = "github:yuxqiu/nix-update-git";cargo install --git https://github.com/yuxqiu/nix-update-gitnix-update-git [OPTIONS] [FILES]...
Options:
-c, --check Check without making changes (default)
-u, --update Perform updates
-i, --interactive Confirm each update
-v, --verbose Enable verbose output
-h, --help Print help
-V, --version Print version
nix-update-git flake.nix
# output:
# flake.nix: Found 1 update(s) from rule 'flake-input':
# - inputs.mylib.ref: v1.0.0 -> v2.0.0nix-update-git --update flake.nix
# Applies changes to flake.nix in placenix-update-git --update --interactive flake.nix
# Prompts y/N for each updateinputs.mylib = {
url = "github:owner/repo";
ref = "v1.0.0"; # updated to latest tag
};inputs.mylib.url = "github:owner/repo?ref=v1.0.0";
# or
inputs.mylib = "git+https://example.com/repo.git?ref=v1.0.0";Any input with a # pin comment is skipped:
inputs.stable = { # pin
url = "github:owner/repo";
ref = "v1.0.0";
};inputs.stable.ref = "v1.0.0"; # pin| Type | Example |
|---|---|
| GitHub | github:owner/repo |
| GitLab | gitlab:owner/repo |
| SourceHut | sourcehut:~user/repo |
| Git HTTPS | git+https://example.com/repo.git |
| Git SSH | git+ssh://git@example.com/repo.git |
| Git local | git+file:///path/to/repo |
This is stage 2 of the planned implementation. Remaining work:
-
fetchgit/fetchFromGitHub/ other nixpkgs fetcher rules -
builtins.fetchGit/builtins.fetchTarballrules - Hash prefetching (
nix-prefetch-gitor internal) - SRI hash conversion