Add nixosModule
This commit is contained in:
parent
a85b9221dc
commit
ed25eca79f
@ -26,6 +26,9 @@
|
||||
labmon = self.packages.${prev.system}.default;
|
||||
};
|
||||
|
||||
nixosModules.labmon = import ./nix/module.nix;
|
||||
nixosModules.default = self.nixosModules.labmon;
|
||||
|
||||
packages = forAllSystems (
|
||||
{ pkgs }:
|
||||
{
|
||||
|
6
main.go
6
main.go
@ -18,7 +18,11 @@ import (
|
||||
const Version = "0.1.0"
|
||||
|
||||
func LoadConfig() (*config.Config, error) {
|
||||
config, err := config.FromFile("labmon.toml")
|
||||
path := "labmon.toml"
|
||||
if len(os.Args) > 1 {
|
||||
path = os.Args[1]
|
||||
}
|
||||
config, err := config.FromFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
65
nix/module.nix
Normal file
65
nix/module.nix
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
settingsFormat = pkgs.format.toml { };
|
||||
|
||||
settingsFile = settingsFormat.generate "labmon.toml" config.labmon.settings;
|
||||
in
|
||||
{
|
||||
options.labmon = {
|
||||
enable = lib.mkEnableOption "Enable labmon";
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = ''
|
||||
Settings for labmon.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.labmon = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.labmon}/bin/labmon ${settingsFile}";
|
||||
DynamicUser = true;
|
||||
Restart = "always";
|
||||
|
||||
# Hardening
|
||||
DevicePolicy = "strict";
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
NoNewPrivileges = true;
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
PrivateUsers = true;
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectProc = "invisible";
|
||||
ProtectSystem = "full";
|
||||
RemoveIPC = true;
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
];
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [
|
||||
"@system-service"
|
||||
"~@privileged"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user