-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflake.nix
157 lines (150 loc) · 4.51 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
description = "tstr devleopment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-npm-buildpackage.url = "github:serokell/nix-npm-buildpackage";
sqlc = {
url = "github:kyleconroy/sqlc/v1.16.0";
flake = false;
};
dbmate = {
url = "github:amacneil/dbmate/v1.16.0";
flake = false;
};
overmind = {
url = "github:DarthSim/overmind/v2.3.0";
flake = false;
};
grpc-gateway = {
url = "github:grpc-ecosystem/grpc-gateway/v2.14.0";
flake = false;
};
protoc-gen-grpc-gateway-ts = {
url = "github:grpc-ecosystem/protoc-gen-grpc-gateway-ts/v1.1.2";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, nix-npm-buildpackage, sqlc, dbmate, overmind, grpc-gateway, protoc-gen-grpc-gateway-ts }:
flake-utils.lib.eachDefaultSystem(system:
let
pkgs = import nixpkgs { inherit system; };
bp = pkgs.callPackage nix-npm-buildpackage {};
version = "0.0.1";
tstr = pkgs.buildGo119Module {
pname = "tstr";
inherit version;
src = ./.;
subPackages = [
"cmd/tstr"
];
vendorSha256 = null;
buildInputs = [ tstr-ui ];
preBuild = ''
rm -rf ui/app/dist
cp -r "${tstr-ui}/dist" ui/app/dist
'';
};
tstr-ui = bp.buildYarnPackage {
pname = "tstr-ui";
inherit version;
src = ./ui/app;
yarnBuildMore = "yarn vite build";
postInstall = ''
cp -r dist $out/
'';
};
devTools = {
sqlc = pkgs.buildGoModule {
name = "sqlc";
src = sqlc;
subPackages = [ "cmd/sqlc" ];
doCheck = false;
vendorSha256 = "sha256-cMYTQ8rATCXOquSxc4iZ2MvxIaMO3RG8PZkpOwwntyc=";
proxyVendor = true;
buildInputs = [
pkgs.xxHash
pkgs.libpg_query
pkgs.postgresql_14
];
};
dbmate = pkgs.buildGoModule {
name = "dbmate";
src = dbmate;
doCheck = false;
vendorSha256 = "sha256-DwQUrNBfKZaVIpqI8yI/C9CQF5Ok/sApOrsLeIxt3hM=";
};
overmind = pkgs.buildGoModule {
name = "overmind";
src = overmind;
doCheck = false;
vendorSha256 = "sha256-QIKyLknPvmt8yiUCSCIqha8h9ozDGeQnKSM9Vwus0uY=";
};
grpc-gateway = pkgs.buildGoModule {
name = "grpc-gateway";
src = grpc-gateway;
doCheck = false;
subPackages = [
"protoc-gen-grpc-gateway"
"protoc-gen-openapiv2"
];
vendorSha256 = "sha256-dGdnDuRbwg8fU7uB5GaHEWa/zI3w06onqjturvooJQA=";
};
protoc-gen-grpc-gateway-ts = pkgs.buildGoModule {
name = "protoc-gen-grpc-gateway-ts";
src = protoc-gen-grpc-gateway-ts;
doCheck = false;
vendorSha256 = "sha256-2Kytwh7jQulrrsYqHAsQPNFWFe3zIXuS4kza3mnkyDs=";
};
};
in
rec {
packages = flake-utils.lib.flattenTree {
tstr = tstr;
image = pkgs.dockerTools.buildLayeredImage {
name = "nanzhong/tstr";
contents = [ tstr pkgs.busybox pkgs.cacert ];
config = {
Cmd = [ "/bin/tstr" ];
};
};
default = tstr;
};
defaultPackage = packages.tstr;
apps = {
tstr = flake-utils.lib.mkApp {
drv = packages.tstr;
exePath = "/bin/tstr";
};
default = apps.tstr;
};
devShell = with pkgs;
mkShell {
buildInputs = [
buf
entr
getopt
go-tools
go_1_19
gopls
grpcurl
kustomize
mockgen
nodePackages.vls
postgresql_14
protobuf
protoc-gen-go
protoc-gen-go-grpc
protoc-gen-validate
yarn
nodejs
devTools.sqlc
devTools.dbmate
devTools.overmind
devTools.grpc-gateway
devTools.protoc-gen-grpc-gateway-ts
];
};
}
);
}