Skip to content

Commit 3ca99fd

Browse files
authored
Add nix flake definition (#48)
1 parent f4b44f3 commit 3ca99fd

7 files changed

+236
-0
lines changed

.envrc.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
watch_file shell.nix
2+
use flake

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*.so
99
*.dylib
1010
/bin
11+
/result
1112

1213
# Test binary, built with `go test -c`
1314
*.test
@@ -21,5 +22,8 @@ tests/cyn-bdd-config.yaml
2122
# Vagrant
2223
/.vagrant
2324

25+
# Direnv nix things
26+
/.direnv
27+
2428
# Prettier installs locally here
2529
node_modules

default.nix

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ pkgs ? (let
2+
inherit (builtins) fetchTree fromJSON readFile;
3+
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
4+
in import (fetchTree nixpkgs.locks) {
5+
overlays = [ (import "${fetchTree gomod2nix.locked}/overlay.nix") ];
6+
}), buildGoApplication ? pkgs.buildGoApplication }:
7+
buildGoApplication {
8+
pname = "cynomys";
9+
version = "main";
10+
pwd = ./.;
11+
src = ./.;
12+
subPackages = [ "cmd/cyn" ];
13+
modules = ./gomod2nix.toml;
14+
}

flake.lock

+84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "nixpkgs/nixos-23.11";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
gomod2nix = {
6+
url = "github:nix-community/gomod2nix";
7+
inputs = {
8+
nixpkgs.follows = "nixpkgs";
9+
flake-utils.follows = "flake-utils";
10+
};
11+
};
12+
};
13+
14+
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
15+
flake-utils.lib.eachDefaultSystem (system:
16+
let
17+
pkgs = nixpkgs.legacyPackages.${system};
18+
19+
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
20+
# This has no effect on other platforms.
21+
callPackage =
22+
pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
23+
in {
24+
packages.default = callPackage ./default.nix {
25+
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
26+
};
27+
28+
devShells.default = callPackage ./shell.nix {
29+
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
30+
};
31+
});
32+
}

