|
2 | 2 | description = "A very marrano bot."; |
3 | 3 |
|
4 | 4 | inputs = { |
5 | | - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; |
6 | 6 | flakelight.url = "github:nix-community/flakelight"; |
7 | 7 | flakelight.inputs.nixpkgs.follows = "nixpkgs"; |
8 | 8 | }; |
9 | 9 |
|
10 | | - outputs = { self, flakelight, ... }@inputs: |
| 10 | + outputs = |
| 11 | + { self, flakelight, ... }@inputs: |
11 | 12 | flakelight ./. { |
12 | 13 | inherit inputs; |
13 | | - systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; |
| 14 | + systems = [ |
| 15 | + "x86_64-linux" |
| 16 | + "aarch64-linux" |
| 17 | + "aarch64-darwin" |
| 18 | + ]; |
14 | 19 |
|
15 | 20 | devShell.packages = pkgs: [ |
16 | 21 | pkgs.go |
|
24 | 29 | pkgs.litecli |
25 | 30 | ]; |
26 | 31 |
|
27 | | - package = { pkgs, lib, buildGoModule, ... }: |
| 32 | + package = |
| 33 | + { |
| 34 | + pkgs, |
| 35 | + lib, |
| 36 | + buildGoModule, |
| 37 | + ... |
| 38 | + }: |
28 | 39 | buildGoModule { |
29 | 40 | name = "marrano-bot"; |
30 | 41 | src = ./.; |
31 | 42 | nativeBuildInputs = [ pkgs.go ]; |
32 | 43 | # vendorHash = "sha256-M1g9Iex93Pr0a/2QeyGnL5803O6VQJQItIfZdUXccCw="; |
33 | 44 | vendorHash = "sha256-kQkNBvsDmDKPxSLkB/ckhgi+Eby+n+VOAo3OIcmVtts="; |
34 | | - tags= [ |
| 45 | + tags = [ |
35 | 46 | "fts5" |
36 | 47 | ]; |
37 | | - meta = { platforms = lib.platforms.all; }; |
| 48 | + meta = { |
| 49 | + platforms = lib.platforms.all; |
| 50 | + }; |
38 | 51 | }; |
39 | 52 |
|
40 | | - formatters = { "*.go" = "go fmt"; }; |
41 | | - |
42 | | - nixosModule = { config, pkgs, lib, system, ... }: |
| 53 | + formatters = { |
| 54 | + "*.go" = "go fmt"; |
| 55 | + }; |
| 56 | + |
| 57 | + nixosModule = |
| 58 | + { |
| 59 | + config, |
| 60 | + pkgs, |
| 61 | + lib, |
| 62 | + ... |
| 63 | + }: |
43 | 64 | with lib; |
44 | 65 | let |
45 | 66 | cfg = config.services.marrano-bot; |
46 | 67 | pkg = self.packages.${pkgs.system}.default; |
47 | | - hardeningOptions = |
48 | | - { }; # TODO systemd hardened settings `systemd analyze security marrano-bot` |
49 | | - in { |
| 68 | + hardeningOptions = { }; # TODO systemd hardened settings `systemd analyze security marrano-bot` |
| 69 | + in |
| 70 | + { |
50 | 71 | options.services.marrano-bot = { |
51 | 72 | enable = mkEnableOption (lib.mdDoc "Enable MarranoBot Service") // { |
52 | 73 | description = lib.mdDoc '' |
|
63 | 84 | hostName = mkOption { |
64 | 85 | type = types.str; |
65 | 86 | default = "bot.marrani.lol"; |
66 | | - description = lib.mdDoc |
67 | | - "marrano-bot public hostname. Used to receive webhook updates."; |
| 87 | + description = lib.mdDoc "marrano-bot public hostname. Used to receive webhook updates."; |
68 | 88 | }; |
69 | 89 |
|
70 | 90 | openPort = mkOption { |
|
82 | 102 | dataDir = mkOption { |
83 | 103 | type = types.path; |
84 | 104 | default = "/var/lib/marrano-bot"; |
85 | | - description = lib.mdDoc |
86 | | - "The directory that will host the database file and config.edn"; |
| 105 | + description = lib.mdDoc "The directory that will host the database file and config.edn"; |
87 | 106 | }; |
88 | 107 |
|
89 | 108 | databaseFile = mkOption { |
|
136 | 155 | message = "Age secret 'marrano-bot' is required!"; |
137 | 156 | } |
138 | 157 | ]; |
139 | | - users.groups = |
140 | | - mkIf (cfg.group == "marrano-bot") { marrano-bot = { }; }; |
| 158 | + users.groups = mkIf (cfg.group == "marrano-bot") { marrano-bot = { }; }; |
141 | 159 |
|
142 | 160 | users.users = mkIf (cfg.user == "marrano-bot") { |
143 | 161 | marrano-bot = { |
|
168 | 186 |
|
169 | 187 | serviceConfig = { |
170 | 188 | # NOTE: needed (r)agenix secret! |
171 | | - LoadCredential = |
172 | | - "marrano-bot.toml:${config.age.secrets.marrano-bot.path}"; |
| 189 | + LoadCredential = "marrano-bot.toml:${config.age.secrets.marrano-bot.path}"; |
173 | 190 |
|
174 | 191 | User = cfg.user; |
175 | 192 | Group = cfg.group; |
176 | 193 | Type = "simple"; |
177 | 194 | Restart = "on-failure"; |
178 | 195 | WorkingDirectory = cfg.dataDir; |
179 | | - ExecStart = |
180 | | - "${pkgs.marrano-bot}/bin/marrano-bot -c \${CREDENTIALS_DIRECTORY}/marrano-bot.toml"; |
| 196 | + ExecStart = "${pkgs.marrano-bot}/bin/marrano-bot -c \${CREDENTIALS_DIRECTORY}/marrano-bot.toml"; |
181 | 197 | }; |
182 | 198 | }; |
183 | 199 |
|
184 | | - networking.firewall = |
185 | | - mkIf cfg.openPort { allowedTCPPorts = [ cfg.port ]; }; |
| 200 | + networking.firewall = mkIf cfg.openPort { allowedTCPPorts = [ cfg.port ]; }; |
186 | 201 |
|
187 | 202 | # |
188 | 203 | # Reverse proxies |
189 | 204 | # |
190 | 205 | services.caddy.virtualHosts."${cfg.hostName}" = { |
191 | | - serverAliases = mkDefault [ "www.${cfg.hostName}" ]; |
192 | 206 | extraConfig = '' |
193 | 207 | encode gzip |
194 | 208 | reverse_proxy :${toString cfg.port} |
|
197 | 211 |
|
198 | 212 | services.nginx.virtualHosts."${cfg.hostName}" = { |
199 | 213 | serverName = mkDefault cfg.hostName; |
200 | | - locations."/".proxyPass = |
201 | | - "https://127.0.0.1:${toString cfg.port}"; |
| 214 | + locations."/".proxyPass = "https://127.0.0.1:${toString cfg.port}"; |
202 | 215 | enableACME = mkDefault true; |
203 | 216 | forceSSL = mkDefault true; |
204 | 217 | }; |
|
0 commit comments