This repository has been archived by the owner on Nov 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
175 lines (161 loc) · 4.55 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
{
description = "homelab";
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://attic.rzegocki.dev/homelab"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"homelab:4QC5tI8xexADyKayaRCRJzZDwFx7Vt56kLz+cVkXQoo="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
arion = {
url = "github:hercules-ci/arion";
inputs.nixpkgs.follows = "nixpkgs";
};
attic = {
url = "github:zhaofengli/attic";
inputs.nixpkgs.follows = "nixpkgs";
};
comin = {
url = "github:nlewo/comin";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
talhelper = {
url = "github:budimanjojo/talhelper";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
};
outputs =
{
self,
arion,
attic,
comin,
flake-utils,
nixpkgs,
nixpkgs-unstable,
pre-commit-hooks,
sops-nix,
talhelper,
}@inputs:
let
upkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
check-json = {
enable = true;
excludes = [ "kubernetes/apps/external/gokapi/files/config.json" ];
};
markdownlint.enable = true;
shellcheck.enable = true;
terraform-format.enable = true;
tflint.enable = true;
yamllint.enable = true;
check-case-conflicts.enable = true;
check-shebang-scripts-are-executable.enable = true;
mixed-line-endings.enable = true;
egress-comment = {
enable = true;
entry = "./.taskfiles/Lint/egress-comment-job.sh";
};
yaml-json-schema = {
enable = true;
entry = "./.taskfiles/Lint/yaml-json-schema-job.sh";
};
deadnix.enable = true;
flake-checker = {
enable = true;
package = upkgs.flake-checker;
};
statix.enable = true;
nixfmt-rfc-style = {
enable = true;
excludes = [ ".direnv" ];
};
};
};
devShells.default = pkgs.mkShell {
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
pkgs.age
pkgs.go-task
pkgs.kubernetes-helm
pkgs.kustomize
pkgs.jq
pkgs.lefthook
pkgs.opentofu
pkgs.sops
talhelper.packages.${system}.default
pkgs.yq-go
# extra linters
pkgs.kubeconform
];
shellHook =
self.checks.${system}.pre-commit-check.shellHook
+ ''
[ ! -f opentofu/terraform.tfvars ] || sh -c 'cd opentofu && ${pkgs.opentofu}/bin/tofu init -backend-config=<(grep '^#' terraform.tfvars | sed "s@^# *@@g") -upgrade'
'';
};
}
)
// {
nixosConfigurations = {
router = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs upkgs;
};
modules = [
./nix/machines/router
comin.nixosModules.comin
sops-nix.nixosModules.sops
];
};
supervisor = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs upkgs;
};
modules = [
./nix/machines/supervisor
arion.nixosModules.arion
attic.nixosModules.atticd
comin.nixosModules.comin
sops-nix.nixosModules.sops
];
};
rustdesk = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs upkgs;
};
modules = [
./nix/machines/rustdesk
comin.nixosModules.comin
];
};
};
};
}