summaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix65
1 files changed, 53 insertions, 12 deletions
diff --git a/default.nix b/default.nix
index 8e634bf..a713f8a 100644
--- a/default.nix
+++ b/default.nix
@@ -3,11 +3,60 @@ let
pkgs = utils.pkgs;
system = utils.system;
in
- rec {
- srv = (import ./srv).build;
- static = (import ./static).build;
+ {config ? ./config.nix}: rec {
config = (import ./config.nix);
+ static = (import ./static).build;
+
+ srv = (import ./srv).build;
+ srvBin = pkgs.writeScript "mediocregopher-mediocre-blog-srvBin" ''
+ #!/bin/sh
+ exec ${srv}/bin/mediocre-blog \
+ -pow-secret "${config.powSecret}" \
+ -ml-smtp-addr "${config.mlSMTPAddr}" \
+ -ml-smtp-auth "${config.mlSMTPAuth}" \
+ -data-dir "${config.dataDir}" \
+ -public-url "${config.publicURL}" \
+ -static-dir "${static}" \
+ -listen-proto "${config.listenProto}" \
+ -listen-addr "${config.listenAddr}"
+ '';
+
+ redisCfg = pkgs.writeText "mediocregopher-mediocre-blog-redisCfg" ''
+ port 0
+ unixsocket ${config.redisListenPath}
+ daemonize no
+ loglevel notice
+ logfile ""
+ appendonly yes
+ appendfilename "appendonly.aof"
+ dir ${config.dataDir}/redis
+ '';
+
+ redisBin = pkgs.writeScript "mediocregopher-mediocre-blog-redisBin" ''
+ #!/bin/sh
+ mkdir -p ${config.dataDir}/redis
+ exec ${pkgs.redis}/bin/redis-server ${redisCfg}
+ '';
+
+ circusCfg = pkgs.writeText "mediocregopher-mediocre-blog-circusCfg" ''
+ [circus]
+ endpoint = tcp://127.0.0.1:0
+ pubsub_endpoint = tcp://127.0.0.1:0
+
+ [watcher:srv]
+ cmd = ${srvBin}
+ numprocesses = 1
+
+ [watcher:redis]
+ cmd = ${redisBin}
+ numprocesses = 1
+ '';
+
+ circusBin = pkgs.writeScript "mediocregopher-mediocre-blog-circusBin" ''
+ exec ${pkgs.circus}/bin/circusd ${circusCfg}
+ '';
+
service = pkgs.writeText "mediocregopher-mediocre-blog" ''
[Unit]
Description=mediocregopher mediocre blog
@@ -18,15 +67,7 @@ in
Restart=always
RestartSec=1s
User=mediocregopher
- ExecStart=${srv}/bin/mediocre-blog \
- -pow-secret "${config.powSecret}" \
- -ml-smtp-addr "${config.mlSMTPAddr}" \
- -ml-smtp-auth "${config.mlSMTPAuth}" \
- -data-dir "${config.dataDir}" \
- -public-url "${config.publicURL}" \
- -static-dir "${static}" \
- -listen-proto "${config.listenProto}" \
- -listen-addr "${config.listenAddr}"
+ ExecStart=${circusBin}
[Install]
WantedBy=multi-user.target