-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2e901b
commit 1dec475
Showing
5 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ pkgs, config, lib, secrets, ... }: | ||
let defaultUser = "admin"; | ||
in { | ||
services = { | ||
infomaniak = { | ||
enable = true; | ||
|
||
username = secrets.infomaniak.username; | ||
password = secrets.infomaniak.password; | ||
hostnames = [ "librenms.00a.ch" ]; | ||
}; | ||
|
||
librenms = { | ||
enable = true; | ||
|
||
hostname = "librenms.00a.ch"; | ||
|
||
settings.auth_mechanism = "http-auth"; | ||
|
||
database = { | ||
createLocally = true; | ||
socket = "/run/mysqld/mysqld.sock"; | ||
}; | ||
|
||
nginx = { | ||
enableACME = true; | ||
forceSSL = true; | ||
|
||
locations."~ .php$" = { | ||
basicAuth = secrets.nginx.basicAuth."librenms.00a.ch"; | ||
|
||
extraConfig = '' | ||
fastcgi_param REMOTE_USER ${defaultUser}; | ||
satisfy any; | ||
allow 192.168.1.0/24; | ||
deny all; | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
systemd.services.librenms-create-admin-user = { | ||
after = [ "librenms-setup.service" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
|
||
serviceConfig = { | ||
Type = "oneshot"; | ||
RemainAfterExit = true; | ||
User = config.services.librenms.user; | ||
Group = config.services.librenms.group; | ||
}; | ||
|
||
script = let | ||
pkg = builtins.head (builtins.filter (pkg: pkg.name == "lnms") config.environment.systemPackages); | ||
lnms = "${pkg}/bin/lnms"; | ||
in '' | ||
${lnms} db:seed --force | ||
${lnms} user:add ${ | ||
lib.concatStringsSep " " [ | ||
''--password "$(${pkgs.openssl}/bin/openssl rand --hex 16)"'' | ||
"--role admin" | ||
''--email "${config.security.acme.defaults.email}"'' | ||
"--no-interaction" | ||
] | ||
} ${defaultUser} || true | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ config, ... }: { | ||
services.snmpd = { | ||
enable = true; | ||
|
||
listenAddress = "127.0.0.1"; | ||
configText = '' | ||
rocommunity public | ||
sysLocation "${config.networking.hostName}" | ||
sysContact "${config.security.acme.defaults.email}" | ||
deny write all | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# TODO remove when merged https://nixpk.gs/pr-tracker.html?pr=XXXXXXXXXXXXXXXX | ||
|
||
{ modulesPath, ... }: | ||
let | ||
src = let | ||
owner = "NixOS"; | ||
repo = "nixpkgs"; | ||
rev = "d2767c43d72169b68e6f89a80eafbe9385638eb1"; | ||
sha256 = "sha256:0dr36p8wd8fshq4wdyk8l5c03j97215k5v85cqai1m8jl0zx8z0g"; | ||
in builtins.fetchTarball { | ||
name = "nixpkgs"; | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
inherit sha256; | ||
}; | ||
in { | ||
disabledModules = [ "${modulesPath}/services/monitoring/librenms.nix" ]; | ||
|
||
imports = [ "${src}/nixos/modules/services/monitoring/librenms.nix" ]; | ||
} |
Binary file not shown.