]> gitweb.ps.run Git - ps-gitweb/commitdiff
flake.nix
authorpatrick-scho <patrick.schoenberger@posteo.de>
Sat, 29 Nov 2025 12:31:39 +0000 (13:31 +0100)
committerpatrick-scho <patrick.schoenberger@posteo.de>
Sat, 29 Nov 2025 12:31:39 +0000 (13:31 +0100)
flake.nix [new file with mode: 0644]

diff --git a/flake.nix b/flake.nix
new file mode 100644 (file)
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
+            '';
+          };
+        });
+    };
+}