Files
millerson-overlay.nix/packages/nftablesbuilder/package.nix
Alexander Miroshnichenko 3ddbedc2cc
Some checks failed
CI / check (push) Has been cancelled
feat(packages): add nftablesbuilder package
Web interface to manage nftables rules with drag-and-drop rule creation.

Upstream source is incomplete (missing settings crate, no GUI build
tooling), so the package builds the Rust workspace from the pinned
commit with a patched-in settings crate (schema recovered from official
release artifacts) and reuses the prebuilt GUI from the hash-pinned
release tarball on nftablesbuilder.eu.
2026-08-07 08:38:15 +03:00

70 lines
2.2 KiB
Nix

{
lib,
rustPlatform,
fetchFromGitHub,
fetchurl,
pkg-config,
openssl,
}:
rustPlatform.buildRustPackage rec {
pname = "nftablesbuilder";
# Pinned to a commit rather than a release tag because upstream
# publishes releases only as tarballs on nftablesbuilder.eu.
version = "0.1.0-unstable-2026-01-27";
src = fetchFromGitHub {
owner = "AiseBouma";
repo = "NftablesBuilder";
rev = "f414e921c2857556cdb4d602ed832a32a6951d25";
hash = "sha256-5qwyVXLrUxOk7poVdUyi/yJUq1CYMffruvAO0ONO+cI=";
};
# Upstream source is incomplete: both crates depend on a `settings`
# crate (path = "../settings") that was never committed, and the GUI
# has no build tooling (raw TSX, no package.json). This patch adds
# the missing settings crate (schema recovered from the official
# release artifacts) plus a workspace Cargo.toml.
patches = [ ./settings-workspace.patch ];
cargoLock.lockFile = ./Cargo.lock;
# Prebuilt GUI from the official release tarball, since the GUI cannot
# be built from source. Upstream serves releases with a self-signed
# TLS certificate, hence curlOpts = "-k"; the hash still pins content.
guiSrc = fetchurl {
url = "https://nftablesbuilder.eu/releases/latest/nftablesbuilder.tar.gz";
sha256 = "sha256-vHyuKVH4OtXEisWeDo+b3gHg3TzdXUSfMbaNpfQOrns=";
curlOpts = "-k";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
installPhase = ''
runHook preInstall
binDir=$(dirname "$(find target -type f -name nftablesbuilder -path '*/release/*' | head -1)")
install -Dm755 $binDir/nftablesbuilder $out/bin/nftablesbuilder
install -Dm755 $binDir/webserver $out/libexec/nftablesbuilder/webserver
mkdir -p $out/share/nftablesbuilder
tar -xzf $guiSrc -C $out/share/nftablesbuilder --strip-components=4 nftablesbuilder/root/opt/nftablesbuilder/html
install -Dm644 ${./settings.example} $out/share/nftablesbuilder/settings.example
runHook postInstall
'';
passthru = {
category = "Networking";
};
meta = with lib; {
description = "Web interface to manage nftables rules";
homepage = "https://github.com/AiseBouma/NftablesBuilder";
license = licenses.mit;
mainProgram = "nftablesbuilder";
platforms = platforms.linux;
};
}