nix/readme.md

100 lines
2.6 KiB
Markdown
Raw Normal View History

2023-09-06 00:14:34 -05:00
# Nix
2023-09-04 11:40:30 -05:00
2023-09-06 00:14:34 -05:00
The grand unification of configuration.
## Not on NixOS?
Install Nix using Determinate Systems's installer:
2023-09-04 11:49:33 -05:00
2023-09-04 11:40:30 -05:00
```bash
2023-09-06 00:14:34 -05:00
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
2023-09-04 11:40:30 -05:00
```
2023-09-06 00:14:34 -05:00
And [install Home Manager in standalone mode](https://nix-community.github.io/home-manager/index.html#sec-install-standalone):
# NixOS
2023-09-04 11:40:30 -05:00
```bash
2023-09-06 00:14:34 -05:00
nixos-rebuild --flake git+https://git.lyte.dev/lytedev/nix switch
```
2023-09-04 11:40:30 -05:00
2023-09-06 00:14:34 -05:00
## Remotely
2023-09-04 11:40:30 -05:00
2023-09-06 00:14:34 -05:00
```bash
nixos-rebuild --flake git+https://git.lyte.dev/lytedev/nix#host \
--target-host root@host --build-host root@host \
switch
2023-09-04 11:40:30 -05:00
```
2023-09-06 00:14:34 -05:00
# Home Manager
2023-09-06 00:14:34 -05:00
This can be used on non-NixOS hosts:
```bash
home-manager switch --flake .#daniel
```
2023-09-06 00:14:34 -05:00
## Remotely
```bash
ssh daniel@host 'home-manager switch --flake git+https://git.lyte.dev/lytedev/nix#daniel'
```
# Provisioning New NixOS Hosts
2023-09-04 11:49:33 -05:00
Documented below is my process for standing up a new NixOS node configured and
2023-09-06 00:14:34 -05:00
managed by this flake from scratch.
2023-09-04 11:49:33 -05:00
## Network Access
2023-09-06 00:14:34 -05:00
Boot a NixOS ISO and establish network access:
2023-09-04 11:49:33 -05:00
```bash
2023-09-06 00:14:34 -05:00
# plug in ethernet or do the wpa_cli song and dance for wifi access
wpa_cli scan # if you need to
2023-09-04 11:49:33 -05:00
wpa_cli scan_results
wpa_cli add_network 0
wpa_cli set_network 0 ssid "MY_SSID"
wpa_cli set_network 0 psk "MY_WIFI_PASSWORD"
wpa_cli enable_network 0
wpa_cli save_config
```
2023-09-06 00:14:34 -05:00
Partition disk(s) and mount up however you like. Preferably, though, use a
[disko configuration](./disko.nix) from this flake like so:
2023-09-04 11:49:33 -05:00
```bash
2023-09-06 00:14:34 -05:00
# TODO: I'm relatively certain this can be simplified to a single `nix run` command
sudo nix-shell --packages git --run "nix run \
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
github:nix-community/disko -- \
--flake 'git+https://git.lyte.dev/lytedev/nix#standard' \
--mode disko \
--arg disks '[ \"/dev/your_disk\" ]'"
2023-09-04 11:49:33 -05:00
```
2023-09-18 09:02:00 -05:00
And finally install NixOS (optionally using my cache) as specified by this flake:
2023-09-04 11:49:33 -05:00
```bash
nix-shell --packages git \
2023-09-06 00:14:34 -05:00
--run "sudo nixos-install \
2023-09-18 09:02:00 -05:00
--flake 'git+https://git.lyte.dev/lytedev/nix#yourNixosConfig' \
--option substituters 'https://nix.h.lyte.dev' \
--option trusted-public-keys 'h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0='"
2023-09-04 11:49:33 -05:00
```
**NOTE**: This takes a while, mostly due to building Helix myself on each box. I
really need to figure out a good local caching setup.
2023-09-06 00:14:34 -05:00
**NOTE**: since the disko setup _should_ be included in the nixosConfiguration,
I would like to know how to do this all in one go -- maybe even building my own
live media?
2023-09-04 11:40:30 -05:00
# Other To Dos
2023-09-06 00:57:08 -05:00
- Port configuration (lytedev/dotfiles) to home manager where applicable?
2023-09-06 01:23:08 -05:00
- Sway, Kitty, and Helix, come to mind
2023-09-06 00:14:34 -05:00
- Pre-commit checks with `nix flake check`?