summaryrefslogtreecommitdiff
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
parentb62307bf39fcb476bad015bd7ec34e7e2c04e9e4 (diff)
replace cgit and go-packages with sites.* functions
-rw-r--r--nixos/sites/cgit.nix55
-rw-r--r--nixos/sites/default.nix2
-rw-r--r--nixos/sites/go-packages.nix20
3 files changed, 77 insertions, 0 deletions
diff --git a/nixos/sites/cgit.nix b/nixos/sites/cgit.nix
new file mode 100644
index 0000000..10037bd
--- /dev/null
+++ b/nixos/sites/cgit.nix
@@ -0,0 +1,55 @@
+{ pkgs, lib }:
+
+{ fcgiwrapSocket
+, scanPath
+, projectList
+
+, aboutFilter ? "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh"
+, sourceFilter ? "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py"
+
+, extraConfig ? ""
+}:
+
+let
+ cgitConfig = pkgs.writeText "cgitrc" ''
+ cache-size=1000
+ virtual-root=/
+
+ about-filter=${aboutFilter}
+ source-filter=${sourceFilter}
+
+ remove-suffix=1
+
+ enable-git-config=1
+ #enable-gitweb-owner=1
+ project-list=${projectList}
+ scan-path=${scanPath}
+
+ enable-blame=1
+ enable-follow-links=1
+ enable-index-owner=0
+
+ enable-http-clone=1
+
+ snapshots=tar.gz zip
+
+ ${extraConfig}
+ '';
+
+in {
+ root = "${pkgs.cgit}/cgit/";
+ extraConfig = ''
+ try_files $uri @cgit;
+
+ location @cgit {
+ include ${pkgs.nginx}/conf/fastcgi_params;
+ fastcgi_param CGIT_CONFIG ${cgitConfig};
+ fastcgi_param HTTP_HOST $server_name;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param QUERY_STRING $args;
+ fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
+
+ fastcgi_pass unix:${fcgiwrapSocket};
+ }
+ '';
+}
diff --git a/nixos/sites/default.nix b/nixos/sites/default.nix
index 032803e..b78d571 100644
--- a/nixos/sites/default.nix
+++ b/nixos/sites/default.nix
@@ -2,6 +2,8 @@
{
catbus-web-ui = pkgs.callPackage ./catbus-web-ui.nix {};
+ cgit = pkgs.callPackage ./cgit.nix {};
+ go-packages = pkgs.callPackage ./go-packages.nix {};
https = site: site // {
forceSSL = true;
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);
+}