From ef512d5ba61df0c7b81db7897e4ecc642578ffec Mon Sep 17 00:00:00 2001 From: Wittano Bonarotti Date: Sat, 25 May 2024 14:28:44 +0200 Subject: [PATCH] feat(todo): added desktop application for TODO: Planify --- lib/default.nix | 3 ++- lib/desktop.nix | 4 +-- lib/hosts.nix | 5 ++-- modules/desktop/submodules/todo.nix | 40 +++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 modules/desktop/submodules/todo.nix diff --git a/lib/default.nix b/lib/default.nix index d9bbbcfe..c92a4b1a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -2,10 +2,11 @@ with lib; let dotfilesPath = ./../dotfiles; + secretDir = ./../secrets; in attrsets.mapAttrs' (n: v: { name = strings.removeSuffix ".nix" n; - value = import (./. + "/${n}") { inherit lib pkgs dotfilesPath privateRepo unstable inputs system; }; + value = import (./. + "/${n}") { inherit lib pkgs dotfilesPath privateRepo unstable inputs system secretDir; }; }) (builtins.readDir ./.) diff --git a/lib/desktop.nix b/lib/desktop.nix index 36528d5f..fa05238c 100644 --- a/lib/desktop.nix +++ b/lib/desktop.nix @@ -1,9 +1,9 @@ -{ pkgs, lib, unstable, ... }: +{ pkgs, lib, unstable, secretDir, ... }: with lib; with lib.my; let mkDesktopApp = config: dotfiles: name: desktopName: import (./../modules/desktop/submodules + "/${name}.nix") { - inherit pkgs dotfiles config unstable lib desktopName; + inherit pkgs dotfiles config unstable lib desktopName secretDir; }; in { diff --git a/lib/hosts.nix b/lib/hosts.nix index 507272bc..ec6ac16c 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,4 +1,4 @@ -{ lib, system, pkgs, unstable, privateRepo, inputs, dotfilesPath, ... }: +{ lib, system, pkgs, unstable, privateRepo, inputs, dotfilesPath, secretDir, ... }: with lib; with lib.my; let @@ -39,8 +39,7 @@ in inherit system; specialArgs = { - inherit pkgs unstable lib dotfiles isDevMode inputs privateRepo system hostname desktopName; - secretDir = ./../secrets; + inherit pkgs unstable lib dotfiles isDevMode inputs privateRepo system hostname desktopName secretDir; templateDir = ./../templates; }; diff --git a/modules/desktop/submodules/todo.nix b/modules/desktop/submodules/todo.nix new file mode 100644 index 00000000..416eff0a --- /dev/null +++ b/modules/desktop/submodules/todo.nix @@ -0,0 +1,40 @@ +{ lib, unstable, secretDir, ... }: +with lib; +with lib.my; +let + port = 5232; + certPath = (secretDir + "/certificate.pem"); + keyPath = (secretDir + "/privatekey.pem"); +in +{ + autostart = autostart.mkAutostart { programs = [ "planify" ]; pkg = unstable; }; + + config = { + networking.firewall.interfaces.eno1.allowedTCPPorts = [ port ]; + + services = { + accounts-daemon.enable = true; + passSecretService.enable = true; + radicale = { + enable = true; + settings = { + server = { + hosts = [ "0.0.0.0:${builtins.toString port}" ]; + ssl = true; + certificate = builtins.toString certPath; + key = builtins.toString keyPath; + }; + auth = { + type = "htpasswd"; + htpasswd_filename = "/var/lib/radicale/users"; + htpasswd_encryption = "bcrypt"; + }; + }; + }; + }; + + security.pki.certificateFiles = [ certPath ]; + + home-manager.users.wittano.home.packages = with unstable; [ planify ]; + }; +}