Skip to content

Instantly share code, notes, and snippets.

@AriRexouium
Last active January 28, 2024 18:29
Show Gist options
  • Save AriRexouium/3eb9ca097c72d086dec19382268af0b9 to your computer and use it in GitHub Desktop.
Save AriRexouium/3eb9ca097c72d086dec19382268af0b9 to your computer and use it in GitHub Desktop.
NixOS Server Setup

NixOS Setup


Desktop Setup

Login

sudo -i

curl https://gist.githubusercontent.com/AriRexouium/3eb9ca097c72d086dec19382268af0b9/raw/disko-client-config.nix -o /tmp/disko-config.nix
nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --mode disko /tmp/disko-config.nix

nixos-generate-config --root /mnt

configuration.nix

fileSystems = {
  "/".options = [ "compress=zstd" ];
  "/home".options = [ "compress=zstd" ];
  "/nix".options = [ "compress=zstd" "noatime" ];
  "/.swap".options = [ "compress=zstd" "noatime" ];
};

swapDevices = [
  { device = "/.swap/swapfile"; }
];

Install

nixos-install

Server Setup

Login

sudo -i

curl https://gist.githubusercontent.com/AriRexouium/3eb9ca097c72d086dec19382268af0b9/raw/disko-server-config.nix -o /tmp/disko-config.nix
nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --mode disko /tmp/disko-config.nix

nixos-generate-config --root /mnt

configuration.nix

fileSystems = {
  "/".options = [ "compress=zstd" ];
  "/root".options = [ "compress=zstd" ];
  "/home".options = [ "compress=zstd" ];
  "/var/log".options = [ "compress=zstd" ];
  "/nix".options = [ "compress=zstd" "noatime" ];
  "/.swap".options = [ "compress=zstd" "noatime" ];
};

swapDevices = [
  { device = "/.swap/swapfile"; }
];

Install

nixos-install
{
disko.devices = {
disk = {
sda = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
ESP = {
label = "boot";
name = "ESP";
type = "EF00";
size = "512M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
luks = {
label = "luks";
size = "100%";
content = {
name = "crypted";
type = "luks";
# settings = {
# crypttabExtraOpts = [ "--tpm2-device=auto" "--tpm2-pcrs=7" ];
# };
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"@" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" ];
};
"@home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@swap" = {
mountpoint = "/.swap";
mountOptions = [ "noatime" ];
swap.swapfile.size = "16G";
};
};
};
};
};
};
};
};
};
};
}
{
disko.devices = {
disk = {
vda = {
type = "disk";
device = "/dev/vda";
content = {
type = "gpt";
partitions = {
BOOT = { # comment this out on EFI systems
type = "EF02";
size = "1M";
};
ESP = {
type = "EF00";
size = "512M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
ROOT = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"@" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" ];
};
"@root" = {
mountpoint = "/root";
mountOptions = [ "compress=zstd" ];
};
"@home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" ];
};
"@var@log" = {
mountpoint = "/var/log";
mountOptions = [ "compress=zstd" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@swap" = {
mountpoint = "/.swap";
mountOptions = [ "compress=zstd" "noatime" ];
swap.swapfile.size = "2G";
};
};
};
};
};
};
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment