~raphi/nix-index-web

Web interface to nix-index
a month ago

b9b41ff update depencies because of RUSTSEC-2024-0019

2 months ago

#nix-index-web

Web interface to nix-index.

#Usage

nix-index-web <address> <databases_dir>
  • address: ip:port combination to listen on, or the special value "systemd" for systemd socket activation support.
  • databases_dir: Directory containing nix-index databases. This directory should contain one subdirectory per system, prefixed with "index-" (e.g. "index-x86_64-linux"). Inside each subdirectory there must be a file called "files".

You should place this service behind a reverse proxy, e.g. nginx (otherwise static files won't be served).

You can use the supplied nixos module (available as the flake attribute "nixosModules.default").

#NixOS example configuration

services.nix-index-web = {
  enable = true;
  listenAddress = "[::1]:1234";
  refreshInterval = "Mon *-*-* 10:10:00";
};

services.nginx.virtualHosts.WHATEVER.locations = {
  "/nix-index".return = "301 $scheme://$host$request_uri/";
  "/nix-index/" = {
    proxyPass = "http://[::1]:1234/";
    extraConfig = ''
      add_header x-content-type-options nosniff;
      add_header content-security-policy "default-src 'self'; object-src 'none'; frame-ancestors 'none'";

      # Optional but recommended:
      proxy_cache default;
      proxy_cache_valid 200 120m;
    '';
  };
  "/nix-index/_/" = {
    alias = "${pkgs.nix-index-web.wwwroot}/_/";
    extraConfig = ''
      add_header x-content-type-options nosniff;
      add_header content-security-policy "default-src 'self'; object-src 'none'; frame-ancestors 'none'";
    '';
  };
};

#License

MIT