feat: moved ollama, tailscale, and sync into folders following the new storage pattern
This commit is contained in:
parent
b67be1472a
commit
d283f88160
11 changed files with 215 additions and 117 deletions
57
modules/nixos-modules/sync/storage.nix
Normal file
57
modules/nixos-modules/sync/storage.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
mountDir = "/mnt/sync";
|
||||
configDir = "/etc/syncthing";
|
||||
in {
|
||||
options = {
|
||||
services.syncthing.impermanence.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = config.services.syncthing.enable && config.storage.impermanence.enable;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.services.syncthing.enable (
|
||||
lib.mkMerge [
|
||||
(lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
||||
{
|
||||
# Syncthing needs persistent storage for configuration and data
|
||||
}
|
||||
(lib.mkIf (!config.services.syncthing.impermanence.enable) {
|
||||
# TODO: placeholder to configure a unique dataset for this service
|
||||
})
|
||||
(lib.mkIf config.services.syncthing.impermanence.enable {
|
||||
assertions =
|
||||
[
|
||||
{
|
||||
assertion = config.services.syncthing.configDir == configDir;
|
||||
message = "syncthing config dir does not match persistence";
|
||||
}
|
||||
]
|
||||
++ lib.attrsets.mapAttrsToList (_: folder: {
|
||||
assertion = lib.strings.hasPrefix mountDir folder.path;
|
||||
message = "syncthing folder ${folder.label} is stored at ${folder.path} which not under the persisted path of ${mountDir}";
|
||||
})
|
||||
config.services.syncthing.settings.folders;
|
||||
|
||||
storage.impermanence.datasets."persist/system/root" = {
|
||||
directories = {
|
||||
"${mountDir}" = {
|
||||
enable = true;
|
||||
owner.name = "syncthing";
|
||||
group.name = "syncthing";
|
||||
};
|
||||
"${configDir}" = {
|
||||
enable = true;
|
||||
owner.name = "syncthing";
|
||||
group.name = "syncthing";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
]))
|
||||
]
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue