stockholm/krebs/3modules/go.nix

67 lines
1.3 KiB
Nix
Raw Normal View History

2015-10-08 23:11:29 +00:00
{ config, lib, pkgs, ... }:
with builtins;
with lib;
let
2015-11-13 00:16:15 +00:00
cfg = config.krebs.go;
2015-10-08 23:11:29 +00:00
out = {
2015-11-13 00:16:15 +00:00
options.krebs.go = api;
2015-10-08 23:11:29 +00:00
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 = {
2015-11-12 23:50:02 +00:00
services.redis = {
enable = mkDefault true;
bind = mkDefault "127.0.0.1";
};
2015-10-08 23:11:29 +00:00
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