diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 13:37:43 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 13:37:43 -0600 |
commit | 16cfbd19157df76e7296dddb287412f1099feb33 (patch) | |
tree | e4bbf892066cceeaeeaee4c25e5365152412a1c3 /srv/src/http/static/markov | |
parent | 3cdee89c961ae9c836234f5aec87174a04a800a8 (diff) |
Move static assets to within srv
Diffstat (limited to 'srv/src/http/static/markov')
-rw-r--r-- | srv/src/http/static/markov/Makefile | 3 | ||||
-rw-r--r-- | srv/src/http/static/markov/Makefile.md | 6 | ||||
-rw-r--r-- | srv/src/http/static/markov/markov.nix | 63 | ||||
-rw-r--r-- | srv/src/http/static/markov/markov.nix.md | 6 |
4 files changed, 78 insertions, 0 deletions
diff --git a/srv/src/http/static/markov/Makefile b/srv/src/http/static/markov/Makefile new file mode 100644 index 0000000..4195baf --- /dev/null +++ b/srv/src/http/static/markov/Makefile @@ -0,0 +1,3 @@ +bundle: + nix-build markov.nix -A nixBundle + ./result/bin/nix-bundle '((import ./markov.nix) {}).entrypoint' '/bin/markov' diff --git a/srv/src/http/static/markov/Makefile.md b/srv/src/http/static/markov/Makefile.md new file mode 100644 index 0000000..a680113 --- /dev/null +++ b/srv/src/http/static/markov/Makefile.md @@ -0,0 +1,6 @@ +--- +layout: code +include: Makefile +lang: make +--- + diff --git a/srv/src/http/static/markov/markov.nix b/srv/src/http/static/markov/markov.nix new file mode 100644 index 0000000..042ab8d --- /dev/null +++ b/srv/src/http/static/markov/markov.nix @@ -0,0 +1,63 @@ +{ + pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d50923ab2d308a1ddb21594ba6ae064cab65d8ae.tar.gz") {} +}: + +rec { + + markov = pkgs.buildGoModule { + pname = "markov"; + version = "618b666484566de71f2d59114d011ff4621cf375"; + src = pkgs.fetchFromGitHub { + owner = "mediocregopher"; + repo = "markov"; + rev = "618b666484566de71f2d59114d011ff4621cf375"; + sha256 = "1sx9dr1q3vr3q8nyx3965x6259iyl85591vx815g1xacygv4i4fg"; + }; + vendorSha256 = "048wygrmv26fsnypsp6vxf89z3j0gs9f1w4i63khx7h134yxhbc6"; + }; + + entrypoint = pkgs.writeScriptBin "markov" '' + #!${pkgs.stdenv.shell} + + # On every run we create new, temporary, configuration files for redis and + # circus. To do this we create a new config directory. + markovCfgDir=$(${pkgs.coreutils}/bin/mktemp -d) + echo "generating configuration to $markovCfgDir" + + ${pkgs.coreutils}/bin/cat >$markovCfgDir/redis.conf <<EOF + save "" + dir "''${MARKOV_DATA_DIR:-$(pwd)}" + appendonly yes + appendfilename "markov.data" + EOF + + ${pkgs.coreutils}/bin/cat >$markovCfgDir/circus.ini <<EOF + + [circus] + + [watcher:markov] + cmd = ${markov}/bin/markov \ + -listenAddr ''${MARKOV_LISTEN_ADDR:-localhost:8000} \ + -timeout ''${MARKOV_TIMEOUT:-720} + numprocesses = 1 + + [watcher:redis] + cmd = ${pkgs.redis}/bin/redis-server $markovCfgDir/redis.conf + numprocesses = 1 + EOF + + exec ${pkgs.circus}/bin/circusd $markovCfgDir/circus.ini + ''; + + nixBundleSrc = pkgs.fetchFromGitHub { + owner = "matthewbauer"; + repo = "nix-bundle"; + rev = "8e396533ef8f3e8a769037476824d668409b4a74"; + sha256 = "1lrq0990p07av42xz203w64abv2rz9xd8jrzxyvzzwj7vjj7qwyw"; + }; + + nixBundle = (import "${nixBundleSrc}/release.nix") { + nixpkgs' = pkgs; + }; +} + diff --git a/srv/src/http/static/markov/markov.nix.md b/srv/src/http/static/markov/markov.nix.md new file mode 100644 index 0000000..57802b4 --- /dev/null +++ b/srv/src/http/static/markov/markov.nix.md @@ -0,0 +1,6 @@ +--- +layout: code +include: markov.nix +lang: plain +--- + |