From 06b47bf4d00d45ec6da1bf4c8a7394896d71ea4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Wed, 29 Jan 2025 00:34:57 +0800 Subject: [PATCH 1/2] crowdsec: Correctly add upstream systemd service to outputs --- pkgs/by-name/cr/crowdsec/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/cr/crowdsec/package.nix b/pkgs/by-name/cr/crowdsec/package.nix index 4c3a030b9e34..6dd3b25da063 100644 --- a/pkgs/by-name/cr/crowdsec/package.nix +++ b/pkgs/by-name/cr/crowdsec/package.nix @@ -42,6 +42,10 @@ buildGoModule rec { mkdir -p $out/share/crowdsec cp -r ./config $out/share/crowdsec/ + mkdir -p $out/lib/systemd/system + substitute ./config/crowdsec.service $out/lib/systemd/system/crowdsec.service \ + --replace-fail /usr/local $out + installShellCompletion --cmd cscli \ --bash <($out/bin/cscli completion bash) \ --fish <($out/bin/cscli completion fish) \ From 426a7afc9a6ecfdac544bda4022acef31e36df34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Wed, 29 Jan 2025 00:36:48 +0800 Subject: [PATCH 2/2] crowdsec: Set tag version as expected by upstream Without setting the correct version here, the package is completely broken as the local API checks that any clients report the correct user agent, which includes this string. The sanity check missed this since `grep` just checks if a string exists in the line, and the version happened to be a superstring of what is expected. I've made this a bit more robust and switched to using `preCheck` rather than replacing the whole `checkPhase` while I'm here. This has been broken since switching to `refs/tags` in 326517a5290c34e0cc4da564825a7193a692f2b0. --- pkgs/by-name/cr/crowdsec/package.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/cr/crowdsec/package.nix b/pkgs/by-name/cr/crowdsec/package.nix index 6dd3b25da063..6a466fa686f8 100644 --- a/pkgs/by-name/cr/crowdsec/package.nix +++ b/pkgs/by-name/cr/crowdsec/package.nix @@ -30,7 +30,7 @@ buildGoModule rec { "-w" "-X github.com/crowdsecurity/go-cs-lib/version.Version=v${version}" "-X github.com/crowdsecurity/go-cs-lib/version.BuildDate=1970-01-01_00:00:00" - "-X github.com/crowdsecurity/go-cs-lib/version.Tag=${src.rev}" + "-X github.com/crowdsecurity/go-cs-lib/version.Tag=v${version}" "-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga" "-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=/etc/crowdsec" "-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=/var/lib/crowdsec/data" @@ -53,8 +53,13 @@ buildGoModule rec { ''; # It's important that the version is correctly set as it also determines feature capabilities - checkPhase = '' - $GOPATH/bin/cscli version 2>&1 | grep -q "version: v${version}" + preCheck = '' + version=$($GOPATH/bin/cscli version 2>&1 | sed -nE 's/^version: (.*)/\1/p') + + if [ "$version" != "v${version}" ]; then + echo "Invalid version string: '$version'" + exit 1 + fi ''; meta = with lib; {