Skip to content

Instantly share code, notes, and snippets.

@seanjensengrey
Last active February 16, 2024 16:18
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seanjensengrey/b69ffddbc668e127b1946d4c147e0bcb to your computer and use it in GitHub Desktop.
Save seanjensengrey/b69ffddbc668e127b1946d4c147e0bcb to your computer and use it in GitHub Desktop.
Nixos with raid-0 root partition using mdadm
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
# Download graphical ISO, http://nixos.org/nixos/download.html
# if you want to do an install over an SSH connection
# $ systemctl start sshd.service
# $ useradd remoteinstaller
# $ passwd remoteinstaller
# $ passwd root
# $ ssh remoteinstaller@<nix live cd host>
# $ su root
## create /dev/sda1
# fdisk n p 1 <return> +50M
## create /dev/sda2 /dev/sdb2 (do this on both disks)
# fdisk <disk> n p 2 <return> <return>
# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda2 /dev/sdb2
# mkfs.ext4 -L boot /dev/sda1
# mkfs.ext4 -L nix /dev/md0
# mount -L nix /mnt
# nixos-generate-config --root /mnt
## edit /mnt/nixos/configuration.nix to be like below
# $ nano /mnt/etc/nixos/configuration.nix
# then
# ** remove filesystem entry in **
# ** remove filesystem entry in **
# vim /mnt/etc/nixos/hardware-configuration.nix
# else it will conflict with configuration.nix during `nixos-install`
# $ nixos-install
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the GRUB 2 boot loader.
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
# Define on which hard drive you want to install Grub.
boot.loader.grub.device = "/dev/sda";
# networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Select internationalisation properties.
# i18n = {
# consoleFont = "Lat2-Terminus16";
# consoleKeyMap = "us";
# defaultLocale = "en_US.UTF-8";
# };
# Set your time zone.
# time.timeZone = "Europe/Amsterdam";
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
# environment.systemPackages = with pkgs; [
# wget
# ];
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.openssh.permitRootLogin = "yes";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable the X11 windowing system.
# services.xserver.enable = true;
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
# Enable the KDE Desktop Environment.
# services.xserver.displayManager.kdm.enable = true;
# services.xserver.desktopManager.kde4.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
# users.extraUsers.guest = {
# isNormalUser = true;
# uid = 1000;
# };
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "16.03";
fileSystems = {
"/" = {
device = "/dev/disk/by-label/nix";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "ext4";
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment