Haven Nostr Relay for NixOS
| .gitignore | Initial package and module | |
| flake.lock | Initial package and module | |
| flake.nix | Initial package and module | |
| LICENSE | Initial commit | |
| module.nix | Update readme | |
| package.nix | fix missing templates | |
| README.md | Update readme | |
Haven NixOS Module & Package
This repository provides a Nix module and package definition for Haven, a self-hosted Nostr relay and blossom server.
What is provided
- A reproducible Nix package for Haven.
- A declarative NixOS module that:
- Configures Haven as a systemd service.
- Creates a persistent
stateDirwith relay database and blossom files. - Allows full customization of relay behavior (chat, inbox, outbox, etc).
- Provides sensible defaults for relays settings, limits, and descriptions.
Usage
Module Configuration
{
inputs.haven.url = "git+https://codeberg.org/karl/haven-nix";
outputs = { self, nixpkgs, haven, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
nixosConfigurations.my-host = pkgs.lib.nixosSystem {
inherit system;
modules = [
haven.nixosModules.haven
./my-config.nix
];
};
};
}
{
services.haven = let
commonRelays = [
"relay.damus.io"
"nos.lol"
"relay.nostr.band"
];
in {
enable = true;
relayUrl = "relay.example.com";
relayPort = 3355;
ownerNpub = "npub1...";
privateRelayName = "Private";
chatRelayName = "Chat";
outboxRelayName = "Outbox";
inboxRelayName = "Inbox";
importSeedRelays = commonRelays ++ [ "relay.extra.com" ];
blastrRelays = commonRelays;
};
}
Package Details
The Haven binary is built via buildGoModule using Go modules and vendoring. The templates/ directory (required at runtime) is included in the package and symlinked to ${stateDir}/templates at service startup when using the module.
Limitations
- No binary cache: builds are local unless you set up Cachix or similar.
- No module tests yet: systemd service and integration tests will be added.
- Templates are not customizable: Haven expects them to be in ./templates. Currently symlinked into stateDir, but not user-configurable.
Planned Improvements
- Add templatesDir option to configure Haven template path.
- Add integration tests via
nixosTest. - Set up a binary cache for the Haven package.
Credits
- Haven
- Nix/NixOS community and the authors of existing service modules for inspiration.
PRs welcome!