samsa/flake.nix
ashisgreat22 518215f62e feat(ui): dark theme redesign, fix image search and defaults
- Inline CSS in base.html (Inter, dark mode, sticky search, tabs, results)
- Remove HTMX/JS from templates; pagination via GET links
- Atmospheric side gradients + grid; wider column on large viewports
- Parse ?category= for HTML tabs (fixes Images category routing)
- Include bing_images, ddg_images, qwant_images in local_ported defaults
- Default listen port 5355; update Docker, compose, flake, README
- Favicon img uses /favicon/ proxy; preferences without inline JS

Made-with: Cursor
2026-03-23 22:49:41 +01:00

153 lines
4.6 KiB
Nix

{
description = "kafka privacy-respecting, open metasearch engine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in
{
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.buildGoModule {
pname = "kafka";
version = "0.1.0";
src = ./.;
vendorHash = "sha256-8wlKD+33s97oorCJTfHKAgE2Xp1HKXV+bSr6z29KrKM=";
# Run: nix build .#packages.x86_64-linux.default
# It will fail with the correct hash. Replace vendorHash with it.
# Embed the templates and static files at build time.
ldflags = [ "-s" "-w" ];
# Remove stale vendor directory before buildGoModule deletes it.
preConfigure = "rm -rf vendor || true";
nativeCheckInputs = with pkgs; [ ];
# Tests require network; they run in CI instead.
checkPhase = "";
meta = with pkgs.lib; {
description = "Privacy-respecting, open metasearch engine";
homepage = "https://git.ashisgreat.xyz/penal-colony/kafka";
license = licenses.mit;
platforms = platforms.linux ++ platforms.darwin;
};
};
});
nixosModules.default = { config, lib, pkgs, ... }:
let
cfg = config.services.kafka;
in
{
options.services.kafka = {
enable = lib.mkEnableOption "kafka metasearch engine";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.system}.default;
description = "kafka package to use.";
};
port = lib.mkOption {
type = lib.types.port;
default = 5355;
description = "Port to listen on.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open the firewall port.";
};
baseUrl = lib.mkOption {
type = lib.types.str;
default = "";
description = "Public base URL for OpenSearch XML (e.g. https://search.example.com).";
};
config = lib.mkOption {
type = lib.types.path;
default = "/etc/kafka/config.toml";
description = "Path to config.toml file.";
};
user = lib.mkOption {
type = lib.types.str;
default = "kafka";
description = "System user to run as.";
};
group = lib.mkOption {
type = lib.types.str;
default = "kafka";
description = "System group to run as.";
};
stateDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/kafka";
description = "State directory.";
};
};
config = lib.mkIf cfg.enable {
users.users.${cfg.user} = lib.mkIf (cfg.user == "kafka") {
isSystemUser = true;
group = cfg.group;
home = cfg.stateDir;
createHome = true;
};
users.groups.${cfg.group} = lib.mkIf (cfg.group == "kafka") { };
systemd.services.kafka = {
description = "kafka metasearch engine";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
ExecStart = "${lib.getExe cfg.package} -config ${cfg.config}";
Restart = "on-failure";
RestartSec = "5s";
WorkingDirectory = cfg.stateDir;
Environment = lib.optionals (cfg.baseUrl != "") [
"BASE_URL=${cfg.baseUrl}"
];
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
};
};
};
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.mkShell {
buildInputs = [
pkgs.go_1_24
pkgs.curl
];
};
});
};
}