Skip to content

Add flake.nix for installation on NixOS#516

Open
mikl wants to merge 2 commits into
arnested:mainfrom
mikl:nix-flake
Open

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

Conversation

@mikl
Copy link
Copy Markdown

@mikl mikl commented May 14, 2026

Add a flake.nix file, to make it easy to install ldddns on NixOS, 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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 4, 2026

CLA assistant check
All committers have signed the CLA.

@mikl mikl marked this pull request as ready for review June 5, 2026 09:05
@mikl mikl requested a review from arnested as a code owner June 5, 2026 09:05
@mikl
Copy link
Copy Markdown
Author

mikl commented Jun 5, 2026

@arnested I've also added an action to auto-update the vendorHash flake.nix file, so it should just work with no extra release steps needed.

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.

2 participants