--- /dev/null
+{
+ description = "Custom Gitweb Package and FCGI Service Wrapper";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ };
+
+ outputs = { self, nixpkgs, ... }:
+ let
+ systems = [ "x86_64-linux" "aarch64-linux" ];
+ forAllSystems = nixpkgs.lib.genAttrs systems;
+ in
+ {
+ packages = forAllSystems (system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+
+ perlDeps = with pkgs.perlPackages; [
+ CGI
+ HTMLParser
+ CGIFast
+ FCGI
+ FCGIProcManager
+ HTMLTagCloud
+ ];
+ in
+ {
+ default = pkgs.stdenv.mkDerivation {
+ pname = "ps-gitweb";
+ version = "1.0.0";
+
+ # Assuming source is in the same directory
+ src = ./.;
+
+ nativeBuildInputs = [ pkgs.makeWrapper ];
+ buildInputs = [ pkgs.perl pkgs.gzip ] ++ perlDeps;
+
+ buildFlags = [ "gitweb" ];
+
+ # 2. The requested postInstall logic
+ postInstall = ''
+ mkdir -p $out/static
+ cp gitweb/gitweb.cgi $out/gitweb.cgi
+ cp gitweb/static/git* $out/static/
+
+ # Ensure the file exists (standard gitweb location)
+ # If your makefile installs elsewhere, adjust this check.
+ if [ -f "$out/gitweb/gitweb.cgi" ]; then
+
+ # Patch gzip path
+ sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${pkgs.gzip}/bin/gzip'|" \
+ $out/gitweb/gitweb.cgi
+
+ # Patch Perl Libs (Injecting dependencies into @INC)
+ for p in ${pkgs.lib.concatStringsSep " " perlDeps}; do
+ sed -i -e "/use CGI /i use lib \"$p/${pkgs.perl.libPrefix}\";" \
+ "$out/gitweb/gitweb.cgi"
+ done
+ else
+ echo "Warning: gitweb.cgi not found in $out/gitweb/"
+ fi
+ '';
+ };
+ });
+ };
+}