asgard
> [!IMPORTANT]
> This configuration is under constant construction so some things may be remove or add accordings to my needs but i want to keep all even if it's not used anymore.
>
> Since this configuration is made for my own needs, you can take inspiration and some configuration but do not expect it to work on your side.
>
> Any damage caused by this configuration is not my responsibility, so use it at your own risks.
## Table of Contents
- [Features & Capabilities](#features--capabilities)
- [Machines](#machines)
- [Installation](#installation)
- [Folder Structure](#folder-structure)
- [Commands](#commands)
- [Documentations](#documentations)
- [Troubleshooting](#troubleshooting)
## Features & Capabilities
This repository want this to be multi-user and multi-host so there is some workaround to make things work like i want and keep it simple.
- [x] NixOS
- [x] Nix Darwin
- [x] Home management (hjem)
- [ ] Persistant storage (impermanence)
- [ ] MicroVM for servers (astro/microvm)
- [ ] Secrets management (agenix)
- [ ] Secure Boot (lanzaboot)
- [ ] Disk configuration (disko)
- [ ] Encrypted disks (?)
- [ ] Network topology (nix-topology)
- [ ] Automatic updates (*cannot be entirely done, since tangled does not support pipeline based on time.*)
## Installation
### NixOS
1. Boot the NixOS ISO, partition/format/mount your disks manually (no disko yet).
2. Clone the repo onto the target: `git clone /mnt/etc/asgard && cd /mnt/etc/asgard`
3. `mkdir -p configurations/`
4. `just generate-hardware` โ generates facter.json
5. Write configurations//configurations.nix (copy an existing host as a template), including your fileSystems entries matching step 1.
6. Install: `sudo nixos-install --flake .#`
7. Reboot, then use `nix develop && just switch` for future rebuilds.
### nix-darwin
1. Install Nix on macOS (e.g. the Lix installer).
2. Clone the repo: `git clone ~/asgard && cd ~/asgard`
3. `mkdir -p configurations/`, write configurations.nix (use njord as a reference โ no facter.json needed on Darwin).
4. Bootstrap once: `nix run nix-darwin -- switch --flake .#`
5. From then on: `nix develop && just switch`
## Machines
| Hostname | Motherboard | CPU | GPU | RAM | OS | Usage | Status |
| :------------- | :-------------------------------- | :------------------- | :-------------- | :--: | :-: | :-----: | :----: |
| `andhrimnir` | MSI PRO B850-P WIFI | AMD Ryzen 5 5500X 3D | AMD RX 9060 XT | 32Go | โ๏ธ | ๐ฎ๏ธ | ๐ข๏ธ |
| `elli` | HP ProDesk 400 G1 DM | Intel Pentium G3250T | - | 8Go | โ๏ธ | ๐พ๏ธ | ๐ |
| `loki` | ASUS ROG STRIX B760-I GAMING WIFI | Intel i5 13600kf | Nvidia 4070ti | 32Go | โ๏ธ | ๐ฎ๏ธ | ๐ข๏ธ |
| `nanna` | Lenovo Legion Y530 15ICH | Intel i5 | Nvidia 1050ti | 16Go | โ๏ธ | ๐ฅ๏ธ/๐ฎ๏ธ | ๐ข๏ธ |
| `njord` | - | Apple M2 Pro | Apple M2 Pro | 32Go | ๐๏ธ | ๐ฅ๏ธ | ๐ข๏ธ |
| `nott` | Aorus B450 Elite | AMD Ryzen 3 3300X | Nvidia 1060 | 16Go | โ๏ธ | ๐ฎ๏ธ | ๐ข๏ธ |
| `sunna` | ASUS ROG STRIX G15 | Intel i7 10870H | Nvidia 2060 | 16Go | โ๏ธ | ๐ฅ๏ธ | ๐ด |
| `syn` | Raspberry Pi3 b+ | - | - | 1Go | โ๏ธ | ๐พ๏ธ | ๐ด |
Annotations
- ๐ฎ๏ธ : Gamingstation
- ๐พ๏ธ : Server
- โ๏ธ : Virtual Machime
- ๐ฅ๏ธ : Workstation
- ๐งจ๏ธ : Testing purpose
- โ๏ธ : NixOS
- ๐๏ธ : MacOS
- ๐น๏ธ : FreeBSD with [NixBSD](https://github.com/nixos-bsd/nixbsd)
## Folder structure
This repository use a `dentritic pattern` combined with the logic of the flake output to make everything work with ease and easy to find.
```
.
โโโ configurations/
โ โโโ /
โ โ โโโ configurations.nix
โ โ โโโ facter.json # Optionnal
โโโ devshells/
โโโ docs/ # Additonnal documentation needed
โโโ lib/
โโโ modules/
โโโ overlays/
โโโ packages/
โโโ secrets/
โ โโโ ..age # Encrypted secrets
โ โโโ secrets.nix # Secrets entrypoint
โโโ templates/
โ โโโ /
โ โ โโโ .nix
โ โ โโโ default.nix # Basic template for the language, used as a base for the framework ones.
โโโ users/ # User based configurations.
โโโ flake.nix
โโโ flake-module.nix # Additionnal modules definition for flake-parts.
โโโ justfile # Command helper
```
## Commands
You can get all recipes using the `just` command and running one of the available commands below with `just `:
```sh
Available recipes:
boot hostname=hostname # Build a new configuration
clean # Cleanup all unused packages and generations
format # Format code
size # Print size of the nix store
switch hostname=hostname # Rebuild the system
update # Update dependencies
generate-hardware # Generate facter report from the current hardware into the host configuration folder
```
## Documentations
These are the things that help me the most to understand Nix ecosystem and help me build my configuration from scratch.
You can retrieve dotfiles that inspired me inside my [`dotfiles` star list](https://github.com/stars/Cosmeak/lists/useful-dotfiles).
- [Flakes book](https://nixos-and-flakes.thiscute.world/)
- [Nix Language](https://nix.dev/)
- [Nix Tour](https://nixcloud.io/tour/?id=introduction/nix)
- [Dentritic Pattern explanation](https://github.com/Doc-Steve/dendritic-design-with-flake-parts)
## Troubleshooting
- If the rebuild command failed because an experimental feature is disabled use this command:
```sh
sudo -E NIX_CONFIG="experimental-features = nix-command flakes pipe-operators" nixos-rebuild switch --flake .
```