nix/readme.md

81 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-15 11:16:38 -05:00
My grand, declarative, and unified application, service, environment, and
machine configuration, secret, and package management in a single flake. ❤️ ❄️
2023-09-06 00:14:34 -05:00
2023-09-15 11:16:38 -05:00
**NOTE**: Everything in here is highly specific to my personal preference. I
can't recommend you actually use this in any way, but hopefully some stuff in
here is useful inspiration.
2023-09-06 00:14:34 -05:00
2023-09-15 11:16:38 -05:00
# Quick Start
2023-09-04 11:49:33 -05:00
2023-09-15 11:16:38 -05:00
You don't have even have to clone this crap yourself. How cool is that!
2023-09-06 00:14:34 -05:00
2023-09-15 11:16:38 -05:00
## NixOS
2023-09-04 11:40:30 -05:00
2023-09-15 11:16:38 -05:00
```shell_session
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-15 11:16:38 -05:00
## Not NixOS
2023-09-04 11:40:30 -05:00
2023-09-15 11:16:38 -05:00
```shell_session
$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
$ nix profile install github:nix-community/home-manager
$ home-manager switch --flake git+https://git.lyte.dev/lytedev/nix
2023-09-04 11:40:30 -05:00
```
2023-09-15 11:16:38 -05:00
# Advanced Usage
2023-09-15 11:16:38 -05:00
## Push NixOS Config
```bash
2023-09-15 11:16:38 -05:00
nix run nixpkgs#nixos-rebuild -- --flake 'git+https://git.lyte.dev/lytedev/nix#host' \
--target-host root@host --build-host root@host \
switch --show-trace
2023-09-06 00:14:34 -05:00
```
2023-09-15 11:16:38 -05:00
<!-- TODO: how to do this with rollbacks if I don't confirm things? -->
2023-09-04 11:49:33 -05:00
2023-09-15 11:16:38 -05:00
## Provisioning New NixOS Hosts
2023-09-04 11:49:33 -05:00
```bash
2023-09-15 11:16:38 -05:00
# establish network access
# plug in ethernet or do the wpa_cli song and dance for wifi
wpa_cli scan
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-15 11:16:38 -05:00
# partition disks
nix-shell --packages git --run "sudo nix run \
2023-09-06 00:14:34 -05:00
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
github:nix-community/disko -- \
2023-09-15 11:16:38 -05:00
--flake 'git+https://git.lyte.dev/lytedev/nix#${PARTITION_SCHEME}' \
2023-09-06 00:14:34 -05:00
--mode disko \
2023-09-15 11:16:38 -05:00
--arg disks '[ \"/dev/${DISK}\" ]'"
2023-09-04 11:49:33 -05:00
2023-09-15 11:16:38 -05:00
# install
2023-09-04 11:49:33 -05:00
nix-shell --packages git \
2023-09-06 00:14:34 -05:00
--run "sudo nixos-install \
--flake 'git+https://git.lyte.dev/lytedev/nix#${FLAKE_ATTR}' \
2023-09-18 09:02:00 -05:00
--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
```
2023-09-15 11:16:38 -05:00
# To Do
2023-09-04 11:40:30 -05:00
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-15 11:16:38 -05:00
- Installation from a live ISO does not fully work yet
- I don't understand Nix well enough to know why stuff is being compiled even when I have a binary cache
- Maybe it detects different CPUs and will recompile certain packages for per-CPU optimizations?
- How does this factor in with "pureness"?
- Custom pre-configured live ISO
- Unify standalone home manager module with NixOS home manager module
- Pre-commit checks with stuff like `nix flake check` and formatting checkers