summaryrefslogtreecommitdiff
path: root/srv/default.nix
blob: 3037fd7a71862eeed0de792d46714949a26da95f (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
{
  buildGoModule,
  writeScript,
  writeScriptBin,
  stdenv,

  config,
  staticBuild,
}: rec {

    env = ''

      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.mlPublicURL}

      # redis
      export MEDIOCRE_BLOG_REDIS_PROTO=unix
      export MEDIOCRE_BLOG_REDIS_ADDR=${config.redisListenPath}

      # pow
      export MEDIOCRE_BLOG_POW_SECRET=${config.powSecret}

      # static proxy
      if [ "${config.staticProxyURL}" == "" ]; then
        export MEDIOCRE_BLOG_STATIC_DIR=${staticBuild}
      else
        export MEDIOCRE_BLOG_STATIC_URL=${config.staticProxyURL}
      fi

      # listening
      export MEDIOCRE_BLOG_LISTEN_PROTO=${config.listenProto}
      export MEDIOCRE_BLOG_LISTEN_ADDR=${config.listenAddr}
    '';

    build = buildGoModule {
        pname = "mediocre-blog-srv";
        version = "dev";
        src = ./.;
        vendorSha256 = "02szg1lisfjk8pk9pflbyv97ykg9362r4fhd0w0p2a7c81kf9b8y";

        # disable tests
        checkPhase = '''';
    };

    bin = writeScript "mediocre-blog-srv-bin" ''
        #!/bin/sh
        mkdir -p "${config.dataDir}"
        source ${env}
        exec ${build}/bin/mediocre-blog
    '';

    shell = stdenv.mkDerivation {
        name = "mediocre-blog-srv-shell";
        shellHook = ''
          source ${env}
        '';
    };
}