Compare commits
2 commits
6e979e317e
...
1ed4500cea
Author | SHA1 | Date | |
---|---|---|---|
|
1ed4500cea | ||
|
58f32985b5 |
|
@ -66,6 +66,7 @@
|
|||
jjui = upkgs.jjui;
|
||||
labelle = upkgs.labelle;
|
||||
orca-slicer = upkgs.orca-slicer; # Not prebuilt in 24.11 for some reason
|
||||
nextcloud-client = upkgs.nextcloud-client; # Need https://github.com/nextcloud/desktop/pull/7714
|
||||
}
|
||||
)
|
||||
];
|
||||
|
|
|
@ -27,7 +27,8 @@ let
|
|||
"calendar.registry.${id}.cache.enabled" = thunderbird.offlineSupport; # TODO Check this actually corresponds
|
||||
"calendar.registry.${id}.color" = thunderbird.color;
|
||||
"calendar.registry.${id}.forceEmailScheduling" = thunderbird.clientSideEmailScheduling;
|
||||
"calendar.registry.${id}.imip.identity.key" = "id_${builtins.hashString "sha256" thunderbird.email}";
|
||||
"calendar.registry.${id}.imip.identity.key" =
|
||||
"id_${builtins.hashString "sha256" thunderbird.email}";
|
||||
"calendar.registry.${id}.name" = account.name;
|
||||
"calendar.registry.${id}.readOnly" = thunderbird.readOnly;
|
||||
"calendar.registry.${id}.refreshInterval" = builtins.toString thunderbird.refreshInterval;
|
||||
|
@ -78,6 +79,10 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
imports = [
|
||||
./netrc.nix
|
||||
./nextcloud.nix
|
||||
];
|
||||
# UPST Thunderbird-specific options (should be named so), to be included in HM Thunderbird module
|
||||
options = {
|
||||
frogeye.accounts.calendar.accounts = lib.mkOption {
|
||||
|
|
83
hm/accounts/netrc.nix
Normal file
83
hm/accounts/netrc.nix
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
# Does not implement everything .netrc allows
|
||||
# (starting with: changing the .netrc position)
|
||||
# but neither do clients anyways.
|
||||
let
|
||||
cfg = config.frogeye.netrc;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
frogeye.passwordFiles = [
|
||||
{
|
||||
path = "${config.home.homeDirectory}/.netrc";
|
||||
text = lib.trivial.pipe cfg [
|
||||
builtins.attrValues
|
||||
(builtins.map (
|
||||
n: "machine ${n.machine} login @${n.machine}_login@ password @${n.machine}_password@"
|
||||
))
|
||||
lib.strings.concatLines
|
||||
];
|
||||
passwords = lib.trivial.pipe cfg [
|
||||
builtins.attrValues
|
||||
(builtins.map (n: [
|
||||
{
|
||||
name = "@${n.machine}_login@";
|
||||
value = {
|
||||
inherit (n) path;
|
||||
selector = n.login;
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "@${n.machine}_password@";
|
||||
value = {
|
||||
inherit (n) path;
|
||||
selector = n.password;
|
||||
};
|
||||
}
|
||||
]))
|
||||
lib.lists.flatten
|
||||
builtins.listToAttrs
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
options = {
|
||||
frogeye.netrc = lib.mkOption {
|
||||
default = { };
|
||||
description = "Entries to add to .netrc";
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ config, name, ... }:
|
||||
{
|
||||
options = {
|
||||
machine = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
login = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "email";
|
||||
description = "Password selector that will be used as the login field";
|
||||
};
|
||||
password = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = "Password selector that will be used as the password field";
|
||||
};
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Path to the password store entry";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
109
hm/accounts/nextcloud.nix
Normal file
109
hm/accounts/nextcloud.nix
Normal file
|
@ -0,0 +1,109 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.frogeye.nextcloud;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
systemd.user = lib.mkIf (builtins.length cfg > 0) {
|
||||
services.nextcloud_sync = {
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "nextcloud_sync";
|
||||
runtimeInputs = with pkgs; [
|
||||
nextcloud-client
|
||||
];
|
||||
text =
|
||||
''
|
||||
sync() {
|
||||
url="$1"
|
||||
remote="$2"
|
||||
local="$3"
|
||||
echo "Syncing $url $remote to $local"
|
||||
|
||||
# Adding to Syncthing ignores (so it's not double-synced)
|
||||
dir="$local"
|
||||
while [ "$dir" != "/" ]
|
||||
do
|
||||
if [ -d "$dir/.stfolder" ]
|
||||
then
|
||||
if [ ! -f "$dir/.stignore" ]
|
||||
then
|
||||
touch "$dir/.stignore"
|
||||
fi
|
||||
rule="''${local#"$dir/"}/**"
|
||||
if ! grep -qFx "$rule" "$dir/.stignore"
|
||||
then
|
||||
echo "$rule" >> "$dir/.stignore"
|
||||
fi
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
|
||||
# Actual syncing
|
||||
mkdir -p "$local"
|
||||
nextcloudcmd -n -h --path "$remote" "$local" "$url"
|
||||
}
|
||||
|
||||
''
|
||||
+ (lib.trivial.pipe cfg [
|
||||
(builtins.map (n: ''
|
||||
sync ${
|
||||
lib.strings.escapeShellArgs [
|
||||
n.url
|
||||
n.remote
|
||||
"${config.home.homeDirectory}/${n.local}"
|
||||
]
|
||||
}
|
||||
''))
|
||||
lib.strings.concatLines
|
||||
]);
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
timers.nextcloud_sync = {
|
||||
Timer = {
|
||||
OnCalendar = "*:1/5";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
options = {
|
||||
frogeye.nextcloud = lib.mkOption {
|
||||
default = { };
|
||||
description = "Sync Nextcloud folders. Uses netrc for authentication";
|
||||
type = lib.types.listOf (
|
||||
lib.types.submodule (
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "URL of the Nextcloud instance";
|
||||
};
|
||||
local = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Local path (relative to home) to sync";
|
||||
};
|
||||
remote = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Remote path to sync";
|
||||
default = "/";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue