Skip to content

pmeiyu/nixos-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix Configuration

Install NixOS

Partition Disk

cfdisk /dev/sda
/dev/sda1/boot/efiFAT255MB
/dev/sda2/Btrfs20GB
mkfs.fat /dev/sda1
cryptsetup luksFormat /dev/sda2
cryptsetup open /dev/sda2 root
mkfs.btrfs -L root /dev/mapper/root
mount /dev/mapper/root /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot

Create swap file

Create swap file on Btrfs

truncate -s 0 /mnt/var/swapfile
chattr +C /mnt/var/swapfile
fallocate -l 4G /mnt/var/swapfile
chmod 600 /mnt/var/swapfile
mkswap /mnt/var/swapfile

NixOS Configuration

Generate hardware configuration.

nixos-generate-config --root /mnt

Move hardware-configuration.nix.

mv /mnt/etc/nixos/hardware-configuration.nix /next/to/configuration.nix
ln -sf /path/to/configuration.nix /mnt/etc/nixos

Execute Installation

nixos-install

Reboot

Reboot into the new NixOS system.

Install NixOS using nixos-lustrate

Install Nix

sh <(curl -L https://nixos.org/nix/install) --daemon

Generate NixOS config

# install nixos-generate-config
nix-env -iE "_: with import <nixpkgs/nixos> { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter ]"

nixos-generate-config

Install the system

nix-env -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' -I nixos-config=/etc/nixos/configuration.nix -iA system

Switch to the new system

touch /etc/NIXOS
echo etc/nixos           > /etc/NIXOS_LUSTRATE
echo var/swapfile       >> /etc/NIXOS_LUSTRATE

echo gnu                >> /etc/NIXOS_LUSTRATE
echo etc/guix           >> /etc/NIXOS_LUSTRATE
echo var/guix           >> /etc/NIXOS_LUSTRATE

mv -v /boot /boot.bak
/nix/var/nix/profiles/system/bin/switch-to-configuration boot

Nix Channel

Enable unstable channels

nix-channel --add https://nixos.org/channels/nixos-unstable nixos
nix-channel --update

Generate Signing Key

nix-store --generate-binary-cache-key $hostname /etc/nix/signing-key.sec /etc/nix/signing-key.pub

Releases

No releases published

Packages

No packages published