aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hoeg <peter@hoeg.com>2019-07-05 09:46:03 +0800
committerPeter Hoeg <peter@hoeg.com>2019-09-25 06:33:34 +0800
commit81cd220c67154ee7f7aaa4ea842a86fc39944d7f (patch)
tree8c6655e81be381c9e3cab5279e1d289bd950c8c2
parent844555626a1aad3eced4945b68d70148d8f2357c (diff)
nixos/pymks: log to journal
-rw-r--r--nixos/modules/rename.nix2
-rw-r--r--nixos/modules/services/misc/pykms.nix39
2 files changed, 26 insertions, 15 deletions
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index 0c7c45a4708..802ffcdc94e 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -66,6 +66,8 @@ with lib;
(mkRenamedOptionModule [ "services" "clamav" "updater" "config" ] [ "services" "clamav" "updater" "extraConfig" ])
+ (mkRemovedOptionModule [ "services" "pykms" "verbose" ] "Use services.pykms.logLevel instead")
+
(mkRemovedOptionModule [ "security" "setuidOwners" ] "Use security.wrappers instead")
(mkRemovedOptionModule [ "security" "setuidPrograms" ] "Use security.wrappers instead")
diff --git a/nixos/modules/services/misc/pykms.nix b/nixos/modules/services/misc/pykms.nix
index ab00086e591..e2d1254602b 100644
--- a/nixos/modules/services/misc/pykms.nix
+++ b/nixos/modules/services/misc/pykms.nix
@@ -4,6 +4,7 @@ with lib;
let
cfg = config.services.pykms;
+ libDir = "/var/lib/pykms";
in {
meta.maintainers = with lib.maintainers; [ peterhoeg ];
@@ -28,12 +29,6 @@ in {
description = "The port on which to listen.";
};
- verbose = mkOption {
- type = types.bool;
- default = false;
- description = "Show verbose output.";
- };
-
openFirewallPort = mkOption {
type = types.bool;
default = false;
@@ -45,30 +40,44 @@ in {
default = "64M";
description = "How much memory to use at most.";
};
+
+ logLevel = mkOption {
+ type = types.enum [ "CRITICAL" "ERROR" "WARNING" "INFO" "DEBUG" "MINI" ];
+ default = "INFO";
+ description = "How much to log";
+ };
+
+ extraArgs = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ description = "Additional arguments";
+ };
};
};
config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewallPort [ cfg.port ];
- systemd.services.pykms = let
- home = "/var/lib/pykms";
- in {
+ systemd.services.pykms = {
description = "Python KMS";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
# python programs with DynamicUser = true require HOME to be set
- environment.HOME = home;
+ environment.HOME = libDir;
serviceConfig = with pkgs; {
DynamicUser = true;
- StateDirectory = baseNameOf home;
- ExecStartPre = "${getBin pykms}/bin/create_pykms_db.sh ${home}/clients.db";
+ StateDirectory = baseNameOf libDir;
+ ExecStartPre = "${getBin pykms}/libexec/create_pykms_db.sh ${libDir}/clients.db";
ExecStart = lib.concatStringsSep " " ([
- "${getBin pykms}/bin/server.py"
+ "${getBin pykms}/bin/server"
+ "--logfile STDOUT"
+ "--loglevel ${cfg.logLevel}"
+ ] ++ cfg.extraArgs ++ [
cfg.listenAddress
(toString cfg.port)
- ] ++ lib.optional cfg.verbose "--verbose");
- WorkingDirectory = home;
+ ]);
+ ProtectHome = "tmpfs";
+ WorkingDirectory = libDir;
Restart = "on-failure";
MemoryLimit = cfg.memoryLimit;
};