From 9ef363410f21bc5e93e7693e1f2baa4d95ed214f Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 22 Apr 2021 11:07:31 -0600 Subject: nix process composition --- src/assets/markov/Makefile | 3 ++ src/assets/markov/Makefile.md | 6 ++++ src/assets/markov/markov.nix | 63 +++++++++++++++++++++++++++++++++++++++++ src/assets/markov/markov.nix.md | 6 ++++ 4 files changed, 78 insertions(+) create mode 100644 src/assets/markov/Makefile create mode 100644 src/assets/markov/Makefile.md create mode 100644 src/assets/markov/markov.nix create mode 100644 src/assets/markov/markov.nix.md (limited to 'src/assets') diff --git a/src/assets/markov/Makefile b/src/assets/markov/Makefile new file mode 100644 index 0000000..4195baf --- /dev/null +++ b/src/assets/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/src/assets/markov/Makefile.md b/src/assets/markov/Makefile.md new file mode 100644 index 0000000..a680113 --- /dev/null +++ b/src/assets/markov/Makefile.md @@ -0,0 +1,6 @@ +--- +layout: code +include: Makefile +lang: make +--- + diff --git a/src/assets/markov/markov.nix b/src/assets/markov/markov.nix new file mode 100644 index 0000000..042ab8d --- /dev/null +++ b/src/assets/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 <$markovCfgDir/circus.ini <