Skip to content

Commit 00607a3

Browse files
committed
use callPackage instead
1 parent 5f42dd5 commit 00607a3

3 files changed

Lines changed: 55 additions & 54 deletions

File tree

flake.nix

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@
1414
flake-utils.lib.eachDefaultSystem (
1515
system: let
1616
pkgs = nixpkgs.legacyPackages.${system};
17-
18-
packages = import ./nix/package.nix {
19-
inherit pkgs;
20-
};
21-
devShells = import ./nix/devShell.nix {
22-
inherit pkgs;
23-
};
2417
in {
25-
packages.default = packages.default;
26-
devShells.default = devShells.default;
18+
packages.default = pkgs.callPackage ./nix/package.nix {};
19+
devShells.default = pkgs.callPackage ./nix/devShell.nix {};
2720
}
2821
);
2922
}

nix/devShell.nix

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
1-
{pkgs}: {
2-
default = pkgs.mkShell {
3-
packages = with pkgs; [
4-
go
5-
gotools
6-
gopls # Go langauge server
7-
nilaway # Go static analysis tool
8-
delve # Go debugger
9-
sqlc # compiles SQL queries to Go code
10-
air # run dev server with hot reload
11-
sqlfluff # SQL linter
12-
gnumake
13-
curl
14-
xh
15-
jq
16-
go-swag
17-
];
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 langauge 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+
];
1833

19-
shellHook = ''
20-
export DATABASE_URL="file:dev.db?cache=shared&mode=rwc"
21-
export CGO_ENABLED=0 # cgo compiler flags cause issues with delve when using Nix
22-
echo "Loaded dev shell."
23-
'';
24-
};
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+
'';
2539
}

nix/package.nix

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
{pkgs}: {
2-
default = pkgs.buildGoModule {
3-
name = "api-acmcsuf";
4-
src = ../.;
5-
vendorHash = "sha256-PbObU1GpSa18kwp1kQvYTR3j+Vuh6dNLphwDYXxOejc=";
1+
{
2+
lib,
3+
buildGoModule,
4+
}:
5+
buildGoModule {
6+
name = "api-acmcsuf";
7+
src = ../.;
8+
vendorHash = "sha256-PbObU1GpSa18kwp1kQvYTR3j+Vuh6dNLphwDYXxOejc=";
69

7-
nativeBuildInputs = with pkgs; [
8-
sqlc
9-
];
10+
postBuild = ''
11+
mv $GOPATH/bin/api $GOPATH/bin/api-acmcsuf
12+
'';
1013

11-
preBuild = ''
12-
go generate ./...
13-
'';
14+
subPackages = ["cmd/api"];
1415

15-
postBuild = ''
16-
mv $GOPATH/bin/api $GOPATH/bin/api-acmcsuf
17-
'';
18-
19-
subPackages = ["cmd/api"];
20-
21-
meta = with pkgs.lib; {
22-
description = "API created and used by CSUF's ACM chapter";
23-
homepage = "https://github.com/acmcsufoss/api.acmcsuf.com";
24-
license = licenses.mit;
25-
};
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;
2620
};
2721
}

0 commit comments

Comments
 (0)