Commit 15be059c0e3a

Vincent Demeester <vincent@sbr.pm>
2020-04-20 18:30:33
Add govanity service module and enable on kerkouane
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 878f16f
Changed files (3)
tmp
nixos-configuration
tmp/nixos-configuration/machine/kerkouane.nix
@@ -23,6 +23,22 @@ with import ../assets/machines.nix; {
     };
   };
   services = {
+    govanityurl = {
+      enable = true;
+      user = "nginx";
+      host = "pkg.sbr.pm";
+      config = ''
+        paths:
+          /ape:
+            repo: https://github.com/vdemeester/ape
+          /nr:
+            repo: https://github.com/vdemeester/nr
+          /ram:
+            repo: https://github.com/vdemeester/ram
+          /sec:
+            repo: https://github.com/vdemeester/sec
+      '';
+    };
     nginx = {
       enable = true;
       virtualHosts."dl.sbr.pm" = {
@@ -41,6 +57,11 @@ with import ../assets/machines.nix; {
           index = "index.html";
         };
       };
+      virtualHosts."go.sbr.pm" = {
+        enableACME = true;
+        forceSSL = true;
+        locations."/" = { proxyPass = "http://127.0.0.1:8080"; };
+      };
       virtualHosts."sbr.pm" = {
         enableACME = true;
         forceSSL = true;
tmp/nixos-configuration/modules/services/govanityurl.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.services.govanityurl;
+in
+{
+  options = {
+    services.govanityurl = {
+      enable = mkEnableOption ''
+        govanityurl is a go canonical path server
+      '';
+      package = mkOption {
+        type = types.package;
+        default = pkgs.nur.repos.vdemeester.govanityurl;
+        description = ''
+          govanityurl package to use.
+        '';
+      };
+
+      user = mkOption {
+        type = types.str;
+      };
+
+      host = mkOption {
+        type = types.str;
+      };
+
+      config = mkOption {
+        type = types.lines;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    systemd.packages = [ cfg.package ];
+    environment.etc."govanityurl/config.yaml".text = ''
+      host: ${cfg.host}
+      ${cfg.config}
+    '';
+    systemd.services.athens = {
+      description = "Govanity service";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        User = cfg.user;
+        Restart = "on-failure";
+        ExecStart = ''
+          ${cfg.package}/bin/govanityurl /etc/govanityurl/config.yaml
+        '';
+      };
+      path = [ cfg.package ];
+    };
+  };
+}
tmp/nixos-configuration/modules/module-list.nix
@@ -32,6 +32,7 @@
     ./profiles/zsh.nix
     ./programs/podman.nix
     ./services/athens.nix
+    ./services/govanityurl.nix
     ./services/nix-binary-cache.nix
     ./services/wireguard.client.nix
     ./virtualisation/buildkit.nix