Skip to content

Add flake.nix for installation on NixOS#516

Draft
mikl wants to merge 1 commit into
arnested:mainfrom
mikl:nix-flake
Draft

Add flake.nix for installation on NixOS#516
mikl wants to merge 1 commit into
arnested:mainfrom
mikl:nix-flake

Conversation

@mikl
Copy link
Copy Markdown

@mikl mikl commented May 14, 2026

Add a flake.nix file, as described by Clåde:

The flake.nix is complete, builds successfully, and passes nix flake check. Here's what it provides:

Package (packages.ldddns / packages.default):

  • Builds the Go binary with buildGo126Module, CGO disabled, -trimpath, and stripped symbols
  • Sets main.version via ldflags from the git revision
  • Renames the binary from ldddns.arnested.dk (the Go module name) to ldddns
  • vendorHash is computed from the current go.sum

NixOS module (nixosModules.default):

  • services.ldddns.enable - enables the systemd service
  • services.ldddns.package - override the package
  • services.ldddns.hostnameLookup - configures hostname lookup methods (defaults to ["env:VIRTUAL_HOST" "containerName"])
  • services.ldddns.ignoreDockerComposeOneoff - ignore oneoff containers (default true)
  • services.ldddns.gops - enable gops diagnostics (default false)
  • The systemd unit mirrors the hardening from systemd/ldddns.service

Dev shell (devShells.default):

  • Go 1.26, gopls, and goreleaser

Usage in a NixOS configuration:

{
  inputs.ldddns.url = "github:arnested/ldddns";

  outputs = { nixpkgs, ldddns, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [
        ldddns.nixosModules.default
        { services.ldddns.enable = true; }
      ];
    };
  };
}

Notes:

  • The prePatch relaxes the go 1.26.3 directive to go 1.26 because nixpkgs-unstable currently ships Go 1.26.2. This can be removed once nixpkgs catches up.
  • Tests are disabled (doCheck = false) because honnef.co/go/netdb reads /etc/protocols at init time, which doesn't exist in the Nix sandbox.
  • The vendorHash will need updating whenever go.mod/go.sum changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant