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": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1664780719,
|
"lastModified": 1664407130,
|
||||||
"narHash": "sha256-Oxe6la5dSqRfJogjtY4sRzJjDDqvroJIVkcGEOT87MA=",
|
"narHash": "sha256-m4vHHvI+Ybjpd3Rn0Zu851P0DfST3UkfMa7SWO7+/dY=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fd54651f5ffb4a36e8463e0c327a78442b26cbe7",
|
"rev": "c0b69f571968269f35561cc09c17c710d938389d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
channelsConfig = { allowUnfree = true; };
|
channelsConfig = { allowUnfree = true; };
|
||||||
channels.unstable.input = nixpkgs;
|
channels.unstable.input = nixpkgs;
|
||||||
channels.unstable-zfs.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.system = "x86_64-linux";
|
||||||
hostDefaults.channelName = "unstable";
|
hostDefaults.channelName = "unstable";
|
||||||
@ -115,7 +115,12 @@
|
|||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
};
|
};
|
||||||
in (genAttrs hostnames mkHost) // {
|
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
|
outputsBuilder = channels: let
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
CONFIG_FOLDER="$(dirname "$(pwd)")"
|
CONFIG_FOLDER="$(dirname "$(pwd)")"
|
||||||
DEVICE_NAME=Testing-VM
|
DEVICE_NAME=AMD-Workstation
|
||||||
MAX_JOBS=4
|
MAX_JOBS=12
|
||||||
SWAP_SIZE=16GiB
|
SWAP_SIZE=48GiB
|
||||||
USE_ECNRYPTION=false
|
USE_ECNRYPTION=false
|
||||||
ZFS_ARC_MAX=1073741824
|
ZFS_ARC_MAX=12884901888
|
||||||
# ZFS_ARC_MAX=8589934592 # 8GiB
|
# ZFS_ARC_MAX=8589934592 # 8GiB
|
||||||
# ZFS_ARC_MAX=4294967296 # Max ARC cache size. default = 4GiB
|
# ZFS_ARC_MAX=4294967296 # Max ARC cache size. default = 4GiB
|
||||||
ZFS_ASHIFT=12 # recommended=12 which 1<<12 (4096)
|
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=off -o mountpoint=/var rpool/nixos/var
|
||||||
zfs create -o canmount=on rpool/nixos/var/lib
|
zfs create -o canmount=on rpool/nixos/var/lib
|
||||||
zfs create -o canmount=on rpool/nixos/var/log
|
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/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
|
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"
|
pprint "Copy config to destination system"
|
||||||
mkdir -p /mnt/home/alukard/nixos-config
|
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";
|
vendor = "amd";
|
||||||
};
|
};
|
||||||
bigScreen = true;
|
bigScreen = true;
|
||||||
ram = 16;
|
ram = 48;
|
||||||
|
fileSystem = "zfs";
|
||||||
};
|
};
|
||||||
deviceSpecific.isHost = true;
|
deviceSpecific.isHost = true;
|
||||||
deviceSpecific.isShared = false;
|
deviceSpecific.isShared = false;
|
||||||
|
@ -14,47 +14,38 @@
|
|||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/nixos/root";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [ "subvol=nixos" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/nix" =
|
fileSystems."/nix" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/nixos/nix";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [ "subvol=nix" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/home" =
|
fileSystems."/home" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/user/home";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [ "subvol=home" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/var" =
|
fileSystems."/var/lib" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/nixos/var/lib";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [ "subvol=var" "compress-force=zstd" "noatime" "autodefrag" "ssd" ];
|
};
|
||||||
|
|
||||||
|
fileSystems."/var/log" =
|
||||||
|
{ device = "rpool/nixos/var/log";
|
||||||
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/media/bittorrent" =
|
fileSystems."/media/bittorrent" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/nixos/bittorrent";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [
|
|
||||||
"subvol=bittorrent" "nodatacow" "ssd"
|
|
||||||
"uid=${toString config.users.users.alukard.uid}"
|
|
||||||
"gid=${toString config.users.groups.users.gid}"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/media/libvirt" =
|
fileSystems."/media/libvirt" =
|
||||||
{ device = "/dev/disk/by-partuuid/07fbbbc3-169c-463c-bd53-28dcedb8634d";
|
{ device = "rpool/nixos/libvirt";
|
||||||
fsType = "btrfs";
|
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
||||||
options = [
|
|
||||||
"subvol=libvirt" "nodatacow" "ssd"
|
|
||||||
"uid=${toString config.users.users.alukard.uid}"
|
|
||||||
"gid=${toString config.users.groups.users.gid}"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
@ -64,14 +55,24 @@
|
|||||||
|
|
||||||
swapDevices = [
|
swapDevices = [
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-partuuid/94696da5-f478-485d-8d92-c6f3093d8010";
|
device = "/dev/disk/by-partuuid/7ffa34d9-862b-42ff-a649-da54f7b8fbf0";
|
||||||
randomEncryption.enable = true;
|
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
|
# high-resolution display
|
||||||
hardware.video.hidpi.enable = lib.mkDefault true;
|
hardware.video.hidpi.enable = lib.mkDefault true;
|
||||||
networking.hostId = "0a9e92cd";
|
networking.hostId = "a32bd2dc";
|
||||||
boot.initrd.supportedFilesystems = [ "btrfs" ];
|
boot.zfs.devNodes = "/dev/disk/by-partuuid/4c6b8cfb-9643-4ff7-961e-89b097328e0e";
|
||||||
boot.supportedFilesystems = [ "btrfs" ];
|
boot.supportedFilesystems = [ "zfs" ];
|
||||||
|
boot.kernelParams = [ "zfs.zfs_arc_max=12884901888" "nohibernate" ];
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
};
|
};
|
||||||
bigScreen = false;
|
bigScreen = false;
|
||||||
ram = 16;
|
ram = 16;
|
||||||
|
fileSystem = "btrfs";
|
||||||
};
|
};
|
||||||
deviceSpecific.isHost = false;
|
deviceSpecific.isHost = false;
|
||||||
deviceSpecific.isShared = false;
|
deviceSpecific.isShared = false;
|
||||||
|
@ -19,6 +19,7 @@ with types; {
|
|||||||
gpu = {
|
gpu = {
|
||||||
vendor = mkOption { type = enum [ "amd" "nvidia" "intel" "vm" "other" ]; };
|
vendor = mkOption { type = enum [ "amd" "nvidia" "intel" "vm" "other" ]; };
|
||||||
};
|
};
|
||||||
|
fileSystem = mkOption { type = enum [ "btrfs" "zfs" "other" ]; default = "other"; };
|
||||||
ram = mkOption { type = int; };
|
ram = mkOption { type = int; };
|
||||||
legacy = mkOption { type = bool; default = false; };
|
legacy = mkOption { type = bool; default = false; };
|
||||||
bigScreen = mkOption {
|
bigScreen = mkOption {
|
||||||
|
@ -7,7 +7,7 @@ with config.deviceSpecific; {
|
|||||||
hardware.bluetooth.enable = !isServer;
|
hardware.bluetooth.enable = !isServer;
|
||||||
services.blueman.enable = !isServer;
|
services.blueman.enable = !isServer;
|
||||||
|
|
||||||
services.btrbk.instances = {
|
services.btrbk.instances = lib.mkIf (devInfo.fileSystem == "btrfs") {
|
||||||
home = {
|
home = {
|
||||||
settings = {
|
settings = {
|
||||||
snapshot_preserve_min = "2d";
|
snapshot_preserve_min = "2d";
|
||||||
@ -35,9 +35,10 @@ with config.deviceSpecific; {
|
|||||||
};
|
};
|
||||||
|
|
||||||
services.fstrim = {
|
services.fstrim = {
|
||||||
enable = isSSD;
|
enable = isSSD && devInfo.fileSystem != "zfs";
|
||||||
interval = "weekly";
|
interval = "weekly";
|
||||||
};
|
};
|
||||||
|
services.zfs.trim.enable = isSSD && devInfo.fileSystem == "zfs";
|
||||||
|
|
||||||
services.gvfs.enable = !isServer;
|
services.gvfs.enable = !isServer;
|
||||||
|
|
||||||
|
@ -3,6 +3,12 @@ with config.deviceSpecific; {
|
|||||||
config = lib.mkIf enableVirtualisation {
|
config = lib.mkIf enableVirtualisation {
|
||||||
virtualisation.docker = {
|
virtualisation.docker = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
storageDriver = if (devInfo.fileSystem == "zfs") then
|
||||||
|
"zfs"
|
||||||
|
else if (devInfo.fileSystem == "btrfs") then
|
||||||
|
"btrfs"
|
||||||
|
else
|
||||||
|
"overlay2";
|
||||||
};
|
};
|
||||||
virtualisation.oci-containers.backend = "docker";
|
virtualisation.oci-containers.backend = "docker";
|
||||||
|
|
||||||
@ -17,6 +23,27 @@ with config.deviceSpecific; {
|
|||||||
onShutdown = "shutdown";
|
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;
|
virtualisation.spiceUSBRedirection.enable = true;
|
||||||
|
|
||||||
networking.nat = {
|
networking.nat = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user