1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/cloud.nix

125 lines
3.7 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
config,
lib,
pkgs,
...
2022-04-10 19:38:41 +02:00
}: let
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";
}
2024-04-02 23:26:35 +02:00
{
type = "L+";
user = config.users.users.me.name;
group = "users";
mode = "0755";
argument = "${config.users.users.me.home}/cloud/syncthing/zotero/storage";
path = "${config.users.users.me.home}/Zotero/storage";
}
2022-04-10 19:38:41 +02:00
];
services.gnome.gnome-keyring.enable = true;
security.pam.services.lightdm.enableGnomeKeyring = true;
2020-10-24 13:26:39 +02:00
home-manager.users.me = {
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;
};
};
systemd.user.services.nextcloud-syncer = {
enable = false;
wants = ["network-online.target"];
wantedBy = ["default.target"];
startAt = "*:00/10";
script = let
kieran = {
user = "kieran";
passwordFile = config.age.secrets.nextcloud-password-kieran.path;
2023-07-16 08:20:47 +02:00
endpoint = "https://cloud.kmein.de";
target = "${config.users.users.me.home}/notes";
};
in ''
mkdir -p ${lib.escapeShellArg kieran.target}
${pkgs.nextcloud-client}/bin/nextcloudcmd --non-interactive --user ${kieran.user} --password "$(cat ${kieran.passwordFile})" --path /Notes ${lib.escapeShellArg kieran.target} ${kieran.endpoint}
'';
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
};
};
environment.systemPackages = [
(pkgs.writers.writeDashBin "book" ''
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
} | ${pkgs.fzf}/bin/fzf)"
exec ${pkgs.zathura}/bin/zathura "$book"
'')
(let
kieran = {
user = "kieran.meinhardt@gmail.com";
passwordFile = config.age.secrets.mega-password.path;
};
megatools = command: ''${pkgs.megatools}/bin/megatools ${command} --username ${lib.escapeShellArg kieran.user} --password "$(cat ${kieran.passwordFile})"'';
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")"
)
'')
];
age.secrets.mega-password = {
file = ../secrets/mega-password.age;
owner = config.users.users.me.name;
group = config.users.users.me.group;
mode = "400";
};
2023-12-06 14:41:49 +01:00
services.syncthing = {
2019-04-19 03:11:51 +02:00
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";
cert = config.age.secrets.syncthing-cert.path;
key = config.age.secrets.syncthing-key.path;
2023-12-06 14:41:49 +01:00
settings = {
inherit ((import ../lib).syncthing) devices;
folders = let
cloud-dir = "${config.users.users.me.home}/cloud";
in {
2024-04-02 23:26:35 +02:00
"${config.users.users.me.home}/sync".devices = ["kabsa" "manakish" "fatteh"];
2024-03-19 20:13:05 +01:00
"${cloud-dir}/syncthing/mundoiu".devices = ["kabsa" "manakish" "heym" "fatteh"];
2023-12-06 14:41:49 +01:00
"${cloud-dir}/syncthing/music" = {
2024-03-19 20:13:05 +01:00
devices = ["kabsa" "manakish" "heym" "zaatar" "fatteh"];
2023-12-06 14:41:49 +01:00
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
};
}