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