From ecd76439f3954c86bb34e03649ece7a13ba4a95e Mon Sep 17 00:00:00 2001 From: kalipso Date: Wed, 4 Oct 2023 16:41:46 +0200 Subject: [PATCH] add basic nixosModule for tasklist --- flake.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index a96aa14..ed73e31 100644 --- a/flake.nix +++ b/flake.nix @@ -3,9 +3,58 @@ outputs = { self, nixpkgs }: { - packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + packages.x86_64-linux.tasklist = nixpkgs.legacyPackages.x86_64-linux.buildGoModule rec { + pname = "tasklist"; + version = "1.0"; + vendorHash = "sha256-olHQNClxU4sykBlhlbvTL6wCUYkMxnaQdLnRwvuJffw="; + src = ./.; + }; - packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + nixosModules.malobeo-tasklist = { config, ... }: + let + cfg = config.services.malobeo-tasklist; + tasklist-pkg = self.packages.x86_64-linux.tasklist; + in + { + options = { + services.malobeo-tasklist = { + enable = nixpkgs.lib.mkOption { + default = false; + type = nixpkgs.types.bool; + description = nixpkgs.lib.mdDoc '' + Enables tasklist + ''; + }; + }; + }; + config = nixpkgs.lib.mkIf cfg.enable { + environment.systemPackages = [ tasklist-pkg]; + + users.users = { + malobeo-tasklist = { + description = "malobeo tasklist user"; + group = "malobeo-tasklist"; + isNormalUser = true; + }; + }; + + systemd.services.malobeo-tasklist = { + description = "malobeo tasklist daemon"; + serviceConfig = { + Type = "simple"; + ExecStart = "${tasklist-pkg}/bin/tasklist -d /var/lib/malobeo-tasklist/tasklist.db"; + Restart = "on-failure"; + }; + + wantedBy = [ "default.target" ]; + + environment = { + USER = "malobeo-tasklist"; + HOME = /var/lib/malobeo-tasklist; + }; + }; + }; + }; }; }