-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathflake.nix
145 lines (117 loc) · 4.14 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
{
inputs = {
nixops.url = "github:nhost/nixops";
nixpkgs.follows = "nixops/nixpkgs";
flake-utils.follows = "nixops/flake-utils";
nix-filter.follows = "nixops/nix-filter";
};
outputs = { self, nixops, nixpkgs, flake-utils, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
nixops.overlays.default
(final: prev: {
certbot-full = prev.certbot.overrideAttrs (old: {
doCheck = false;
});
})
];
pkgs = import nixpkgs {
inherit system overlays;
};
src = nix-filter.lib.filter {
root = ./.;
include = with nix-filter.lib;[
".golangci.yaml"
"go.mod"
"go.sum"
(inDirectory "ssl/.ssl")
(inDirectory "vendor")
(inDirectory "cmd/config/testdata")
(inDirectory "cmd/project/templates")
isDirectory
(nix-filter.lib.matchExt "go")
"get_access_token.sh"
"gqlgenc.yaml"
(inDirectory "nhostclient/graphql/query/")
];
};
nix-src = nix-filter.lib.filter {
root = ./.;
include = with nix-filter.lib;[
(matchExt "nix")
];
};
checkDeps = with pkgs; [
jq
curl
cacert
gqlgenc
];
buildInputs = with pkgs; [
];
nativeBuildInputs = with pkgs; [
];
nixops-lib = nixops.lib { inherit pkgs; };
name = "cli";
description = "Nhost CLI";
version = pkgs.lib.fileContents ./VERSION;
module = "github.com/nhost/cli";
submodule = ".";
tags = [ ];
ldflags = [
"-X main.Version=${version}"
];
in
{
checks = flake-utils.lib.flattenTree rec {
nixpkgs-fmt = nixops-lib.nix.check { src = nix-src; };
go-checks = nixops-lib.go.check {
inherit src submodule ldflags tags buildInputs nativeBuildInputs checkDeps;
preCheck = ''
echo "➜ Getting access token"
export NHOST_ACCESS_TOKEN=$(bash ${src}/get_access_token.sh)
'';
};
};
devShells = flake-utils.lib.flattenTree rec {
default = nixops-lib.go.devShell {
buildInputs = with pkgs; [
certbot-full
python312Packages.certbot-dns-route53
] ++ checkDeps ++ buildInputs ++ nativeBuildInputs;
};
};
packages = flake-utils.lib.flattenTree rec {
cli = nixops-lib.go.package {
inherit name submodule description src version ldflags buildInputs nativeBuildInputs;
cgoEnabled = 0;
};
cli-arm64-darwin = (nixops-lib.go.package {
inherit name submodule description src version ldflags buildInputs nativeBuildInputs;
cgoEnabled = 0;
}).overrideAttrs (old: old // { GOOS = "darwin"; GOARCH = "arm64"; });
cli-amd64-darwin = (nixops-lib.go.package {
inherit name submodule description src version ldflags buildInputs nativeBuildInputs;
cgoEnabled = 0;
}).overrideAttrs (old: old // { GOOS = "darwin"; GOARCH = "amd64"; });
cli-arm64-linux = (nixops-lib.go.package {
inherit name submodule description src version ldflags buildInputs nativeBuildInputs;
cgoEnabled = 0;
}).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = "arm64"; });
cli-amd64-linux = (nixops-lib.go.package {
inherit name submodule description src version ldflags buildInputs nativeBuildInputs;
cgoEnabled = 0;
}).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = "amd64"; });
docker-image-arm64 = nixops-lib.go.docker-image {
inherit name version buildInputs;
package = cli-arm64-linux;
};
docker-image-amd64 = nixops-lib.go.docker-image {
inherit name version buildInputs;
package = cli-amd64-linux;
};
};
}
);
}