From ce6b63de06e83b3d908777e4f4dd0a15cca2cd72 Mon Sep 17 00:00:00 2001 From: Neyts Zupan Date: Sun, 6 Apr 2025 18:38:56 +0100 Subject: [PATCH] paretosecurity: 0.1.3 -> 0.1.9 Also some modernization/gardening package and tests, thanks @tfc! --- .../services/security/paretosecurity.nix | 31 +++++----- nixos/tests/paretosecurity.nix | 59 ++++++++----------- pkgs/by-name/pa/paretosecurity/package.nix | 36 ++++++----- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/nixos/modules/services/security/paretosecurity.nix b/nixos/modules/services/security/paretosecurity.nix index a1080ede8431..822fe76ec6af 100644 --- a/nixos/modules/services/security/paretosecurity.nix +++ b/nixos/modules/services/security/paretosecurity.nix @@ -4,6 +4,9 @@ pkgs, ... }: +let + cfg = config.services.paretosecurity; +in { options.services.paretosecurity = { @@ -12,9 +15,9 @@ trayIcon = lib.mkEnableOption "tray icon for ParetoSecurity"; }; - config = lib.mkIf config.services.paretosecurity.enable { - environment.systemPackages = [ config.services.paretosecurity.package ]; - systemd.packages = [ config.services.paretosecurity.package ]; + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + systemd.packages = [ cfg.package ]; # In traditional Linux distributions, systemd would read the [Install] section from # unit files and automatically create the appropriate symlinks to enable services. @@ -36,19 +39,17 @@ ]; # Enable the tray icon and timer services if the trayIcon option is enabled - systemd.user = lib.mkIf config.services.paretosecurity.trayIcon { - services.paretosecurity-trayicon = { - wantedBy = [ "graphical-session.target" ]; - }; - services.paretosecurity-user = { - wantedBy = [ "graphical-session.target" ]; - serviceConfig.Environment = [ - "PATH=${config.system.path}/bin:${config.system.path}/sbin" - ]; - }; - timers.paretosecurity-user = { - wantedBy = [ "timers.target" ]; + systemd.user = lib.mkIf cfg.trayIcon { + services = { + paretosecurity-trayicon.wantedBy = [ "graphical-session.target" ]; + paretosecurity-user = { + wantedBy = [ "graphical-session.target" ]; + serviceConfig.Environment = [ + "PATH=${config.system.path}/bin:${config.system.path}/sbin" + ]; + }; }; + timers.paretosecurity-user.wantedBy = [ "timers.target" ]; }; }; } diff --git a/nixos/tests/paretosecurity.nix b/nixos/tests/paretosecurity.nix index bf9af17e2f5e..051903696119 100644 --- a/nixos/tests/paretosecurity.nix +++ b/nixos/tests/paretosecurity.nix @@ -4,53 +4,45 @@ meta.maintainers = [ lib.maintainers.zupo ]; nodes.terminal = - { - config, - pkgs, - lib, - ... - }: - let - # Create a patched version of the package that points to the local dashboard - # for easier testing - patchedPareto = pkgs.paretosecurity.overrideAttrs (oldAttrs: { - postPatch = '' - substituteInPlace team/report.go \ - --replace-warn 'const reportURL = "https://dash.paretosecurity.com"' \ - 'const reportURL = "http://dashboard"' - ''; - }); - in + { pkgs, ... }: { imports = [ ./common/user-account.nix ]; + networking.firewall.enable = true; services.paretosecurity = { enable = true; - package = patchedPareto; - }; - networking.firewall.enable = true; + # Create a patched version of the package that points to the local dashboard + # for easier testing + package = pkgs.paretosecurity.overrideAttrs (oldAttrs: { + postPatch = + oldAttrs.postPatch or "" + + '' + substituteInPlace team/report.go \ + --replace-warn 'const reportURL = "https://dash.paretosecurity.com"' \ + 'const reportURL = "http://dashboard"' + ''; + }); + }; }; - nodes.dashboard = - { config, pkgs, ... }: - { - networking.firewall.allowedTCPPorts = [ 80 ]; + nodes.dashboard = { + networking.firewall.allowedTCPPorts = [ 80 ]; - services.nginx = { - enable = true; - virtualHosts."dashboard" = { - locations."/api/v1/team/".extraConfig = '' - add_header Content-Type application/json; - return 200 '{"message": "Linked device."}'; - ''; - }; + services.nginx = { + enable = true; + virtualHosts."dashboard" = { + locations."/api/v1/team/".extraConfig = '' + add_header Content-Type application/json; + return 200 '{"message": "Linked device."}'; + ''; }; }; + }; nodes.xfce = - { config, pkgs, ... }: + { pkgs, ... }: { imports = [ ./common/user-account.nix ]; @@ -76,7 +68,6 @@ environment.systemPackages = [ pkgs.xdotool ]; environment.variables.XAUTHORITY = "/home/alice/.Xauthority"; - }; enableOCR = true; diff --git a/pkgs/by-name/pa/paretosecurity/package.nix b/pkgs/by-name/pa/paretosecurity/package.nix index 25728d4e32a3..65101cc442fd 100644 --- a/pkgs/by-name/pa/paretosecurity/package.nix +++ b/pkgs/by-name/pa/paretosecurity/package.nix @@ -5,49 +5,57 @@ testers, paretosecurity, nixosTests, + pkg-config, + gtk3, + webkitgtk_4_1, }: -buildGoModule rec { +buildGoModule (finalAttrs: { + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ + gtk3 + webkitgtk_4_1 + ]; pname = "paretosecurity"; - version = "0.1.3"; + version = "0.1.9"; src = fetchFromGitHub { owner = "ParetoSecurity"; repo = "agent"; - rev = version; - hash = "sha256-ovyfHqLCf5U3UR1HfoA+UQhqLZ6IaILcpqptPRQsb60="; + rev = finalAttrs.version; + hash = "sha256-KJs4xC3EtGG4116UE+oIEwAMcuDWIm9gqgZY+Bv14ac="; }; - vendorHash = "sha256-7mKAFkKGpBOjXc3J/sfF3k3pJF53tFybXZgbfJInuSY="; + vendorHash = "sha256-3plpvwLe32AsGuVzdM2fSmTPkKwRFmhi651NEIRdOxw="; proxyVendor = true; ldflags = [ "-s" - "-X=github.com/ParetoSecurity/agent/shared.Version=${version}" - "-X=github.com/ParetoSecurity/agent/shared.Commit=${src.rev}" + "-X=github.com/ParetoSecurity/agent/shared.Version=${finalAttrs.version}" + "-X=github.com/ParetoSecurity/agent/shared.Commit=${finalAttrs.src.rev}" "-X=github.com/ParetoSecurity/agent/shared.Date=1970-01-01T00:00:00Z" ]; postInstall = '' # Install global systemd files - install -Dm400 ${src}/apt/paretosecurity.socket $out/lib/systemd/system/paretosecurity.socket - install -Dm400 ${src}/apt/paretosecurity.service $out/lib/systemd/system/paretosecurity.service + install -Dm400 ${finalAttrs.src}/apt/paretosecurity.socket $out/lib/systemd/system/paretosecurity.socket + install -Dm400 ${finalAttrs.src}/apt/paretosecurity.service $out/lib/systemd/system/paretosecurity.service substituteInPlace $out/lib/systemd/system/paretosecurity.service \ --replace-fail "/usr/bin/paretosecurity" "$out/bin/paretosecurity" # Install user systemd files - install -Dm444 ${src}/apt/paretosecurity-user.timer $out/lib/systemd/user/paretosecurity-user.timer - install -Dm444 ${src}/apt/paretosecurity-user.service $out/lib/systemd/user/paretosecurity-user.service + install -Dm444 ${finalAttrs.src}/apt/paretosecurity-user.timer $out/lib/systemd/user/paretosecurity-user.timer + install -Dm444 ${finalAttrs.src}/apt/paretosecurity-user.service $out/lib/systemd/user/paretosecurity-user.service substituteInPlace $out/lib/systemd/user/paretosecurity-user.service \ --replace-fail "/usr/bin/paretosecurity" "$out/bin/paretosecurity" - install -Dm444 ${src}/apt/paretosecurity-trayicon.service $out/lib/systemd/user/paretosecurity-trayicon.service + install -Dm444 ${finalAttrs.src}/apt/paretosecurity-trayicon.service $out/lib/systemd/user/paretosecurity-trayicon.service substituteInPlace $out/lib/systemd/user/paretosecurity-trayicon.service \ --replace-fail "/usr/bin/paretosecurity" "$out/bin/paretosecurity" ''; passthru.tests = { version = testers.testVersion { - version = "${version}"; + inherit (finalAttrs) version; package = paretosecurity; }; integration_test = nixosTests.paretosecurity; @@ -80,4 +88,4 @@ buildGoModule rec { maintainers = with lib.maintainers; [ zupo ]; mainProgram = "paretosecurity"; }; -} +})