summaryrefslogtreecommitdiff
path: root/nixos/sites/go-packages.nix
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-07-11 14:10:50 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-07-11 14:10:50 +0100
commita280569c89bef9d67e20db601a0a26cc3b0fe302 (patch)
tree1bacf6bfce4216a53892dde1667727670aa31393 /nixos/sites/go-packages.nix
parentb62307bf39fcb476bad015bd7ec34e7e2c04e9e4 (diff)
replace cgit and go-packages with sites.* functions
Diffstat (limited to '')
-rw-r--r--nixos/sites/go-packages.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/sites/go-packages.nix b/nixos/sites/go-packages.nix
new file mode 100644
index 0000000..639b4c5
--- /dev/null
+++ b/nixos/sites/go-packages.nix
@@ -0,0 +1,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);
+}