Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/packetbeat: Add packetbeat module #97152

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lejonet
Copy link
Contributor

@lejonet lejonet commented Sep 4, 2020

Motivation for this change

Adds a packetbeat module so that it can be configured with
freeform settings. Made with big help from @aanderse and
@infinisil.

We have the packetbeat package in nixpkgs for some time, but no module, so I decided to make one. It uses the freeform module concept.

Remade PR after screwing up the prior PR with a botched rebase.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Adds a packetbeat module so that it can be configured with
freeform settings. Made with big help from @aanderse and
@infinisil.
@lejonet
Copy link
Contributor Author

lejonet commented Sep 4, 2020

@infinisil here's the config again:

packetbeat = {
    enable = true;
    package = pkgs.packetbeat7;
    settings = {
      name = config.networking.hostName;
      packetbeat = {
        interfaces = {
          device = "ens3";
          type = "af_packet";
          ignore_outgoing = true;
        };
        protocols = {
          tls = {
            ports = [ 443 993 995 5223 8443 8883 9243 ];
            send_certificates = true;
            include_raw_certificates = false;
            include_detailed_fields = true;
            fingerprints = [ "md5" "sha1" "sha256" ];
          };
        };
      };
      output = {
        elasticsearch = lib.mkForce {};
        file = {
          path = "/var/log/packetbeat";
          filename = "packetbeat.log";
          rotate_every_kb = "102400";
          number_of_files = "20";
        };
      };
      fields = {
        env = "utility";
      };
      processors = [ "add_host_metadata: ~" ];
    };
  };

@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 4, 2020
@aanderse
Copy link
Member

@lejonet I think this looks good 👍 I'll defer to @infinisil for final approval and merge, though.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Nov 19, 2020
…pes.listOf format.type and change the default to a list with mkBefore
@stale
Copy link

stale bot commented Jun 3, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2021
@lelongg
Copy link
Contributor

lelongg commented Nov 25, 2022

Is this ready to be merged ?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 25, 2022
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2023
@@ -0,0 +1,289 @@
{ config, lib, pkgs, ... }:

with lib;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with lib;

Use specific inherits or add lib..

Comment on lines +15 to +23
package = mkOption {
type = types.package;
default = pkgs.packetbeat;
defaultText = "pkgs.packetbeat";
example = literalExample "pkgs.packetbeat7";
description = ''
The packetbeat package to use
'';
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package = mkOption {
type = types.package;
default = pkgs.packetbeat;
defaultText = "pkgs.packetbeat";
example = literalExample "pkgs.packetbeat7";
description = ''
The packetbeat package to use
'';
};
package = mkPackageOption pkgs "packetbeat" { };

"CAP_NET_ADMIN"
];
ExecStart = ''
${cfg.package}/bin/packetbeat \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${cfg.package}/bin/packetbeat \
${lib.getExe cfg.package} \

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants