Nvd: Simple Nix/NixOS version diff tool

Depends on whether there are any changes to the PR if it merges. Currently it would not be enabled by default, so you wouldn’t see any changes and have to switch to using the new option manually.

If you’re using NixOS stable, you won’t have to consider this at all until the next release (November/December), at which point the release notes should tell you if the PR merged and whether the setting is enabled by default. Even if that’s missed, you’ll just see the messages twice, or nix will tell you there’s a conflict if the activation script names overlap.

1 Like

That merge request has been closed.

FYI This is what srvos does; output is also created by nvd:

system.activationScripts.preActivation = ''
  if [[ -e /run/current-system ]]; then
    echo "--- diff to current-system"
    ${pkgs.nvd}/bin/nvd --nix-bin-dir=${config.nix.package}/bin diff /run/current-system "$systemConfig"
    echo "---"
  fi
'';

See here.

2 Likes

I’m becoming a fan of GitHub - viperML/nh: Yet another nix cli helper, which combines nvd with GitHub - maralorn/nix-output-monitor: Pipe your nix-build output through the nix-output-monitor a.k.a nom to get additional information while building. for a nicer home-manager/nixos-rebuild switch experience.

Unless you are using flakes, I recommend the prerelease/beta version of nh v4 from its flake as opposed to v3.6.0

2 Likes

Also use the beta of nh if you are on macOS as the beta supports darwin_rebuild

Caveat that nh only supports flakes.

1 Like

(I wanted this to be a reply to Waffle, and it was, but the UI confused me by not showing it. Hence, there’s another copy of this message below)

That’s true for nh 3.6. nh 4 beta supports non-flake setups.

2 Likes

Where is this mentioned? I don’t see anything in the README or git commit history that implies this. (Nor do I see an explanation of the syntax to use without flakes.)

EDIT: I guess it’s only shown within the tool for now.

Usage: nh os build [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]

Arguments:
  [INSTALLABLE]
          Which installable to use.
          Nix accepts various kinds of installables:
          
          [FLAKEREF[#ATTRPATH]]
              Flake reference with an optional attribute path.
              [env: NH_FLAKE=]
          
          -f, --file <FILE> [ATTRPATH]
              Path to file with an optional attribute path.
              [env: NH_FILE=]
              [env: NH_ATTR=]
          
          -e, --expr <EXPR> [ATTRPATH]
              Nix expression with an optional attribute path.
          
          [PATH]
              Path or symlink to a /nix/store path
          

  [EXTRA_ARGS]...
          Extra arguments passed to nix build

There are also these useful (but unfortunately easy to miss) instructions:

  • For flakes, the command is nh os switch /path/to/flake
  • For a classical configuration:
    nh os switch -f '<nixpkgs/nixos>', or
    nh os switch -f '<nixpkgs/nixos>' -- -I nixos-config=/path/to/configuration.nix if using a different location than the default.

The home-manager commands likely work similarly, but I actually use a flake there, so I haven’t tested them.

2 Likes