nh icon indicating copy to clipboard operation
nh copied to clipboard

Feature parity with nixos-rebuild

Open viperML opened this issue 10 months ago • 1 comments

If we strive for mass adoption of nh, feature parity is something to consider

  • nixos-rebuild
    • [x] switch
    • [x] boot
    • [x] test
    • [x] build
    • [ ] dry-build
    • [ ] dry-activate
    • [ ] edit
    • [ ] build-vm
    • [ ] build-vm-with-bootloader
    • [x] --upgrade (flakes)
    • [ ] --upgrade (channels)
    • [ ] --install-bootloader
    • [x] --no-build-nix, --fast (only this is supported)
    • [ ] --rollback https://github.com/nix-community/nh/issues/30
    • [x] --builders (via passthrough of options)
    • [ ] --profile-name
    • [ ] --build-host, --target-host, --use-substitutes, --use-remote-sudo (nh as a deployment tool)
    • [x] --flake
    • [ ] -I nixos-config=...

viperML avatar Apr 24 '25 09:04 viperML

I'll take a look at rollback tonight.

NotAShelf avatar Apr 24 '25 09:04 NotAShelf

having the --target-host option would be really awesome, i might look into implementing when i have some time

cramt avatar May 03 '25 09:05 cramt

Note that we already have --dry which covers dry-build, and from looking at the source of nixos-rebuild, it seems that dry-activate does pretty much the same thing as build, so I can't really see a use case for it. edit just looks up NIX_CONFIG (failing that does a search in your NIX_PATH for nixos-config) and opens ./default.nix in that directory. I don't think very many people have a ./default.nix in their NixOS config, so this command seems broken by design, and I vote we don't bother including it. build-vm and build-vm-with-bootloader are in pull 208, and should be nearly ready to merge.

--install-bootloader apparently reinstalls the bootloader and can be achieved by simly setting NIXOS_INSTALL_BOOTLOADER=1 before running switch-to-configuraiton, so that's an easy one. --no-build-nix, --fast both stop nix being updated and nixos-rebuild being run a second time. That's not done in nh to my knowledge, so these aren't neccessary. --rollback has been merged.

There's a few more passthrough args: (from nixos-rebuild.sh). Should be fairly low-hanging.

      -I|--builders)
        j="$1"; shift 1
        extraBuildFlags+=("$i" "$j")
        ;;
      --max-jobs|-j|--cores|--log-format)
        j="$1"; shift 1
        extraBuildFlags+=("$i" "$j")
        copyFlags+=("$i" "$j")
        ;;
      --accept-flake-config|-j*|--quiet|--print-build-logs|-L|--no-build-output|-Q|--show-trace|--refresh|--impure|--offline|--no-net)
        extraBuildFlags+=("$i")
        ;;
      --keep-going|-k|--keep-failed|-K|--fallback|--repair)
        extraBuildFlags+=("$i")
        copyFlags+=("$i")
        ;;
      --verbose|-v|-vv|-vvv|-vvvv|-vvvvv)
        verboseScript="true"
        extraBuildFlags+=("$i")
        copyFlags+=("$i")
        ;;
      --option)
        j="$1"; shift 1
        k="$1"; shift 1
        extraBuildFlags+=("$i" "$j" "$k")
        copyFlags+=("$i" "$j" "$k")
        ;;

--profile-name can be parameterized, it has needs to be propagated to work with rollback and info, but shouldn't be too hard.

The remote deployment I have no idea about, at a guess probably the most work of those yet to be done.

-I - isn't this just the number of builders?

cdo256 avatar May 09 '25 09:05 cdo256

for nh {os,home,darwin} edit I was thinking $EDITOR $NH_FLAKE and not much else. Open to debate whether this is worth the... 5 lines of code to handle it.

NotAShelf avatar May 10 '25 12:05 NotAShelf

That could suport easily -f as an installable, and for --expr just bail out.

viperML avatar May 12 '25 13:05 viperML

I really don't want to think about non-flake setups, to be perfectly honest. I don't use non-flakes and over 80% of our users use flakes. Though I think the code will be mildly easier to manage after #281, hopefully.

NotAShelf avatar May 12 '25 14:05 NotAShelf

Any comments on future support for --file?

kalyanoliveira avatar May 26 '25 21:05 kalyanoliveira

NH has supported --file since v4

viperML avatar May 26 '25 21:05 viperML

Remote sudo isn't working for me, I get this: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

Henry-Hiles avatar Jun 02 '25 01:06 Henry-Hiles

Remote sudo isn't working for me, I get this: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

Please could you raise a PR please with the command you're running, the environment you're running in and the messages printed when running when -v --no-nom is appended to your command.

cdo256 avatar Jun 03 '25 08:06 cdo256

I've made a PR adding rebuild passthrough arguments: #311

I've included all of them there that seemed relevant, but we probably don't want to support all of them, so leave feedback on that PR as to what you think could be dropped.

cdo256 avatar Jun 03 '25 09:06 cdo256

Remote sudo isn't working for me, I get this: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

Please could you raise a PR please with the command you're running, the environment you're running in and the messages printed when running when -v --no-nom is appended to your command.

Sorry, a PR? Do you mean an issue? I'll open an issue.

Henry-Hiles avatar Jun 03 '25 17:06 Henry-Hiles

Remote sudo isn't working for me, I get this: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

Please could you raise a PR please with the command you're running, the environment you're running in and the messages printed when running when -v --no-nom is appended to your command.

Done: https://github.com/nix-community/nh/issues/312

Henry-Hiles avatar Jun 04 '25 02:06 Henry-Hiles

Let me know what you thinkg of this: https://github.com/nix-community/nh/issues/336 for supporting flakeless --upgrade.

viperML avatar Jun 27 '25 06:06 viperML

I'm closing this issue in favor of https://github.com/nix-community/nh/issues/358 with a larger scope. Feature parity is still a thing we strive for, but it is not the only goal. For those interested in chiming in, I encourage you to leave your thoughts, comments and requests in #358. You are also welcome to create PRs that help take down issues from the roadmap. Cheers!

NotAShelf avatar Jul 16 '25 19:07 NotAShelf