mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 10:09:45 +01:00
qcal: add module
This commit is contained in:
parent
ea59b79f31
commit
8eb8c212e5
11 changed files with 186 additions and 0 deletions
|
@ -1193,6 +1193,13 @@ in
|
||||||
A new module is available: 'programs.pqiv'.
|
A new module is available: 'programs.pqiv'.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2023-08-22T16:06:52+00:00";
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.qcal'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,7 @@ let
|
||||||
./programs/pubs.nix
|
./programs/pubs.nix
|
||||||
./programs/pyenv.nix
|
./programs/pyenv.nix
|
||||||
./programs/pylint.nix
|
./programs/pylint.nix
|
||||||
|
./programs/qcal.nix
|
||||||
./programs/qutebrowser.nix
|
./programs/qutebrowser.nix
|
||||||
./programs/rbw.nix
|
./programs/rbw.nix
|
||||||
./programs/readline.nix
|
./programs/readline.nix
|
||||||
|
|
66
modules/programs/qcal.nix
Normal file
66
modules/programs/qcal.nix
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = config.programs.qcal;
|
||||||
|
|
||||||
|
qcalAccounts = lib.attrValues
|
||||||
|
(lib.filterAttrs (_: a: a.qcal.enable) config.accounts.calendar.accounts);
|
||||||
|
|
||||||
|
rename = oldname:
|
||||||
|
builtins.getAttr oldname {
|
||||||
|
url = "Url";
|
||||||
|
userName = "Username";
|
||||||
|
passwordCommand = "PasswordCmd";
|
||||||
|
};
|
||||||
|
|
||||||
|
filteredAccounts = let
|
||||||
|
mkAccount = account:
|
||||||
|
lib.filterAttrs (_: v: v != null) (with account.remote; {
|
||||||
|
Url = url;
|
||||||
|
Username = if userName == null then null else userName;
|
||||||
|
PasswordCmd =
|
||||||
|
if passwordCommand == null then null else toString passwordCommand;
|
||||||
|
});
|
||||||
|
in map mkAccount qcalAccounts;
|
||||||
|
|
||||||
|
in {
|
||||||
|
meta.maintainers = with lib.maintainers; [ antonmosich ];
|
||||||
|
|
||||||
|
options = {
|
||||||
|
programs.qcal = {
|
||||||
|
enable = lib.mkEnableOption "qcal, a CLI calendar application";
|
||||||
|
|
||||||
|
timezone = lib.mkOption {
|
||||||
|
type = lib.types.singleLineStr;
|
||||||
|
default = "Local";
|
||||||
|
example = "Europe/Vienna";
|
||||||
|
description = "Timezone to display calendar entries in";
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultNumDays = lib.mkOption {
|
||||||
|
type = lib.types.ints.positive;
|
||||||
|
default = 30;
|
||||||
|
description = "Default number of days to show calendar entries for";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
accounts.calendar.accounts = lib.mkOption {
|
||||||
|
type = with lib.types;
|
||||||
|
attrsOf
|
||||||
|
(submodule { options.qcal.enable = lib.mkEnableOption "qcal access"; });
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home.packages = [ pkgs.qcal ];
|
||||||
|
|
||||||
|
xdg.configFile."qcal/config.json".source =
|
||||||
|
let jsonFormat = pkgs.formats.json { };
|
||||||
|
in jsonFormat.generate "qcal.json" {
|
||||||
|
DefaultNumDays = cfg.defaultNumDays;
|
||||||
|
Timezone = cfg.timezone;
|
||||||
|
Calendars = filteredAccounts;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -120,6 +120,7 @@ import nmt {
|
||||||
./modules/programs/powerline-go
|
./modules/programs/powerline-go
|
||||||
./modules/programs/pubs
|
./modules/programs/pubs
|
||||||
./modules/programs/pyenv
|
./modules/programs/pyenv
|
||||||
|
./modules/programs/qcal
|
||||||
./modules/programs/qutebrowser
|
./modules/programs/qutebrowser
|
||||||
./modules/programs/readline
|
./modules/programs/readline
|
||||||
./modules/programs/ripgrep
|
./modules/programs/ripgrep
|
||||||
|
|
5
tests/modules/programs/qcal/default.nix
Normal file
5
tests/modules/programs/qcal/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
qcal-http = ./http-calendar.nix;
|
||||||
|
qcal-webdav = ./webdav-calendar.nix;
|
||||||
|
qcal-mixed = ./mixed.nix;
|
||||||
|
}
|
9
tests/modules/programs/qcal/http-calendar.json-expected
Normal file
9
tests/modules/programs/qcal/http-calendar.json-expected
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Calendars": [
|
||||||
|
{
|
||||||
|
"Url": "https://example.com/events.ical"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DefaultNumDays": 30,
|
||||||
|
"Timezone": "Local"
|
||||||
|
}
|
18
tests/modules/programs/qcal/http-calendar.nix
Normal file
18
tests/modules/programs/qcal/http-calendar.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.qcal.enable = true;
|
||||||
|
accounts.calendar.accounts.test = {
|
||||||
|
qcal.enable = true;
|
||||||
|
remote = { url = "https://example.com/events.ical"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs = { qcal = { }; };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/qcal/config.json
|
||||||
|
assertFileContent home-files/.config/qcal/config.json ${
|
||||||
|
./http-calendar.json-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
14
tests/modules/programs/qcal/mixed.json-expected
Normal file
14
tests/modules/programs/qcal/mixed.json-expected
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"Calendars": [
|
||||||
|
{
|
||||||
|
"Url": "https://example.com/events.ical"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"PasswordCmd": "pass show calendar",
|
||||||
|
"Url": "https://cal.example.com/anton/work",
|
||||||
|
"Username": "anton"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DefaultNumDays": 30,
|
||||||
|
"Timezone": "Local"
|
||||||
|
}
|
28
tests/modules/programs/qcal/mixed.nix
Normal file
28
tests/modules/programs/qcal/mixed.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.qcal.enable = true;
|
||||||
|
accounts.calendar.accounts = {
|
||||||
|
http-test = {
|
||||||
|
remote = { url = "https://example.com/events.ical"; };
|
||||||
|
qcal.enable = true;
|
||||||
|
};
|
||||||
|
webdav-test = {
|
||||||
|
remote = {
|
||||||
|
url = "https://cal.example.com/anton/work";
|
||||||
|
userName = "anton";
|
||||||
|
passwordCommand = [ "pass" "show" "calendar" ];
|
||||||
|
};
|
||||||
|
qcal.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs = { qcal = { }; };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/qcal/config.json
|
||||||
|
assertFileContent home-files/.config/qcal/config.json ${
|
||||||
|
./mixed.json-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
11
tests/modules/programs/qcal/webdav-calendar.json-expected
Normal file
11
tests/modules/programs/qcal/webdav-calendar.json-expected
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"Calendars": [
|
||||||
|
{
|
||||||
|
"PasswordCmd": "pass show calendar",
|
||||||
|
"Url": "https://cal.example.com/anton/work",
|
||||||
|
"Username": "anton"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DefaultNumDays": 23,
|
||||||
|
"Timezone": "Europe/Berlin"
|
||||||
|
}
|
26
tests/modules/programs/qcal/webdav-calendar.nix
Normal file
26
tests/modules/programs/qcal/webdav-calendar.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.qcal = {
|
||||||
|
enable = true;
|
||||||
|
defaultNumDays = 23;
|
||||||
|
timezone = "Europe/Berlin";
|
||||||
|
};
|
||||||
|
accounts.calendar.accounts.test = {
|
||||||
|
qcal.enable = true;
|
||||||
|
remote = {
|
||||||
|
url = "https://cal.example.com/anton/work";
|
||||||
|
userName = "anton";
|
||||||
|
passwordCommand = [ "pass" "show" "calendar" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs = { qcal = { }; };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/qcal/config.json
|
||||||
|
assertFileContent home-files/.config/qcal/config.json ${
|
||||||
|
./webdav-calendar.json-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue