Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML authored Apr 17, 2024
1 parent d10c7fb commit de46775
Showing 1 changed file with 17 additions and 54 deletions.
71 changes: 17 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,63 +28,36 @@ As the main features:

nh is available in nixpkgs:

- NixOS search: https://search.nixos.org/packages?channel=unstable&query=nh
- https://search.nixos.org/packages?channel=unstable&query=nh
- Hydra status:
- x86_64-linux: https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.nh.x86_64-linux
- aarch64-linux: https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.nh.aarch64-linux

### Flake

If you want to get the latest nh version not published to nixpkgs, you can use the flake
### NixOS module

The NixOS module has some niceties, like an alternative to `nix.gc.automatic` which also cleans XDG profiles, result and direnv GC roots.

```nix
{
inputs.nh = {
url = "github:viperML/nh";
inputs.nixpkgs.follows = "nixpkgs"; # override this repo's nixpkgs snapshot
{ config, pkgs, ... }:
nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 4d --keep 3";
flake = "/home/user/my-nixos-config";
};
}
```

Then, include it in your `environment.systemPackages` or `home.packages` by referencing the input:
```
inputs.nh.packages.<system>.default
```


### Configure **FLAKE** env variable
### FLAKE environment variable

nh uses the `FLAKE` env variable as a default for `os` and `home`. This is a shorthand for `--flake` in other commands. This saves typing it every time.
nh uses the `FLAKE` environment variable as the default flake to use for its operations. This can be configured by whichever method you want,
or use the `programs.nh.flake` NixOS option.

For NixOS, configuring it could be as simple as:

```
environment.sessionVariables.FLAKE = "/home/ayats/Documents/dotfiles";
```

### NixOS module
### Specialisations support

The nh NixOS modules provides an garbage collection alternative to the default one. Currently you can only get it through the flake.

```nix
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
modules = [
inputs.nh.nixosModules.default
{
nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 4d --keep 3";
};
}
];
}
```

### Configure specialisations

NH is capable of detecting which specialisation you are running, so it runs the proper activation script.
To do so, you need to give NH some information of the spec that is currently running by writing its name to `/etc/specialisation`. The config would look like this:
nh is capable of detecting which specialisation you are running, so it runs the proper activation script.
To do so, you need to give nh some information of the spec that is currently running by writing its name to `/etc/specialisation`. The config would look like this:

```nix
{config, pkgs, ...}: {
Expand All @@ -100,17 +73,7 @@ To do so, you need to give NH some information of the spec that is currently run
}
```

### Configure the **NH_NOM** env variable

By default nh uses nix-output-monitor (nom) to show the build log. This can be disabled either by:

- Exporting the environment variable `NH_NOM=0`
- Overriding the package: `nh.override { use-nom = false; }`

## Hacking

Just `nix develop`

[^1]: At the time of this writing.

[^2]: The toplevel package is what you can build with `nix build /flake#nixosConfiguration.HOSTNAME.config.system.build.toplevel`, and what sits on `/run/current-system`, `/run/booted-system` and `/nix/var/nix/profiles/system`.
Just `nix develop`. We also provide an `.envrc` for direnv.

0 comments on commit de46775

Please sign in to comment.