|
16 | 16 | pkg: |
17 | 17 | if config.secshell.netbox.oidc.endpoint != "" then |
18 | 18 | pkg.overrideAttrs (old: { |
19 | | - installPhase = |
20 | | - old.installPhase |
21 | | - + '' |
22 | | - ln -s ${./pipeline.py} $out/opt/netbox/netbox/netbox/secshell_pipeline.py |
23 | | - ''; |
| 19 | + installPhase = old.installPhase + '' |
| 20 | + ln -s ${./pipeline.py} $out/opt/netbox/netbox/netbox/secshell_pipeline.py |
| 21 | + ''; |
24 | 22 | }) |
25 | 23 | else |
26 | 24 | pkg; |
| 25 | + description = '' |
| 26 | + The netbox package to use. |
| 27 | + If oidc is configured the secshell oidc pipeline for social auth |
| 28 | + will be automaticlly added to the package. |
| 29 | + ''; |
27 | 30 | }; |
28 | 31 | domain = lib.mkOption { |
29 | 32 | type = lib.types.str; |
30 | 33 | default = "netbox.${toString config.networking.fqdn}"; |
31 | 34 | defaultText = "netbox.\${toString config.networking.fqdn}"; |
| 35 | + description = '' |
| 36 | + The primary domain name for this service. |
| 37 | + Used for virtual host configuration, TLS certificates, and service URLs. |
| 38 | + ''; |
| 39 | + }; |
| 40 | + internal_port = lib.mkOption { |
| 41 | + type = lib.types.port; |
| 42 | + description = '' |
| 43 | + The local port the service listens on. |
| 44 | + ''; |
32 | 45 | }; |
33 | | - internal_port = lib.mkOption { type = lib.types.port; }; |
34 | 46 | oidc = { |
35 | 47 | endpoint = lib.mkOption { |
36 | 48 | type = lib.types.str; |
37 | 49 | default = ""; |
| 50 | + description = '' |
| 51 | + The open id connect server used for authentication. |
| 52 | + Leave null to disable oidc authentication. |
| 53 | + ''; |
38 | 54 | }; |
39 | 55 | clientId = lib.mkOption { |
40 | 56 | type = lib.types.str; |
41 | 57 | default = config.secshell.netbox.domain; |
42 | 58 | defaultText = "config.secshell.netbox.domain"; |
| 59 | + description = '' |
| 60 | + The client id for the open id connect authentication. |
| 61 | + ''; |
43 | 62 | }; |
44 | 63 | }; |
45 | 64 | useLocalDatabase = lib.mkOption { |
46 | 65 | type = lib.types.bool; |
47 | 66 | default = true; |
| 67 | + description = '' |
| 68 | + Whether to use a local database instance for this service. |
| 69 | + When enabled (default), the service will deploy and manage |
| 70 | + its own postgres database. When disabled, you must configure external |
| 71 | + database connection parameters separately. |
| 72 | + ''; |
48 | 73 | }; |
49 | 74 | database = { |
50 | 75 | hostname = lib.mkOption { |
51 | 76 | type = lib.types.str; |
52 | 77 | default = ""; |
| 78 | + description = '' |
| 79 | + Database server hostname. Not required if local database is being used. |
| 80 | + ''; |
53 | 81 | }; |
54 | 82 | username = lib.mkOption { |
55 | 83 | type = lib.types.str; |
56 | 84 | default = "netbox"; |
| 85 | + description = '' |
| 86 | + Database user account with read/write privileges. |
| 87 | + For PostgreSQL, ensure the user has CREATEDB permission |
| 88 | + for initial setup if creating databases automatically. |
| 89 | + ''; |
57 | 90 | }; |
58 | 91 | name = lib.mkOption { |
59 | 92 | type = lib.types.str; |
60 | 93 | default = "netbox"; |
| 94 | + description = '' |
| 95 | + Name of the database to use. |
| 96 | + Will be created automatically if the user has permissions. |
| 97 | + ''; |
61 | 98 | }; |
62 | 99 | }; |
63 | 100 | plugin = { |
|
78 | 115 | }; |
79 | 116 | }; |
80 | 117 | config = lib.mkIf config.secshell.netbox.enable { |
81 | | - sops.secrets = |
82 | | - { |
83 | | - "netbox/secretKey".owner = "netbox"; |
84 | | - } |
85 | | - // (lib.optionalAttrs (config.secshell.netbox.oidc.endpoint != "") { |
86 | | - "netbox/socialAuthSecret".owner = "netbox"; |
87 | | - }) |
88 | | - // (lib.optionalAttrs (!config.secshell.netbox.useLocalDatabase) { |
89 | | - "netbox/databasePassword".owner = "netbox"; |
90 | | - }); |
| 118 | + sops.secrets = { |
| 119 | + "netbox/secretKey".owner = "netbox"; |
| 120 | + } |
| 121 | + // (lib.optionalAttrs (config.secshell.netbox.oidc.endpoint != "") { |
| 122 | + "netbox/socialAuthSecret".owner = "netbox"; |
| 123 | + }) |
| 124 | + // (lib.optionalAttrs (!config.secshell.netbox.useLocalDatabase) { |
| 125 | + "netbox/databasePassword".owner = "netbox"; |
| 126 | + }); |
91 | 127 |
|
92 | 128 | services = { |
93 | 129 | postgresql = { |
|
101 | 137 | secretKeyFile = config.sops.secrets."netbox/secretKey".path; |
102 | 138 | port = config.secshell.netbox.internal_port; |
103 | 139 | listenAddress = "127.0.0.1"; |
104 | | - settings = |
105 | | - { |
106 | | - LOGIN_REQUIRED = true; |
107 | | - TIME_ZONE = "Europe/Berlin"; |
108 | | - METRICS_ENABLED = true; |
109 | | - } |
110 | | - // (lib.optionalAttrs (config.secshell.netbox.oidc.endpoint != "") { |
111 | | - # https://stackoverflow.com/questions/53550321/keycloak-gatekeeper-aud-claim-and-client-id-do-not-match |
112 | | - REMOTE_AUTH_ENABLED = true; |
113 | | - REMOTE_AUTH_AUTO_CREATE_USER = true; |
114 | | - REMOTE_AUTH_GROUP_SYNC_ENABLED = true; |
115 | | - SOCIAL_AUTH_JSONFIELD_ENABLED = true; |
116 | | - SOCIAL_AUTH_VERIFY_SSL = true; |
117 | | - #SOCIAL_AUTH_OIDC_SCOPE = ["groups" "roles"]; |
118 | | - REMOTE_AUTH_BACKEND = "social_core.backends.open_id_connect.OpenIdConnectAuth"; |
| 140 | + settings = { |
| 141 | + LOGIN_REQUIRED = true; |
| 142 | + TIME_ZONE = "Europe/Berlin"; |
| 143 | + METRICS_ENABLED = true; |
| 144 | + } |
| 145 | + // (lib.optionalAttrs (config.secshell.netbox.oidc.endpoint != "") { |
| 146 | + # https://stackoverflow.com/questions/53550321/keycloak-gatekeeper-aud-claim-and-client-id-do-not-match |
| 147 | + REMOTE_AUTH_ENABLED = true; |
| 148 | + REMOTE_AUTH_AUTO_CREATE_USER = true; |
| 149 | + REMOTE_AUTH_GROUP_SYNC_ENABLED = true; |
| 150 | + SOCIAL_AUTH_JSONFIELD_ENABLED = true; |
| 151 | + SOCIAL_AUTH_VERIFY_SSL = true; |
| 152 | + #SOCIAL_AUTH_OIDC_SCOPE = ["groups" "roles"]; |
| 153 | + REMOTE_AUTH_BACKEND = "social_core.backends.open_id_connect.OpenIdConnectAuth"; |
119 | 154 |
|
120 | | - #REMOTE_AUTH_GROUP_SEPARATOR=","; |
121 | | - REMOTE_AUTH_SUPERUSER_GROUPS = [ "superuser" ]; |
122 | | - REMOTE_AUTH_STAFF_GROUPS = [ "staff" ]; |
123 | | - REMOTE_AUTH_DEFAULT_GROUPS = [ "staff" ]; |
124 | | - SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = config.secshell.netbox.oidc.endpoint; |
125 | | - SOCIAL_AUTH_OIDC_KEY = config.secshell.netbox.oidc.clientId; |
126 | | - LOGOUT_REDIRECT_URL = "${config.secshell.netbox.oidc.endpoint}end-session/"; |
127 | | - }) |
128 | | - // { |
129 | | - PLUGINS = [ |
130 | | - (lib.mkIf config.secshell.netbox.plugin.bgp "netbox_bgp") |
131 | | - (lib.mkIf config.secshell.netbox.plugin.documents "netbox_documents") |
132 | | - (lib.mkIf config.secshell.netbox.plugin.floorplan "netbox_floorplan") |
133 | | - (lib.mkIf config.secshell.netbox.plugin.qrcode "netbox_qrcode") |
134 | | - (lib.mkIf config.secshell.netbox.plugin.topologyViews "netbox_topology_views") |
135 | | - #(lib.mkIf config.secshell.netbox.plugin.proxbox "netbox_proxbox") |
136 | | - (lib.mkIf config.secshell.netbox.plugin.contract "netbox_contract") |
137 | | - (lib.mkIf config.secshell.netbox.plugin.interface-synchronization "netbox_interface_synchronization") |
138 | | - (lib.mkIf config.secshell.netbox.plugin.dns "netbox_dns") |
139 | | - (lib.mkIf config.secshell.netbox.plugin.napalm "netbox_napalm_plugin") |
140 | | - (lib.mkIf config.secshell.netbox.plugin.reorder-rack "netbox_reorder_rack") |
141 | | - (lib.mkIf config.secshell.netbox.plugin.prometheus-sd "netbox_prometheus_sd") |
142 | | - #(lib.mkIf config.secshell.netbox.plugin.kea "netbox_kea") |
143 | | - (lib.mkIf config.secshell.netbox.plugin.attachments "netbox_attachments") |
144 | | - ]; |
145 | | - }; |
| 155 | + #REMOTE_AUTH_GROUP_SEPARATOR=","; |
| 156 | + REMOTE_AUTH_SUPERUSER_GROUPS = [ "superuser" ]; |
| 157 | + REMOTE_AUTH_STAFF_GROUPS = [ "staff" ]; |
| 158 | + REMOTE_AUTH_DEFAULT_GROUPS = [ "staff" ]; |
| 159 | + SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = config.secshell.netbox.oidc.endpoint; |
| 160 | + SOCIAL_AUTH_OIDC_KEY = config.secshell.netbox.oidc.clientId; |
| 161 | + LOGOUT_REDIRECT_URL = "${config.secshell.netbox.oidc.endpoint}end-session/"; |
| 162 | + }) |
| 163 | + // { |
| 164 | + PLUGINS = [ |
| 165 | + (lib.mkIf config.secshell.netbox.plugin.bgp "netbox_bgp") |
| 166 | + (lib.mkIf config.secshell.netbox.plugin.documents "netbox_documents") |
| 167 | + (lib.mkIf config.secshell.netbox.plugin.floorplan "netbox_floorplan") |
| 168 | + (lib.mkIf config.secshell.netbox.plugin.qrcode "netbox_qrcode") |
| 169 | + (lib.mkIf config.secshell.netbox.plugin.topologyViews "netbox_topology_views") |
| 170 | + #(lib.mkIf config.secshell.netbox.plugin.proxbox "netbox_proxbox") |
| 171 | + (lib.mkIf config.secshell.netbox.plugin.contract "netbox_contract") |
| 172 | + (lib.mkIf config.secshell.netbox.plugin.interface-synchronization "netbox_interface_synchronization") |
| 173 | + (lib.mkIf config.secshell.netbox.plugin.dns "netbox_dns") |
| 174 | + (lib.mkIf config.secshell.netbox.plugin.napalm "netbox_napalm_plugin") |
| 175 | + (lib.mkIf config.secshell.netbox.plugin.reorder-rack "netbox_reorder_rack") |
| 176 | + (lib.mkIf config.secshell.netbox.plugin.prometheus-sd "netbox_prometheus_sd") |
| 177 | + #(lib.mkIf config.secshell.netbox.plugin.kea "netbox_kea") |
| 178 | + (lib.mkIf config.secshell.netbox.plugin.attachments "netbox_attachments") |
| 179 | + ]; |
| 180 | + }; |
146 | 181 |
|
147 | 182 | plugins = |
148 | 183 | ps: |
|
0 commit comments