From d98dd03fef91137f32fb1adb3b0bffa82d1b8f89 Mon Sep 17 00:00:00 2001 From: Jan Grosser Date: Sat, 25 May 2024 22:55:10 +0200 Subject: [PATCH] Updated README --- README.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 859c371..4384cd4 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@ ## Description My NixOS configuration repository -## Install a new host +## Install a New Host 1. Install NixOS with graphical ISO image (e.g. GNOME). During the installation the desktop environment can be choosen. 2. Reboot into NixOS 3. Edit `/etc/nixos/configuration.nix` with sudoedit - a) Change hostname - b) Enable flakes. Add the following lines: + - Change hostname + - Enable flakes. Add the following lines: ``` # Enable flakes nix.settings.experimental-features = [ "nix-command" "flakes" ]; ``` - c) Install tmux, neovim, git by adding them to `environment.systemPackages = with pkgs; [` + - Install tmux, neovim, git by adding them to `environment.systemPackages = with pkgs; [` 4. Apply changes: `sudo nixos-rebuild switch` and reboot 5. Clone NixOS config repository to /home/$USER/nixos: ``` @@ -20,9 +20,25 @@ cd git clone https://git.plueschbit.de/jan/nixos-conf ~/nixos ``` 6. Add the new host to repository - a) Create ~/nixos/hosts/$HOSTNAME - b) `cp /etc/nixos/*.nix $HOSTNAME/.` - c) Edit `~/nixos/flake.nix` and add section for new host - d) Stage new config files: `git add flake.nix hosts/$HOSTNAME/*`. Otherwise, nixos-rebuild will refuse to work with the files. + - Create ~/nixos/hosts/$HOSTNAME + - `cp /etc/nixos/*.nix $HOSTNAME/.` + - Edit `~/nixos/flake.nix` and add section for new host + - Stage new config files: `git add flake.nix hosts/$HOSTNAME/*`. Otherwise, nixos-rebuild will refuse to work with the files. 8. Apply config: `sudo nixos-rebuild switch --flake ~/nixos/#` +## Update Packages on a Host +Update of the file `flake.nix`: +``` +sudo nix flake update +``` +Then, perform nixos rebuild: +``` +sudo nixos-rebuild switch --flake ~/nixos/# +``` + +## Garbage Collection +Keep e.g. the last five generations and perform garbage collection: +``` +sudo nix-env --delete-generations +5 +sudo nix-store --gc +```