summaryrefslogtreecommitdiff
path: root/Biz/Dragons.nix
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Dragons.nix')
-rw-r--r--Biz/Dragons.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/Biz/Dragons.nix b/Biz/Dragons.nix
new file mode 100644
index 0000000..6473232
--- /dev/null
+++ b/Biz/Dragons.nix
@@ -0,0 +1,66 @@
+{ options
+, lib
+, config
+, pkgs
+, ...
+}:
+
+let
+ cfg = config.services.dragons;
+in
+{
+ options.services.dragons = {
+ enable = lib.mkEnableOption "Enable the dragons service";
+ port = lib.mkOption {
+ type = lib.types.int;
+ default = 3000;
+ description = ''
+ The port on which dragons will listen for
+ incoming HTTP traffic.
+ '';
+ };
+ keep = lib.mkOption {
+ type = lib.types.path;
+ default = "/var/dragons/keep";
+ description = "Keep location";
+ };
+ depo = lib.mkOption {
+ type = lib.types.path;
+ default = "/var/dragons/depo";
+ description = "depo location";
+ };
+ package = lib.mkOption {
+ type = lib.types.package;
+ description = "dragons package to use";
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ systemd.services.dragons = {
+ path = [ cfg.package pkgs.git ];
+ wantedBy = [ "multi-user.target" ];
+ preStart = ''
+ mkdir -p ${cfg.keep}
+ mkdir -p ${cfg.depo}
+ '';
+ script = ''
+ ${cfg.package}/bin/dragons
+ '';
+ description = ''
+ Dragons
+ '';
+ serviceConfig = {
+ Environment = [
+ "PORT=${toString cfg.port}"
+ "AREA=Live"
+ "DEPO=${cfg.depo}"
+ "KEEP=${cfg.keep}"
+ ];
+ EnvironmentFile="/run/dragons/env";
+ KillSignal = "INT";
+ Type = "simple";
+ Restart = "on-abort";
+ RestartSec = "1";
+ };
+ };
+ };
+}