-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
191 lines (189 loc) · 7.9 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
{
description = "Helmet mods";
inputs = {
hotPot.url = "github:shopstic/nix-hot-pot";
nixpkgs.follows = "hotPot/nixpkgs";
flakeUtils.follows = "hotPot/flakeUtils";
fdbPkg.follows = "hotPot/fdbPkg";
nix2containerPkg.follows = "hotPot/nix2containerPkg";
};
outputs = { self, nixpkgs, flakeUtils, fdbPkg, hotPot, nix2containerPkg }:
flakeUtils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] (system:
let
hotPotPkgs = hotPot.packages.${system};
hotPotLib = hotPot.lib.${system};
nix2container = nix2containerPkg.packages.${system}.nix2container;
pkgs = import nixpkgs {
inherit system;
};
fdb = fdbPkg.packages.${system}.fdb_7;
src = builtins.path
{
path = ./.;
name = "helmet-mods-src";
filter = with pkgs.lib; (path: type:
hasInfix "/src" path ||
hasSuffix "/deno.json" path ||
hasSuffix "/deno.lock" path
);
};
cache-entry-file = pkgs.callPackage hotPotLib.denoAppCacheEntry {
inherit src;
name = "helmet-mods";
};
deno-cache-dir = pkgs.callPackage hotPotLib.denoAppCache {
inherit cache-entry-file;
name = "helmet-mods";
config-file = ./deno.json;
lock-file = ./deno.lock;
};
deno = hotPotPkgs.deno_2_2_x;
denort = hotPotPkgs.denort_2_2_x;
denoCompile = tsPath:
let
name = pkgs.lib.removeSuffix ".ts" (builtins.baseNameOf tsPath);
compiled = pkgs.callPackage hotPotLib.denoAppCompile {
inherit name deno-cache-dir src;
appSrcPath = tsPath;
prefix-patch = ./src/patched_fetch.ts;
denoCompileFlags = "-A --frozen --no-code-cache";
};
in
compiled;
fdb-configurator = denoCompile "src/apps/fdb_configurator/fdb_configurator.ts";
iac-version-bumper = denoCompile "src/apps/iac_version_bumper/iac_version_bumper.ts";
registry-authenticator = denoCompile "src/apps/registry_authenticator/registry_authenticator.ts";
registry-syncer = denoCompile "src/apps/registry_syncer/registry_syncer.ts";
k8s-job-autoscaler = denoCompile "src/apps/k8s_job_autoscaler/k8s_job_autoscaler.ts";
grafana-syncer = denoCompile "src/apps/grafana_syncer/grafana_syncer.ts";
github-actions-registry = denoCompile "src/apps/github_actions_registry/github_actions_registry.ts";
gitlab-cicd-registry = denoCompile "src/apps/gitlab_cicd_registry/gitlab_cicd_registry.ts";
openapi-merger = denoCompile "src/apps/openapi_merger/openapi_merger.ts";
vscode-settings = pkgs.writeTextFile {
name = "vscode-settings.json";
text = builtins.toJSON {
"deno.enable" = true;
"deno.lint" = true;
"deno.unstable" = true;
"deno.path" = deno + "/bin/deno";
"deno.suggest.imports.hosts" = {
"https://deno.land" = false;
};
"editor.inlayHints.enabled" = "offUnlessPressed";
"deno.inlayHints.enumMemberValues.enabled" = true;
"deno.inlayHints.functionLikeReturnTypes.enabled" = true;
"deno.inlayHints.parameterNames.enabled" = "all";
"deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName" = true;
"deno.inlayHints.parameterTypes.enabled" = true;
"deno.inlayHints.propertyDeclarationTypes.enabled" = true;
"deno.inlayHints.variableTypes.enabled" = true;
"editor.tabSize" = 2;
"[typescript]" = {
"editor.defaultFormatter" = "denoland.vscode-deno";
"editor.formatOnSave" = true;
};
"yaml.schemaStore.enable" = true;
"yaml.schemas" = {
"https://json.schemastore.org/github-workflow.json" = ".github/workflows/*.yaml";
"https://json.schemastore.org/github-action.json" = "*/action.yaml";
};
"nix.enableLanguageServer" = true;
"nix.formatterPath" = pkgs.nixpkgs-fmt + "/bin/nixpkgs-fmt";
"nix.serverSettings" = {
"nil" = {
"formatting" = {
"command" = [ "nixpkgs-fmt" ];
};
};
};
"nix.serverPath" = pkgs.nil + "/bin/nil";
};
};
in
rec {
devShell = pkgs.mkShellNoCC {
buildInputs = builtins.attrValues
{
inherit deno;
inherit (pkgs)
gh
awscli2
jq
parallel
;
inherit (hotPotPkgs)
manifest-tool
skopeo-nix2container
regclient
typescript-eslint
openapi-ts-gen
;
};
shellHook = ''
echo 'will cite' | parallel --citation >/dev/null 2>&1
mkdir -p ./.vscode
cat ${vscode-settings} > ./.vscode/settings.json
export DENORT_BIN="${denort}/bin/denort"
if [[ -f ./.env ]]; then
source ./.env
fi
'';
};
packages = {
inherit
deno-cache-dir
fdb-configurator
iac-version-bumper
registry-authenticator
registry-syncer
k8s-job-autoscaler
grafana-syncer
openapi-merger
github-actions-registry
gitlab-cicd-registry
;
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux (
let
inherit (hotPotLib) nonRootShadowSetup;
images = {
image-fdb-server = pkgs.callPackage ./nix/images/fdb-server {
inherit nix2container nonRootShadowSetup fdb;
};
image-fdb-configurator = pkgs.callPackage ./nix/images/fdb-configurator {
inherit nonRootShadowSetup nix2container fdb fdb-configurator;
};
image-iac-version-bumper = pkgs.callPackage ./nix/images/iac-version-bumper {
inherit nonRootShadowSetup nix2container iac-version-bumper;
};
image-registry-authenticator = pkgs.callPackage ./nix/images/registry-authenticator {
inherit nonRootShadowSetup nix2container registry-authenticator;
};
image-registry-syncer = pkgs.callPackage ./nix/images/registry-syncer {
inherit nonRootShadowSetup nix2container registry-syncer;
};
image-k8s-job-autoscaler = pkgs.callPackage ./nix/images/k8s-job-autoscaler {
inherit nonRootShadowSetup nix2container k8s-job-autoscaler;
};
image-grafana-syncer = pkgs.callPackage ./nix/images/grafana-syncer {
inherit nonRootShadowSetup nix2container grafana-syncer;
};
image-github-actions-registry = pkgs.callPackage ./nix/images/github-actions-registry {
inherit nonRootShadowSetup nix2container github-actions-registry;
};
image-gitlab-cicd-registry = pkgs.callPackage ./nix/images/gitlab-cicd-registry {
inherit nonRootShadowSetup nix2container gitlab-cicd-registry;
};
image-openapi-merger = pkgs.callPackage ./nix/images/openapi-merger {
inherit nonRootShadowSetup nix2container openapi-merger;
};
};
in
(images // ({
all-images = pkgs.linkFarmFromDrvs "all-images" (pkgs.lib.attrValues images);
}))
);
defaultPackage = pkgs.linkFarmFromDrvs "helmet-mods"
(pkgs.lib.unique (builtins.attrValues (pkgs.lib.filterAttrs (n: _: (!(pkgs.lib.hasPrefix "image-" n) && n != "all-images")) packages)));
}
);
}