Skip to content

Commit db984d4

Browse files
authored
Merge pull request #66 from acmcsufoss/nix-stuff
Modularize nix and other little things
2 parents 5ccea4b + 2a19871 commit db984d4

6 files changed

Lines changed: 82 additions & 64 deletions

File tree

.air.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ tmp_dir = "tmp"
55
[build]
66
args_bin = []
77
bin = "./bin/api"
8-
cmd = "make"
8+
cmd = "go build -o bin/api ./cmd/api"
99
delay = 1000
1010
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
1111
exclude_file = []
1212
exclude_regex = ["_test.go"]
1313
exclude_unchanged = false
1414
follow_symlink = false
1515
full_bin = ""
16-
include_dir = []
16+
include_dir = ["internal", "cmd"]
1717
include_ext = ["go", "tpl", "tmpl", "html"]
1818
include_file = []
1919
kill_delay = "0s"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ go.work
2727

2828
# Nix related
2929
.direnv/
30-
result/
30+
result
3131

3232
# Build artifact generated by Makefile
3333
.generate.marker

LICENSE

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2-
Version 2, December 2004
1+
MIT License
32

4-
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
3+
Copyright (c) 2025 acmcsufoss
54

6-
Everyone is permitted to copy and distribute verbatim or modified
7-
copies of this license document, and changing it is allowed as long
8-
as the name is changed.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
911

10-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1114

12-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
13-
14-
0. You just DO WHAT THE FUCK YOU WANT TO.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

flake.nix

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,8 @@
1515
system: let
1616
pkgs = nixpkgs.legacyPackages.${system};
1717
in {
18-
packages.default = pkgs.buildGoModule {
19-
name = "api-acmcsuf";
20-
src = ./.;
21-
vendorHash = "sha256-xcJrcUGnMKkYxJnNsJ3nvSWHb8u2ujRv/PmJMJdEWhM=";
22-
23-
nativeBuildInputs = with pkgs; [
24-
sqlc
25-
];
26-
27-
env.CGO_ENABLED = 0;
28-
29-
preBuild = ''
30-
go generate ./...
31-
'';
32-
33-
postBuild = ''
34-
mv $GOPATH/bin/api $GOPATH/bin/api-acmcsuf
35-
'';
36-
37-
subPackages = ["cmd/api"];
38-
39-
meta = with pkgs.lib; {
40-
description = "api for acmcsuf oss";
41-
homepage = "https://github.com/acmcsufoss/api.acmcsuf.com";
42-
license = licenses.mit;
43-
};
44-
};
45-
46-
devShells.default = pkgs.mkShell {
47-
packages = with pkgs; [
48-
go
49-
gotools
50-
gopls # Go langauge server
51-
nilaway # Go static analysis tool
52-
delve # Go debugger
53-
sqlc # compiles SQL queries to Go code
54-
air # run dev server with hot reload
55-
sqlfluff # SQL linter
56-
gnumake
57-
curl
58-
xh
59-
jq
60-
go-swag
61-
];
62-
63-
shellHook = ''
64-
export DATABASE_URL="file:dev.db?cache=shared&mode=rwc"
65-
export CGO_ENABLED=0 # cgo compiler flags cause issues with delve when using Nix
66-
echo "Loaded dev shell."
67-
'';
68-
};
18+
packages.default = pkgs.callPackage ./nix/package.nix {};
19+
devShells.default = pkgs.callPackage ./nix/devShell.nix {};
6920
}
7021
);
7122
}

nix/devShell.nix

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
mkShell,
3+
go,
4+
gotools,
5+
gopls,
6+
nilaway,
7+
delve,
8+
sqlc,
9+
air,
10+
sqlfluff,
11+
gnumake,
12+
curl,
13+
xh,
14+
jq,
15+
go-swag,
16+
}:
17+
mkShell {
18+
packages = [
19+
go
20+
gotools
21+
gopls # Go language server
22+
nilaway # Go static analysis tool
23+
delve # Go debugger
24+
sqlc # compiles SQL queries to Go code
25+
air # run dev server with hot reload
26+
sqlfluff # SQL linter
27+
gnumake
28+
curl
29+
xh
30+
jq
31+
go-swag
32+
];
33+
34+
shellHook = ''
35+
export DATABASE_URL="file:dev.db?cache=shared&mode=rwc"
36+
export CGO_ENABLED=0 # cgo compiler flags cause issues with delve when using Nix
37+
echo "Loaded dev shell."
38+
'';
39+
}

nix/package.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
lib,
3+
buildGoModule,
4+
}:
5+
buildGoModule {
6+
name = "api-acmcsuf";
7+
src = ../.;
8+
vendorHash = "sha256-PbObU1GpSa18kwp1kQvYTR3j+Vuh6dNLphwDYXxOejc=";
9+
10+
postBuild = ''
11+
mv $GOPATH/bin/api $GOPATH/bin/api-acmcsuf
12+
'';
13+
14+
subPackages = ["cmd/api"];
15+
16+
meta = {
17+
description = "API created and used by CSUF's ACM chapter";
18+
homepage = "https://github.com/acmcsufoss/api.acmcsuf.com";
19+
license = lib.licenses.mit;
20+
};
21+
}

0 commit comments

Comments
 (0)