|
1 | | -## 🚀 Installation |
2 | 1 |
|
3 | | -### Quick Start |
| 2 | +## Installation |
4 | 3 |
|
5 | | -1. **Clone the Repository** |
6 | | - ```bash |
7 | | - git clone https://github.com/sijanthapa171/NixOS.git |
8 | | - cd NixOS |
9 | | - ``` |
| 4 | +> [!Note] |
| 5 | +> Before proceeding with the installation, check these files and adjust them for your system: |
| 6 | +> |
| 7 | +> - `hosts/Default/variables.nix`: Contains host-specific variables. |
| 8 | +> - `hosts/Default/host-packages.nix`: Lists installed packages for the host. |
| 9 | +> - `hosts/Default/configuration.nix`: Module imports for the host and extra configuration. |
10 | 10 |
|
11 | | -2. **Review Configuration** |
12 | | - ```bash |
13 | | - # Edit flake.nix to set your preferences |
14 | | - nvim flake.nix |
15 | | - ``` |
| 11 | +<!-- You can install this configuration either on a running system or from the NixOS live installer. The minimal ISO is recommended and can be downloaded from the [official NixOS website](https://nixos.org/download/#nixos-iso). --> |
16 | 12 |
|
17 | | -3. **Installation Options** |
| 13 | +You can install on a running system or from the NixOS live installer. Get the minimal ISO from the [NixOS website](https://nixos.org/download/#nixos-iso). |
18 | 14 |
|
19 | | - For existing NixOS systems: |
20 | | - ```bash |
21 | | - ./install.sh |
22 | | - ``` |
| 15 | +### Installation Steps |
23 | 16 |
|
24 | | - For fresh installations: |
25 | | - ```bash |
26 | | - ./live-install.sh |
27 | | - ``` |
| 17 | +1. Clone the Repository: |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone https://github.com/sijanthapa171/NixOS.git ~/NixOS |
| 21 | +``` |
| 22 | + |
| 23 | +<!-- 2. Navigate to the Directory: --> |
| 24 | + |
| 25 | +2. Change Directory: |
| 26 | + |
| 27 | +```bash |
| 28 | +cd ~/NixOS |
| 29 | +``` |
| 30 | + |
| 31 | +3. Run the Installer: |
| 32 | + |
| 33 | +```bash |
| 34 | +./install.sh |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- The script handles host setup, username configuration, and automatically generates `hardware-configuration.nix` based on your hardware. --> |
28 | 38 |
|
29 | | -4. **Post-Installation** |
30 | | - ```bash |
31 | | - # Rebuild and switch to the new configuration |
32 | | - sysup |
| 39 | +The install and rebuild scripts automate the setup process, including hosts, username, and applying the configuration. It also automatically generates the hardware-configuration.nix file based on your system's detected hardware, eliminating the need to manually generate it. |
| 40 | + |
| 41 | +## Usage |
| 42 | + |
| 43 | +### Managing Hosts |
| 44 | + |
| 45 | +**Method 1: Automatic** - run the installer again to select or create another host: |
| 46 | + |
| 47 | +```bash |
| 48 | +./install.sh |
| 49 | +``` |
| 50 | + |
| 51 | +**Method 2: Manual:** |
| 52 | + |
| 53 | +1. Copy `hosts/Default` to a new directory (e.g., `hosts/Laptop`) |
| 54 | +2. Edit the new host's `variables.nix` and `host-packages.nix` |
| 55 | +3. Add the host to `flake.nix`: |
| 56 | + |
| 57 | + ```nix |
| 58 | + nixosConfigurations = { |
| 59 | + Default = mkHost "Default"; |
| 60 | + Laptop = mkHost "Laptop"; |
| 61 | + }; |
33 | 62 | ``` |
34 | | - |
| 63 | + |
| 64 | +<!-- 4. Rebuild with the new hostname (see below) --> |
| 65 | + |
| 66 | +4. Rebuild with the new hostname using either `nixos-rebuild` or `nh` (see [Rebuilding](#rebuilding) below). Once rebuilt, any rebuilding method can be used, as the host name will be implicitly recognised. |
| 67 | + |
| 68 | +### Rebuilding |
| 69 | + |
| 70 | +Apply configuration changes: |
| 71 | + |
| 72 | +- **Keyboard shortcut:** `Super + U` |
| 73 | +- **rebuild script:** `rebuild` |
| 74 | +- **nixos-rebuild:** `sudo nixos-rebuild switch --flake ~/NixOS#<HOST>` |
| 75 | +- **nh:** `nh os switch --hostname <HOST>` |
| 76 | + |
| 77 | +Replace `<HOST>` with the name of your host (e.g., `Laptop`). |
| 78 | + |
| 79 | +### Rollbacks |
| 80 | + |
| 81 | +List generations: |
| 82 | + |
| 83 | +```bash |
| 84 | +list-gens |
| 85 | +``` |
| 86 | + |
| 87 | +Rollback to generation N: |
| 88 | + |
| 89 | +```bash |
| 90 | +rollback N |
| 91 | +``` |
| 92 | + |
| 93 | +Replace `N` with the generation number (e.g., `69`). |
| 94 | + |
| 95 | +### Keybindings |
| 96 | + |
| 97 | +View all keybindings with `Super + ?` or `Super + Ctrl + K`. |
| 98 | + |
| 99 | +## Development Shells |
| 100 | + |
| 101 | +Pre-configured dev shells for various languages are included. |
| 102 | + |
| 103 | +Initialize a project from a template: |
| 104 | + |
| 105 | +```bash |
| 106 | +nix flake init -t ~/NixOS#<TEMPLATE_NAME> |
| 107 | +``` |
| 108 | + |
| 109 | +Create a new project directory: |
| 110 | + |
| 111 | +```bash |
| 112 | +nix flake new -t ~/NixOS#<TEMPLATE_NAME> <PROJECT_NAME> |
| 113 | +``` |
| 114 | + |
| 115 | +Templates are defined in `dev-shells/default.nix` (python, node, etc.). |
| 116 | + |
| 117 | +Enter the shell: |
| 118 | + |
| 119 | +```bash |
| 120 | +cd <PROJECT_NAME> |
| 121 | +nix develop |
| 122 | +``` |
| 123 | + |
| 124 | +If you're using direnv, the shell activates automatically. |
| 125 | + |
| 126 | +<!-- ## Hosts |
| 127 | +
|
| 128 | +| | Hostname | Board | CPU | RAM | GPU | Purpose | |
| 129 | +| --- | ---------- | ----------------- | ------------------ | ---- | ------------------------- | ---------------------------------------------------------------------------------- | |
| 130 | +| 🖥️ | `nix-wsl` | MSI MAG B760 Tomahawk | Intel I7-13700F | 32GB | RTX 4070 | Triple-monitor desktop running Windows Subsystem for Linux. | --> |
0 commit comments