gomod2nix.toml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
schema = 3
2+
3+
[mod]
4+
[mod."github.com/cucumber/gherkin-go/v19"]
5+
version = "v19.0.3"
6+
hash = "sha256-8fvqG4/zWTMWOzQ3tZV2eRtvmv3Qb1HgXLON98ZzXAw="
7+
[mod."github.com/cucumber/godog"]
8+
version = "v0.12.5"
9+
hash = "sha256-NbO0XFEiiAMd1Xl6qanQ9gRRU14xys79uwavZJsHiDs="
10+
[mod."github.com/cucumber/messages-go/v16"]
11+
version = "v16.0.1"
12+
hash = "sha256-L6Q78f68EbthwTsQNAscUkIIt/8GAalJaPFkT8998NI="
13+
[mod."github.com/evertras/gonsen"]
14+
version = "v0.3.3"
15+
hash = "sha256-sSqCKaWXczOYrwDInaQwAANZgt5Ey8hPqiC+Y82+rco="
16+
[mod."github.com/fsnotify/fsnotify"]
17+
version = "v1.4.7"
18+
hash = "sha256-j/Ts92oXa3k1MFU7Yd8/AqafRTsFn7V2pDKCyDJLah8="
19+
[mod."github.com/gofrs/uuid"]
20+
version = "v4.0.0+incompatible"
21+
hash = "sha256-LM2nBpmCAp32ihzuUx2xec3/6zLlvBWx8vJIxGX5YS8="
22+
[mod."github.com/hashicorp/go-immutable-radix"]
23+
version = "v1.3.0"
24+
hash = "sha256-mQEWWUmvryUF+w2TIIaHCXnUBcINEALgWBGlQTCB1nI="
25+
[mod."github.com/hashicorp/go-memdb"]
26+
version = "v1.3.0"
27+
hash = "sha256-PUG2wUHkY1eWOIYXS/idXVYZRBi+WLSUFrPGeyVjrBk="
28+
[mod."github.com/hashicorp/golang-lru"]
29+
version = "v0.5.4"
30+
hash = "sha256-1skUMZX+iIf66J1TBVYGWO1OWwQcaoXut3mne331q+k="
31+
[mod."github.com/hashicorp/hcl"]
32+
version = "v1.0.0"
33+
hash = "sha256-xsRCmYyBfglMxeWUvTZqkaRLSW+V2FvNodEDjTGg1WA="
34+
[mod."github.com/inconshreveable/mousetrap"]
35+
version = "v1.0.0"
36+
hash = "sha256-ogTuLrV40FwS4ueo4hh6hi1wPywOI+LyIqfNjsibwNY="
37+
[mod."github.com/magiconair/properties"]
38+
version = "v1.8.1"
39+
hash = "sha256-y9tzLVKluie7cCruJ86XvjA2rUDeE8Q+gpkBDnrg+Kc="
40+
[mod."github.com/mitchellh/mapstructure"]
41+
version = "v1.1.2"
42+
hash = "sha256-OU9HZYHtl0qaqMFd84w7snkkRuRY6UMSsfCnL5HYdw0="
43+
[mod."github.com/pelletier/go-toml"]
44+
version = "v1.2.0"
45+
hash = "sha256-Yt9MGTbIaU/1FhE7SO5UCQbTLxe+2vsypTdf38i3kFY="
46+
[mod."github.com/spf13/afero"]
47+
version = "v1.1.2"
48+
hash = "sha256-00yWOvw9GosWm6QkogM8MxpnVFRm/7BcdBLG4pQjO1Y="
49+
[mod."github.com/spf13/cast"]
50+
version = "v1.3.0"
51+
hash = "sha256-hbVF7F0YsgSybYEJa7W+Rz0As6OpgmpZOxB5JLFzAXc="
52+
[mod."github.com/spf13/cobra"]
53+
version = "v1.1.1"
54+
hash = "sha256-YdKaCAvr6wAMOQSGzNnNG9LO6Q60T6Z6VSJVTUblomM="
55+
[mod."github.com/spf13/jwalterweatherman"]
56+
version = "v1.0.0"
57+
hash = "sha256-KLftz+gaA5wSkvLqvQ7CuboB79kKEoTJvgTtrXatbiQ="
58+
[mod."github.com/spf13/pflag"]
59+
version = "v1.0.5"
60+
hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw="
61+
[mod."github.com/spf13/viper"]
62+
version = "v1.7.0"
63+
hash = "sha256-rEBEKDZBAwf429NryLeHHpdzcleC4689hiib584TNiU="
64+
[mod."github.com/subosito/gotenv"]
65+
version = "v1.2.0"
66+
hash = "sha256-RUsfBl9xvHk8H6SPwiLi/BpHjkyO/YLvlFmRfGRIW1U="
67+
[mod."golang.org/x/sync"]
68+
version = "v0.0.0-20190423024810-112230192c58"
69+
hash = "sha256-1lGQ6frW6gwuLzwomu530IsFh7vlQWQOphQ0IQeZIhY="
70+
[mod."golang.org/x/sys"]
71+
version = "v0.3.0"
72+
hash = "sha256-TIHhfYbZ99sCU1ZMikxwomXH5AEtD/lA1VMMW+UAhbU="
73+
[mod."golang.org/x/text"]
74+
version = "v0.3.2"
75+
hash = "sha256-XCq76CoE5+BMqkzKbjV6l3RS6E0TrNANaOfs6faJEWo="
76+
[mod."gopkg.in/ini.v1"]
77+
version = "v1.51.0"
78+
hash = "sha256-gQ77WlSLs7+1ACOxnaSp5qb8KZd1tGsoNL9O4uq/jPE="
79+
[mod."gopkg.in/yaml.v2"]
80+
version = "v2.2.8"
81+
hash = "sha256-/KoaoUbFCm3r8nZyPaWZshMVTM2iSebS5kz/5rc+zsY="

shell.nix

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{ pkgs ? (let
2+
inherit (builtins) fetchTree fromJSON readFile;
3+
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
4+
in import (fetchTree nixpkgs.locked) {
5+
overlays = [ (import "${fetchTree gomod2nix.locked}/overlay.nix") ];
6+
}), mkGoEnv ? pkgs.mkGoEnv, gomod2nix ? pkgs.gomod2nix }:
7+
8+
let goEnv = mkGoEnv { pwd = ./.; };
9+
in pkgs.mkShell {
10+
packages = with pkgs; [
11+
goEnv
12+
gomod2nix
13+
14+
# Dev tools
15+
golangci-lint
16+
nixfmt
17+
nodejs_21
18+
];
19+
}

0 commit comments

Comments
 (0)