default.nix (1304B) - Raw
1 { 2 config, 3 lib, 4 pkgs, 5 ... 6 }: 7 let 8 cfg = config.mj.profiles.btrfs; 9 in 10 { 11 options.mj.profiles.btrfs = with lib.types; { 12 disk = lib.mkOption { 13 type = nullOr str; 14 default = null; 15 example = "/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_2TB_..."; 16 description = "Disk device path for LUKS+BTRFS layout (part1=boot, part2=swap, part3=luks root)"; 17 }; 18 luksExtraConfig = lib.mkOption { 19 type = attrs; 20 default = { }; 21 description = "Extra config merged into boot.initrd.luks.devices.luksroot"; 22 }; 23 }; 24 25 config = lib.mkMerge [ 26 { 27 boot.supportedFilesystems = [ "btrfs" ]; 28 environment.systemPackages = [ pkgs.btrfs-auto-snapshot ]; 29 } 30 31 (lib.mkIf (cfg.disk != null) { 32 boot.initrd.luks.devices.luksroot = { 33 device = "${cfg.disk}-part3"; 34 allowDiscards = true; 35 } 36 // cfg.luksExtraConfig; 37 38 fileSystems = { 39 "/" = { 40 device = "/dev/mapper/luksroot"; 41 fsType = "btrfs"; 42 options = [ "compress=zstd" ]; 43 }; 44 "/boot" = { 45 device = "${cfg.disk}-part1"; 46 fsType = "vfat"; 47 }; 48 }; 49 50 swapDevices = [ 51 { 52 device = "${cfg.disk}-part2"; 53 randomEncryption.enable = true; 54 } 55 ]; 56 }) 57 ]; 58 }