I am trying to answer to Package request: forticlient · Issue #267158 · NixOS/nixpkgs · GitHub and package a proprietary VPN client (mandatory for my workplace). Upsteam provides a debian build which I took inspiration to write a derivation.
So far, I was able to correctly download, extract and patch the binaries.
The derivation looks like this:
(import <nixpkgs> { }).callPackage ({ stdenv, fetchurl, dpkg, autoPatchelfHook
, libuuid, libgcc, libsecret, libglibutil, libgudev, udev, libX11, sqlite }:
stdenv.mkDerivation rec {
pname = "forticlient";
version = "7.2.2.0753";
src = fetchurl {
url =
"https://filestore.fortinet.com/forticlient/forticlient_vpn_${version}_amd64.deb";
hash = "sha256-nsbwfaEBQkF/FUu+g6JHuEIuBd/VBXZlJ7A5oQiYWL8=";
};
nativeBuildInputs = [ dpkg autoPatchelfHook ];
buildInputs =
[ libuuid libgcc libsecret libglibutil libgudev udev libX11 sqlite ];
installPhase = ''
# removing GUI related things
rm opt/forticlient/{fortitray,fortitraylauncher}
rm -rf opt/forticlient/gui
mkdir -p $out/bin
mkdir -p $out/share
mkdir -p $out/etc
mv opt $out/bin
mv lib $out/lib
mv etc $out/etc
'';
}) { }
result/
contains some binaries that I can launch in isolation, but they all fail. Upstream package provides a systemd service, under a source tree, reproduced here. On my colleagues machines (Ubuntu/Debian), this service needs to be run before launching the other binaries:
[Unit]
Description=Forticlient Scheduler
Requires=dbus.service
Wants=dbus.service
After=dbus.service
[Service]
Type=simple
ExecStart=/opt/forticlient/fctsched
User=root
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=5
StartLimitInterval=300
StartLimitBurst=30
KillMode=mixed
[Install]
WantedBy=multi-user.target
How can I edit this service as to use the correct path in the nix store? Is there an automated way of doing so?
My past experience with Nix is to package software that provide binaries and files. How can I package a program that needs a systemd service to be run (I assume this has to do with the NixOS module system, but some examples would help me understand how to do so).