Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Rename project s/nix-headbump/nixpkgs-url/ (#21)
Browse files Browse the repository at this point in the history
* Rename project

* Rename again

* Update abbrev
  • Loading branch information
kachick committed Jul 24, 2023
1 parent 748ecaa commit 23f14bb
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
go.work

# Binary when not used goreleaser
/nix-headbump
/nixpkgs-url

# goreleaser generates to
dist/
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ before:
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/nix-headbump
main: ./cmd/nixpkgs-url
goos:
- linux
# - windows
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
# 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

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(-)
```
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions cmd/nix-headbump/main.go → cmd/nixpkgs-url/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"os"

nhb "github.com/kachick/nix-headbump"
nixurl "github.com/kachick/nixpkgs-url"
)

var (
Expand All @@ -19,11 +19,11 @@ var (
)

func main() {
const usage = `Usage: nix-headbump <subcommand> <flags>
const usage = `Usage: nixpkgs-url <subcommand> <flags>
$ 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)
Expand All @@ -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 {
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}

Expand Down
10 changes: 5 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
};
}
);
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/kachick/nix-headbump
module github.com/kachick/nixpkgs-url

go 1.20

0 comments on commit 23f14bb

Please sign in to comment.