From ba1bbc2fa848a0b1ad38fdf77bb51530d7a463f2 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Mon, 13 Jan 2014 00:18:05 +0100 Subject: [PATCH] nixos/cgminer: fix restarts, set uid --- nixos/modules/misc/ids.nix | 1 + nixos/modules/services/misc/cgminer.nix | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 82041b3f954e..16eec9043212 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -109,6 +109,7 @@ mongodb = 98; openldap = 99; memcached = 100; + cgminer = 101; # When adding a uid, make sure it doesn't match an existing gid. diff --git a/nixos/modules/services/misc/cgminer.nix b/nixos/modules/services/misc/cgminer.nix index 890d7a4020bc..f715013b51f3 100644 --- a/nixos/modules/services/misc/cgminer.nix +++ b/nixos/modules/services/misc/cgminer.nix @@ -108,20 +108,21 @@ in config = mkIf config.services.cgminer.enable { - users.extraUsers = singleton - { name = cfg.user; + users.extraUsers = optionalAttrs (cfg.user == "cgminer") (singleton + { name = "cgminer"; + uid = config.ids.uids.cgminer; description = "Cgminer user"; - }; + }); environment.systemPackages = [ cfg.package ]; systemd.services.cgminer = { path = [ pkgs.cgminer ]; - after = [ "display-manager.target" "network.target" ]; + after = [ "network.target" "display-manager.service" ]; wantedBy = [ "multi-user.target" ]; - environment = { + environment = { LD_LIBRARY_PATH = ''/run/opengl-driver/lib:/run/opengl-driver-32/lib''; DISPLAY = ":0"; GPU_MAX_ALLOC_PERCENT = "100"; @@ -129,9 +130,11 @@ in }; serviceConfig = { - ExecStart = "${pkgs.cgminer}/bin/cgminer -T -c ${cgminerConfig}"; + ExecStart = "${pkgs.cgminer}/bin/cgminer --syslog --text-only --config ${cgminerConfig}"; User = cfg.user; - RestartSec = 10; + RestartSec = "30s"; + Restart = "always"; + StartLimitInterval = "1m"; }; };