Add NixOS module
This commit is contained in:
parent
32d8f78a09
commit
284c713f5f
1 changed files with 63 additions and 0 deletions
63
module.nix
Normal file
63
module.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
strojnadzor = import ./. {};
|
||||
|
||||
cfg = config.services.strojnadzor;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
services.strojnadzor = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable Strojnadzor
|
||||
";
|
||||
};
|
||||
hostname = mkOption {
|
||||
default = "localhost";
|
||||
description = "Listen to this hostname or ip.";
|
||||
};
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 9000;
|
||||
description = "Listen on this port.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.strojnadzor = {
|
||||
description = "Strojnadzor user";
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
group = "strojnadzor";
|
||||
home = "/var/lib/strojnadzor";
|
||||
};
|
||||
|
||||
users.groups.strojnadzor = {};
|
||||
|
||||
environment.systemPackages = [
|
||||
strojnadzor
|
||||
];
|
||||
systemd.services.strojnadzor =
|
||||
{
|
||||
description = "Strojnadzor HTTP server.";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
User = "strojnadzor";
|
||||
Group = "strojnadzor";
|
||||
ExecStartPre = "${strojnadzor}/bin/strojnadzor-admin migrate";
|
||||
ExecStart = "${strojnadzor}/bin/strojnadzor-admin runserver-uvicorn ${cfg.hostname} ${toString cfg.port}";
|
||||
};
|
||||
environment.STROJNADZOR_DATA_DIR = "/var/lib/strojnadzor/data";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue