move cloudsync submodule to user definition
This commit is contained in:
parent
284a9e5c36
commit
16daeb5f6f
4 changed files with 44 additions and 33 deletions
|
@ -10,12 +10,13 @@ in {
|
|||
nextcloud-client
|
||||
];
|
||||
|
||||
systemd = lib.mkMerge (lib.mapAttrsToList (local_user: paths: let
|
||||
systemd.services = lib.mkMerge (lib.mapAttrsToList (local_user: user_conf: let
|
||||
paths = user_conf.syncPaths;
|
||||
sync_script = lib.strings.concatLines (map ({local, remote}: let
|
||||
remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote);
|
||||
in "${cloud_cmd} /${remote_clean} ${local} ${sync_server}" ) paths);
|
||||
in { # user-specific sync jobs
|
||||
services."nextcloud-autosync-${local_user}" = {
|
||||
"nextcloud-autosync-${local_user}" = lib.mkIf ( paths != [] ) {
|
||||
description = "Auto sync Nextcloud";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
|
@ -29,13 +30,18 @@ in {
|
|||
wantedBy = ["multi-user.target"];
|
||||
enable=true;
|
||||
};
|
||||
timers."nextcloud-autosync-${local_user}" = {
|
||||
}) config.users.users );
|
||||
|
||||
systemd.timers = lib.mkMerge (lib.mapAttrsToList (local_user: user_conf: let
|
||||
paths = user_conf.syncPaths;
|
||||
in { # user-specific sync jobs
|
||||
"nextcloud-autosync-${local_user}" = lib.mkIf ( paths != [] ) {
|
||||
description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
|
||||
timerConfig.OnBootSec = "5min";
|
||||
timerConfig.OnUnitActiveSec = "60min";
|
||||
wantedBy = ["multi-user.target" "timers.target"];
|
||||
enable = true;
|
||||
};
|
||||
}) cfg.cloudSync.paths );
|
||||
}) config.users.users );
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,14 +56,6 @@
|
|||
username = "Grimmauld";
|
||||
server = "cloud.grimmauld.de";
|
||||
passwordFile = config.age.secrets.nextcloud_pass.path;
|
||||
paths = {
|
||||
grimmauld = [
|
||||
{ remote = "3d"; }
|
||||
{ remote = "Pictures"; }
|
||||
{ remote = "Documents"; }
|
||||
{ remote = "Videos"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,20 @@
|
|||
with lib;
|
||||
let
|
||||
cfg = config.grimmShared;
|
||||
sync_mod = types.submodule ({config, ...} : {
|
||||
options = {
|
||||
remote = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
description = "path on the cloud server";
|
||||
};
|
||||
|
||||
local = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
default = "$HOME/" + (lib.strings.concatStrings (builtins.match "/*(.+)" config.remote));
|
||||
description = "local path to sync";
|
||||
};
|
||||
};
|
||||
});
|
||||
in {
|
||||
options.grimmShared = {
|
||||
enable = mkEnableOption "grimm-shared-common";
|
||||
|
@ -143,30 +157,21 @@ in {
|
|||
type = types.nonEmptyStr;
|
||||
description = "password file to use for login";
|
||||
};
|
||||
|
||||
paths = mkOption {
|
||||
type = let
|
||||
mod = types.submodule ({config, ...} : {
|
||||
options = {
|
||||
remote = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
description = "path on the cloud server";
|
||||
};
|
||||
|
||||
local = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
default = "$HOME/" + (lib.strings.concatStrings (builtins.match "/*(.+)" config.remote));
|
||||
description = "local path to sync";
|
||||
};
|
||||
};
|
||||
});
|
||||
in types.attrsOf (types.listOf mod);
|
||||
default = [];
|
||||
description = "puts my personal config in place using above methods";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
options.users.users = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
syncPaths = mkOption {
|
||||
type = types.listOf sync_mod;
|
||||
default = [];
|
||||
description = "paths to sync via nextcloud";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
imports = [
|
||||
./common/localisation.nix
|
||||
./common/printing.nix
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
shell = pkgs.xonsh;
|
||||
description = "grimmauld";
|
||||
extraGroups = [ "networkmanager" "kvm" "wheel" "input" "video" "lp" "scanner" "libvirt" "libvirt-qemu" "libvirtd" "pipewire" "gamemode" ];
|
||||
|
||||
syncPaths = [
|
||||
{ remote = "3d"; }
|
||||
{ remote = "Pictures"; }
|
||||
{ remote = "Documents"; }
|
||||
{ remote = "Videos"; }
|
||||
];
|
||||
|
||||
packages = with pkgs; [
|
||||
webcord
|
||||
discord
|
||||
|
|
Loading…
Reference in a new issue