Background: I’m packaging some closed-source software to run on NixOS, and I’m having trouble with the systemd
configuration options. I originally asked this question here, but I realize that the unorthodox handling of /opt/CrowdStrike
makes this a more relevant question for NixOS users.
My configuration is below. Note: env
is a buildFHSUserEnv
drv related, and crowdstrike
is an unpackged .deb
with a few binaries I patchElf
'd.
I’m having trouble primarily with two things:
-
/var/log/falconctl.log
- Something (I’m not sure what exactly) seems to be symlinking this to/dev/stdout
, which thesystemd
unit later complains about being “unable to open”:
Unable to open falconctl log file /var/log/falconctl.log, errno = 6
-
/opt/CrowdStrike
- If Imkdir -p /opt/CrowdStrike
inExecStartPre
I can get this to work, but this feels a bit too imperative to pass my smell test; I also don’t want/opt/CrowdStrike
at the root of my filesystem if I can avoid it… What are the NixOS/systemd
idioms for ensuring this directory exists (and persists) at/opt/CrowdStrike
from the perspective of the unit? Could something like BindPaths be the answer? I halfheartedly tried this option, but I ran into “Namespace” errors withsystemd
, and I did not debug further in case I was traversing the wrong subtree…
systemd.services.falcon-sensor = {
description = "CrowdStrike Falcon Sensor";
unitConfig.DefaultDependencies = false;
after = [ "local-fs.target" ];
conflicts = [ "shutdown.target" ];
before = [ "shutdown.target" ];
serviceConfig = {
EnvironmentFile = cfg.envFile;
StandardOutput = "journal";
ExecStartPre = pkgs.writeShellScript "crowdstrike-prestart" ''
mkdir -p /opt/CrowdStrike
touch /var/log/falconctl.log
${env}/bin/setup -c "${crowdstrike}/opt/CrowdStrike/falconctl -s -f --cid=$CID"
'';
ExecStart = ''
${env}/bin/setup -c ${crowdstrike}/opt/CrowdStrike/falcond
'';
Type = "forking";
PIDFile = "/run/falcond.pid";
Restart = "no";
TimeoutStopSec = "60s";
KillMode = "control-group";
KillSignal = "SIGTERM";
};
wantedBy = [ "multi-user.target" ];
};
Any suggestions or drive-by comments welcome