fix: added missing datasets to config

This commit is contained in:
Leyla Becker 2026-02-08 18:01:31 -06:00
parent 6ce567a53b
commit 65e0c6e0e5
7 changed files with 185 additions and 42 deletions

View file

@ -67,6 +67,7 @@
};
storage = {
generateBase = false;
zfs = {
enable = true;
notifications = {

View file

@ -4,6 +4,7 @@
./hardware-configuration.nix
./configuration.nix
./packages.nix
./legacy-storage.nix
./legacy-impermanence.nix
];
}

View file

@ -14,7 +14,17 @@
...
}: {
config = lib.mkIf config.storage.impermanence.enable {
environment.persistence."/persist/replicate/system/root" = {
system.activationScripts = {
"var-lib-private-permissions" = {
deps = ["specialfs"];
text = ''
mkdir -p /persist/system/root/var/lib/private
chmod 0700 /persist/system/root/var/lib/private
'';
};
};
environment.persistence."/persist/system/root" = {
enable = true;
hideMounts = true;
directories = lib.mkMerge [
@ -78,7 +88,7 @@
}
])
# Jellyfin
# Jellyfin (data/cache only - media is on separate dataset)
(lib.mkIf config.services.jellyfin.enable [
{
directory = "/var/lib/jellyfin";
@ -90,12 +100,6 @@
user = "jellyfin";
group = "jellyfin";
}
{
directory = config.services.jellyfin.media_directory;
user = "jellyfin";
group = "jellyfin_media";
mode = "1770";
}
])
# Immich
@ -152,19 +156,13 @@
}
])
# qBittorrent
# qBittorrent (config only - media is on separate dataset)
(lib.mkIf config.services.qbittorrent.enable [
{
directory = "/var/lib/qBittorrent/";
user = "qbittorrent";
group = "qbittorrent";
}
{
directory = config.services.qbittorrent.mediaDir;
user = "qbittorrent";
group = "qbittorrent";
mode = "1775";
}
])
# Sonarr
@ -222,5 +220,42 @@
])
];
};
# Jellyfin media on separate dataset (matching main)
environment.persistence."/persist/system/jellyfin" = lib.mkIf config.services.jellyfin.enable {
enable = true;
hideMounts = true;
directories = [
{
directory = config.services.jellyfin.media_directory;
user = "jellyfin";
group = "jellyfin_media";
mode = "1770";
}
];
};
# qBittorrent media on separate dataset (matching main)
environment.persistence."/persist/system/qbittorrent" = lib.mkIf config.services.qbittorrent.enable {
enable = true;
hideMounts = true;
directories = [
{
directory = config.services.qbittorrent.mediaDir;
user = "qbittorrent";
group = "qbittorrent";
mode = "1775";
}
];
};
# /var/log persistence (matching main)
environment.persistence."/persist/system/var/log" = {
enable = true;
hideMounts = true;
directories = [
"/var/log"
];
};
};
}

View file

@ -0,0 +1,103 @@
# Legacy storage configuration for defiant
# This file manually defines ZFS datasets matching the main branch structure
# to allow incremental migration to the new storage module.
#
# Datasets from main branch:
# - local/ - ephemeral parent
# - local/home/leyla - ephemeral user home
# - local/system/nix - nix store
# - local/system/root - root filesystem (rolled back on boot)
# - local/system/sops - sops age key
# - persist/ - persistent parent
# - persist/home/leyla - persistent user home
# - persist/system/jellyfin - jellyfin media
# - persist/system/qbittorrent - qbittorrent media
# - persist/system/root - persistent root data
# - persist/system/var/log - log persistence
{lib, ...}: {
# Manually define ZFS datasets matching main's structure
storage.zfs.datasets = {
# Ephemeral datasets (local/)
"local" = {
type = "zfs_fs";
mount = null;
};
"local/home/leyla" = {
type = "zfs_fs";
mount = "/home/leyla";
snapshot = {
blankSnapshot = true;
};
};
"local/system/nix" = {
type = "zfs_fs";
mount = "/nix";
atime = "off";
relatime = "off";
snapshot = {
autoSnapshot = false;
};
};
"local/system/root" = {
type = "zfs_fs";
mount = "/";
snapshot = {
blankSnapshot = true;
};
};
"local/system/sops" = {
type = "zfs_fs";
mount = "/persist/sops";
};
# Persistent datasets (persist/)
"persist" = {
type = "zfs_fs";
mount = null;
};
"persist/home/leyla" = {
type = "zfs_fs";
mount = "/persist/home/leyla";
snapshot = {
autoSnapshot = true;
};
};
"persist/system/jellyfin" = {
type = "zfs_fs";
mount = "/persist/system/jellyfin";
atime = "off";
relatime = "off";
};
"persist/system/qbittorrent" = {
type = "zfs_fs";
mount = "/persist/system/qbittorrent";
atime = "off";
relatime = "off";
};
"persist/system/root" = {
type = "zfs_fs";
mount = "/persist/system/root";
snapshot = {
autoSnapshot = true;
};
};
"persist/system/var/log" = {
type = "zfs_fs";
mount = "/persist/system/var/log";
};
};
# Boot commands to rollback ephemeral root on boot
boot.initrd.postResumeCommands = lib.mkAfter ''
zfs rollback -r rpool/local/system/root@blank
'';
# FileSystems needed for boot
fileSystems = {
"/".neededForBoot = true;
"/persist/system/root".neededForBoot = true;
"/persist/system/var/log".neededForBoot = true;
"/persist/system/jellyfin".neededForBoot = true;
"/persist/system/qbittorrent".neededForBoot = true;
};
}