summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 3107f8cb05aa77ec0d9807b3d118310318297d23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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"
      '';
    };

  });
}