Home Explore Blog CI



nixpkgs

2nd chunk of `pkgs/by-name/ni/nixos-rebuild-ng/README.md`
a908ceca162edadfb111d1147a8d86d469e163633de49e90000000010000087b
```

And use `nixos-rebuild-ng` instead of `nixos-rebuild`.

If you want to completely replace `nixos-rebuild` with `nixos-rebuild-ng`, add
the following to your NixOS configuration:

```nix
{ ... }:
{
  system.rebuild.enableNg = true;
}
```

This will set `config.system.build.nixos-rebuild` to `nixos-rebuild-ng`, so
all tools that expect it in that location should work.

## Development

Run:

```console
nix-build -A nixos-rebuild-ng -A nixos-rebuild-ng.tests.linters
```

The command above will build, run the unit tests and linters, and also check if
the code is formatted. However, sometimes is more convenient to run just a few
tests to debug, in this case you can run:

```console
nix-shell -A nixos-rebuild-ng.devShell
```

The command above should automatically put you inside `src` directory, and you
can run:

```console
# run program
python -m nixos_rebuild
# run tests
pytest
# check types
mypy .
# fix lint issues
ruff check --fix .
# format code
ruff format .
```

## Breaking changes

While `nixos-rebuild-ng` tries to be as much of a clone of the original as
possible, there are still some breaking changes that were done in order to
improve the user experience. If they break your workflow in some way that is
not possible to fix, please open an issue and we can discuss a solution.

- For `--build-host` and `--target-host`, `nixos-rebuild-ng` does not allocate
  a pseudo-TTY via SSH (e.g., `ssh -t`) anymore. The reason for this is that
  pseudo-TTY breaks some expectations from SSH, like it mangles stdout and
  stderr, and can
  [break terminal output](https://github.com/NixOS/nixpkgs/issues/336967) in
  some situations.
  The issue is that `sudo` needs a TTY to ask for password, otherwise it will
  fail. The solution for this is a new flag, `--ask-sudo-password`, that when
  used with `--target-host` (`--build-host` doesn't need `sudo`), will ask for
  the `sudo` password for the target host using Python's
  [getpass](https://docs.python.org/3/library/getpass.html) and forward it to
  every `sudo` request. Keep in mind that there is no check, so if you type
  your password wrong, it will fail during activation (this can be improved

Title: Usage, Development and Breaking Changes in nixos-rebuild-ng
Summary
This section details how to use nixos-rebuild-ng, including replacing the original nixos-rebuild. It provides instructions for development, such as building, running tests, and using the development shell. It also highlights breaking changes, specifically the removal of pseudo-TTY allocation via SSH for `--build-host` and `--target-host`, replaced by the `--ask-sudo-password` flag to handle sudo authentication on target hosts.