]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/buildbot/default.nix
Add caldance buildbot and optimize a bit the drivations
[perso/Immae/Config/Nix.git] / nixops / modules / buildbot / default.nix
index cd5b2609e86484789f56f0a05604d720fd9f8541..9b661f199628bb349bedf3163ce067ab205670a8 100644 (file)
@@ -34,13 +34,15 @@ let
     doCheck = false;
     src = buildslist_src.src;
   };
-  buildbot_common = pkgsNext.python3Packages.buildPythonPackage (mylibs.fetchedGitPrivate ./buildbot_common.json // rec {
+  buildbot_common = pkgsNext.python3Packages.buildPythonPackage rec {
+    name = "buildbot_common";
+    src = ./common;
     format = "other";
     installPhase = ''
       mkdir -p $out/${pkgsNext.python3.pythonForBuild.sitePackages}
       cp -a $src $out/${pkgsNext.python3.pythonForBuild.sitePackages}/buildbot_common
       '';
-  });
+  };
   buildbot = pkgsNext.python3Packages.buildbot-full.withPlugins ([ buildslist ]);
 in
 {
@@ -75,7 +77,7 @@ in
         ProxyPassReverse /buildbot/${project.name}/      unix:///run/buildbot/${project.name}.sock|http://${project.name}-git.immae.eu/
         <Location /buildbot/${project.name}/>
           Use LDAPConnect
-          Require ldap-group cn=users,cn=buildbot,ou=services,dc=immae,dc=eu
+          Require ldap-group cn=users,ou=${project.name},cn=buildbot,ou=services,dc=immae,dc=eu
 
           SetEnvIf X-Url-Scheme https HTTPS=1
           ProxyPreserveHost On
@@ -89,15 +91,50 @@ in
       deps = [ "users" "wrappers" ];
       text = let
         master-cfg = "${buildbot_common}/${pkgsNext.python3.pythonForBuild.sitePackages}/buildbot_common/master.cfg";
-        puppet_notify = pkgs.writeText "puppet_notify" (builtins.readFile "${myconfig.privateFiles}/buildbot_puppet_notify");
+        buildbot_key = pkgs.writeText "buildbot_key" (builtins.readFile "${myconfig.privateFiles}/buildbot_ssh_key");
+        tac_file = pkgs.writeText "buildbot.tac" ''
+            import os
+
+            from twisted.application import service
+            from buildbot.master import BuildMaster
+
+            basedir = '${varDir}/${project.name}'
+            rotateLength = 10000000
+            maxRotatedFiles = 10
+            configfile = '${master-cfg}'
+
+            # Default umask for server
+            umask = None
+
+            # if this is a relocatable tac file, get the directory containing the TAC
+            if basedir == '.':
+                import os
+                basedir = os.path.abspath(os.path.dirname(__file__))
+
+            # note: this line is matched against to check that this is a buildmaster
+            # directory; do not edit it.
+            application = service.Application('buildmaster')
+            from twisted.python.logfile import LogFile
+            from twisted.python.log import ILogObserver, FileLogObserver
+            logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
+                                            maxRotatedFiles=maxRotatedFiles)
+            application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+            m = BuildMaster(basedir, configfile, umask)
+            m.setServiceParent(application)
+            m.log_rotation.rotateLength = rotateLength
+            m.log_rotation.maxRotatedFiles = maxRotatedFiles
+          '';
       in ''
       install -m 0755 -o buildbot -g buildbot -d /run/buildbot/
       install -m 0755 -o buildbot -g buildbot -d ${varDir}
       if [ ! -f ${varDir}/${project.name}/buildbot.tac ]; then
         $wrapperDir/sudo -u buildbot ${buildbot}/bin/buildbot create-master -c "${master-cfg}" "${varDir}/${project.name}"
         rm -f ${varDir}/${project.name}/master.cfg.sample
+        rm -f ${varDir}/${project.name}/buildbot.tac
       fi
-      install -Dm600 -o buildbot -g buildbot -T ${puppet_notify} ${varDir}/puppet_notify
+      ln -sf ${tac_file} ${varDir}/${project.name}/buildbot.tac
+      install -Dm600 -o buildbot -g buildbot -T ${buildbot_key} ${varDir}/buildbot_key
       buildbot_secrets=${varDir}/${project.name}/secrets
       install -m 0600 -o buildbot -g buildbot -d $buildbot_secrets
       echo "${myconfig.env.buildbot.ldap.password}" > $buildbot_secrets/ldap
@@ -119,7 +156,7 @@ in
         project_env = lib.attrsets.mapAttrs' (k: v: lib.attrsets.nameValuePair "BUILDBOT_${k}" v) project.environment;
         buildbot_config = pkgsNext.python3Packages.buildPythonPackage (rec {
           name = "buildbot_config-${project.name}";
-          src = "${./projects}/${project.name}";
+          src = ./projects + "/${project.name}";
           format = "other";
           installPhase = ''
             mkdir -p $out/${pkgsNext.python3.pythonForBuild.sitePackages}