using zfs on workstation
This commit is contained in:
parent
1c7a3bba91
commit
a5410593d6
8
flake.lock
generated
8
flake.lock
generated
@ -544,11 +544,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1664780719,
|
||||
"narHash": "sha256-Oxe6la5dSqRfJogjtY4sRzJjDDqvroJIVkcGEOT87MA=",
|
||||
"owner": "nixos",
|
||||
"lastModified": 1664407130,
|
||||
"narHash": "sha256-m4vHHvI+Ybjpd3Rn0Zu851P0DfST3UkfMa7SWO7+/dY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fd54651f5ffb4a36e8463e0c327a78442b26cbe7",
|
||||
"rev": "c0b69f571968269f35561cc09c17c710d938389d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -103,7 +103,7 @@
|
||||
channelsConfig = { allowUnfree = true; };
|
||||
channels.unstable.input = nixpkgs;
|
||||
channels.unstable-zfs.input = nixpkgs;
|
||||
channels.unstable-zfs.patches = [ ./patches/zen-kernels.patch ];
|
||||
channels.unstable-zfs.patches = [ ./patches/update-zfs.patch ];
|
||||
|
||||
hostDefaults.system = "x86_64-linux";
|
||||
hostDefaults.channelName = "unstable";
|
||||
@ -115,7 +115,12 @@
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
in (genAttrs hostnames mkHost) // {
|
||||
# AMD-Workstation.channelName = "unstable-zfs";
|
||||
AMD-Workstation = {
|
||||
system = builtins.readFile (./machines + "/AMD-Workstation/system");
|
||||
modules = [ (import (./machines + "/AMD-Workstation")) { device = "AMD-Workstation"; } ];
|
||||
specialArgs = { inherit inputs; };
|
||||
channelName = "unstable-zfs";
|
||||
};
|
||||
};
|
||||
|
||||
outputsBuilder = channels: let
|
||||
|
@ -4,11 +4,11 @@
|
||||
set -e
|
||||
|
||||
CONFIG_FOLDER="$(dirname "$(pwd)")"
|
||||
DEVICE_NAME=Testing-VM
|
||||
MAX_JOBS=4
|
||||
SWAP_SIZE=16GiB
|
||||
DEVICE_NAME=AMD-Workstation
|
||||
MAX_JOBS=12
|
||||
SWAP_SIZE=48GiB
|
||||
USE_ECNRYPTION=false
|
||||
ZFS_ARC_MAX=1073741824
|
||||
ZFS_ARC_MAX=12884901888
|
||||
# ZFS_ARC_MAX=8589934592 # 8GiB
|
||||
# ZFS_ARC_MAX=4294967296 # Max ARC cache size. default = 4GiB
|
||||
ZFS_ASHIFT=12 # recommended=12 which 1<<12 (4096)
|
||||
@ -186,6 +186,8 @@ zfs create -o canmount=on -o mountpoint=/home rpool/user/home
|
||||
zfs create -o canmount=off -o mountpoint=/var rpool/nixos/var
|
||||
zfs create -o canmount=on rpool/nixos/var/lib
|
||||
zfs create -o canmount=on rpool/nixos/var/log
|
||||
zfs create -o canmount=noauto -o atime=off rpool/nixos/lxd
|
||||
zfs create -o canmount=on -o mountpoint=/var/lib/docker -o atime=off rpool/nixos/docker
|
||||
zfs create -o canmount=on -o mountpoint=/media/bittorrent -o atime=off -o recordsize=256K rpool/nixos/bittorrent
|
||||
zfs create -o canmount=on -o mountpoint=/media/libvirt -o atime=off -o recordsize=64K rpool/nixos/libvirt
|
||||
|
||||
@ -257,4 +259,4 @@ fi
|
||||
|
||||
pprint "Copy config to destination system"
|
||||
mkdir -p /mnt/home/alukard/nixos-config
|
||||
cp -aT $CONFIG_FOLDER /mnt/home/alukard/nixos-config
|
||||
cp -aT $CONFIG_FOLDER /mnt/home/alukard/nixos-config
|
||||
|
@ -19,7 +19,8 @@
|
||||
vendor = "amd";
|
||||
};
|
||||
bigScreen = true;
|
||||
ram = 16;
|
||||
ram = 48;
|
||||
fileSystem = "zfs";
|
||||
};
|
||||
deviceSpecific.isHost = true;
|
||||
deviceSpecific.isShared = false;
|
||||
|
@ -14,47 +14,38 @@
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=nixos" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
||||
{ device = "rpool/nixos/root";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/nix" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=nix" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
||||
{ device = "rpool/nixos/nix";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/home" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=home" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
||||
{ device = "rpool/user/home";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/var" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=var" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
||||
fileSystems."/var/lib" =
|
||||
{ device = "rpool/nixos/var/lib";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/var/log" =
|
||||
{ device = "rpool/nixos/var/log";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/media/bittorrent" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [
|
||||
"subvol=bittorrent" "nodatacow" "ssd"
|
||||
"uid=${toString config.users.users.alukard.uid}"
|
||||
"gid=${toString config.users.groups.users.gid}"
|
||||
];
|
||||
{ device = "rpool/nixos/bittorrent";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/media/libvirt" =
|
||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
||||
fsType = "btrfs";
|
||||
options = [
|
||||
"subvol=libvirt" "nodatacow" "ssd"
|
||||
"uid=${toString config.users.users.alukard.uid}"
|
||||
"gid=${toString config.users.groups.users.gid}"
|
||||
];
|
||||
{ device = "rpool/nixos/libvirt";
|
||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||
};
|
||||
|
||||
fileSystems."/boot" =
|
||||
@ -64,14 +55,24 @@
|
||||
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/dev/disk/by-partuuid/94696da5-f478-485d-8d92-c6f3093d8010";
|
||||
device = "/dev/disk/by-partuuid/7ffa34d9-862b-42ff-a649-da54f7b8fbf0";
|
||||
randomEncryption.enable = true;
|
||||
}
|
||||
];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp9s0.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
# high-resolution display
|
||||
hardware.video.hidpi.enable = lib.mkDefault true;
|
||||
networking.hostId = "0a9e92cd";
|
||||
boot.initrd.supportedFilesystems = [ "btrfs" ];
|
||||
boot.supportedFilesystems = [ "btrfs" ];
|
||||
networking.hostId = "a32bd2dc";
|
||||
boot.zfs.devNodes = "/dev/disk/by-partuuid/4c6b8cfb-9643-4ff7-961e-89b097328e0e";
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
boot.kernelParams = [ "zfs.zfs_arc_max=12884901888" "nohibernate" ];
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
};
|
||||
bigScreen = false;
|
||||
ram = 16;
|
||||
fileSystem = "btrfs";
|
||||
};
|
||||
deviceSpecific.isHost = false;
|
||||
deviceSpecific.isShared = false;
|
||||
|
@ -19,6 +19,7 @@ with types; {
|
||||
gpu = {
|
||||
vendor = mkOption { type = enum [ "amd" "nvidia" "intel" "vm" "other" ]; };
|
||||
};
|
||||
fileSystem = mkOption { type = enum [ "btrfs" "zfs" "other" ]; default = "other"; };
|
||||
ram = mkOption { type = int; };
|
||||
legacy = mkOption { type = bool; default = false; };
|
||||
bigScreen = mkOption {
|
||||
|
@ -7,7 +7,7 @@ with config.deviceSpecific; {
|
||||
hardware.bluetooth.enable = !isServer;
|
||||
services.blueman.enable = !isServer;
|
||||
|
||||
services.btrbk.instances = {
|
||||
services.btrbk.instances = lib.mkIf (devInfo.fileSystem == "btrfs") {
|
||||
home = {
|
||||
settings = {
|
||||
snapshot_preserve_min = "2d";
|
||||
@ -35,9 +35,10 @@ with config.deviceSpecific; {
|
||||
};
|
||||
|
||||
services.fstrim = {
|
||||
enable = isSSD;
|
||||
enable = isSSD && devInfo.fileSystem != "zfs";
|
||||
interval = "weekly";
|
||||
};
|
||||
services.zfs.trim.enable = isSSD && devInfo.fileSystem == "zfs";
|
||||
|
||||
services.gvfs.enable = !isServer;
|
||||
|
||||
|
@ -3,6 +3,12 @@ with config.deviceSpecific; {
|
||||
config = lib.mkIf enableVirtualisation {
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
storageDriver = if (devInfo.fileSystem == "zfs") then
|
||||
"zfs"
|
||||
else if (devInfo.fileSystem == "btrfs") then
|
||||
"btrfs"
|
||||
else
|
||||
"overlay2";
|
||||
};
|
||||
virtualisation.oci-containers.backend = "docker";
|
||||
|
||||
@ -17,6 +23,27 @@ with config.deviceSpecific; {
|
||||
onShutdown = "shutdown";
|
||||
};
|
||||
|
||||
virtualisation.lxd = {
|
||||
enable = true;
|
||||
zfsSupport = (devInfo.fileSystem == "zfs");
|
||||
recommendedSysctlSettings = true;
|
||||
};
|
||||
virtualisation.lxc = {
|
||||
enable = true;
|
||||
lxcfs.enable = true;
|
||||
systemConfig = ''
|
||||
lxc.lxcpath = /var/lib/lxd/containers
|
||||
${if devInfo.fileSystem == "zfs" then ''
|
||||
lxc.bdev.zfs.root = rpool/lxd
|
||||
'' else ""}
|
||||
'';
|
||||
defaultConfig = ''
|
||||
lxc.idmap = u 0 100000 65535
|
||||
lxc.idmap = g 0 100000 65535
|
||||
lxc.include = ${pkgs.lxcfs}/share/lxc/config/common.conf.d/00-lxcfs.conf
|
||||
'';
|
||||
};
|
||||
|
||||
virtualisation.spiceUSBRedirection.enable = true;
|
||||
|
||||
networking.nat = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user