summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile22
-rw-r--r--config.nix18
-rw-r--r--default.nix93
-rw-r--r--tmp-dev-env.sh14
5 files changed, 0 insertions, 148 deletions
diff --git a/.gitignore b/.gitignore
index 2d3cf65..b2be92b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
result
-prod.config.nix
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 552dd7b..0000000
--- a/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-
-CONFIG = ./config.nix
-BASH = $$(nix-build --no-out-link -A pkgs.bash)/bin/bash
-
-entrypoint:
- nix-build -A entrypoint --arg config '(import ${CONFIG})'
-
-install-systemd:
- $$(nix-build -A install --arg config '(import ${CONFIG})')
-
-test:
- ${BASH} tmp-dev-env.sh \
- --run "cd src; go test ./... -count=1 -tags integration"
-
-shell:
- ${BASH} tmp-dev-env.sh \
- --command " \
- cd src; \
- echo 'Loading test data...'; \
- (cd cmd/load-test-data && go run main.go); \
- return; \
- "
diff --git a/config.nix b/config.nix
deleted file mode 100644
index 410171a..0000000
--- a/config.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- dataDir = "/tmp/mediocre-blog/data";
- publicURL = "http://localhost:4000";
-
- powSecret = "ssshhh";
- mlSMTPAddr = "";
- mlSMTPAuth = "";
- httpListenProto = "tcp";
- httpListenAddr = ":4000";
-
- # password is "bar". This should definitely be changed for prod.
- httpAuthUsers = {
- "foo" = "$2a$13$0JdWlUfHc.3XimEMpEu1cuu6RodhUvzD9l7iiAqa4YkM3mcFV5Pxi";
- };
-
- # Very low, should be increased for prod.
- httpAuthRatelimit = "1s";
-}
diff --git a/default.nix b/default.nix
deleted file mode 100644
index b342fb7..0000000
--- a/default.nix
+++ /dev/null
@@ -1,93 +0,0 @@
-{
-
- pkgs ? import (fetchTarball {
- name = "nixpkgs-21-05";
- url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz";
- sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
- }) {},
-
- config ? import ./config.nix,
-
-}: rec {
-
- inherit pkgs;
-
- init = pkgs.writeText "mediocre-blog-init" ''
-
- export MEDIOCRE_BLOG_DATA_DIR="${config.dataDir}"
-
- # mailing list
- export MEDIOCRE_BLOG_ML_SMTP_ADDR="${config.mlSMTPAddr}"
- export MEDIOCRE_BLOG_ML_SMTP_AUTH="${config.mlSMTPAuth}"
- export MEDIOCRE_BLOG_ML_PUBLIC_URL="${config.publicURL}"
-
- # pow
- export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
-
- # http
- export MEDIOCRE_BLOG_HTTP_PUBLIC_URL="${config.publicURL}"
- export MEDIOCRE_BLOG_HTTP_LISTEN_PROTO="${config.httpListenProto}"
- export MEDIOCRE_BLOG_HTTP_LISTEN_ADDR="${config.httpListenAddr}"
- export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
- export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
- '';
-
- bin = pkgs.buildGoModule {
- pname = "mediocre-blog";
- version = "dev";
- src = ./src;
- vendorSha256 = "sha256:1vazrrg8rs9n8x40c9r53h9qnyxw59xkp0aq7jl15fliigk6q0cr";
-
- subPackages = [ "cmd/mediocre-blog" ];
-
- # disable tests
- checkPhase = '''';
- };
-
- entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
- #!${pkgs.bash}/bin/bash
-
- set -e
- source ${init}
-
- mkdir -p ${config.runDir}
- mkdir -p ${config.dataDir}
-
- exec ${bin}/bin/mediocre-blog "$@"
- '';
-
- shell = pkgs.stdenv.mkDerivation {
- name = "mediocre-blog-shell";
- buildInputs = [ pkgs.go pkgs.sqlite ];
- shellHook = ''
- source ${init}
- '';
- };
-
- service = pkgs.writeText "mediocre-blog" ''
- [Unit]
- Description=mediocregopher mediocre blog
- Requires=network.target
- After=network.target
-
- [Service]
- Restart=always
- RestartSec=1s
- User=mediocregopher
- Group=mediocregopher
- RuntimeDirectory=mediocre-blog
- ExecStart=${entrypoint}
-
- [Install]
- WantedBy=multi-user.target
- '';
-
- install = pkgs.writeScript "mediocre-blog" ''
- set -e -x
-
- sudo cp ${service} /etc/systemd/system/mediocregopher-mediocre-blog.service
- sudo systemctl daemon-reload
- sudo systemctl enable mediocregopher-mediocre-blog.service
- sudo systemctl restart mediocregopher-mediocre-blog.service
- '';
-}
diff --git a/tmp-dev-env.sh b/tmp-dev-env.sh
deleted file mode 100644
index d95cc7b..0000000
--- a/tmp-dev-env.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-set -e
-
-test_dir="$(mktemp -d)"
-trap "rm -rf $test_dir" EXIT
-
-mkdir -p "$test_dir"/run
-mkdir -p "$test_dir"/data
-
-test_cfg="(import ./config.nix) // {
- runDir=\"${test_dir}/run\";
- dataDir=\"${test_dir}/data\";
-}"
-
-nix-shell -A shell --arg config "$test_cfg" "$@"