Skip to content

Commit e2f90fa

Browse files
authored
nixos/osquery: add package option (NixOS#485164)
2 parents 64d8fd4 + c5aee3b commit e2f90fa

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

nixos/modules/services/monitoring/osquery.nix

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ let
2525
({ config_path = conf; } // cfg.flags)
2626
)
2727
);
28-
28+
osquery = cfg.package;
2929
osqueryi = pkgs.runCommand "osqueryi" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
3030
mkdir -p $out/bin
31-
makeWrapper ${pkgs.osquery}/bin/osqueryi $out/bin/osqueryi \
31+
makeWrapper ${osquery}/bin/osqueryi $out/bin/osqueryi \
3232
--add-flags "--flagfile ${flagfile} --disable-database"
3333
'';
34+
3435
in
3536
{
3637
options.services.osquery = {
3738
enable = lib.mkEnableOption "osqueryd daemon";
3839

40+
package = lib.mkPackageOption pkgs "osquery" { };
41+
3942
settings = lib.mkOption {
4043
default = { };
4144
description = ''
@@ -108,15 +111,15 @@ in
108111
];
109112
description = "The osquery daemon";
110113
serviceConfig = {
111-
ExecStart = "${pkgs.osquery}/bin/osqueryd --flagfile ${flagfile}";
114+
ExecStart = "${osquery}/bin/osqueryd --flagfile ${flagfile}";
112115
PIDFile = cfg.flags.pidfile;
113116
LogsDirectory = lib.mkIf (cfg.flags.logger_path == "/var/log/osquery") [ "osquery" ];
114117
StateDirectory = lib.mkIf (cfg.flags.database_path == "/var/lib/osquery/osquery.db") [ "osquery" ];
115118
Restart = "always";
116119
};
117120
wantedBy = [ "multi-user.target" ];
118121
};
119-
systemd.tmpfiles.settings."10-osquery".${dirname (cfg.flags.pidfile)}.d = {
122+
systemd.tmpfiles.settings."10-osquery".${dirname cfg.flags.pidfile}.d = {
120123
user = "root";
121124
group = "root";
122125
mode = "0755";

nixos/tests/osquery.nix

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ./make-test-python.nix (
2-
{ lib, pkgs, ... }:
2+
{ lib, ... }:
33

44
let
55
config_refresh = "10";
@@ -13,19 +13,17 @@ import ./make-test-python.nix (
1313
lewo
1414
];
1515

16-
nodes.machine =
17-
{ config, pkgs, ... }:
18-
{
19-
services.osquery = {
20-
enable = true;
21-
22-
settings.options = { inherit nullvalue utc; };
23-
flags = {
24-
inherit config_refresh;
25-
nullvalue = "IGNORED";
26-
};
16+
nodes.machine = _: {
17+
services.osquery = {
18+
enable = true;
19+
20+
settings.options = { inherit nullvalue utc; };
21+
flags = {
22+
inherit config_refresh;
23+
nullvalue = "IGNORED";
2724
};
2825
};
26+
};
2927

3028
testScript =
3129
{ nodes, ... }:

0 commit comments

Comments
 (0)