finally zfs is working
This commit is contained in:
parent
5634e20d49
commit
95de139644
|
@ -1,36 +1,29 @@
|
||||||
{ pkgs
|
{
|
||||||
, inputs
|
pkgs,
|
||||||
, modulesPath
|
inputs,
|
||||||
, lib
|
modulesPath,
|
||||||
, ...
|
lib,
|
||||||
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/profiles/qemu-guest.nix") # Temporary
|
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
|
||||||
hardware.cpu.intel.updateMicrocode = true;
|
|
||||||
|
|
||||||
boot.loader = {
|
boot.loader = {
|
||||||
systemd-boot.enable = true;
|
systemd-boot.enable = true;
|
||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
# boot.zfs.extraPools = [ "zraid" ];
|
boot.zfs.devNodes = "/dev/disk/by-path";
|
||||||
|
|
||||||
boot.supportedFilesystems = [ "zfs" ];
|
nix.settings.experimental-features = ["nix-command" "flakes"];
|
||||||
boot.zfs.forceImportRoot = false;
|
|
||||||
|
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
||||||
nix.gc = {
|
nix.gc = {
|
||||||
automatic = true;
|
automatic = true;
|
||||||
options = "--delete-older-than 30d";
|
options = "--delete-older-than 30d";
|
||||||
};
|
};
|
||||||
nix.optimise = {
|
nix.optimise = {
|
||||||
automatic = true;
|
automatic = true;
|
||||||
dates = [ "05:00" ];
|
dates = ["05:00"];
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = "enis";
|
networking.hostName = "enis";
|
||||||
|
@ -38,12 +31,12 @@
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
enable = true;
|
enable = true;
|
||||||
allowedTCPPorts = [ ];
|
allowedTCPPorts = [];
|
||||||
allowedUDPPorts = [ ];
|
allowedUDPPorts = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
extraSpecialArgs = { inherit inputs; };
|
extraSpecialArgs = {inherit inputs;};
|
||||||
users = {
|
users = {
|
||||||
"enis" = import ./home.nix;
|
"enis" = import ./home.nix;
|
||||||
};
|
};
|
||||||
|
@ -61,17 +54,15 @@
|
||||||
shell = pkgs.zsh;
|
shell = pkgs.zsh;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users."nixos" =
|
users.users."nixos" = {
|
||||||
{
|
isNormalUser = true;
|
||||||
isNormalUser = true;
|
initialPassword = "1234";
|
||||||
initialPassword = "1234";
|
extraGroups = ["wheel"];
|
||||||
extraGroups = [ "wheel" ];
|
};
|
||||||
};
|
|
||||||
|
|
||||||
users.users.root =
|
users.users.root = {
|
||||||
{
|
initialPassword = "1234";
|
||||||
initialPassword = "1234";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
programs.zsh = {
|
programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -112,12 +103,14 @@
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
PasswordAuthentication = true;
|
PasswordAuthentication = false;
|
||||||
KbdInteractiveAuthentication = true;
|
KbdInteractiveAuthentication = false;
|
||||||
AllowUsers = null;
|
AllowUsers = null;
|
||||||
PermitRootLogin = "no";
|
PermitRootLogin = "no";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nix.settings.trusted-users = ["@wheel"];
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
71
disko.nix
71
disko.nix
|
@ -1,8 +1,8 @@
|
||||||
{
|
{ lib
|
||||||
lib,
|
, root-disk ? throw "Expected a mf disk brother"
|
||||||
root-disk ? "Expected a mf disk brother",
|
, raid-disks ? []
|
||||||
raid-disks ? "Expected disks for raid",
|
, swap-size ? -1
|
||||||
...
|
, ...
|
||||||
}: {
|
}: {
|
||||||
disko.devices = {
|
disko.devices = {
|
||||||
disk =
|
disk =
|
||||||
|
@ -20,15 +20,22 @@
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
mountOptions = ["umask=0077"];
|
mountOptions = [ "umask=0077" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
swap = lib.mkIf (swap-size != -1) {
|
||||||
|
size = swap-size;
|
||||||
|
content = {
|
||||||
|
type = "swap";
|
||||||
|
discardPolicy = "both";
|
||||||
|
resumeDevice = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
root = {
|
root = {
|
||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "zfs";
|
||||||
format = "ext4";
|
pool = "zroot";
|
||||||
mountpoint = "/";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -55,6 +62,7 @@
|
||||||
# };
|
# };
|
||||||
# };
|
# };
|
||||||
}
|
}
|
||||||
|
# Import all disks into raid named "raid5"
|
||||||
// lib.attrsets.genAttrs raid-disks (name: {
|
// lib.attrsets.genAttrs raid-disks (name: {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
device = "/dev/" + name;
|
device = "/dev/" + name;
|
||||||
|
@ -65,29 +73,54 @@
|
||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "zfs";
|
type = "zfs";
|
||||||
pool = "storage";
|
pool = "raid5";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
zpool = lib.mkIf (builtins.length raid-disks > 0) {
|
zpool = {
|
||||||
storage = {
|
zroot = {
|
||||||
|
type = "zpool";
|
||||||
|
rootFsOptions.mountpoint = "none";
|
||||||
|
|
||||||
|
datasets = {
|
||||||
|
root = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
|
||||||
|
"nix/store" = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
mountpoint = "/nix/store";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
raid5 = lib.mkIf (builtins.length raid-disks > 0) {
|
||||||
type = "zpool";
|
type = "zpool";
|
||||||
mode = "raidz";
|
mode = "raidz";
|
||||||
# TODO: Cache-ing
|
|
||||||
# rootFsOptions = {
|
|
||||||
# compression = "zstd";
|
|
||||||
# "com.sun:auto-snapshot" = "false";
|
|
||||||
# };
|
|
||||||
|
|
||||||
mountpoint = "/storage";
|
rootFsOptions.compression = "zstd";
|
||||||
|
rootFsOptions.mountpoint = "none";
|
||||||
|
|
||||||
datasets = {
|
datasets = {
|
||||||
var = {
|
var = {
|
||||||
type = "zfs_fs";
|
type = "zfs_fs";
|
||||||
mountpoint = "/storage/var";
|
mountpoint = "/var";
|
||||||
|
};
|
||||||
|
home = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
mountpoint = "/home";
|
||||||
|
};
|
||||||
|
src = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
mountpoint = "/srv";
|
||||||
|
};
|
||||||
|
opt = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
mountpoint = "/opt";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
27
flake.nix
27
flake.nix
|
@ -26,12 +26,13 @@
|
||||||
formatter.${system} = pkgs.alejandra;
|
formatter.${system} = pkgs.alejandra;
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
server = nixpkgs.lib.nixosSystem {
|
server-vm = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {inherit inputs;};
|
specialArgs = {inherit inputs;};
|
||||||
modules = [
|
modules = [
|
||||||
inputs.disko.nixosModules.default
|
inputs.disko.nixosModules.default
|
||||||
(import ./disko.nix {
|
(import ./disko.nix {
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
swap-size = "16G";
|
||||||
root-disk = "/dev/vda";
|
root-disk = "/dev/vda";
|
||||||
raid-disks = [
|
raid-disks = [
|
||||||
"vdb"
|
"vdb"
|
||||||
|
@ -41,9 +42,33 @@
|
||||||
})
|
})
|
||||||
inputs.home-manager.nixosModules.default
|
inputs.home-manager.nixosModules.default
|
||||||
|
|
||||||
|
./vm-hardware-configuration.nix
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
server = nixpkgs.lib.nixosSystem {
|
||||||
|
specialArgs = {inherit inputs;};
|
||||||
|
modules = [
|
||||||
|
inputs.disko.nixosModules.default
|
||||||
|
(import ./disko.nix {
|
||||||
|
lib = pkgs.lib;
|
||||||
|
swap-size = "128G";
|
||||||
|
root-disk = "/dev/nvme0n1";
|
||||||
|
raid-disks = [
|
||||||
|
"sda"
|
||||||
|
"sdb"
|
||||||
|
"sdc"
|
||||||
|
"sdd"
|
||||||
|
];
|
||||||
|
})
|
||||||
|
inputs.home-manager.nixosModules.default
|
||||||
|
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./configuration.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
20
vm-hardware-configuration.nix
Normal file
20
vm-hardware-configuration.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/profiles/qemu-guest.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sr_mod" "virtio_blk"];
|
||||||
|
boot.initrd.kernelModules = [];
|
||||||
|
boot.kernelModules = ["kvm_amd"];
|
||||||
|
boot.extraModulePackages = [];
|
||||||
|
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
}
|
Loading…
Reference in a new issue