diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2021-08-30 21:38:09 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2021-08-30 21:38:09 -0600 |
commit | 6bebc3fae73b5f5f68e5de9e083635cfab9037b1 (patch) | |
tree | 634bf166a2295ba3d4fc12bf71f22eeb48fe3b35 | |
parent | 9343d2ea697f13e52e9199fce62a959f1954f580 (diff) |
have circus run static serve, and optionally able to skip services via Makefile
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | default.nix | 34 | ||||
-rw-r--r-- | srv/default.nix | 2 | ||||
-rw-r--r-- | static/default.nix | 1 |
4 files changed, 44 insertions, 9 deletions
@@ -1,8 +1,20 @@ +SKIP_SERVICES = [] + all: - nix-build -A entrypoint --arg baseConfig '(import ./config.nix) // { staticProxyURL = ""; }' + nix-build -A entrypoint \ + --arg baseConfig '(import ./config.nix)' \ + --arg baseSkipServices '${SKIP_SERVICES}' + +run: all + ./result all.prod: - nix-build -A entrypoint --arg baseConfig '(import ./prod.config.nix)' + nix-build -A entrypoint \ + --arg baseConfig '(import ./prod.config.nix)' \ + --arg baseSkipServices '${SKIP_SERVICES}' + +run.prod: all.prod + ./result install.prod: nix-build -A install --arg baseConfig '(import ./prod.config.nix)' diff --git a/default.nix b/default.nix index 4352e5c..fac1871 100644 --- a/default.nix +++ b/default.nix @@ -7,6 +7,7 @@ }) {}, baseConfig ? import ./config.nix, + baseSkipServices ? [], }: rec { @@ -14,6 +15,12 @@ redisListenPath = "${config.runDir}/redis"; }; + skipServices = baseSkipServices ++ ( + if baseConfig.staticProxyURL == "" + then [ "static" ] + else [] + ); + static = (import ./static) { inherit pkgs; }; srv = (import ./srv) { @@ -38,20 +45,37 @@ exec ${pkgs.redis}/bin/redis-server ${redisCfg} ''; - circusCfg = pkgs.writeText "mediocre-blog-circusCfg" '' - [circus] - endpoint = tcp://127.0.0.1:0 - pubsub_endpoint = tcp://127.0.0.1:0 - + srvCircusCfg = '' [watcher:srv] cmd = ${srv.bin} numprocesses = 1 + ''; + redisCircusCfg = '' [watcher:redis] cmd = ${redisBin} numprocesses = 1 ''; + staticCircusCfg = '' + [watcher:static] + cmd = ${static.serve}/bin/static-serve + numprocesses = 1 + working_dir = ./static + ''; + + circusCfg = pkgs.writeText "mediocre-blog-circusCfg" '' + [circus] + endpoint = tcp://127.0.0.1:0 + pubsub_endpoint = tcp://127.0.0.1:0 + + ${if (!builtins.elem "srv" skipServices) then srvCircusCfg else ""} + + ${if (!builtins.elem "redis" skipServices) then redisCircusCfg else ""} + + ${if (!builtins.elem "static" skipServices) then staticCircusCfg else ""} + ''; + entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" '' #!/bin/sh mkdir -p ${config.runDir} diff --git a/srv/default.nix b/srv/default.nix index eaf6ddc..a36739a 100644 --- a/srv/default.nix +++ b/srv/default.nix @@ -12,7 +12,7 @@ "-listen-proto=${config.listenProto}" "-listen-addr=${config.listenAddr}" "-redis-proto=unix" - "-redis-addr=${config.runDir}/redis" + "-redis-addr=${config.redisListenPath}" ] ++ ( if config.staticProxyURL == "" then [ "-static-dir=${staticBuild}" ] diff --git a/static/default.nix b/static/default.nix index 7c50dfa..04bd077 100644 --- a/static/default.nix +++ b/static/default.nix @@ -13,7 +13,6 @@ gemdir = ./.; }; - build = pkgs.stdenv.mkDerivation { name = "mediocre-blog-static"; src = ./src; |