From c99fb04f29877a1fe383af36eeba76b50ecc81dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 14 Aug 2023 08:46:19 +0200 Subject: [PATCH] feat: add timers service --- flake.lock | 104 ++++++++++++++++++++++++++++++++++- flake.nix | 2 + modules/profiles/desktop.nix | 1 + modules/services/timers.nix | 32 +++++++++++ overlays/packages.nix | 1 + 5 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 modules/services/timers.nix diff --git a/flake.lock b/flake.lock index 14e7bc4..e88cba3 100644 --- a/flake.lock +++ b/flake.lock @@ -533,6 +533,25 @@ "type": "github" } }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs_8" + }, + "locked": { + "lastModified": 1686572087, + "narHash": "sha256-jXTut7ZSYqLEgm/nTk7TuVL2ExahTip605bLINklAnQ=", + "owner": "nix-community", + "repo": "naersk", + "rev": "8507af04eb40c5520bd35d9ce6f9d2342cea5ad1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, "neovim-flake": { "inputs": { "flake-utils": "flake-utils_2", @@ -788,6 +807,35 @@ "type": "github" } }, + "nixpkgs_8": { + "locked": { + "lastModified": 1685677062, + "narHash": "sha256-zoHF7+HNwNwne2XEomphbdc4Y8tdWT16EUxUTXpOKpQ=", + "path": "/nix/store/dnqwkazyg92hzya7400klxlk072g3zsk-source", + "rev": "95be94370d09f97f6af6a1df1eb9649b5260724e", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_9": { + "locked": { + "lastModified": 1687103638, + "narHash": "sha256-dwy/TK6Db5W7ivcgmcxUykhFwodIg0jrRzOFt7H5NUc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "91430887645a0953568da2f3e9a3a3bb0a0378ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nvim-treesitter-textsubjects": { "flake": false, "locked": { @@ -867,7 +915,8 @@ "rofi-wayland": "rofi-wayland", "smartcolumn-nvim": "smartcolumn-nvim", "stable": "stable", - "telekasten-nvim": "telekasten-nvim" + "telekasten-nvim": "telekasten-nvim", + "timers": "timers" } }, "rust-overlay": { @@ -972,6 +1021,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "telekasten-nvim": { "flake": false, "locked": { @@ -988,6 +1052,44 @@ "type": "github" } }, + "timers": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs_9", + "utils": "utils" + }, + "locked": { + "lastModified": 1690749969, + "narHash": "sha256-legyKOJljfuNrY74jsgA641E3q6hle4G6qz8YD55CgI=", + "ref": "refs/heads/main", + "rev": "e3fd65e98be42b367aef019812375e418ef77448", + "revCount": 18, + "type": "git", + "url": "https://gitea.moritzboeh.me/moritz/timers.git" + }, + "original": { + "type": "git", + "url": "https://gitea.moritzboeh.me/moritz/timers.git" + } + }, + "utils": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1687171271, + "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "wlroots": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 42191c8..bf9e85c 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,8 @@ # Firefox user.js arkenfox-userjs.url = "github:arkenfox/user.js"; arkenfox-userjs.flake = false; + + timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git"; }; /* diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index 5fcd3f1..f23ec05 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -78,6 +78,7 @@ in }; }; }; + timers.enable = true; wireguard.enable = true; }; }; diff --git a/modules/services/timers.nix b/modules/services/timers.nix new file mode 100644 index 0000000..52c4260 --- /dev/null +++ b/modules/services/timers.nix @@ -0,0 +1,32 @@ +{ config +, lib +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.services.timers; +in +{ + options.my.services.timers.enable = mkEnableOption "timers"; + options.my.services.timers.package = mkOption { + type = types.package; + default = pkgs.timers; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + systemd.user.services.timers-daemon = { + after = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + wantedBy = [ "graphical-session.target" ]; + serviceConfig = { + Restart = "always"; + RestartSec = "1s"; + ExecStart = "${getExe cfg.package} daemon"; + }; + }; + }; +} diff --git a/overlays/packages.nix b/overlays/packages.nix index e56b410..ceef671 100644 --- a/overlays/packages.nix +++ b/overlays/packages.nix @@ -10,6 +10,7 @@ final: prev: src = inputs.rofi-wayland; version = lib.my.mkVersionInput inputs.rofi-wayland; }); + timers = inputs.timers.defaultPackage.${prev.system}; fzf1 = final.writeShellApplication { name = "fzf1";