summaryrefslogtreecommitdiffstats
path: root/lass/3modules/go.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-10-14 00:17:15 +0200
committermakefu <github@syntax-fehler.de>2015-10-14 00:17:15 +0200
commitdf3dc3dac1f6c1cc36dbbea506e3d610aa1b417d (patch)
tree038a837b20d267d0ba5aad837884b6a5a9087613 /lass/3modules/go.nix
parentf73fe104d84b2f0d2fc3b4f0342c36735b3fb220 (diff)
parent96f4248b65ff1539eded24572ae1805b27c53d50 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'lass/3modules/go.nix')
-rw-r--r--lass/3modules/go.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/lass/3modules/go.nix b/lass/3modules/go.nix
new file mode 100644
index 000000000..aa900f118
--- /dev/null
+++ b/lass/3modules/go.nix
@@ -0,0 +1,61 @@
+{ config, lib, pkgs, ... }:
+
+with builtins;
+with lib;
+
+let
+ cfg = config.lass.go;
+
+ out = {
+ options.lass.go = api;
+ config = mkIf cfg.enable imp;
+ };
+
+ api = {
+ enable = mkEnableOption "Enable go url shortener";
+ port = mkOption {
+ type = types.str;
+ default = "1337";
+ description = "on which port go should run on";
+ };
+ redisKeyPrefix = mkOption {
+ type = types.str;
+ default = "go:";
+ description = "change the Redis key prefix which defaults to `go:`";
+ };
+ };
+
+ imp = {
+ users.extraUsers.go = {
+ name = "go";
+ uid = 42774411; #genid go
+ description = "go url shortener user";
+ home = "/var/lib/go";
+ createHome = true;
+ };
+
+ systemd.services.go = {
+ description = "go url shortener";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+
+ path = with pkgs; [
+ go
+ ];
+
+ environment = {
+ PORT = cfg.port;
+ REDIS_KEY_PREFIX = cfg.redisKeyPrefix;
+ };
+
+ restartIfChanged = true;
+
+ serviceConfig = {
+ User = "go";
+ Restart = "always";
+ ExecStart = "${pkgs.go}/bin/go";
+ };
+ };
+ };
+
+in out