Howdy!
I’m an intermittent NixOS user, trying again to make it my daily driver. My ability to debug Nix is limited to repeatedly trying to run nixos-rebuild again and again until something works. Would love to hear tips and tricks other people are using as part of this discussion.
I have a home server with a couple of services exposed. I’ve set up avahi so that I can access my server at home via kitsault.local, but trying to remember all the ports for my various services is a drag! I want to have subdomains for each service, but the kicker is that this seems difficult to accomplish even without the Gates of Nix standing before us.
I started after finding this blog post: Painfully Obvious → Using mDNS aliases within your home network
This is where I discovered mdns-publish, a python package not currently nix-ified. So, to start, and with help from Python - NixOS Wiki, I set up a configuration.nix to look like this:
{ config, pkgs, ...}:
let
my-python-packages = ps: with ps; [
# ...
(
buildPythonPackage rec {
pname = "mdns-publisher";
version = "0.9.2";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-sjCQKnsFR6w3IwCvZ1GDw0VqnLjEbO3ecgKOJrSZj84==";
};
doCheck = false;
propagatedBuildInputs = with pythonPackages; [
dbus-python
];
}
)
];
in
{
environment.systemPackages = with pkgs; [
nssmdns
avahi
# mdns-publisher
(pkgs.python3.withPackages my-python-packages)
];
services.avahi = {
enable = true;
publish = {
enable = true;
addresses = true;
workstation = true;
};
nssmdns = true;
};
}
I manage my machine states with a single flake.nix, without exposing a lot of unneeded detail, it looks like
{
inputs.nixpkgs.url = github:NixOS/nixpkgs;
outputs = { self, nixpkgs, ... }:
{
nixosConfigurations.kitsault = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./mdns-configuration.nix
...
];
};
};
}
This has gotten me pretty close, I can run the command that mdns-publisher exposes but when I run
sudo mdns-publish-cname test.my-machine.local
sudo mdns-publish-cname test.local
I get
dbus.exceptions.DBusException: org.freedesktop.Avahi.NotPermittedError: Not permitted
And I’m unsure of how to continue - ChatGPT isn’t versed enough in Nix to help. Thoughts?