forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / by-name / x2 / x2goserver / package.nix
blob44e16e378f5594756629300e0fa86d5b79b29bff
1 { stdenv, lib, fetchurl, perlPackages, makeWrapper, perl, which, nx-libs
2 , util-linux, coreutils, glibc, gawk, gnused, gnugrep, findutils, xorg
3 , nettools, iproute2, bc, procps, psmisc, lsof, pwgen, openssh, sshfs, bash
4 }:
6 let
7   pname = "x2goserver";
8   version = "4.1.0.3";
10   src = fetchurl {
11     url = "https://code.x2go.org/releases/source/${pname}/${pname}-${version}.tar.gz";
12     sha256 = "Z3aqo1T1pE40nws8F21JiMiKYYwu30bJijeuicBp3NA=";
13   };
15   x2go-perl = perlPackages.buildPerlPackage rec {
16     pname = "X2Go";
17     inherit version src;
18     makeFlags = [ "-f" "Makefile.perl" ];
19     patchPhase = ''
20       substituteInPlace X2Go/Config.pm --replace '/etc/x2go' '/var/lib/x2go/conf'
21       substituteInPlace X2Go/Server/DB.pm \
22         --replace '$x2go_lib_path/libx2go-server-db-sqlite3-wrapper' \
23                   '/run/wrappers/bin/x2gosqliteWrapper'
24       substituteInPlace X2Go/Server/DB/SQLite3.pm --replace "user='x2gouser'" "user='x2go'"
25     '';
26   };
28   perlEnv = perl.withPackages (p: with p; [
29     x2go-perl DBI DBDSQLite FileBaseDir TryTiny CaptureTiny ConfigSimple Switch FileWhich
30   ]);
32   binaryDeps = [
33     perlEnv which nx-libs util-linux coreutils glibc.bin gawk gnused gnugrep
34     findutils nettools iproute2 bc procps psmisc lsof pwgen openssh sshfs
35     xorg.xauth xorg.xinit xorg.xrandr xorg.xmodmap xorg.xwininfo xorg.fontutil
36     xorg.xkbcomp xorg.setxkbmap
37   ];
39 stdenv.mkDerivation rec {
40   inherit pname version src;
42   buildInputs = [ perlEnv bash ];
44   nativeBuildInputs = [ makeWrapper ];
46   prePatch = ''
47     patchShebangs .
48     sed -i '/Makefile.PL\|Makefile.perl/d' Makefile
49     for i in */Makefile; do
50       substituteInPlace "$i" --replace "-o root -g root " ""
51     done
52     substituteInPlace libx2go-server-db-perl/Makefile --replace "chmod 2755" "chmod 755"
53     for i in x2goserver/sbin/x2godbadmin x2goserver/bin/x2go*
54     do
55       substituteInPlace $i --replace '/etc/x2go' '/var/lib/x2go/conf'
56     done
57     substituteInPlace x2goserver/sbin/x2gocleansessions \
58       --replace '/var/run/x2goserver.pid' '/var/run/x2go/x2goserver.pid'
59     substituteInPlace x2goserver/sbin/x2godbadmin --replace 'user="x2gouser"' 'user="x2go"'
60     substituteInPlace x2goserver-xsession/etc/Xsession \
61       --replace "SSH_AGENT /bin/bash -c" "SSH_AGENT ${bash}/bin/bash -c" \
62       --replace "[ -f /etc/redhat-release ]" "[ -d /etc/nix ] || [ -f /etc/redhat-release ]"
63   '';
65   makeFlags = [ "PREFIX=/" "NXLIBDIR=${nx-libs}/lib/nx" ];
67   installFlags = [ "DESTDIR=$(out)" ];
69   postInstall = ''
70     mv $out/etc/x2go/x2goserver.conf{,.example}
71     mv $out/etc/x2go/x2goagent.options{,.example}
72     ln -sf ${nx-libs}/bin/nxagent $out/bin/x2goagent
73     for i in $out/sbin/x2go* $(find $out/bin -type f) \
74       $(ls $out/lib/x2go/x2go* | grep -v x2gocheckport)
75     do
76       wrapProgram $i --prefix PATH : ${lib.makeBinPath binaryDeps}:$out
77     done
78     # We're patching @INC of the setgid wrapper, because we can't mix
79     # the perl wrapper (for PERL5LIB) with security.wrappers (for setgid)
80     sed -ie "s,.\+bin/perl,#!${perl}/bin/perl -I ${perlEnv}/lib/perl5/site_perl," \
81       $out/lib/x2go/libx2go-server-db-sqlite3-wrapper.pl
82   '';
84   enableParallelBuilding = true;
86   meta = with lib; {
87     description = "Remote desktop application, server component";
88     homepage = "http://x2go.org/";
89     platforms = lib.platforms.linux;
90     license = licenses.gpl2;
91     maintainers = with maintainers; [ averelld ];
92   };