Skip to content

nixdiff: port to macOS and surface home-manager package changes #683

Description

@genebean

Background

During the feat/genebean-programs-namespace branch, `nixdiff` was promoted from a shell alias to a `writeShellApplication` package (commit on that branch) and extended to show flatpak changes alongside nvd's package diff. The implementation lives in `modules/shared/home/linux/default.nix`.

What nixdiff does today (Linux only)

  1. Runs `nixos-rebuild build --flake .`
  2. Uses `nvd diff /run/current-system result` to show package changes
  3. Traces the nix store path chain from `result` to find embedded `flatpak-state.json` files (both system-level and user/HM-level) and shows a +/- diff of flatpak app IDs

What we learned about the output

When packages move from `environment.systemPackages` to `home.packages` (e.g. sops/age/ssh-to-age moving to the genebean.programs.sops module), nvd shows them as `[C-]` (removed from system closure) but does not show them being added in the HM profile. This makes the output confusing — it looks like packages disappeared rather than moved.

Similarly, HM-managed config file derivations show up with mangled names (e.g. `hm_weztermwezterm.lua` instead of `wezterm/wezterm.lua`) because nix strips slashes from the store name.

Goals for improvement

  • Port to macOS: Create an equivalent `nixdiff` for Darwin. `nixos-rebuild build` does not exist; the equivalent is `darwin-rebuild build --flake .`. The `nvd diff` invocation would compare `/run/current-system` with `result` the same way.
  • Surface HM package changes: The HM profile lives separately from the system profile. Investigate whether `nvd` can be pointed at the HM generation paths to show package additions/removals there too. Something like diffing `~/.local/state/nix/profiles/home-manager` (or the equivalent on macOS) against the new generation embedded in `result`.
  • Cleaner HM file names: The mangled derivation names (`hm_weztermwezterm.lua`) are hard to read. Filter or rename these in output, or skip them entirely (config file changes are less actionable than package changes).
  • Puppet noop parity (stretch): Longer term, show which systemd/launchd services would restart — the closest equivalent to what puppet noop provides.

Related

  • nixdiff implementation: `modules/shared/home/linux/default.nix`
  • macOS would live in `modules/shared/home/darwin/` or similar once that directory exists

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions