2022-03-10 21:52:12 +01:00
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
pkgs,
|
|
|
|
|
...
|
2022-04-10 19:38:41 +02:00
|
|
|
}: let
|
2023-02-22 10:02:55 +01:00
|
|
|
inherit (import ../lib) tmpfilesConfig;
|
2022-04-10 19:38:41 +02:00
|
|
|
in {
|
|
|
|
|
systemd.tmpfiles.rules = map tmpfilesConfig [
|
|
|
|
|
{
|
|
|
|
|
type = "L+";
|
|
|
|
|
user = config.users.users.me.name;
|
|
|
|
|
group = "users";
|
|
|
|
|
mode = "0755";
|
2023-07-17 08:31:34 +02:00
|
|
|
argument = "${config.users.users.me.home}/cloud/nextcloud/Uni";
|
2022-04-10 19:38:41 +02:00
|
|
|
path = "${config.users.users.me.home}/uni";
|
|
|
|
|
}
|
|
|
|
|
];
|
2020-04-22 17:42:45 +02:00
|
|
|
|
2020-10-24 13:26:39 +02:00
|
|
|
home-manager.users.me = {
|
2023-07-17 08:31:34 +02:00
|
|
|
services.gnome-keyring.enable = true;
|
2022-01-08 10:18:33 +01:00
|
|
|
services.nextcloud-client = {
|
2023-07-17 08:31:34 +02:00
|
|
|
enable = true;
|
2022-01-08 10:18:33 +01:00
|
|
|
startInBackground = true;
|
|
|
|
|
};
|
2022-05-08 09:14:37 +02:00
|
|
|
systemd.user.services.nextcloud-client = {
|
|
|
|
|
Unit = {
|
|
|
|
|
Wants = ["gnome-keyring.service"];
|
|
|
|
|
After = ["gnome-keyring.service"];
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-04-17 10:48:32 +02:00
|
|
|
};
|
|
|
|
|
|
2022-09-27 19:18:42 +02:00
|
|
|
systemd.user.services.nextcloud-syncer = {
|
2023-07-04 09:40:00 +02:00
|
|
|
enable = false;
|
2022-09-27 19:18:42 +02:00
|
|
|
wants = ["network-online.target"];
|
|
|
|
|
wantedBy = ["default.target"];
|
|
|
|
|
startAt = "*:00/10";
|
|
|
|
|
script = let
|
|
|
|
|
kieran = {
|
|
|
|
|
user = "kieran";
|
2023-02-22 10:02:55 +01:00
|
|
|
passwordFile = config.age.secrets.nextcloud-password-kieran.path;
|
2023-07-16 08:20:47 +02:00
|
|
|
endpoint = "https://cloud.kmein.de";
|
2022-09-27 22:07:03 +02:00
|
|
|
target = "${config.users.users.me.home}/notes";
|
2022-09-27 19:18:42 +02:00
|
|
|
};
|
|
|
|
|
in ''
|
2022-09-27 22:07:03 +02:00
|
|
|
mkdir -p ${lib.escapeShellArg kieran.target}
|
2023-02-22 10:02:55 +01:00
|
|
|
${pkgs.nextcloud-client}/bin/nextcloudcmd --non-interactive --user ${kieran.user} --password "$(cat ${kieran.passwordFile})" --path /Notes ${lib.escapeShellArg kieran.target} ${kieran.endpoint}
|
2022-09-27 19:18:42 +02:00
|
|
|
'';
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-19 13:40:32 +01:00
|
|
|
environment.systemPackages = [
|
2021-11-20 09:39:27 +01:00
|
|
|
(pkgs.writers.writeDashBin "book" ''
|
2021-11-19 13:40:32 +01:00
|
|
|
set -efu
|
|
|
|
|
book="$({
|
|
|
|
|
${pkgs.findutils}/bin/find ${config.users.users.me.home}/cloud/syncthing/library -type f
|
2023-07-17 08:31:34 +02:00
|
|
|
${pkgs.findutils}/bin/find ${config.users.users.me.home}/cloud/nextcloud/Books -type f
|
2021-11-19 13:40:32 +01:00
|
|
|
} | ${pkgs.fzf}/bin/fzf)"
|
2022-09-27 22:07:03 +02:00
|
|
|
exec ${pkgs.zathura}/bin/zathura "$book"
|
2021-11-19 13:40:32 +01:00
|
|
|
'')
|
2022-09-27 22:07:03 +02:00
|
|
|
(let
|
|
|
|
|
kieran = {
|
|
|
|
|
user = "kieran.meinhardt@gmail.com";
|
2023-02-22 10:02:55 +01:00
|
|
|
passwordFile = config.age.secrets.mega-password.path;
|
2022-09-27 22:07:03 +02:00
|
|
|
};
|
2023-02-22 10:02:55 +01:00
|
|
|
megatools = command: ''${pkgs.megatools}/bin/megatools ${command} --username ${lib.escapeShellArg kieran.user} --password "$(cat ${kieran.passwordFile})"'';
|
2022-09-27 22:07:03 +02:00
|
|
|
in
|
|
|
|
|
pkgs.writers.writeDashBin "book-mega" ''
|
|
|
|
|
set -efu
|
|
|
|
|
selection="$(${megatools "ls"} | ${pkgs.fzf}/bin/fzf)"
|
|
|
|
|
test -n "$selection" || exit 1
|
|
|
|
|
|
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
|
trap clean EXIT
|
|
|
|
|
clean() {
|
|
|
|
|
rm -rf "$tmpdir"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cd "$tmpdir"
|
|
|
|
|
${megatools "get"} "$selection"
|
|
|
|
|
exec ${pkgs.zathura}/bin/zathura "$(basename "$selection")"
|
|
|
|
|
)
|
|
|
|
|
'')
|
2021-11-19 13:40:32 +01:00
|
|
|
];
|
|
|
|
|
|
2023-02-24 23:10:45 +01:00
|
|
|
age.secrets.mega-password = {
|
2023-07-04 16:28:26 +02:00
|
|
|
file = ../secrets/mega-password.age;
|
2023-02-24 23:10:45 +01:00
|
|
|
owner = config.users.users.me.name;
|
|
|
|
|
group = config.users.users.me.group;
|
|
|
|
|
mode = "400";
|
|
|
|
|
};
|
2023-02-22 10:02:55 +01:00
|
|
|
|
2019-04-19 03:11:51 +02:00
|
|
|
services.syncthing = rec {
|
|
|
|
|
enable = true;
|
2019-05-29 17:23:38 +02:00
|
|
|
user = "kfm";
|
2019-04-19 03:11:51 +02:00
|
|
|
openDefaultPorts = true;
|
2019-05-29 17:23:38 +02:00
|
|
|
configDir = "/home/kfm/.config/syncthing";
|
|
|
|
|
dataDir = "/home/kfm/.config/syncthing";
|
2023-02-22 10:02:55 +01:00
|
|
|
cert = config.age.secrets.syncthing-cert.path;
|
|
|
|
|
key = config.age.secrets.syncthing-key.path;
|
|
|
|
|
inherit ((import ../lib).syncthing) devices;
|
2022-03-10 21:52:12 +01:00
|
|
|
folders = let
|
|
|
|
|
cloud-dir = "${config.users.users.me.home}/cloud";
|
|
|
|
|
in {
|
2023-09-08 16:38:04 +02:00
|
|
|
"${cloud-dir}/syncthing/zotero/storage".devices = ["kabsa" "manakish"];
|
2022-03-10 21:52:12 +01:00
|
|
|
"${cloud-dir}/syncthing/common".devices = ["kabsa" "manakish"];
|
|
|
|
|
"${cloud-dir}/syncthing/library".devices = ["kabsa" "manakish" "heym"];
|
|
|
|
|
"${cloud-dir}/syncthing/mundoiu".devices = ["kabsa" "manakish" "heym"];
|
2023-06-04 15:43:08 +02:00
|
|
|
"${cloud-dir}/syncthing/obsidian" = {
|
|
|
|
|
devices = ["kabsa" "manakish" "heym"];
|
|
|
|
|
id = "3r1hu-3barr";
|
|
|
|
|
};
|
2022-03-10 21:52:12 +01:00
|
|
|
"${cloud-dir}/syncthing/music" = {
|
|
|
|
|
devices = ["kabsa" "manakish" "heym" "zaatar"];
|
|
|
|
|
id = "music";
|
2021-12-01 17:38:47 +01:00
|
|
|
};
|
2022-03-10 21:52:12 +01:00
|
|
|
};
|
2019-04-19 03:11:51 +02:00
|
|
|
};
|
|
|
|
|
}
|