Repository navigation
nixos/crowdsec: refactor sprint - #535319
Conversation
|
|
||
| The main usecase for this is to allow reading group readable log files. | ||
| ''; | ||
| defaultText = lib.literalExpression ''[ "systemd-journal" ]''; |
There was a problem hiding this comment.
This likely isn't what you want - providing a defaultText without a real default. ;)
There was a problem hiding this comment.
Also, I'm wondering: I don't think extraGroups is a good idea - we don't want the service to run with the privileges of those services.
I'd rather recommend providing an inverse helper that uses setfacl to add the crowdsec user (and/or group) to the relevant log files.
There was a problem hiding this comment.
Also, I'm wondering: I don't think extraGroups is a good idea - we don't want the service to run with the privileges of those services.
I'd rather recommend providing an inverse helper that uses setfacl to add the crowdsec user (and/or group) to the relevant log files.
That sounds like a good idea. Hm... I'm wondering if I should do that in this PR or in a follow up PR.
There was a problem hiding this comment.
This likely isn't what you want - providing a defaultText without a real default. ;)
Regarding this: The default value is automatically added at the bottom of the file.
| Settings for the main CrowdSec configuration file. | ||
|
|
||
| See <https://docs.crowdsec.net/docs/data_sources/intro> for details. | ||
| Refer to the defaults at <https://github.com/crowdsecurity/crowdsec/blob/master/config/config.yaml>. |
There was a problem hiding this comment.
do they have stable versioned references we could generate based on the specific package version we use?
There was a problem hiding this comment.
I posted a question for this in the crowdsec discord server and I'm waiting for a response of them.
| default = [ ]; | ||
| description = '' | ||
| A list of stage s00-raw specifications. Most of the time, those are already included in the hub, but are presented here anyway. | ||
|
|
||
| See <https://docs.crowdsec.net/docs/parsers/intro> for details. | ||
| See <https://docs.crowdsec.net/docs/next/log_processor/parsers/intro/#s00-raw> for details. |
There was a problem hiding this comment.
There isn't a consistent URL pattern sadly for the version and according to the discord server they only keep about the latest 3 versions of the docs around.
| description = '' | ||
| The Console Token file to use. | ||
|
|
||
| Normally you would do `cscli enroll <token>`, but you can put the token in a file instead and pass the path of that file to this option. |
There was a problem hiding this comment.
I'm not seeing a double space 👀 (also I this description has been reformatted in a later commit, so I think we can close this? 👀 )
| }) localNotificationsMap | ||
| ); | ||
| }; | ||
| systemd.tmpfiles.settings."10-crowdsec" = |
There was a problem hiding this comment.
the helpers look interesting and might be placed in a utility or at least earlier in this file to support the readability
skowalak
left a comment
There was a problem hiding this comment.
Reviewed the crowdsec.nix module only for now. Nitpick, I don't know if it's required but you could squash/rebase your refactor commits into one, that makes it a little cleaner here.
@skowalak yes, but I'd like to keep those commits for the time being in order to simplify the reviewing process: |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
Is there a regression on state permanence since switching to this new #535319 from #446307 ? This refactor now seems to route every managed directory through the systemd.tmpfiles rule ([uppercase] D type), including the runtime data directory Seems that So because the LAPI sqlite database ( If I understand correctly, this means bouncer registration, registered machines, CAPI engine identity, and local decisions all get destroyed on every reboot/nixos switch, whioch appears to be a regression from the previous PR #446307, which persisted
I think switching to using tmpfiles |
|
Potentially you could also use lowercase d on just |
nicomem
left a comment
There was a problem hiding this comment.
With these changes, the services run on my machine
hm... I'd say: Let's keep it simple and stick with |
|
Hi @TornaxO7 and thanks for your work, |
they are almost identical. If I remember correctly, only the |
|
|
||
| online_client.credentials_path = lib.mkOption { | ||
| type = lib.types.nullOr secret_path; | ||
| default = null; |
There was a problem hiding this comment.
settings.console.enrollKeyFile require this to be not null otherwise crowdsec-setup.service will fail on enrollment
There was a problem hiding this comment.
May I ask how it can fail? There's a check that it's not null for the setup script?
There was a problem hiding this comment.
I don’t remember details, as it been a while already, but if i had to guess this is because enroll called without registration first.
|
I hit what I think is a startup race with On the first activation, crowdsec-setup and crowdsec-update-hub started at the same time. Both use DynamicUser=true and share StateDirectory=crowdsec, and they failed with: Making crowdsec-update-hub run after/require setup fixed the race locally. There might also be a problem with multiple dynamic user units writing to the same state directory, because making an explicit user and having them all use it fixed the permissions. If you've tested this on a completely clean install I'm very confused why this would only be happening to me, but it's been a consistent issue. |
Thank you for the information! |
|
What are the chances that this refactor will make it into 26.11? Seems like progress has kind of stalled a little? |
I... don't know. My plan is, that I'll contact the people (which is usually announced some months before afaik) who will organize the 26.11 release and ask them, what else is needed for this PR to get merged.
I'm waiting for some more reviews. So from my side, it's not stalled. I just need some feedback xD |
|
I reordered the commits now. You @TornaxO7 can have a look and tell me if you don't like something. Generally speaking: A fixup to a previous commit should be squashed. Also, when the commit is for example about introducing documentation, it should contain no module changes. From my side this PR works. I also don't understand the above comment. Please @LarsArtmann write something like this without AI. This just reads like word bingo and is not understandable. IMHO this is also about respect of other peoples time. |
|
|
@leona-ya keeping the commit history during development proved really useful to allow reviewers to keep track of what's going on (versus constant force-push of a single commit), at least on big changes like this one. Of course I fully agree that a final squash and rebase on master is mandatory, once there is a consensus that the PR is ready to merge. Anyhow, thanks for helping this get merged. And thanks to TornaxO7 for the perseverance ! |
There was a problem hiding this comment.
I think this is now good, we have breaking feature freeze for NixOS 26.11 in less than a week and I think we're quite sure this is an improvement over the current merged module.
Eventually remaining bugs or more features can be done afterwards.
Thanks to @TornaxO7 for the patience with this huge PR. :)
|
@TornaxO7 could you write another small PR with a release note in nixos/doc for this? Thanks |
|
thank you for reviewing and merging it!
|
|
Congratulations and good job, @TornaxO7 |
NixOS/nixpkgs#535319 rewrote services.crowdsec: openFirewall is gone, settings.general is now settings.config, localConfig.* moved to settings.*, and the lapi/capi credentialsFile options moved under settings.config.api. the module now links /etc/crowdsec/config.yaml itself, so drop the environment.etc workaround and the `cscli -c` flags in the bouncer register scripts. pin data_dir to /var/lib/crowdsec/state and keep use_wal, the old module defaults, so the existing db, hub and credentials stay in place. upstream now sets Restart=always, which conflicts with our Restart=on-failure, so drop ours. Assisted-by: LLM
NixOS/nixpkgs#535319 rewrote services.crowdsec: openFirewall is gone, settings.general is now settings.config, localConfig.* moved to settings.*, and the lapi/capi credentialsFile options moved under settings.config.api. the module now links /etc/crowdsec/config.yaml itself, so drop the environment.etc workaround and the `cscli -c` flags in the bouncer register scripts. pin data_dir to /var/lib/crowdsec/state and keep use_wal, the old module defaults, so the existing db, hub and credentials stay in place. upstream now sets Restart=always, which conflicts with our Restart=on-failure, so drop ours. Assisted-by: LLM
NixOS/nixpkgs#535319 rewrote services.crowdsec: openFirewall is gone, settings.general is now settings.config, localConfig.* moved to settings.*, and the lapi/capi credentialsFile options moved under settings.config.api. the module now links /etc/crowdsec/config.yaml itself, so drop the environment.etc workaround and the `cscli -c` flags in the bouncer register scripts. pin data_dir to /var/lib/crowdsec/state and keep use_wal, the old module defaults, so the existing db, hub and credentials stay in place. upstream now sets Restart=always, which conflicts with our Restart=on-failure, so drop ours. Assisted-by: LLM
NixOS/nixpkgs#535319 rewrote services.crowdsec: openFirewall is gone, settings.general is now settings.config, localConfig.* moved to settings.*, and the lapi/capi credentialsFile options moved under settings.config.api. the module now links /etc/crowdsec/config.yaml itself, so drop the environment.etc workaround and the `cscli -c` flags in the bouncer register scripts. pin data_dir to /var/lib/crowdsec/state and keep use_wal, the old module defaults, so the existing db, hub and credentials stay in place. upstream now sets Restart=always, which conflicts with our Restart=on-failure, so drop ours. Assisted-by: LLM
* flake: update nixpkgs Diff: NixOS/nixpkgs@fe13242...3ec6363 * crowdsec: migrate to rewritten nixpkgs module NixOS/nixpkgs#535319 rewrote services.crowdsec: openFirewall is gone, settings.general is now settings.config, localConfig.* moved to settings.*, and the lapi/capi credentialsFile options moved under settings.config.api. the module now links /etc/crowdsec/config.yaml itself, so drop the environment.etc workaround and the `cscli -c` flags in the bouncer register scripts. pin data_dir to /var/lib/crowdsec/state and keep use_wal, the old module defaults, so the existing db, hub and credentials stay in place. upstream now sets Restart=always, which conflicts with our Restart=on-failure, so drop ours. Assisted-by: LLM * overlays: skip broken urllib3-future and niquests tests urllib3-future 2.25.902 socks tests time out against python-socks v3, run ~1.6 h and fail on hydra. caldav pulls it in for calendar-mcp and for home-assistant on ha-green, so the override moves from calendar-mcp into a global overlay. niquests test_use_proxy_from_environment also fails once urllib3-future builds. drop once https://redirect.github.com/NixOS/nixpkgs/pull/575392 reaches nixos-unstable. Assisted-by: LLM * calendar-mcp, laya-mcp: port to mcp 2 MCPServer nixpkgs ships mcp 2.2.0, which removed mcp.server.fastmcp: FastMCP is now mcp.server.mcpserver.MCPServer and call_tool returns a CallToolResult instead of a tuple. Assisted-by: LLM * flake: update hermes-agent the npm hook of hermes-agent 7ac2c6dc segfaults on the new nixpkgs; the current revision builds against it. Diff: NousResearch/hermes-agent@7ac2c6d...085f562 Assisted-by: LLM * caddy: update desec plugin hash for new nixpkgs the vendored go modules of caddy.withPlugins changed with the nixpkgs bump, so the fixed-output hash no longer matches. Assisted-by: LLM --------- Co-authored-by: fosskar[bot] <300917551+fosskar[bot]@users.noreply.github.com> Co-authored-by: fosskar <[email protected]>







Continues #446307
This PR is created in order to have some smaller commits to understand the changes easier... I recommend to read commit-by-commit to understand the changes although I have to admit that some changes could be splitted to even smaller commits.
Compared to the previous PR, this fully uses
systemd.tmpfilesfor the file management which fixes the case that when the user sets some different paths that the module doesn't break...A follow-up PR could be done to do the same for the
crowdsec-firewall-bouncer.Also note: If everything's fine, I'd need to add an entry for the 26.11 changelog. Due to merge-conflicts I'd like to do that at the end.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.