-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
73 lines (66 loc) · 1.96 KB
/
default.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
{ inputs, lib, config, ... }:
let cfg = config.homelab;
in {
imports = [
./media
./observability
./acme.nix
./homepage.nix
./samba.nix
inputs.nix-topology.nixosModules.default
inputs.agenix.nixosModules.default
];
options.homelab = {
lan-domain = lib.mkOption {
type = lib.types.str;
description = "The base domain of the local network";
example = "your-domain.com";
};
domain = lib.mkOption {
type = lib.types.str;
description = "The domain all services will be deployed under";
default = "${config.networking.hostName}.${cfg.lan-domain}";
};
};
config = {
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.nginx = {
enable = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
virtualHosts._ = {
forceSSL = true;
useACMEHost = cfg.domain;
default = true;
locations."/" = { return = "404"; };
};
};
topology.self.services.nginx = { hidden = true; };
# Helper function to create a subdomain for a service
lib.homelab.mkServiceSubdomain = subdomain: "${subdomain}.${cfg.domain}";
lib.homelab.mkServiceOptionSet = name: subdomain: cfg: {
enable = lib.mkEnableOption name;
subdomain = lib.mkOption {
type = lib.types.str;
default = subdomain;
description = "${name}'s subdomain";
};
domain = lib.mkOption {
type = lib.types.str;
default = config.lib.homelab.mkServiceSubdomain cfg.subdomain;
description = "${name}'s domain";
readOnly = true;
};
url = lib.mkOption {
type = lib.types.str;
default = "https://${cfg.domain}";
description = "${name}'s URL";
readOnly = true;
};
};
homelab.samba.enable = lib.mkDefault true;
homelab.homepage.enable = lib.mkDefault true;
};
}