Merge pull request #127989 from ymatsiuk/appgate

appgate-sdp: minimize and improve derivation

authored by

Elis Hirwing and committed by
GitHub
536cb54f 4f3bc6aa

+47 -76
+5 -3
nixos/modules/programs/appgate-sdp.nix
··· 5 5 { 6 6 options = { 7 7 programs.appgate-sdp = { 8 - enable = mkEnableOption 9 - "AppGate SDP VPN client"; 8 + enable = mkEnableOption "AppGate SDP VPN client"; 10 9 }; 11 10 }; 12 11 ··· 17 16 systemd = { 18 17 packages = [ pkgs.appgate-sdp ]; 19 18 # https://github.com/NixOS/nixpkgs/issues/81138 20 - services.appgatedriver.wantedBy = [ "multi-user.target" ]; 19 + services.appgatedriver.wantedBy = [ "multi-user.target" ]; 20 + services.appgate-dumb-resolver.path = [ pkgs.e2fsprogs ]; 21 + services.appgate-resolver.path = [ pkgs.procps pkgs.e2fsprogs ]; 22 + services.appgatedriver.path = [ pkgs.e2fsprogs ]; 21 23 }; 22 24 }; 23 25 }
+42 -73
pkgs/applications/networking/appgate-sdp/default.nix
··· 2 2 , at-spi2-atk 3 3 , at-spi2-core 4 4 , atk 5 - , bash 5 + , autoPatchelfHook 6 6 , cairo 7 - , coreutils 8 7 , cups 9 8 , curl 10 9 , dbus 11 10 , dnsmasq 12 11 , dpkg 13 - , e2fsprogs 14 12 , expat 15 13 , fetchurl 16 14 , gdk-pixbuf ··· 20 18 , iproute2 21 19 , krb5 22 20 , lib 23 - , mesa 24 21 , libdrm 25 - , libX11 26 - , libXScrnSaver 27 - , libXcomposite 28 - , libXcursor 29 - , libXdamage 30 - , libXext 31 - , libXfixes 32 - , libXi 33 - , libXrandr 34 - , libXrender 35 - , libXtst 36 - , libxkbcommon 37 22 , libsecret 38 23 , libuuid 39 24 , libxcb 25 + , libxkbcommon 40 26 , lttng-ust 41 27 , makeWrapper 28 + , mesa 42 29 , networkmanager 43 30 , nspr 44 31 , nss ··· 50 37 , stdenv 51 38 , systemd 52 39 , xdg-utils 40 + , xorg 53 41 , zlib 54 42 }: 55 43 with lib; ··· 69 57 gtk3 70 58 icu 71 59 krb5 72 - mesa 73 60 libdrm 74 - libX11 75 - libXScrnSaver 76 - libXcomposite 77 - libXcursor 78 - libXdamage 79 - libXext 80 - libXfixes 81 - libXi 82 - libXrandr 83 - libXrender 84 - libXtst 85 - libxkbcommon 86 61 libsecret 87 62 libuuid 88 63 libxcb 64 + libxkbcommon 89 65 lttng-ust 66 + mesa 90 67 nspr 91 68 nss 92 69 openssl 93 70 pango 94 71 stdenv.cc.cc 95 72 systemd 73 + xorg.libX11 74 + xorg.libXScrnSaver 75 + xorg.libXcomposite 76 + xorg.libXcursor 77 + xorg.libXdamage 78 + xorg.libXext 79 + xorg.libXfixes 80 + xorg.libXi 81 + xorg.libXrandr 82 + xorg.libXrender 83 + xorg.libXtst 84 + xorg.libxkbfile 85 + xorg.libxshmfence 96 86 zlib 97 87 ]; 98 - rpath = lib.makeLibraryPath deps; 99 88 in 100 89 stdenv.mkDerivation rec { 101 90 pname = "appgate-sdp"; 102 91 version = "5.4.2"; 103 92 104 93 src = fetchurl { 105 - url = "https://bin.appgate-sdp.com/${lib.versions.majorMinor version}/client/appgate-sdp_${version}_amd64.deb"; 94 + url = "https://bin.appgate-sdp.com/${versions.majorMinor version}/client/appgate-sdp_${version}_amd64.deb"; 106 95 sha256 = "sha256-wAhcTRO/Cd4MG1lfPNDq92yGcu3NOfymucddy92VaXo="; 107 96 }; 108 97 98 + # just patch interpreter 99 + autoPatchelfIgnoreMissingDeps = true; 109 100 dontConfigure = true; 110 101 dontBuild = true; 111 - enableParallelBuilding = true; 112 102 113 103 buildInputs = [ 114 104 python37 ··· 116 106 ]; 117 107 118 108 nativeBuildInputs = [ 109 + autoPatchelfHook 119 110 makeWrapper 120 111 dpkg 121 112 ]; ··· 125 116 ''; 126 117 127 118 installPhase = '' 128 - mkdir -p $out/bin 129 - ln -s "$out/opt/appgate/appgate" "$out/bin/appgate" 130 119 cp -r $out/usr/share $out/share 131 120 132 - for file in $out/opt/appgate/linux/appgate-resolver.pre \ 133 - $out/opt/appgate/linux/appgate-dumb-resolver.pre 134 - do 135 - substituteInPlace $file \ 136 - --replace "/bin/sh" "${bash}/bin/sh" \ 137 - --replace "cat" "${coreutils}/bin/cat" \ 138 - --replace "chattr" "${e2fsprogs}/bin/chattr" \ 139 - --replace "mv " "${coreutils}/bin/mv " \ 140 - --replace "pkill" "${procps}/bin/pkill" 141 - done 121 + substituteInPlace $out/lib/systemd/system/appgate-dumb-resolver.service \ 122 + --replace "/opt/" "$out/opt/" 142 123 143 - for file in $out/lib/systemd/system/appgatedriver.service \ 144 - $out/lib/systemd/system/appgate-dumb-resolver.service \ 145 - $out/lib/systemd/system/appgate-resolver.service 146 - do 147 - substituteInPlace $file \ 148 - --replace "/bin/sh" "${bash}/bin/sh" \ 124 + substituteInPlace $out/lib/systemd/system/appgatedriver.service \ 149 125 --replace "/opt/" "$out/opt/" \ 150 - --replace "chattr" "${e2fsprogs}/bin/chattr" \ 151 - --replace "mv " "${coreutils}/bin/mv " 152 - done 153 - 154 - substituteInPlace $out/lib/systemd/system/appgatedriver.service \ 155 126 --replace "InaccessiblePaths=/mnt /srv /boot /media" "InaccessiblePaths=-/mnt -/srv -/boot -/media" 156 127 157 128 substituteInPlace $out/lib/systemd/system/appgate-resolver.service \ 129 + --replace "/usr/sbin/dnsmasq" "${dnsmasq}/bin/dnsmasq" \ 130 + --replace "/opt/" "$out/opt/" 131 + 132 + substituteInPlace $out/opt/appgate/linux/nm.py \ 158 133 --replace "/usr/sbin/dnsmasq" "${dnsmasq}/bin/dnsmasq" 159 134 160 - substituteInPlace $out/opt/appgate/linux/nm.py --replace "/usr/sbin/dnsmasq" "${dnsmasq}/bin/dnsmasq" 161 - substituteInPlace $out/opt/appgate/linux/set_dns --replace "/etc/appgate.conf" "$out/etc/appgate.conf" 135 + substituteInPlace $out/opt/appgate/linux/set_dns \ 136 + --replace "/etc/appgate.conf" "$out/etc/appgate.conf" 162 137 163 - ''; 138 + wrapProgram $out/opt/appgate/service/createdump \ 139 + --set LD_LIBRARY_PATH "${makeLibraryPath [ stdenv.cc.cc ]}" 164 140 165 - postFixup = '' 166 - find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \; 167 - for binary in $out/opt/appgate/appgate-driver \ 168 - $out/opt/appgate/appgate \ 169 - $out/opt/appgate/service/createdump \ 170 - $out/opt/appgate/service/appgateservice.bin 171 - do 172 - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath "$ORIGIN:$out/opt/appgate/service/:$out/opt/appgate/:${rpath}" $binary 173 - done 141 + wrapProgram $out/opt/appgate/appgate-driver \ 142 + --prefix PATH : ${makeBinPath [ iproute2 networkmanager dnsmasq ]} \ 143 + --set LD_LIBRARY_PATH $out/opt/appgate/service 174 144 175 - # fail if there are missing dependencies 176 - ldd $out/opt/appgate/appgate | grep -i 'not found' && exit 1 177 - ldd $out/opt/appgate/service/appgateservice.bin | grep -i 'not found' && exit 1 178 - ldd $out/opt/appgate/appgate-driver | grep -i 'not found' && exit 1 145 + makeWrapper $out/opt/appgate/Appgate $out/bin/appgate \ 146 + --prefix PATH : ${makeBinPath [ xdg-utils ]} \ 147 + --set LD_LIBRARY_PATH $out/opt/appgate:${makeLibraryPath deps} 179 148 180 - wrapProgram $out/opt/appgate/appgate-driver --prefix PATH : ${lib.makeBinPath [ iproute2 networkmanager dnsmasq ]} 181 149 wrapProgram $out/opt/appgate/linux/set_dns --set PYTHONPATH $PYTHONPATH 182 - wrapProgram $out/bin/appgate --prefix PATH : ${lib.makeBinPath [ xdg-utils ]} 183 150 ''; 151 + 184 152 meta = with lib; { 185 153 description = "Appgate SDP (Software Defined Perimeter) desktop client"; 186 154 homepage = "https://www.appgate.com/support/software-defined-perimeter-support"; ··· 189 157 maintainers = with maintainers; [ ymatsiuk ]; 190 158 }; 191 159 } 160 +