2 description = "Custom Gitweb Package and FCGI Service Wrapper";
5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
8 outputs = { self, nixpkgs, ... }:
10 systems = [ "x86_64-linux" "aarch64-linux" ];
11 forAllSystems = nixpkgs.lib.genAttrs systems;
14 packages = forAllSystems (system:
16 pkgs = nixpkgs.legacyPackages.${system};
18 perlDeps = with pkgs.perlPackages; [
28 default = pkgs.stdenv.mkDerivation {
32 # Assuming source is in the same directory
35 nativeBuildInputs = [ pkgs.makeWrapper ];
36 buildInputs = [ pkgs.perl pkgs.gzip ] ++ perlDeps;
38 buildFlags = [ "gitweb" ];
40 # 2. The requested postInstall logic
43 cp gitweb/gitweb.cgi $out/gitweb.cgi
44 cp gitweb/static/git* $out/static/
46 # Ensure the file exists (standard gitweb location)
47 # If your makefile installs elsewhere, adjust this check.
48 if [ -f "$out/gitweb/gitweb.cgi" ]; then
51 sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${pkgs.gzip}/bin/gzip'|" \
52 $out/gitweb/gitweb.cgi
54 # Patch Perl Libs (Injecting dependencies into @INC)
55 for p in ${pkgs.lib.concatStringsSep " " perlDeps}; do
56 sed -i -e "/use CGI /i use lib \"$p/${pkgs.perl.libPrefix}\";" \
57 "$out/gitweb/gitweb.cgi"
60 echo "Warning: gitweb.cgi not found in $out/gitweb/"