NixOS: Difference between revisions

Created page with " == Install == The graphical installer is trivial. However, the minimal ISO doesn't handle partitioning for you. === Partitioning and Formatting === ```bash # Create a new GPT partition table parted /dev/sda -- mklabel gpt # Create the EFI Boot partition parted /dev/sda -- mkpart ESP fat32 1MB 512MB parted /dev/sda -- set 1 esp on # Create the Root partition (ext4) parted /dev/sda -- mkpart primary ext4 512MB 100% # Format partitions mkfs.fat -F 32 -n boot /dev/sda1..."
 
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:


=== Partitioning and Formatting ===
=== Partitioning and Formatting ===
```bash
<syntaxhighlight lang="bash>
# Create a new GPT partition table
# Create a new GPT partition table
parted /dev/sda -- mklabel gpt
parted /dev/sda -- mklabel gpt
Line 31: Line 31:
mkswap /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
swapon /mnt/swapfile
```
</syntaxhighlight>


=== Generate a config and install===
=== Generate a config and install===
```
<syntaxhighlight lang="bash">
nixos-generate-config --root /mnt
nixos-generate-config --root /mnt
# Edit the config to your desire
# Edit the config to your desire
Line 40: Line 40:


nixos-install
nixos-install
```
</syntaxhighlight>
 
Example config:
<pre>
{ config, pkgs, ... }:
 
{
  imports = [ ./hardware-configuration.nix ];
 
  # Bootloader settings
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
 
  # 1. ZFS Support for additional drives
  boot.supportedFilesystems = [ "zfs" ];
  networking.hostId = "8425e349"; # Required for ZFS; use 8 random hex digits
 
  # 2. Static IP Configuration
  # Replace 'eth0' with your actual interface name found via 'ip link'
  networking.useDHCP = false;
  networking.interfaces.eth0.ipv4.addresses = [{
    address = "192.168.1.50";
    prefixLength = 24;
  }];
  networking.defaultGateway = "192.168.1.1";
  networking.nameservers = [ "1.1.1.1" "8.8.8.8" ];
 
  # 3. Swapfile declaration
  swapDevices = [ {
    device = "/swapfile";
    size = 4096; # In MB
  } ];
 
  # Standard System Settings
  system.stateVersion = "24.11"; # Check the current version on the ISO
}
</pre>
 
=== Install on VPS ===
For a VPS, first install Ubuntu or Debian.
Then run https://github.com/elitak/nixos-infect.


== Resources==
== Resources==
* https://nixos.org/manual/nixos/stable/
* https://nixos.org/manual/nixos/stable/
* https://wiki.nixos.org/wiki/NixOS_Wiki
* https://wiki.nixos.org/wiki/NixOS_Wiki