From 557705fc88fc0405d8f79bb15cbf0679e168cf6c Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 7 Nov 2021 13:47:02 +0700 Subject: Migrate NixOS to tmpfs+btrfs --- nix/configuration.nix | 2 +- nix/devel.nix | 7 +++-- nix/games.nix | 2 -- nix/hardware-configuration.nix | 65 ++++++++++++++++++++++++++++++------------ 4 files changed, 53 insertions(+), 23 deletions(-) (limited to 'nix') diff --git a/nix/configuration.nix b/nix/configuration.nix index 37a0a83..bc0d12c 100644 --- a/nix/configuration.nix +++ b/nix/configuration.nix @@ -13,6 +13,7 @@ boot = { binfmt.emulatedSystems = [ "aarch64-linux" ]; + supportedFilesystems = [ "btrfs" ]; loader = { efi.canTouchEfiVariables = true; grub = { @@ -62,7 +63,6 @@ extraGroups = [ "dialout" "networkmanager" "video" "wheel" ]; }; - nix.autoOptimiseStore = true; environment.systemPackages = with pkgs; [ htop inotify-tools isync killall oathToolkit rsync stow tor unzip w3m wget mpv pavucontrol sent vimiv-qt yacreader youtube-dl diff --git a/nix/devel.nix b/nix/devel.nix index ebd4da7..11d0509 100644 --- a/nix/devel.nix +++ b/nix/devel.nix @@ -17,8 +17,11 @@ services = { # openssh.enable = true; ipfs = { - enable = false; - dataDir = "/data/IPFS"; + enable = true; + user = "sea"; + dataDir = "/home/sea/.ipfs"; + # autoMount = true; + localDiscovery = true; }; }; } diff --git a/nix/games.nix b/nix/games.nix index 8381cba..d441078 100644 --- a/nix/games.nix +++ b/nix/games.nix @@ -1,8 +1,6 @@ { config, pkgs, ... }: { - nixpkgs.config.allowUnfree = true; - environment.systemPackages = with pkgs; [ _20kly hedgewars globulation2 scorched3d teeworlds # strategy astromenace chromium-bsu # scrolling diff --git a/nix/hardware-configuration.nix b/nix/hardware-configuration.nix index 4ed5ba4..63c0801 100644 --- a/nix/hardware-configuration.nix +++ b/nix/hardware-configuration.nix @@ -6,38 +6,67 @@ { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ - "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" - ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; + boot = { + initrd = { + availableKernelModules = [ + "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" + "sd_mod" "rtsx_pci_sdmmc" + ]; + kernelModules = [ ]; + }; + kernelModules = [ "kvm-intel" ]; + extraModulePackages = [ ]; + }; + nix.readOnlyStore = false; fileSystems = { "/" = { - device = "/dev/disk/by-uuid/34058769-4280-4374-ad92-259554380a9e"; - fsType = "ext4"; + device = "none"; + fsType = "tmpfs"; }; "/boot" = { - device = "/dev/disk/by-uuid/8EB8-6EDD"; + device = "/dev/disk/by-uuid/B283-B76E"; fsType = "vfat"; }; + "/nix" = { + device = "/dev/disk/by-uuid/c334d115-eda9-4470-8c28-b01c4628865b"; + fsType = "btrfs"; + options = [ "subvol=nix" "compress=zstd" "noatime" ]; + }; + + "/etc" = { + device = "/dev/disk/by-uuid/c334d115-eda9-4470-8c28-b01c4628865b"; + fsType = "btrfs"; + options = [ "subvol=etc" "compress=zstd" "noatime" ]; + }; + + "/root" = { + device = "/dev/disk/by-uuid/c334d115-eda9-4470-8c28-b01c4628865b"; + fsType = "btrfs"; + options = [ "subvol=root" "compress=zstd" "noatime" ]; + }; + "/home" = { - device = "/dev/disk/by-uuid/69991f9d-8fec-4b32-8e3e-83d6a2c64257"; - fsType = "ext4"; + device = "/dev/disk/by-uuid/c334d115-eda9-4470-8c28-b01c4628865b"; + fsType = "btrfs"; + options = [ "subvol=home" "compress=zstd" ]; }; - # "/data" = { - # device = "/dev/disk/by-uuid/02594f2b-d681-49fc-8f4a-0616d44c8987"; - # fsType = "ext4"; - # }; + "/var/log" = { + device = "/dev/disk/by-uuid/c334d115-eda9-4470-8c28-b01c4628865b"; + fsType = "btrfs"; + options = [ "subvol=log" "compress=zstd" ]; + neededForBoot = true; + }; }; - # swapDevices = [ - # { device = "/dev/disk/by-uuid/6f45a147-3b44-4eb9-8ac3-2201e80cff5e"; } - # ]; + services.fstrim.enable = true; + + swapDevices = [ + { device = "/dev/disk/by-uuid/d3a6d2bc-19dd-4260-a6d4-89c04264dbd8"; } + ]; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; } -- cgit 1.4.1