<jasom>
andi-: like you just write a bunch of nftables commands?
<andi->
Yes, I generate them with nix
<jasom>
in 20.09, it looks like it's just networking.nftables.ruleset as a string; did you write some functions to help out with that or are there already such tools that I'm missing?
<jasom>
Though reading docs from nftables.org it doesn't look too bad.
teto has quit [Ping timeout: 260 seconds]
<andi->
jasom: yeah that is all I use for it. It has a huge list of static rules and some others that are generated from my custom modules.
<andi->
Looking at the structure of nftables rules I wasn't yet motivated to write a nixos module that supports all the potential options. One of the blockers for me is verification of the configuration before we apply it. nftables can only be verified as root as the syntax is finally checked in the kernel... Currently I just spawn a VM when building the config to ensure the rules do not have
<NinjaTrappeur>
The nftables syntax is pretty wide. I don't think re-writing the AST in Nix has much value, especially when looking at the implementation complexity it'll involve.
<NinjaTrappeur>
Why do you want a formal grammar when you can have a man page full of examples? :P
<NinjaTrappeur>
Fair point, let's forget about that :)
<andi->
That + requiring KVM to verify the confi really turns me away from creating a general purpose module. We are missing something like `ferm` for nftables that ensures the config is valid (as much as possible)
<hexa->
what bothers me is that most of their examples are from the cmdline
<hexa->
who would ever use a production firewall like that?
<jasom>
Hmm, I wonder how tightly coupled the parsing is to the implementation; it might be possible to extract the parsing code from the kernel, but maybe that's wishful thinking.
<hexa->
sounds like manual labor :)
<hexa->
on a moving target
<jasom>
hexa-: if it's sufficiently decoupled it could probably be mostly automated, and eventually mainlined
<andi->
jasom: I actually looked at that some time ago
<andi->
and it looks sufficiently well structured
<andi->
My idea back then was to add an API to the kernel that exports the valid schema
<andi->
you could at least du some unpriv. validation
<andi->
but that doesn't solve the case where buildtime system != runtime system
laduke-132 has joined #nixos-on-your-router
<flokli>
jasom: isn't there libkernel for these things