Skip to content

Commit ffcac7a

Browse files
committed
feat: remove gomod2nix
1 parent 5b98df5 commit ffcac7a

File tree

8 files changed

+90
-124
lines changed

8 files changed

+90
-124
lines changed

.github/workflows/goreleaser.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,43 @@ jobs:
1212
permissions:
1313
contents: write
1414
steps:
15+
- name: Install Act dependencies
16+
if: ${{ env.ACT }}
17+
run: |
18+
apt-get update && apt-get install curl git sudo xz-utils -y
1519
- name: Checkout
1620
uses: actions/checkout@v3
1721
with:
1822
fetch-depth: 0
23+
- name: install nix
24+
uses: cachix/install-nix-action@v31
25+
with:
26+
nix_path: nixpkgs=channel:nixos-unstable
27+
- uses: cachix/cachix-action@v14
28+
with:
29+
name: devenv
30+
env:
31+
USER: root
32+
- name: Install devenv.sh
33+
run: nix profile install nixpkgs#devenv
1934
- name: Setup go
2035
uses: actions/setup-go@v4
2136
with:
2237
go-version-file: 'go.mod'
2338
env:
2439
GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
25-
- name: Bump version and push tag
26-
shell: bash
40+
- name: Bump version and push tag
41+
shell: bash -c 'nix develop --no-pure-eval -c {0}'
2742
run: |
2843
git config --global user.email "[email protected]"
2944
git config --global user.name "Github Actions"
3045
go install github.com/caarlos0/svu@latest
31-
OLD_TAG=$(svu current --strip-prefix)
32-
NEW_TAG=$(svu next --strip-prefix)
46+
OLD_TAG=$(svu current)
47+
NEW_TAG=$(svu next)
3348
[ "$OLD_TAG" == "$NEW_TAG" ] && echo "no version bump" && exit 0
34-
echo default.nix README.md main.go | xargs sed -i "s/$(svu current)/$(svu next)/g"
35-
echo default.nix README.md main.go | xargs sed -i "s/$(svu current --prefix='')/$(svu next --prefix='')/g"
36-
sed -i "s/BUILD_DATE = \".*\"/BUILD_DATE = \"$(date -Iseconds)\"/g" main.go
49+
echo default.nix README.md | xargs sed -i "s/$(svu current)/$(svu next)/g"
50+
go mod vendor
51+
sed -i "s|vendorHash = \".*\"|vendorHash = \"$(nix hash path ./vendor | tr --delete '\n')\"|g" default.nix
3752
git add default.nix main.go README.md
3853
git commit -m "bump release version" --allow-empty
3954
git tag v$NEW_TAG

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
.direnv
33
.devenv
44
.pre-commit-config.yaml
5+
result/
6+
vendor/
7+
ess

