161 lines
3.8 KiB
Nix
161 lines
3.8 KiB
Nix
{ inputs, ... }:
|
|
{
|
|
imports = [ inputs.disko.nixosModules.disko ];
|
|
|
|
config = {
|
|
users.groups.storage = { };
|
|
|
|
users.users.storage = {
|
|
isSystemUser = true;
|
|
description = "storage";
|
|
group = "storage";
|
|
};
|
|
|
|
systemd.tmpfiles.settings = {
|
|
"10-media-public" = {
|
|
"/mnt/media/public" = {
|
|
d = {
|
|
# Create directory
|
|
user = "storage";
|
|
group = "storage";
|
|
mode = "2775";
|
|
};
|
|
z = {
|
|
# Ensure permissions are inherited
|
|
user = "storage";
|
|
group = "storage";
|
|
mode = "2775";
|
|
};
|
|
};
|
|
};
|
|
|
|
"10-cameras-public" = {
|
|
"/mnt/cameras/public" = {
|
|
d = {
|
|
# Create directory
|
|
user = "storage";
|
|
group = "storage";
|
|
mode = "2775";
|
|
};
|
|
z = {
|
|
# Ensure permissions are inherited
|
|
user = "storage";
|
|
group = "storage";
|
|
mode = "2775";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
networking.hostId = "0a9474e7"; # Required by ZFS
|
|
disko.devices = {
|
|
disk = {
|
|
root = {
|
|
type = "disk";
|
|
device = "/dev/nvme0n1";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
size = "500M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [ "umask=0077" ];
|
|
};
|
|
};
|
|
|
|
root = {
|
|
size = "100%";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "ext4";
|
|
mountpoint = "/";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
disk1 = {
|
|
type = "disk";
|
|
device = "/dev/disk/by-id/ata-ST8000VN004-3CP101_WWZ8QCG4";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "storage";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
disk2 = {
|
|
type = "disk";
|
|
device = "/dev/disk/by-id/ata-ST8000VN004-3CP101_WWZ8QDJ5";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "storage";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
zpool = {
|
|
storage = {
|
|
type = "zpool";
|
|
|
|
mode = {
|
|
topology = {
|
|
type = "topology";
|
|
vdev = [
|
|
{
|
|
mode = "mirror";
|
|
members = [
|
|
"disk1"
|
|
"disk2"
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
rootFsOptions = {
|
|
mountpoint = "none";
|
|
compression = "zstd";
|
|
xattr = "sa";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
|
|
datasets = {
|
|
media = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/mnt/media";
|
|
options.mountpoint = "legacy"; # otherwise we get a race between systemd and zfs; https://github.com/nix-community/disko/issues/214
|
|
};
|
|
|
|
cameras = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/mnt/cameras";
|
|
options.mountpoint = "legacy"; # otherwise we get a race between systemd and zfs; https://github.com/nix-community/disko/issues/214
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|