blob: 5094ebe8c5cfd3797357901b9ce443ba1eee8708 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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.cgi" ]; then
# Patch gzip path
sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${pkgs.gzip}/bin/gzip'|" \
$out/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.cgi"
done
else
echo "Warning: gitweb.cgi not found in $out/"
fi
'';
};
});
};
}
|