From 12047d230075bac819e179eb8814c97fd18da8b4 Mon Sep 17 00:00:00 2001 From: patrick-scho Date: Sat, 29 Nov 2025 13:31:39 +0100 Subject: [PATCH] flake.nix --- flake.nix | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..07d1cdd --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + 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 + ''; + }; + }); + }; +} -- 2.50.1