summaryrefslogtreecommitdiff
path: root/nixos/sites/go-packages.nix
blob: 639b4c5df4f91d486eb7115ecc751ff0941708f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{ pkgs }:
with pkgs.lib;

let
  mkLocation = virtualHost: module: url: {
    name = "/${module}";
    value = {
      extraConfig = ''
        if ($args = "go-get=1") {
          add_header Content-Type text/html;
          return 200 '<meta name="go-import" content="${virtualHost}/${module} git ${url}">';
        }
        return 302 ${url};
      '';
    };
  };

in { virtualHost, modules }: {
  locations = listToAttrs (mapAttrsToList (mkLocation virtualHost) modules);
}