Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 28 additions & 38 deletions named-hosts/matic/falcon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
# sudo cp ~/Downloads/falcon-sensor*.deb /etc/nixos/falcon-sensor.deb
# 3. Create /etc/falcon-sensor.env with: FALCON_CID=<your-cid>
#
# This module is automatically disabled if the .deb file doesn't exist.
#
# Based on: https://github.com/taylanpince/nixos-config
{ pkgs, lib, ... }:
let
falconDebPath = /etc/nixos/falcon-sensor.deb;
falconDebExists = builtins.pathExists falconDebPath;

falcon = pkgs.callPackage ./falcon { };

initScript = pkgs.writeScript "init-falcon" ''
Expand All @@ -38,43 +33,38 @@ let
${falcon}/bin/fs-bash -c "/opt/CrowdStrike/falconctl -g --cid"
'';
in
if falconDebExists then
{
systemd.tmpfiles.rules = [
"d /opt/CrowdStrike 0770 root root -"
];
{
systemd.tmpfiles.rules = [
"d /opt/CrowdStrike 0770 root root -"
];

systemd.services.falcon-sensor = {
description = "CrowdStrike Falcon Sensor";
wantedBy = [ "multi-user.target" ];
systemd.services.falcon-sensor = {
description = "CrowdStrike Falcon Sensor";
wantedBy = [ "multi-user.target" ];

unitConfig.DefaultDependencies = false;
after = [ "local-fs.target" ];
conflicts = [ "shutdown.target" ];
before = [
"sysinit.target"
"shutdown.target"
];
unitConfig.DefaultDependencies = false;
after = [ "local-fs.target" ];
conflicts = [ "shutdown.target" ];
before = [
"sysinit.target"
"shutdown.target"
];

serviceConfig = {
Type = "forking";
PIDFile = "/run/falcond.pid";
ExecStartPre = initScript;
ExecStart = "${falcon}/bin/fs-bash -c \"/opt/CrowdStrike/falcond\"";
serviceConfig = {
Type = "forking";
PIDFile = "/run/falcond.pid";
ExecStartPre = initScript;
ExecStart = "${falcon}/bin/fs-bash -c \"/opt/CrowdStrike/falcond\"";

Restart = "on-failure";
RestartSec = "15s";
Restart = "on-failure";
RestartSec = "15s";

# Avoid systemd giving up during flapping
StartLimitIntervalSec = 0;
# Avoid systemd giving up during flapping
StartLimitIntervalSec = 0;

TimeoutStopSec = "60s";
KillMode = "process";
Delegate = true;
};
TimeoutStopSec = "60s";
KillMode = "process";
Delegate = true;
};
}
else
{
# Falcon sensor disabled - /etc/nixos/falcon-sensor.deb not found
}
};
}
Loading