From 5217f6d2229e246f0df4d47c1b4046559160c14f Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Wed, 24 Apr 2024 14:26:24 +0500 Subject: [PATCH] astora: ext4 -> btrfs --- devShells/bonfire.nix | 5 +- nixosConfigurations/astora/README.md | 72 +++++++++++++++++++++++++ nixosConfigurations/astora/default.nix | 13 +++-- nixosConfigurations/astora/hardware.nix | 43 +++++++++++---- nixosConfigurations/astora/users.nix | 37 +++++++------ nixosConfigurations/catarina/README.md | 5 +- nixosModules/bonfire.nix | 16 ++++-- nixosModules/papermc/default.nix | 2 +- 8 files changed, 158 insertions(+), 35 deletions(-) create mode 100644 nixosConfigurations/astora/README.md diff --git a/devShells/bonfire.nix b/devShells/bonfire.nix index 2a2a804..cba3b1b 100644 --- a/devShells/bonfire.nix +++ b/devShells/bonfire.nix @@ -1,8 +1,11 @@ { crane-lib, pkgs, ... }: crane-lib.devShell { packages = with pkgs; [ - # nil + nil jq cachix + nodejs + python3 + marksman ]; } diff --git a/nixosConfigurations/astora/README.md b/nixosConfigurations/astora/README.md new file mode 100644 index 0000000..4526538 --- /dev/null +++ b/nixosConfigurations/astora/README.md @@ -0,0 +1,72 @@ +# astora + +## Specs + +| Type | Description | +|---|---| +| Case | MSI MPG Sekira 100R | +| Motherboard | MSI MEG X570 Unify | +| CPU | AMD Ryzen 9 3900X, 12-core, 24-thread | +| Cooler | MSI MAG Coreliquid 240R V2 | +| RAM | Kingston Fury Renegade, 2x16GB | +| Power supply | DeepCool PQ1000M, 1000W | +| GPU | MSI GeForce RTX 3060 Ventus 2X, 12GB | +| NVMe M.2 | Samsung 980, 250GB | +| SSD | Samsung 860 EVO, 500GB | +| HDD | Seagate SkyHawk, 8TB | + +## Disk management + +* Samsung 980 + +```bash +parted /dev/nvme0n1 -- mktable gpt +parted /dev/nvme0n1 -- mkpart primary fat32 0% 4GB +parted /dev/nvme0n1 -- set 1 boot on +parted /dev/nvme0n1 -- set 1 no_automount on +parted /dev/nvme0n1 -- mkpart primary btrfs 4GB 100% + +mkfs.fat -F 32 /dev/nvme0n1p1 +fatlabel /dev/nvme0n1p1 boot +mkfs.btrfs /dev/nvme0n1p2 +btrfs filesystem label /dev/nvme0n1p2 nixos + +mkdir -p /mnt +mount /dev/nvme0n1p2 /mnt +btrfs subvolume create /mnt/root +btrfs subvolume create /mnt/nix +btrfs subvolume create /mnt/home +btrfs subvolume create /mnt/swap +umount /mnt + +mount -o compress=zstd,subvol=root /dev/nvme0n1p2 /mnt +mkdir /mnt/{boot,nix,home,swap} +mount /dev/nvme0n1p1 /mnt/boot +mount -o compress=zstd,noatime,subvol=nix /dev/nvme0n1p2 /mnt/nix +mount -o compress=zstd,subvol=home /dev/nvme0n1p2 /mnt/home +mount -o noatime,subvol=swap /dev/nvme0n1p2 /mnt/swap +btrfs filesystem mkswapfile --size 16g --uuid clear /mnt/swap/swapfile +# umount /mnt +``` + +* Samsung 860 + +```bash +parted /dev/sda -- mktable gpt +parted /dev/sda -- mkpart primary btrfs 0% 100% + +mkfs.btrfs /dev/sda1 +btrfs filesystem label /dev/sda1 nixos + +mkdir -p /mnt +mount /dev/sda1 /mnt +btrfs subvolume create /mnt/steam-library +btrfs subvolume create /mnt/lutris +umount /mnt + +mount -o compress=zstd,subvol=root /dev/sda1 /media +mkdir /media/{steam-library,lutris} +mount -o compress=zstd,subvol=steam-library /dev/sda1 /media/steam-library +mount -o compress=zstd,subvol=lutris /dev/sda1 /media/lutris +# umount /media +``` diff --git a/nixosConfigurations/astora/default.nix b/nixosConfigurations/astora/default.nix index 4c99425..9153ce3 100644 --- a/nixosConfigurations/astora/default.nix +++ b/nixosConfigurations/astora/default.nix @@ -8,8 +8,8 @@ nix = { settings = { experimental-features = [ "nix-command" "flakes" "repl-flake" ]; - trusted-users = [ "nafaryus" ]; - allowed-users = [ "nafaryus" ]; + trusted-users = [ "l-nafaryus" ]; + allowed-users = [ "l-nafaryus" ]; substituters = [ "https://nix-community.cachix.org" ]; trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; auto-optimise-store = true; @@ -83,10 +83,17 @@ services.blueman.enable = true; + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ "/" ]; + }; + # Packages environment.systemPackages = with pkgs; [ wget + parted ntfs3g sshfs exfat @@ -129,7 +136,7 @@ Host astora HostName 192.168.156.101 Port 22 - User nafaryus + User l-nafaryus Host catarina HostName 192.168.156.102 diff --git a/nixosConfigurations/astora/hardware.nix b/nixosConfigurations/astora/hardware.nix index e951820..a17a7aa 100644 --- a/nixosConfigurations/astora/hardware.nix +++ b/nixosConfigurations/astora/hardware.nix @@ -82,27 +82,50 @@ # Filesystem fileSystems = { "/" = { - device = "/dev/disk/by-uuid/77e1fc4b-31af-46e8-8b9c-907e4113b31b"; - fsType = "ext4"; + device = "/dev/disk/by-label/nixos"; + fsType = "btrfs"; + options = [ "subvol=root" "compress=zstd" ]; }; "/boot" = { - device = "/dev/disk/by-uuid/92C6-2268"; + device = "/dev/disk/by-label/boot"; fsType = "vfat"; }; - "/mnt/ext" = { - device = "/dev/disk/by-uuid/4b47d83c-42da-4e78-b279-7726dfbdfde7"; - fsType = "ext4"; + "/nix" = { + device = "/dev/disk/by-label/nixos"; + fsType = "btrfs"; + options = [ "subvol=nix" "compress=zstd" "noatime" ]; }; - "/mnt/ext2" = { - device = "/dev/disk/by-uuid/8f8f6576-5608-4474-acb5-409c59dff696"; - fsType = "ext4"; + "/home" = { + device = "/dev/disk/by-label/nixos"; + fsType = "btrfs"; + options = [ "subvol=home" "compress=zstd" ]; + }; + + "/swap" = { + device = "/dev/disk/by-label/nixos"; + fsType = "btrfs"; + options = [ "subvol=swap" "noatime" ]; + }; + + "/media/steam-library" = { + device = "/dev/disk/by-label/siegward"; + fsType = "btrfs"; + options = [ "subvol=steam-library" "compress=zstd" ]; + }; + + "/media/lutris" = { + device = "/dev/disk/by-label/siegward"; + fsType = "btrfs"; + options = [ "subvol=lutris" "compress=zstd" ]; }; }; - swapDevices = [ ]; + swapDevices = [ + { device = "/swap/swapfile"; } + ]; services.fstrim.enable = true; diff --git a/nixosConfigurations/astora/users.nix b/nixosConfigurations/astora/users.nix index 22bdd24..04b3f10 100644 --- a/nixosConfigurations/astora/users.nix +++ b/nixosConfigurations/astora/users.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, inputs, self, ... }: { # Users - users.users.nafaryus = { + users.users.l-nafaryus = { isNormalUser = true; description = "L-Nafaryus"; extraGroups = [ "networkmanager" "wheel" "audio" ]; @@ -16,10 +16,10 @@ bonfire.enable = true; - home-manager.users.nafaryus = { pkgs, ... }: { + home-manager.users.l-nafaryus = { pkgs, ... }: { home.stateVersion = "23.11"; - home.username = "nafaryus"; - home.homeDirectory = "/home/nafaryus"; + home.username = "l-nafaryus"; + home.homeDirectory = "/home/l-nafaryus"; home.packages = with pkgs; [ gnupg git @@ -62,7 +62,7 @@ olive-editor openshot-qt musescore - # soundux # unmaintained + # soundux # unmaintained losslesscut-bin yt-dlp ffmpeg @@ -86,8 +86,6 @@ onlyoffice-bin - anydesk - jdk self.packages.${pkgs.system}.ultimmc @@ -96,15 +94,24 @@ steamtinkerlaunch ]; - xdg.enable = true; - xdg.mime.enable = true; + xdg = { + enable = true; + mime.enable = true; + }; - home.file.".config/gnupg/gpg-agent.conf".text = '' - default-cache-ttl 3600 - pinentry-program ${pkgs.pinentry.gtk2}/bin/pinentry - ''; - home.file.".config/git/config".source = "${config.bonfire.configDir}/git/config"; - home.file.".config/nvim" = { source = "${config.bonfire.configDir}/nvim"; recursive = true; }; + home.file = { + ".config/gnupg/gpg-agent.conf".text = '' + default-cache-ttl 3600 + pinentry-program ${pkgs.pinentry.gtk2}/bin/pinentry + ''; + + ".config/git/config".source = "${config.bonfire.configDir}/git/config"; + + ".config/nvim" = { + source = "${config.bonfire.configDir}/nvim"; + recursive = true; + }; + }; }; programs.gnupg.agent = { diff --git a/nixosConfigurations/catarina/README.md b/nixosConfigurations/catarina/README.md index 1425e9f..1f03908 100644 --- a/nixosConfigurations/catarina/README.md +++ b/nixosConfigurations/catarina/README.md @@ -1,6 +1,7 @@ # catarina -## Partitions +## Disk management + ```sh mkfs.fat -F 32 /dev/sda1 fatlabel /dev/sda1 boot @@ -25,7 +26,7 @@ mount -o compress=zstd,subvol=home /dev/sda2 /mnt/home mount -o compress=zstd,subvol=persist /dev/sda2 /mnt/persist mount -o noatime,subvol=swap /dev/sda2 /mnt/swap -btrfs filesystem mkswapfile --size 16g --uuid clear /swap/swapfile +btrfs filesystem mkswapfile --size 16g --uuid clear /mnt/swap/swapfile mkdir -p /media/{storage,btrbk-backups,btrbk-snapshots} ``` diff --git a/nixosModules/bonfire.nix b/nixosModules/bonfire.nix index d5f4a33..85fc129 100644 --- a/nixosModules/bonfire.nix +++ b/nixosModules/bonfire.nix @@ -4,9 +4,19 @@ let cfg = config.bonfire; in { options= { bonfire = { - enable = mkOption { type = types.bool; default = false; }; - home = mkOption { type = types.path; default = ../.; }; - configDir = mkOption { type = types.path; default = "${config.bonfire.home}/config"; }; + enable = mkEnableOption "Enables the Bonfire module"; + + home = mkOption { + type = types.path; + default = ../.; + description = "Bonfire root flake directory"; + }; + + configDir = mkOption { + type = types.path; + default = "${config.bonfire.home}/config"; + description = "Path to directory with static configuration files"; + }; }; }; diff --git a/nixosModules/papermc/default.nix b/nixosModules/papermc/default.nix index be4c69a..f2e1e37 100644 --- a/nixosModules/papermc/default.nix +++ b/nixosModules/papermc/default.nix @@ -52,7 +52,7 @@ in { options.services.papermc = { enable = mkEnableOption "Enables the PaperMC service."; - openFirewall = mkOption rec { + openFirewall = mkOption { type = types.bool; default = false; description = lib.mdDoc ''