From 22d72054137c6962ef7b73ee2c18f38ac388bb4b Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:19:09 +0100 Subject: [PATCH 1/8] New `org-roam-ql` predicate --- hmModules/emacs/init.el | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/hmModules/emacs/init.el b/hmModules/emacs/init.el index e630922..435ad0a 100644 --- a/hmModules/emacs/init.el +++ b/hmModules/emacs/init.el @@ -787,11 +787,30 @@ This is meant to be an helper to be called from the window manager." (defun org-roam-node-date (node) "Return the org datestring when a node was created (obtained from the filename)" (format "<%s>" (file-name-sans-extension (file-name-nondirectory (org-roam-node-file node))))) + + (org-roam-ql-defpred + 'date-range + "Check if node was created in given time range" + #'org-roam-node-date + #'(lambda (node-date start-date end-date) + (let ((node-date (condition-case nil + ;; if the entry is not from the journal (i.e. the filename is not something like "2024-10-10.org") + ;; then it's always discarded (the epoch time is given to it) + (encode-time (org-parse-time-string node-date)) + (error (encode-time (org-parse-time-string "<1970-01-01>"))))) + (start-date (encode-time (org-parse-time-string start-date))) + (end-date (encode-time (org-parse-time-string end-date)))) + (and (time-less-p start-date node-date) + (time-less-p node-date end-date))) + )) - (defun ccr/org-roam-spent-hours (client) + (defun ccr/org-roam-spent-hours (client &optional date-start date-end) "Return the total spent hours on something (usually a client)" - (apply #'+(mapcar #'org-roam-node-spent (org-roam-ql-nodes `(tags ,client "billable"))))) - ) + (let* ((query-tags `(tags ,client "billable")) + (query (if (and date-start date-end) + `(and ,query-tags (date-range ,date-start ,date-end)) + query-tags))) + (apply #'+(mapcar #'org-roam-node-spent (org-roam-ql-nodes query)))))) (use-package org-roam-ql :after org-roam From 45aa2c98fd3ff1050c89a7a60477626f56a04bf4 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:19:54 +0100 Subject: [PATCH 2/8] Remove aerc stuff --- hmModules/email/default.nix | 306 ++++++++++++++++++------------------ 1 file changed, 153 insertions(+), 153 deletions(-) diff --git a/hmModules/email/default.nix b/hmModules/email/default.nix index 5ae160a..ab37b05 100644 --- a/hmModules/email/default.nix +++ b/hmModules/email/default.nix @@ -22,183 +22,183 @@ ); }; - home.file.".config/aerc/stylesets" = - let - catppuccin-aerc = pkgs.fetchFromGitHub { - owner = "catppuccin"; - repo = "aerc"; - rev = "ca404a9f2d125ef12db40db663d43c9d94116a05"; - hash = "sha256-OWIkHsKFts/zkrDUtbBPXHVSrHL/F0v3LB1rnlFAKmE="; - }; - in - { - source = "${catppuccin-aerc}/dist"; - recursive = true; - }; + # home.file.".config/aerc/stylesets" = + # let + # catppuccin-aerc = pkgs.fetchFromGitHub { + # owner = "catppuccin"; + # repo = "aerc"; + # rev = "ca404a9f2d125ef12db40db663d43c9d94116a05"; + # hash = "sha256-OWIkHsKFts/zkrDUtbBPXHVSrHL/F0v3LB1rnlFAKmE="; + # }; + # in + # { + # source = "${catppuccin-aerc}/dist"; + # recursive = true; + # }; - programs.aerc = { - enable = true; - extraBinds = { - global = { - "" = ":prev-tab"; - "" = ":next-tab"; - "?" = ":help keys"; - }; + # programs.aerc = { + # enable = true; + # extraBinds = { + # global = { + # "" = ":prev-tab"; + # "" = ":next-tab"; + # "?" = ":help keys"; + # }; - messages = { - "h" = ":prev-tab"; - "l" = ":next-tab"; + # messages = { + # "h" = ":prev-tab"; + # "l" = ":next-tab"; - "j" = ":next"; - "" = ":next"; - "" = ":next 50%"; - "" = ":next 100%"; - "" = ":next 100%"; + # "j" = ":next"; + # "" = ":next"; + # "" = ":next 50%"; + # "" = ":next 100%"; + # "" = ":next 100%"; - "k" = ":prev"; - "" = ":prev"; - "" = ":prev 50%"; - "" = ":prev 100%"; - "" = ":prev 100%"; - "g" = ":select 0"; - "G" = ":select -1"; + # "k" = ":prev"; + # "" = ":prev"; + # "" = ":prev 50%"; + # "" = ":prev 100%"; + # "" = ":prev 100%"; + # "g" = ":select 0"; + # "G" = ":select -1"; - "J" = ":next-folder"; - "K" = ":prev-folder"; - "H" = ":collapse-folder"; - "L" = ":expand-folder"; + # "J" = ":next-folder"; + # "K" = ":prev-folder"; + # "H" = ":collapse-folder"; + # "L" = ":expand-folder"; - "v" = ":mark -t"; - "x" = ":mark -t:next"; - "V" = ":mark -v"; + # "v" = ":mark -t"; + # "x" = ":mark -t:next"; + # "V" = ":mark -v"; - "T" = ":toggle-threads"; + # "T" = ":toggle-threads"; - "" = ":view"; - "d" = ":prompt 'Really delete this message?' 'delete-message'"; - "D" = ":delete"; - "A" = ":archive flat"; + # "" = ":view"; + # "d" = ":prompt 'Really delete this message?' 'delete-message'"; + # "D" = ":delete"; + # "A" = ":archive flat"; - "C" = ":compose"; + # "C" = ":compose"; - "rr" = ":reply -a"; - "rq" = ":reply -aq"; - "Rr" = ":reply"; - "Rq" = ":reply -q"; + # "rr" = ":reply -a"; + # "rq" = ":reply -aq"; + # "Rr" = ":reply"; + # "Rq" = ":reply -q"; - "c" = ":cf"; - "$" = ":term"; - "!" = ":term"; - "|" = ":pipe"; + # "c" = ":cf"; + # "$" = ":term"; + # "!" = ":term"; + # "|" = ":pipe"; - "/" = ":search"; - "\\" = ":filter"; - "n" = ":next-result"; - "N" = ":prev-result"; - "" = ":clear"; - }; + # "/" = ":search"; + # "\\" = ":filter"; + # "n" = ":next-result"; + # "N" = ":prev-result"; + # "" = ":clear"; + # }; - "messages:folder=Drafts" = { - "" = ":recall"; - }; + # "messages:folder=Drafts" = { + # "" = ":recall"; + # }; - view = { - "/" = ":toggle-key-passthrough/"; - "q" = ":close"; - "O" = ":open"; - "S" = ":save"; - "|" = ":pipe"; - "D" = ":delete"; - "A" = ":archive flat"; + # view = { + # "/" = ":toggle-key-passthrough/"; + # "q" = ":close"; + # "O" = ":open"; + # "S" = ":save"; + # "|" = ":pipe"; + # "D" = ":delete"; + # "A" = ":archive flat"; - "" = ":open-link "; + # "" = ":open-link "; - "f" = ":forward"; - "rr" = ":reply -a"; - "rq" = ":reply -aq"; - "Rr" = ":reply"; - "Rq" = ":reply -q"; + # "f" = ":forward"; + # "rr" = ":reply -a"; + # "rq" = ":reply -aq"; + # "Rr" = ":reply"; + # "Rq" = ":reply -q"; - "H" = ":toggle-headers"; - "" = ":prev-part"; - "" = ":next-part"; - "J" = ":next"; - "K" = ":prev"; - }; + # "H" = ":toggle-headers"; + # "" = ":prev-part"; + # "" = ":next-part"; + # "J" = ":next"; + # "K" = ":prev"; + # }; - "view::passthrough" = { - "$noinherit" = true; - "$ex" = ""; - "" = ":toggle-key-passthrough"; - }; + # "view::passthrough" = { + # "$noinherit" = true; + # "$ex" = ""; + # "" = ":toggle-key-passthrough"; + # }; - compose = { - "$noinherit" = "true"; - "$ex" = ""; - "" = ":prev-field"; - "" = ":next-field"; - "" = ":switch-account -p"; - "" = ":switch-account -n"; - "" = ":next-field"; - "" = ":prev-tab"; - "" = ":next-tab"; - }; + # compose = { + # "$noinherit" = "true"; + # "$ex" = ""; + # "" = ":prev-field"; + # "" = ":next-field"; + # "" = ":switch-account -p"; + # "" = ":switch-account -n"; + # "" = ":next-field"; + # "" = ":prev-tab"; + # "" = ":next-tab"; + # }; - "compose::editor" = { - "$noinherit" = "true"; - "$ex" = ""; - "" = ":prev-field"; - "" = ":next-field"; - "" = ":prev-tab"; - "" = ":next-tab"; - }; + # "compose::editor" = { + # "$noinherit" = "true"; + # "$ex" = ""; + # "" = ":prev-field"; + # "" = ":next-field"; + # "" = ":prev-tab"; + # "" = ":next-tab"; + # }; - "compose::review" = { - "y" = ":send"; - "n" = ":abort"; - "p" = ":postpone"; - "q" = ":choose -o d discard abort -o p postpone postpone"; - "e" = ":edit"; - "a" = ":attach"; - "d" = ":detach"; - }; + # "compose::review" = { + # "y" = ":send"; + # "n" = ":abort"; + # "p" = ":postpone"; + # "q" = ":choose -o d discard abort -o p postpone postpone"; + # "e" = ":edit"; + # "a" = ":attach"; + # "d" = ":detach"; + # }; - terminal = { - "$noinherit" = "true"; - "$ex" = ""; + # terminal = { + # "$noinherit" = "true"; + # "$ex" = ""; - "" = ":prev-tab"; - "" = ":next-tab"; - }; - }; - extraConfig = { - general.unsafe-accounts-conf = true; - ui = { - styleset-name = "catppuccin-mocha"; - this-day-time-format = ''" 15:04"''; - this-year-time-format = "Mon Jan 02 15:04"; - timestamp-format = "2006-01-02 15:04"; + # "" = ":prev-tab"; + # "" = ":next-tab"; + # }; + # }; + # extraConfig = { + # general.unsafe-accounts-conf = true; + # ui = { + # styleset-name = "catppuccin-mocha"; + # this-day-time-format = ''" 15:04"''; + # this-year-time-format = "Mon Jan 02 15:04"; + # timestamp-format = "2006-01-02 15:04"; - spinner = "[ ⡿ ],[ ⣟ ],[ ⣯ ],[ ⣷ ],[ ⣾ ],[ ⣽ ],[ ⣻ ],[ ⢿ ]"; - border-char-vertical = "┃"; - border-char-horizontal = "━"; - }; - viewer = { - always-show-mime = true; - }; - compose = { - no-attachment-warning = "^[^>]*attach(ed|ment)"; - }; - filters = { - "text/plain" = "colorize"; - "text/html" = "html"; - "text/calendar" = "calendar"; - "message/delivery-status" = "colorize"; - "message/rfc822" = "colorize"; - "image/*" = "${pkgs.catimg}/bin/catimg -"; - }; - }; - }; + # spinner = "[ ⡿ ],[ ⣟ ],[ ⣯ ],[ ⣷ ],[ ⣾ ],[ ⣽ ],[ ⣻ ],[ ⢿ ]"; + # border-char-vertical = "┃"; + # border-char-horizontal = "━"; + # }; + # viewer = { + # always-show-mime = true; + # }; + # compose = { + # no-attachment-warning = "^[^>]*attach(ed|ment)"; + # }; + # filters = { + # "text/plain" = "colorize"; + # "text/html" = "html"; + # "text/calendar" = "calendar"; + # "message/delivery-status" = "colorize"; + # "message/rfc822" = "colorize"; + # "image/*" = "${pkgs.catimg}/bin/catimg -"; + # }; + # }; + # }; programs.notmuch = { enable = true; From f92a7d0bc9f18f34ad67d5c4835819e62fc81171 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:20:03 +0100 Subject: [PATCH 3/8] Use `xterm-direct` in foot (emacs in shell works well now) --- hmModules/foot/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmModules/foot/default.nix b/hmModules/foot/default.nix index e8ac8d3..840b866 100644 --- a/hmModules/foot/default.nix +++ b/hmModules/foot/default.nix @@ -10,7 +10,7 @@ lib.mkMerge [ server.enable = true; settings = { main = { - term = "xterm-256color"; + term = "xterm-direct"; login-shell = "yes"; dpi-aware = "no"; horizontal-letter-offset = "1"; From b97907ebcd0e08780117d72a5d8d8f0244d4e271 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:20:28 +0100 Subject: [PATCH 4/8] Fix atuin when the system doesn't power off properly --- hmModules/shell/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hmModules/shell/default.nix b/hmModules/shell/default.nix index 22ced2b..048a65f 100644 --- a/hmModules/shell/default.nix +++ b/hmModules/shell/default.nix @@ -3,6 +3,7 @@ pkgs, age, hostname, + config, ... }: { @@ -47,13 +48,19 @@ Install = { WantedBy = [ "default.target" ]; }; - Service.ExecStart = "${lib.getExe pkgs.atuin} daemon"; + Service = { + # ExecStartPre = "${lib.getExe' pkgs.toybox "rm"} -f ${config.programs.atuin.settings.daemon.socket_path}"; + ExecStart = "${lib.getExe pkgs.atuin} daemon"; + }; }; programs.atuin = { enable = true; settings = { - daemon.enabled = true; + daemon = { + enabled = true; + socket_path = "/home/ccr/.local/share/atuin/atuin.sock"; # FIXME using ~ or $HOME doesn't work: https://github.com/atuinsh/atuin/issues/2289 + }; auto_sync = true; sync_frequency = "5m"; sync_address = "http://sisko.fleet:8889"; From 04d19cb17d71ddeb567bb36c8d8b2dd0d3e8cd69 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:21:24 +0100 Subject: [PATCH 5/8] Disabling `garmin-collector` --- hosts/default.nix | 1 - hosts/sisko/default.nix | 1 - 2 files changed, 2 deletions(-) diff --git a/hosts/default.nix b/hosts/default.nix index 0498e19..5636017 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -115,7 +115,6 @@ owner = "grafana"; group = "forgejo"; }; - "garmin-collector-environment".owner = "garmin-collector"; }; }; }; diff --git a/hosts/sisko/default.nix b/hosts/sisko/default.nix index 6295c63..7fc9233 100644 --- a/hosts/sisko/default.nix +++ b/hosts/sisko/default.nix @@ -25,7 +25,6 @@ "prometheus-exporters" "loki" "promtail" - "garmin-collector" "restic" "atuin" "immich" From c4a7c09930c31c5ad8e4b3d460e18215b6cd4037 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:21:39 +0100 Subject: [PATCH 6/8] New syncthing id for sisko --- modules/syncthing/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/syncthing/default.nix b/modules/syncthing/default.nix index eb25947..b1b9857 100644 --- a/modules/syncthing/default.nix +++ b/modules/syncthing/default.nix @@ -20,7 +20,7 @@ ]; }; sisko = { - id = "5JYQLMP-KNBMSOE-I452UDU-UTKPXJI-K27X2DI-MSCSRCG-6V54Q6U-NVGXPQA"; + id = "TOC7QXZ-JLB4LYP-VNIJAV5-DCKVGFN-UE45SPX-PPFJHSG-O3UHFCK-2PEMAQ6"; addresses = [ "tcp://sisko.fleet" ]; From aa3ccc9a9d4bec632619db75f50ed9bd32201c40 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:22:25 +0100 Subject: [PATCH 7/8] Fix serial for `sisko` --- hosts/sisko/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hosts/sisko/default.nix b/hosts/sisko/default.nix index 7fc9233..ba45c12 100644 --- a/hosts/sisko/default.nix +++ b/hosts/sisko/default.nix @@ -62,10 +62,18 @@ ]; boot.kernelParams = [ + "earlycon" + "consoleblank=0" "console=tty1" - "console=ttyS0,1500000" + "console=ttyS2,1500000" ]; + systemd.services."serial-getty@ttyS2" = { + enable = true; + wantedBy = [ "getty.target" ]; + serviceConfig.restart = "always"; + }; + environment.persistence."/persist" = { hideMounts = true; directories = [ From 5fe4764f01822479214a7aca9a3c49402b6013bc Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 4 Nov 2024 11:22:37 +0100 Subject: [PATCH 8/8] Stop and restart services during restic backups --- modules/restic/default.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/restic/default.nix b/modules/restic/default.nix index c3ba948..7aedfcd 100644 --- a/modules/restic/default.nix +++ b/modules/restic/default.nix @@ -55,5 +55,19 @@ in ]; timerConfig.OnCalendar = "daily"; timerConfig.RandomizedDelaySec = "1h"; + backupPrepareCommand = '' + ${pkgs.systemd}/bin/systemctl stop podman-* + ${pkgs.systemd}/bin/systemctl stop syncthing + ${pkgs.systemd}/bin/systemctl stop paperless-* + ${pkgs.systemd}/bin/systemctl stop forgejo + ${pkgs.systemd}/bin/systemctl stop home-assistant + ''; + backupCleanupCommand = '' + ${pkgs.systemd}/bin/systemctl start --no-block --all "podman-*" + ${pkgs.systemd}/bin/systemctl start syncthing + ${pkgs.systemd}/bin/systemctl start --no-block --all "paperless-*" + ${pkgs.systemd}/bin/systemctl start forgejo + ${pkgs.systemd}/bin/systemctl start home-assistant + ''; }; }