From 58c4fb6e110f7e801a689e2f0c3322e0164dfb46 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 3 Dec 2024 11:10:41 +0100 Subject: [PATCH 1/4] slowlorust: refactor --- pkgs/tools/networking/slowlorust/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/networking/slowlorust/default.nix b/pkgs/tools/networking/slowlorust/default.nix index d5e924d10272..89b6c961305c 100644 --- a/pkgs/tools/networking/slowlorust/default.nix +++ b/pkgs/tools/networking/slowlorust/default.nix @@ -11,8 +11,8 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "MJVL"; - repo = pname; - rev = version; + repo = "slowlorust"; + rev = "refs/tags/${version}"; hash = "sha256-c4NWkQ/QvlUo1YoV2s7rWB6wQskAP5Qp1WVM23wvV3c="; }; @@ -25,6 +25,7 @@ rustPlatform.buildRustPackage rec { meta = with lib; { description = "Lightweight slowloris (HTTP DoS) tool"; homepage = "https://github.com/MJVL/slowlorust"; + changelog = "https://github.com/MJVL/slowlorust/releases/tag/${version}"; license = licenses.mit; maintainers = with maintainers; [ fab ]; mainProgram = "slowlorust"; From ab73ad0d48f21b588c2b4d32767e93d523ecb74d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 3 Dec 2024 11:11:02 +0100 Subject: [PATCH 2/4] slowlorust: format with nixfmt --- pkgs/tools/networking/slowlorust/default.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/networking/slowlorust/default.nix b/pkgs/tools/networking/slowlorust/default.nix index 89b6c961305c..d68ad8d59aa1 100644 --- a/pkgs/tools/networking/slowlorust/default.nix +++ b/pkgs/tools/networking/slowlorust/default.nix @@ -1,8 +1,9 @@ -{ lib -, stdenv -, fetchFromGitHub -, rustPlatform -, Security +{ + lib, + stdenv, + fetchFromGitHub, + rustPlatform, + Security, }: rustPlatform.buildRustPackage rec { From 29657fce4b05ca4580bd8ba50e3a7124f354ee91 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 3 Dec 2024 11:16:36 +0100 Subject: [PATCH 3/4] slowlorust: add versionCheckHook --- pkgs/tools/networking/slowlorust/default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/tools/networking/slowlorust/default.nix b/pkgs/tools/networking/slowlorust/default.nix index d68ad8d59aa1..efb4fb6b463c 100644 --- a/pkgs/tools/networking/slowlorust/default.nix +++ b/pkgs/tools/networking/slowlorust/default.nix @@ -4,6 +4,7 @@ fetchFromGitHub, rustPlatform, Security, + versionCheckHook, }: rustPlatform.buildRustPackage rec { @@ -19,10 +20,22 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-Wu1mm+yJw2SddddxC5NfnMWLr+dplnRxH3AJ1/mTAKM="; + postPatch = '' + # https://github.com/MJVL/slowlorust/issues/2 + substituteInPlace src/main.rs \ + --replace-fail 'version = "1.0"' 'version = "${version}"' + ''; + buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ Security ]; + nativeInstallCheckInputs = [ versionCheckHook ]; + + doInstallCheck = true; + + versionCheckProgramArg = [ "--version" ]; + meta = with lib; { description = "Lightweight slowloris (HTTP DoS) tool"; homepage = "https://github.com/MJVL/slowlorust"; From fe5fb91889ea2e2dff29b2bd363af7eca4d50bbe Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 3 Dec 2024 11:20:57 +0100 Subject: [PATCH 4/4] slowlorust: move to pkgs/by-name --- .../default.nix => by-name/sl/slowlorust/package.nix} | 6 ++---- pkgs/top-level/all-packages.nix | 4 ---- 2 files changed, 2 insertions(+), 8 deletions(-) rename pkgs/{tools/networking/slowlorust/default.nix => by-name/sl/slowlorust/package.nix} (90%) diff --git a/pkgs/tools/networking/slowlorust/default.nix b/pkgs/by-name/sl/slowlorust/package.nix similarity index 90% rename from pkgs/tools/networking/slowlorust/default.nix rename to pkgs/by-name/sl/slowlorust/package.nix index efb4fb6b463c..3d3ced6d29ec 100644 --- a/pkgs/tools/networking/slowlorust/default.nix +++ b/pkgs/by-name/sl/slowlorust/package.nix @@ -1,9 +1,9 @@ { lib, stdenv, + darwin, fetchFromGitHub, rustPlatform, - Security, versionCheckHook, }: @@ -26,9 +26,7 @@ rustPlatform.buildRustPackage rec { --replace-fail 'version = "1.0"' 'version = "${version}"' ''; - buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ - Security - ]; + buildInputs = lib.optional stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Security ]; nativeInstallCheckInputs = [ versionCheckHook ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e6d18c1a3849..ba99cad15808 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5235,10 +5235,6 @@ with pkgs; ocamlPackages = ocaml-ng.ocamlPackages_4_12; }; - slowlorust = callPackage ../tools/networking/slowlorust { - inherit (darwin.apple_sdk.frameworks) Security; - }; - slstatus = callPackage ../applications/misc/slstatus { conf = config.slstatus.conf or null; };