default.nix

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
{ pkgs ? (
1+
{
2+
pkgs ? (
23
let
34
inherit (builtins) fetchTree fromJSON readFile;
4-
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
5+
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs;
56
in
6-
import (fetchTree nixpkgs.locked) {
7-
overlays = [
8-
(import "${fetchTree gomod2nix.locked}/overlay.nix")
9-
];
10-
}
11-
)
12-
, buildGoApplication ? pkgs.buildGoApplication
7+
import (fetchTree nixpkgs.locked) {}
8+
),
9+
buildGoModule ? pkgs.buildGoModule,
1310
}:
14-
15-
buildGoApplication {
11+
buildGoModule {
1612
pname = "ess";
1713
version = "2.14.1";
1814
pwd = ./.;
1915
src = ./.;
20-
modules = ./gomod2nix.toml;
16+
vendorHash = "sha256-ooTP3mS7AEzwJm1JKebL0V2lqVge3WnpFZcbr1f/LIg=";
2117
}

flake.lock

Lines changed: 8 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,51 @@
11
{
2+
description = "ess (env sampple sync)";
23
inputs = {
34
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4-
systems.url = "github:nix-systems/default";
5+
flake-utils.url = "github:numtide/flake-utils";
56
devenv.url = "github:cachix/devenv";
6-
7-
gomod2nix = {
8-
url = "github:nix-community/gomod2nix";
9-
inputs.nixpkgs.follows = "nixpkgs";
10-
};
117
};
128

139
outputs = {
1410
self,
1511
nixpkgs,
12+
flake-utils,
1613
devenv,
17-
systems,
18-
gomod2nix,
19-
...
20-
} @ inputs: let
21-
forEachSystem = nixpkgs.lib.genAttrs (import systems);
22-
in {
23-
packages = forEachSystem (system: let
24-
callPackage = nixpkgs.darwin.apple_sdk_11_0.callPackage or nixpkgs.legacyPackages.${system}.callPackage;
25-
in {
26-
default = callPackage ./. {
27-
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
28-
};
29-
});
14+
} @ inputs:
15+
flake-utils.lib.eachDefaultSystem (
16+
system: let
17+
pkgs = import nixpkgs {
18+
inherit system;
19+
};
20+
in {
21+
packages.default = pkgs.callPackage ./. {};
22+
CGO_ENABLED = 0;
23+
defaultPackage = self.packages.${system}.default;
24+
apps.default = flake-utils.lib.mkApp {
25+
drv = self.packages.${system}.default;
26+
};
3027

31-
devShells = forEachSystem (system: let
32-
pkgs = nixpkgs.legacyPackages.${system};
33-
in {
34-
default = devenv.lib.mkShell {
35-
inherit inputs pkgs;
36-
modules = [
37-
{
38-
packages = with pkgs; [
39-
automake
40-
go_1_23
41-
gomod2nix.legacyPackages.${system}.gomod2nix
42-
gotools
43-
golangci-lint
44-
go-tools
45-
gopls
46-
pre-commit
47-
svu
28+
devShells = let
29+
pkgs = nixpkgs.legacyPackages.${system};
30+
in {
31+
default = devenv.lib.mkShell {
32+
inherit inputs pkgs;
33+
modules = [
34+
{
35+
packages = with pkgs; [
36+
act
37+
automake
38+
go_1_24
39+
gotools
40+
golangci-lint
41+
go-tools
42+
gopls
43+
svu
44+
];
45+
}
4846
];
49-
50-
pre-commit.hooks.gomod2nix = {
51-
enable = true;
52-
pass_filenames = false;
53-
name = "gomod2nix";
54-
description = "Run gomod2nix before commit";
55-
entry = "${gomod2nix.legacyPackages.${system}.gomod2nix}/bin/gomod2nix";
56-
};
57-
}
58-
];
59-
};
60-
});
61-
};
47+
};
48+
};
49+
}
50+
);
6251
}

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module github.com/acaloiaro/ess
22

3-
go 1.24
3+
go 1.24.1
44

5-
require github.com/acaloiaro/go-envparse v0.5.0
5+
require (
6+
github.com/acaloiaro/go-envparse v0.5.0
7+
)

gomod2nix.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ import (
1414
"regexp"
1515
"strings"
1616
"text/template"
17+
"time"
1718

1819
"github.com/acaloiaro/go-envparse"
1920
)
2021

21-
const VERSION = "2.14.1"
22-
const BUILD_DATE = "2024-12-12T19:42:19+00:00"
22+
var (
23+
version = "dev"
24+
commit = "none"
25+
date = time.Now().Format(time.RFC822)
26+
)
2327

2428
type exampleFlag map[string]string
2529

@@ -71,7 +75,7 @@ func init() {
7175
flag.Parse()
7276

7377
if versionFlag {
74-
fmt.Fprintf(os.Stdout, "ess version: %s built at: %s\n", VERSION, BUILD_DATE)
78+
fmt.Fprintf(os.Stdout, "ess version: %s built at: %s\n", version, date)
7579
os.Exit(0)
7680
}
7781

0 commit comments

Comments
 (0)