diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2016-09-29 13:51:44 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2016-09-29 13:51:44 +0300 |
commit | 62f28d30a069135f9c48678507203958adfc334f (patch) | |
tree | 7f38af0c8d3f445ee8cc50906a639baec7011127 /modules/apps/juandelacosa.nix | |
parent | 1af9e6589bdd18e6ba7eeabf073aa7d710020cdd (diff) | |
download | nixsap-62f28d30a069135f9c48678507203958adfc334f.tar.gz |
Moved everything into ./modules
Diffstat (limited to 'modules/apps/juandelacosa.nix')
-rw-r--r-- | modules/apps/juandelacosa.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/apps/juandelacosa.nix b/modules/apps/juandelacosa.nix new file mode 100644 index 0000000..8df6af0 --- /dev/null +++ b/modules/apps/juandelacosa.nix @@ -0,0 +1,68 @@ +{ config, pkgs, lib, ... }: + +let + inherit (builtins) filter toString; + inherit (lib) types mkOption mkEnableOption mkIf hasPrefix + concatStrings optionalString; + inherit (types) str path int nullOr; + + cfg = config.nixsap.apps.juandelacosa; + + ExecStart = concatStrings [ + "${pkgs.juandelacosa}/bin/juandelacosa" + (optionalString (cfg.myFile != null) " -f '${cfg.myFile}'") + (optionalString (cfg.myGroup != null) " -g ${cfg.myGroup}") + (if (cfg.port != null) + then " -p ${toString cfg.port}" + else " -s '${cfg.socket}'") + ]; + + keys = filter (f: f != null && hasPrefix "/run/keys/" f) [ cfg.myFile ]; + +in { + options.nixsap.apps.juandelacosa = { + enable = mkEnableOption "Juan de la Cosa"; + user = mkOption { + description = "User to run as"; + default = "juandelacosa"; + type = str; + }; + port = mkOption { + description = "TCP port to listen on"; + default = null; + type = nullOr int; + }; + socket = mkOption { + description = "UNIX socket to listen on. Ignored when TCP port is set"; + default = "/tmp/juandelacosa.sock"; + type = path; + }; + myFile = mkOption { + description = "MySQL client configuration file"; + default = null; + type = nullOr path; + }; + myGroup = mkOption { + description = "Options group in the MySQL client configuration file"; + default = null; + type = nullOr str; + }; + }; + + config = mkIf cfg.enable { + nixsap.system.users.daemons = [ cfg.user ]; + nixsap.deployment.keyrings.${cfg.user} = keys; + systemd.services.juandelacosa = { + description = "captain of the MariaDB"; + wantedBy = [ "multi-user.target" ]; + wants = [ "keys.target" ]; + after = [ "keys.target" "network.target" "local-fs.target" ]; + serviceConfig = { + inherit ExecStart; + User = cfg.user; + Restart = "on-failure"; + }; + }; + }; +} + |