diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 66472ca..9aed98d 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -23,6 +23,6 @@ jobs: # https://spdx.org/licenses/ allow-licenses: MIT, BSD-3-Clause, BSD-2-Clause, 0BSD, Unlicense, ISC, Apache-2.0, CC-BY-4.0 # The PURL prefix is got from following command - # `gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/kachick/nix-headbump/dependency-graph/compare/87d736b80a8a254bcac003d97e0b84712176b04f...5ba877ff1048d5fedcc6758484623eb67737f0fb` + # `gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/kachick/nixpkgs-url/dependency-graph/compare/87d736b80a8a254bcac003d97e0b84712176b04f...5ba877ff1048d5fedcc6758484623eb67737f0fb` # Not found in https://github.com/package-url/packageurl-js allow-dependencies-licenses: pkg:githubactions/DeterminateSystems/nix-installer-action@4 diff --git a/.gitignore b/.gitignore index 3895295..7b2f991 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ go.work # Binary when not used goreleaser -/nix-headbump +/nixpkgs-url # goreleaser generates to dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 82b6ec6..aca2f2a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -9,7 +9,7 @@ before: builds: - env: - CGO_ENABLED=0 - main: ./cmd/nix-headbump + main: ./cmd/nixpkgs-url goos: - linux # - windows diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43e8ade..38339e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,8 +20,8 @@ task: [test] go test task: [lint] dprint check task: [lint] go vet PASS -ok nix-headbump 0.313s +ok nixpkgs-url 0.313s -> ./dist/nix-headbump --version -nix-headbump dev (rev) # unknown +> ./dist/nixpkgs-url --version +nixpkgs-url dev (rev) # unknown ``` diff --git a/README.md b/README.md index 1807d14..83895a2 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,41 @@ -# nix-headbump +# nixpkgs-url For my personal use. I'm a new to the Nix ecosystem.\ (If you know a better way, please let me know!) -I have `flake.nix` and `default.nix` in many repositories. They have different nixpath(?) in the ref from the created timing.\ +I have `flake.nix` and `default.nix` in many repositories.\ +They use different nipkgs url from the created timing.\ Personally, I use the latest [nixpkgs](https://github.com/NixOS/nixpkgs) ref. But I avoid to specify `unstable`.\ When I want to bump it, I always visit the nixpkgs repository and copy and paste. It is a tedious task. ## Installation -[Prebuilt binaries](https://github.com/kachick/nix-headbump/releases) +[Prebuilt binaries](https://github.com/kachick/nixpkgs-url/releases) ```console -> curl -L https://github.com/kachick/nix-headbump/releases/latest/download/nix-headbump_Linux_x86_64.tar.gz | tar xvz -C ./ nix-headbump -> ./nix-headbump --version -nix-headbump 0.2.0 (70f68fa) # 2023-06-22T09:58:05Z +> curl -L https://github.com/kachick/nixpkgs-url/releases/latest/download/nixpkgs-url_Linux_x86_64.tar.gz | tar xvz -C ./ nixpkgs-url +> ./nixpkgs-url --version +nixpkgs-url 0.2.0 (70f68fa) # 2023-06-22T09:58:05Z ``` In [Nix](https://nixos.org/), you can skip installation steps ```console -> nix run github:kachick/nix-headbump -- --version -nix-headbump dev (rev) # unknown -> nix run github:kachick/nix-headbump/v0.2.3 -- detect --current +> nix run github:kachick/nixpkgs-url -- --version +nixpkgs-url dev (rev) # unknown +> nix run github:kachick/nixpkgs-url/v0.2.3 -- detect --current (Will work with specific versions since v0.2.3) ``` `go install` ```console -> go install github.com/kachick/nix-headbump/cmd/nix-headbump@latest +> go install github.com/kachick/nixpkgs-url/cmd/nixpkgs-url@latest go: downloading... -> ${GOPATH:-"$HOME/go"}/bin/nix-headbump --version -nix-headbump dev (rev) # unknown +> ${GOPATH:-"$HOME/go"}/bin/nixpkgs-url --version +nixpkgs-url dev (rev) # unknown ``` ## Usage @@ -42,10 +43,10 @@ nix-headbump dev (rev) # unknown Providing two subcommands. I'm using `detect` in CI and `bump` in local. ```console -> nix-headbump detect --current +> nixpkgs-url detect --current e57b65abbbf7a2d5786acc86fdf56cde060ed026 -> nix-headbump bump && git commit -m 'Bump nixpkgs to latest' *.nix +> nixpkgs-url bump && git commit -m 'Bump nixpkgs to latest' *.nix [main 213d1bf] Bump nixpkgs to latest 1 file changed, 1 insertion(+), 1 deletion(-) ``` diff --git a/Taskfile.yml b/Taskfile.yml index c25a7f5..e520a14 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,10 +13,10 @@ tasks: - go install -ldflags "-X main.commit=$(git rev-parse HEAD) -X main.date=$(date --iso-8601)" build:preview: cmds: - - goreleaser build --snapshot --single-target --clean --output dist/nix-headbump + - goreleaser build --snapshot --single-target --clean --output dist/nixpkgs-url build: cmds: - - go build -o ./dist/nix-headbump ./cmd/nix-headbump + - go build -o ./dist/nixpkgs-url ./cmd/nixpkgs-url test: cmds: - go test diff --git a/cmd/nix-headbump/main.go b/cmd/nixpkgs-url/main.go similarity index 81% rename from cmd/nix-headbump/main.go rename to cmd/nixpkgs-url/main.go index c7d6ad9..8f6e30f 100644 --- a/cmd/nix-headbump/main.go +++ b/cmd/nixpkgs-url/main.go @@ -6,7 +6,7 @@ import ( "log" "os" - nhb "github.com/kachick/nix-headbump" + nixurl "github.com/kachick/nixpkgs-url" ) var ( @@ -19,11 +19,11 @@ var ( ) func main() { - const usage = `Usage: nix-headbump + const usage = `Usage: nixpkgs-url -$ nix-headbump detect -current -$ nix-headbump bump -$ nix-headbump -version` +$ nixpkgs-url detect -current +$ nixpkgs-url bump +$ nixpkgs-url -version` detectCmd := flag.NewFlagSet("detect", flag.ExitOnError) bumpCmd := flag.NewFlagSet("bump", flag.ExitOnError) @@ -46,7 +46,7 @@ $ nix-headbump -version` if len(commit) >= 7 { revision = commit[:7] } - version := fmt.Sprintf("%s\n", "nix-headbump"+" "+version+" "+"("+revision+") # "+date) + version := fmt.Sprintf("%s\n", "nixpkgs-url"+" "+version+" "+"("+revision+") # "+date) flag.Parse() if *versionFlag { @@ -59,7 +59,7 @@ $ nix-headbump -version` os.Exit(1) } - path, err := nhb.GetTargetPath() + path, err := nixurl.GetTargetPath() if err != nil { log.Fatalf("Failed to get target files: %s", err.Error()) } @@ -78,14 +78,14 @@ $ nix-headbump -version` return } if *currentFlag { - current, err := nhb.GetCurrentVersion(path) + current, err := nixurl.GetCurrentVersion(path) if err != nil { log.Fatalf("Getting the current version has been failed: %s", err.Error()) } fmt.Println(current) return } - last, err := nhb.GetLastVersion() + last, err := nixurl.GetLastVersion() if err != nil { log.Fatalf("Getting the last version has been failed: %s", err.Error()) } @@ -100,11 +100,11 @@ $ nix-headbump -version` if err != nil { flag.Usage() } - last, err := nhb.GetLastVersion() + last, err := nixurl.GetLastVersion() if err != nil { log.Fatalf("Getting the last version has been failed: %s", err.Error()) } - if err = nhb.Bump(path, last); err != nil { + if err = nixurl.Bump(path, last); err != nil { log.Fatalf("Bumping the version has been failed: %s", err.Error()) } diff --git a/flake.nix b/flake.nix index 85bb4b0..682f7b3 100644 --- a/flake.nix +++ b/flake.nix @@ -25,9 +25,9 @@ ]; }; - packages.nix-headbump = pkgs.stdenv.mkDerivation + packages.nixpkgs-url = pkgs.stdenv.mkDerivation { - name = "nix-headbump"; + name = "nixpkgs-url"; src = self; buildInputs = with pkgs; [ go_1_20 @@ -40,16 +40,16 @@ ''; installPhase = '' mkdir -p $out/bin - install -t $out/bin dist/nix-headbump + install -t $out/bin dist/nixpkgs-url ''; }; - packages.default = packages.nix-headbump; + packages.default = packages.nixpkgs-url; # `nix run` apps.default = { type = "app"; - program = "${packages.nix-headbump}/bin/nix-headbump"; + program = "${packages.nixpkgs-url}/bin/nixpkgs-url"; }; } ); diff --git a/go.mod b/go.mod index db31b2c..8d51ad1 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/kachick/nix-headbump +module github.com/kachick/nixpkgs-url go 1.20