diff --git a/nixos/modules/services/monitoring/osquery.nix b/nixos/modules/services/monitoring/osquery.nix index a54f4f4ecbbf..5f9638ce8992 100644 --- a/nixos/modules/services/monitoring/osquery.nix +++ b/nixos/modules/services/monitoring/osquery.nix @@ -25,17 +25,20 @@ let ({ config_path = conf; } // cfg.flags) ) ); - + osquery = cfg.package; osqueryi = pkgs.runCommand "osqueryi" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' mkdir -p $out/bin - makeWrapper ${pkgs.osquery}/bin/osqueryi $out/bin/osqueryi \ + makeWrapper ${osquery}/bin/osqueryi $out/bin/osqueryi \ --add-flags "--flagfile ${flagfile} --disable-database" ''; + in { options.services.osquery = { enable = lib.mkEnableOption "osqueryd daemon"; + package = lib.mkPackageOption pkgs "osquery" { }; + settings = lib.mkOption { default = { }; description = '' @@ -108,7 +111,7 @@ in ]; description = "The osquery daemon"; serviceConfig = { - ExecStart = "${pkgs.osquery}/bin/osqueryd --flagfile ${flagfile}"; + ExecStart = "${osquery}/bin/osqueryd --flagfile ${flagfile}"; PIDFile = cfg.flags.pidfile; LogsDirectory = lib.mkIf (cfg.flags.logger_path == "/var/log/osquery") [ "osquery" ]; StateDirectory = lib.mkIf (cfg.flags.database_path == "/var/lib/osquery/osquery.db") [ "osquery" ]; @@ -116,7 +119,7 @@ in }; wantedBy = [ "multi-user.target" ]; }; - systemd.tmpfiles.settings."10-osquery".${dirname (cfg.flags.pidfile)}.d = { + systemd.tmpfiles.settings."10-osquery".${dirname cfg.flags.pidfile}.d = { user = "root"; group = "root"; mode = "0755"; diff --git a/nixos/tests/osquery.nix b/nixos/tests/osquery.nix index 5faf2f343740..e0ac28e68e90 100644 --- a/nixos/tests/osquery.nix +++ b/nixos/tests/osquery.nix @@ -1,5 +1,5 @@ import ./make-test-python.nix ( - { lib, pkgs, ... }: + { lib, ... }: let config_refresh = "10"; @@ -13,19 +13,17 @@ import ./make-test-python.nix ( lewo ]; - nodes.machine = - { config, pkgs, ... }: - { - services.osquery = { - enable = true; + nodes.machine = _: { + services.osquery = { + enable = true; - settings.options = { inherit nullvalue utc; }; - flags = { - inherit config_refresh; - nullvalue = "IGNORED"; - }; + settings.options = { inherit nullvalue utc; }; + flags = { + inherit config_refresh; + nullvalue = "IGNORED"; }; }; + }; testScript = { nodes, ... }: