diff --git a/config.nix b/config.nix index 5f4bc13..410171a 100644 --- a/config.nix +++ b/config.nix @@ -1,5 +1,4 @@ { - runDir = "/tmp/mediocre-blog/run"; dataDir = "/tmp/mediocre-blog/data"; publicURL = "http://localhost:4000"; diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f359845 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "pkgsSrc": { + "locked": { + "lastModified": 1659914493, + "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "pkgsSrc": "pkgsSrc", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3107f8c --- /dev/null +++ b/flake.nix @@ -0,0 +1,63 @@ +{ + inputs.pkgsSrc.url = "nixpkgs/nixos-21.05"; + inputs.utils.url = "github:numtide/flake-utils"; + + outputs = { + + self, pkgsSrc, utils + + }: utils.lib.eachSystem utils.lib.allSystems (system: let + + pkgs = import pkgsSrc { inherit system; }; + + in { + + defaultPackage = pkgs.buildGoModule { + pname = "mediocre-blog"; + version = "dev"; + src = ./src; + + vendorSha256 = "sha256:1vazrrg8rs9n8x40c9r53h9qnyxw59xkp0aq7jl15fliigk6q0cr"; + + subPackages = [ "cmd/mediocre-blog" ]; + + # disable tests + checkPhase = ''''; + }; + + devShell = pkgs.mkShell { + buildInputs = [ pkgs.go pkgs.sqlite ]; + shellHook = '' + + export MEDIOCRE_BLOG_DATA_DIR="/tmp/mediocre-blog/data" + + # mailing list + export MEDIOCRE_BLOG_ML_SMTP_ADDR="" + export MEDIOCRE_BLOG_ML_SMTP_AUTH="" + export MEDIOCRE_BLOG_ML_PUBLIC_URL="http://localhost:4000" + + # pow + export MEDIOCRE_BLOG_POW_SECRET="ssshhh" + + # http + export MEDIOCRE_BLOG_HTTP_PUBLIC_URL="$MEDIOCRE_BLOG_ML_PUBLIC_URL" + export MEDIOCRE_BLOG_HTTP_LISTEN_PROTO="tcp" + export MEDIOCRE_BLOG_HTTP_LISTEN_ADDR=":4000" + + # http auth + # (password is "bar". This should definitely be changed for prod.) + export MEDIOCRE_BLOG_HTTP_AUTH_USERS='{"foo":"$2a$13$0JdWlUfHc.3XimEMpEu1cuu6RodhUvzD9l7iiAqa4YkM3mcFV5Pxi"}' + export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT="1s" + + cd src + + echo 'Loading test data...' + (cd cmd/load-test-data && go run main.go) + + echo -e "\n\nTest data has been loaded into $MEDIOCRE_BLOG_DATA_DIR\n" + echo -e "You can do 'go run ./cmd/mediocre-blog/main.go' to start a dev instance on http://localhost:4000\n\n" + ''; + }; + + }); +}