cool shit
This commit is contained in:
parent
279f90bfb8
commit
8b1c25a579
168
README.md
168
README.md
|
@ -1,165 +1,5 @@
|
||||||
# My nixos flake
|
# If your nix config is so great why isn't there a nix config tw-
|
||||||
This is my nixos configuration.
|
Second iteration of my nix config. Got tired of the old one not quite working how i liked on my desktop (mainly impermanence not working without disk encryption enaled)
|
||||||
|
|
||||||
# Installation
|
## AAAAAa
|
||||||
To install either run the following script, or follow the instructions.
|
dont use this. *yet*
|
||||||
|
|
||||||
```sh
|
|
||||||
curl https://gitlab.com/SpoodyTheOne/nixos-config/-/raw/master/install.sh -o install.sh
|
|
||||||
sudo chmod +x install.sh
|
|
||||||
./install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Disko partitioning
|
|
||||||
### Finding your disk
|
|
||||||
run `lsblk` to find the name of your drive. In my case it was `/dev/nvme0n1` but other names it can have are `/dev/sd[a-z]` or `/dev/vd[a-z]` if you are installing on a virtual machine.
|
|
||||||
|
|
||||||
### Acquire disko config
|
|
||||||
run
|
|
||||||
```sh
|
|
||||||
curl https://gitlab.com/SpoodyTheOne/nixos-config/-/raw/master/modules/disko/disko-luks.nix -o /tmp/disko.nix
|
|
||||||
```
|
|
||||||
to download the latest version of my disko config
|
|
||||||
|
|
||||||
### Run disko partitioning
|
|
||||||
This will run my disko config and partition your disk.
|
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> This command will erase all data on the chosen disk. Make sure you partition the correct disk and that you've backed up anything important on it
|
|
||||||
|
|
||||||
The command to run the config is
|
|
||||||
```sh
|
|
||||||
sudo nix --experimental-features "nix-command flakes" \
|
|
||||||
run github:nix-community/disko -- \
|
|
||||||
--mode disko /tmp/disko.nix \
|
|
||||||
--arg device '"<YOUR DISK HERE>"' \
|
|
||||||
--arg swap-size '"<eg. 8G>"'
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> The swap size can be any number suffixed with the standard K,M,G for gigabytes and such.
|
|
||||||
|
|
||||||
During the installation you will be prompted for a password. This is the password used for unencrypting your disk every time you boot.
|
|
||||||
You will be prompted twice, once to lock it, and then again to unlock it.
|
|
||||||
|
|
||||||
The device will now be mounted on `/mnt` and should contain the following structure
|
|
||||||
- /persist
|
|
||||||
- /boot
|
|
||||||
- /nix
|
|
||||||
|
|
||||||
## Generate configuration
|
|
||||||
You need to generate the `hardware-configuration.nix` file for your system.
|
|
||||||
To do this run
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo nixos-generate-config --no-filesystems --root /mnt
|
|
||||||
```
|
|
||||||
|
|
||||||
This will generate a folder called `/mnt/etc/nixos` with the hardware configuration file in it.
|
|
||||||
|
|
||||||
Next step is to move `hardware-configuration.nix` into `/tmp` and then clone the git repo to `/etc/nixos`
|
|
||||||
|
|
||||||
```sh
|
|
||||||
nix-shell -p git # For the git command
|
|
||||||
sudo mv /mnt/etc/nixos/hardware-configuration.nix /tmp # Move configuration away
|
|
||||||
sudo rm -rf /mnt/etc/nixos # Nuke config folder so we can clone
|
|
||||||
sudo git clone https://gitlab.com/SpoodyTheOne/nixos-config.git /mnt/etc/nixos # Clone config
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuring config
|
|
||||||
Start by replacing the bootstrap hosts hardware-configuration with your own
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Move hardware configuration
|
|
||||||
sudo mv /tmp/hardware-configuration.nix /mnt/etc/nixos/hosts/bootstrap
|
|
||||||
# go to /etc/nixos
|
|
||||||
cd /mnt/etc/nixos
|
|
||||||
# Add hardware configuration to git for nix to recognize it
|
|
||||||
sudo git add .
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configure users
|
|
||||||
Go to `/mnt/etc/nixos/flake.nix` and change the config for the bootstrap host disko module to have the same settings you used for setting up your disk.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo vim /mnt/etc/nixos/flake.nix
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install
|
|
||||||
Now that everything is configured run
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Copy configuration to permanent storage so its not nuked on reboot
|
|
||||||
sudo cp -r /mnt/etc/nixos /mnt/persist
|
|
||||||
sudo nixos-install --root /mnt --flake /mnt/etc/nixos#bootstrap
|
|
||||||
```
|
|
||||||
|
|
||||||
to install everything and then reboot.
|
|
||||||
|
|
||||||
## After reboot
|
|
||||||
After the reboot you will be prompted for your disk password. After inputting it the system will boot as normal.
|
|
||||||
|
|
||||||
Once booted log in using the user `bootstrap` and the password `1234`.
|
|
||||||
|
|
||||||
Next step, modify the bootstrap host configuration to enable impermanence and change the user and password. Then rebuild and reboot
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd /persist/nixos
|
|
||||||
sudo vim hosts/bootstrap/configuration.nix
|
|
||||||
```
|
|
||||||
|
|
||||||
in the config go to imports and uncomment this block
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# UNCOMMENT AFTER REBOOT
|
|
||||||
# Delete unwanted files
|
|
||||||
# (import ../../modules/disko/delete-on-boot.nix {
|
|
||||||
# inherit lib;
|
|
||||||
# persistExtraDirectories = [ ];
|
|
||||||
# persistExtraFiles = [ ];
|
|
||||||
# })
|
|
||||||
```
|
|
||||||
|
|
||||||
Futher down in the file theres a line that says `users.users."bootstrap"`. Modify the string to your desired username and change the following lines in the user
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Generate a password and place the output in a file
|
|
||||||
mkpasswd > /tmp/passwd
|
|
||||||
```
|
|
||||||
Then in vim read the contenst of the password into the hashedPassword field
|
|
||||||
```vim
|
|
||||||
:read /tmp/passwd
|
|
||||||
```
|
|
||||||
|
|
||||||
The end result should look something like this
|
|
||||||
```diff
|
|
||||||
- initialPassword = "1234";
|
|
||||||
+ hashedPassword = "$y$j9T$TK08gB8eSmQdGaS2Gfiex/$L2moQMRxYDEiuEeql/MidoQhFBAJC1qnOTx7ChpAOtC"';
|
|
||||||
```
|
|
||||||
|
|
||||||
Move `/persist/nixos/` to `/etc/nixos` and rebuild. Then the installation will be done
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo mv -r /persist/nixos /etc
|
|
||||||
```
|
|
||||||
|
|
||||||
Then rebuild
|
|
||||||
```sh
|
|
||||||
sudo nix-rebuild switch --flake /persist/nixos#bootstrap
|
|
||||||
reboot
|
|
||||||
```
|
|
||||||
|
|
||||||
Don't worry about all the errors that occur during the rebuild. This only happens the first time after switching to impermanence
|
|
||||||
|
|
||||||
# Post Installation
|
|
||||||
Once you've installed you're free to create a new host and modify it to your hearts content. You can base it off of my laptop host, it has a lot of nice things
|
|
||||||
|
|
||||||
My config includes an alias for rebuilding the system called `nix-rebuild` for fast iterations
|
|
||||||
|
|
||||||
# Update
|
|
||||||
In order to update the flake inputs simply run
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd /etc/nixos
|
|
||||||
nix flake update
|
|
||||||
```
|
|
||||||
|
|
Loading…
Reference in a new issue