]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/buildbot/default.nix
Move secrets module outside of nixops
[perso/Immae/Config/Nix.git] / nixops / modules / buildbot / default.nix
index 057b58ba1d336b0c8b6d5cd6509cc83814769f30..5cf833b8e2a41bf8ae948accd89c55d4e54362c7 100644 (file)
@@ -8,6 +8,9 @@ let
     inherit (pkgs.buildbot-pkg) version;
     packageJSON = "${buildslist_src.src}/package.json";
     yarnLock = "${buildslist_src.src}/yarn.lock";
+    pkgConfig = {
+      all = { buildInputs = [ mylibs.yarn2nixPackage.src ]; };
+    };
   };
   buildslist_bower = pkgs.buildBowerComponents {
     name = "buildslist";
@@ -59,33 +62,6 @@ in
   };
 
   config = lib.mkIf config.services.buildbot.enable {
-    nixpkgs.overlays = [ (self: super: rec {
-      python3 = super.python3.override {
-        packageOverrides = python-self: python-super: {
-          wokkel = python-self.buildPythonPackage rec {
-            pname = "wokkel";
-            version = "18.0.0";
-            src = python-self.fetchPypi {
-              inherit pname version;
-              sha256 = "1spq44gg8gsviqx1dvlmjpgfc0wk0jpyx4ap01y2pad1ai9cw016";
-            };
-            propagatedBuildInputs = with python-self; [ twisted.extras.tls twisted incremental dateutil ];
-            doChecks = false;
-          };
-          apprise = python-self.buildPythonPackage rec {
-            pname = "apprise";
-            version = "0.7.4";
-            src = (mylibs.fetchedGithub ./apprise.json).src;
-            propagatedBuildInputs = with python-self; [ decorator
-            requests requests_oauthlib oauthlib urllib3 six click
-            markdown pyyaml sleekxmpp
-            ];
-            doChecks = false;
-          };
-        };
-      };
-    }) ];
-
     ids.uids.buildbot = myconfig.env.buildbot.user.uid;
     ids.gids.buildbot = myconfig.env.buildbot.user.gid;
 
@@ -116,7 +92,7 @@ in
           <RequireAny>
             Require local
             Require ldap-group cn=users,ou=${project.name},cn=buildbot,ou=services,dc=immae,dc=eu
-            Include /run/keys/buildbot/${project.name}/buildbot-${project.name}-webhook-httpd-include
+            Include /var/secrets/buildbot/${project.name}/webhook-httpd-include
           </RequireAny>
         </Location>
         '') myconfig.env.buildbot.projects;
@@ -130,52 +106,51 @@ in
       '';
     }) myconfig.env.buildbot.projects;
 
-    deployment.keys = lib.attrsets.listToAttrs (
+    secrets.keys = (
       lib.lists.flatten (
         lib.attrsets.mapAttrsToList (k: project:
           lib.attrsets.mapAttrsToList (k: v:
-            lib.attrsets.nameValuePair "buildbot-${project.name}-${k}" {
+            {
               permissions = "0600";
               user = "buildbot";
               group = "buildbot";
               text = v;
-              destDir = "/run/keys/buildbot/${project.name}";
+              dest = "buildbot/${project.name}/${k}";
             }
           ) project.secrets
           ++ [
-            (lib.attrsets.nameValuePair "buildbot-${project.name}-webhook-httpd-include" {
+            {
               permissions = "0600";
               user = "wwwrun";
               group = "wwwrun";
               text = lib.optionalString (lib.attrsets.hasAttr "webhookTokens" project) ''
                 Require expr "req('Access-Key') in { ${builtins.concatStringsSep ", " (map (x: "'${x}'") project.webhookTokens)} }"
                 '';
-              destDir = "/run/keys/buildbot/${project.name}";
-            })
+              dest = "buildbot/${project.name}/webhook-httpd-include";
+            }
           ]
         ) myconfig.env.buildbot.projects
       )
-    ) // {
-      buildbot-ldap = {
+    ) ++ [
+      {
         permissions = "0600";
         user = "buildbot";
         group = "buildbot";
         text = myconfig.env.buildbot.ldap.password;
-        destDir = "/run/keys/buildbot";
-      };
-      buildbot-ssh-key = {
+        dest = "buildbot/ldap";
+      }
+      {
         permissions = "0600";
         user = "buildbot";
         group = "buildbot";
         text = builtins.readFile "${myconfig.privateFiles}/buildbot_ssh_key";
-        destDir = "/run/keys/buildbot";
-      };
-    };
+        dest = "buildbot/ssh_key";
+      }
+    ];
 
     systemd.services = lib.attrsets.mapAttrs' (k: project: lib.attrsets.nameValuePair "buildbot-${project.name}" {
       description = "Buildbot Continuous Integration Server ${project.name}.";
-      after = [ "network-online.target" "keys.target" ];
-      wants = [ "keys.target" ];
+      after = [ "network-online.target" ];
       wantedBy = [ "multi-user.target" ];
       path = project.packages pkgs ++ (project.pythonPackages buildbot.pythonModule pkgs);
       preStart = let
@@ -220,12 +195,13 @@ in
         rm -f ${varDir}/${project.name}/buildbot.tac
       fi
       ln -sf ${tac_file} ${varDir}/${project.name}/buildbot.tac
-      install -Dm600 -o buildbot -g buildbot -T /run/keys/buildbot/buildbot-ssh-key ${varDir}/buildbot_key
+      # different buildbots may be trying that simultaneously, add the || true to avoid complaining in case of race
+      install -Dm600 -o buildbot -g buildbot -T /var/secrets/buildbot/ssh_key ${varDir}/buildbot_key || true
       buildbot_secrets=${varDir}/${project.name}/secrets
       install -m 0700 -o buildbot -g buildbot -d $buildbot_secrets
-      install -Dm600 -o buildbot -g buildbot -T /run/keys/buildbot/buildbot-ldap $buildbot_secrets/ldap
+      install -Dm600 -o buildbot -g buildbot -T /var/secrets/buildbot/ldap $buildbot_secrets/ldap
       ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList
-        (k: v: "install -Dm600 -o buildbot -g buildbot -T /run/keys/buildbot/${project.name}/buildbot-${project.name}-${k} $buildbot_secrets/${k}") project.secrets
+        (k: v: "install -Dm600 -o buildbot -g buildbot -T /var/secrets/buildbot/${project.name}/${k} $buildbot_secrets/${k}") project.secrets
       )}
       '';
       environment = let