about summary refs log blame commit diff
path: root/third_party/gerrit_plugins/builder.nix
blob: a478dfe5d71daa0fd839964d9134b0b6485e4533 (plain) (tree)
1
2
3
4
5
6
7
8
9
                          
 

                          
             
         
                     

                                             
                                                                                                                               
        
                            
                    
                   
                                                  
                           
 

                                                      
                          
                           
                            
         
                                                                       
 





                                     








                                                 
        
 
{ depot, lib, pkgs, ... }:
{
  buildGerritBazelPlugin =
    { name
    , version
    , src
    , depsHash ? null
    , overlayPluginCmd ? ''
        cp -R "${src}" "$out/plugins/${name}"
        echo "STABLE_BUILD_${lib.toUpper name}_LABEL v${version}-nix${if patches != [] then "-dirty" else ""}" >> $out/.version
      ''
    , postOverlayPlugin ? ""
    , postPatch ? ""
    , patches ? [ ]
    }: ((depot.third_party.gerrit.override (old: {
      name = "${name}.jar";

      src = pkgs.runCommandLocal "${name}-src" { } ''
        cp -R "${depot.third_party.gerrit.src}" "$out"
        chmod -R +w "$out"
        ${overlayPluginCmd}
        ${postOverlayPlugin}
      '';
      depsHash = (if depsHash != null then depsHash else old.depsHash);

      bazelTargets = {
        "//plugins/${name}" = "$out";
      };

      extraBuildInstall = "";
    })).overrideAttrs (super: {
      postPatch = ''
        ${super.postPatch or ""}
        pushd "plugins/${name}"
        ${lib.concatMapStringsSep "\n" (patch: ''
          patch -p1 < ${patch}
        '') patches}
        popd
        ${postPatch}
      '';
    }));
}