]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Change buildbot environment variables to secrets location
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 29 Jan 2021 13:14:41 +0000 (14:14 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 29 Jan 2021 13:14:41 +0000 (14:14 +0100)
modules/private/buildbot/default.nix
nixops/secrets

index 6674ad72f622326eadde698ed2831797df3fd7a0..d6753e54ac23c7d09074083d8a617b5d6a2539b0 100644 (file)
@@ -98,6 +98,19 @@ in
                 '';
               dest = "buildbot/${project.name}/webhook-httpd-include";
             }
+            {
+              permissions = "0600";
+              user = "buildbot";
+              group = "buildbot";
+              dest = "buildbot/${project.name}/environment_file";
+              text = let
+                project_env = with lib.attrsets;
+                  mapAttrs' (k: v: nameValuePair "BUILDBOT_${k}" v) project.environment //
+                  mapAttrs' (k: v: nameValuePair "BUILDBOT_PATH_${k}" (v pkgs)) (attrByPath ["builderPaths"] {} project) //
+                  { BUILDBOT_PROJECT_DIR = ./projects + "/${project.name}"; };
+                in builtins.concatStringsSep "\n"
+                  (lib.mapAttrsToList (envK: envV: "${envK}=${envV}") project_env);
+            }
           ]
         ) config.myEnv.buildbot.projects
       )
@@ -123,6 +136,7 @@ in
       paths = [
         "/var/secrets/buildbot/ldap"
         "/var/secrets/buildbot/ssh_key"
+        "/var/secrets/buildbot/${project.name}/environment_file"
       ] ++ lib.attrsets.mapAttrsToList (k: v: "/var/secrets/buildbot/${project.name}/${k}") project.secrets;
     }) config.myEnv.buildbot.projects;
 
@@ -188,10 +202,6 @@ in
       ${buildbot}/bin/buildbot upgrade-master ${varDir}/${project.name}
       '';
       environment = let
-        project_env = with lib.attrsets;
-          mapAttrs' (k: v: nameValuePair "BUILDBOT_${k}" v) project.environment //
-          mapAttrs' (k: v: nameValuePair "BUILDBOT_PATH_${k}" (v pkgs)) (attrByPath ["builderPaths"] {} project) //
-          { BUILDBOT_PROJECT_DIR = ./projects + "/${project.name}"; };
         buildbot_config = pkgs.python3Packages.buildPythonPackage (rec {
           name = "buildbot_config-${project.name}";
           src = ./projects + "/${project.name}";
@@ -208,7 +218,7 @@ in
           pkgs.python3Packages.buildbot-worker
           buildbot_common buildbot_config
         ])}/${buildbot.pythonModule.sitePackages}${if project.pythonPathHome then ":${varDir}/${project.name}/.local/${pkgs.python3.pythonForBuild.sitePackages}" else ""}";
-      in project_env // { inherit PYTHONPATH HOME; };
+      in { inherit PYTHONPATH HOME; };
 
       serviceConfig = {
         Slice = "buildbot.slice";
@@ -221,6 +231,7 @@ in
         SupplementaryGroups = "keys";
         WorkingDirectory = "${varDir}/${project.name}";
         ExecStart = "${buildbot}/bin/buildbot start";
+        EnvironmentFile = "/var/secrets/buildbot/${project.name}/environment_file";
       };
     }) config.myEnv.buildbot.projects;
   };
index 3a74f309999f47dc843a61a23bd4799a23f8ffae..e570ae5038b922f24b946b2c54af2d4b51f1bae3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 3a74f309999f47dc843a61a23bd4799a23f8ffae
+Subproject commit e570ae5038b922f24b946b2c54af2d4b51f1bae3