Add netrc
This commit is contained in:
parent
6e979e317e
commit
58f32985b5
hm/accounts
|
@ -27,7 +27,8 @@ let
|
||||||
"calendar.registry.${id}.cache.enabled" = thunderbird.offlineSupport; # TODO Check this actually corresponds
|
"calendar.registry.${id}.cache.enabled" = thunderbird.offlineSupport; # TODO Check this actually corresponds
|
||||||
"calendar.registry.${id}.color" = thunderbird.color;
|
"calendar.registry.${id}.color" = thunderbird.color;
|
||||||
"calendar.registry.${id}.forceEmailScheduling" = thunderbird.clientSideEmailScheduling;
|
"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}.name" = account.name;
|
||||||
"calendar.registry.${id}.readOnly" = thunderbird.readOnly;
|
"calendar.registry.${id}.readOnly" = thunderbird.readOnly;
|
||||||
"calendar.registry.${id}.refreshInterval" = builtins.toString thunderbird.refreshInterval;
|
"calendar.registry.${id}.refreshInterval" = builtins.toString thunderbird.refreshInterval;
|
||||||
|
@ -78,6 +79,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
imports = [
|
||||||
|
./netrc.nix
|
||||||
|
];
|
||||||
# UPST Thunderbird-specific options (should be named so), to be included in HM Thunderbird module
|
# UPST Thunderbird-specific options (should be named so), to be included in HM Thunderbird module
|
||||||
options = {
|
options = {
|
||||||
frogeye.accounts.calendar.accounts = lib.mkOption {
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue