From 2a3f2210b560af4cea9b8127020c65c953355601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Tue, 28 Jan 2025 13:58:20 +0100 Subject: [PATCH] Add fzgo timer --- home/Mallorea.nix | 26 +++++++++++++++++--------- home/zsh/files/fzgo.zsh | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/home/Mallorea.nix b/home/Mallorea.nix index 89d1e03..1632212 100644 --- a/home/Mallorea.nix +++ b/home/Mallorea.nix @@ -1,11 +1,19 @@ { inputs, config, pkgs, ... }: let + username = "server"; + home_dir = "/home/${username}"; scripts = { disk_check = import ./utils/disk_check.nix { inherit pkgs; }; # vdirsyncer = { # when = "*:0/15"; # script = toString (pkgs.writeShellScript "script" '' ${pkgs.vdirsyncer}/bin/vdirsyncer sync imec/pair ''); # }; + fzgo = { + when = "*:0/5"; + script = toString (pkgs.writeShellScript "script" '' + ${pkgs.zsh}/bin/zsh -c "source ${./zsh/files/fzgo.zsh} && fzgo_update_cache" + ''); + }; mbsync = { when = "*-*-* 00:00:00"; script = toString (pkgs.writeShellScript "script" '' @@ -48,19 +56,19 @@ let }; }; fzgo_paths = [ - "/home/server/.dotfiles" - "/home/server/Containers" - "/home/server/Workspace" - "/home/server/Storage/Thomas" - "/home/server/Storage/Shared" + "${home_dir}/.dotfiles" + "${home_dir}/Workspace" + "${home_dir}/Containers" + "${home_dir}/Storage/Thomas" + "${home_dir}/Storage/Shared" ]; in { - home.username = "server"; - home.homeDirectory = "/home/server"; + home.username = username; + home.homeDirectory = home_dir; nix = { package = pkgs.nix; settings = { - trusted-users = [ "server" ]; + trusted-users = [ username ]; use-xdg-base-directories = true; }; }; @@ -73,7 +81,7 @@ in { (import ./utils/fzgo_links.nix { inherit config pkgs fzgo_paths; }) ./ssh ]; - programs.ssh.matchBlocks."*".identityFile = "/home/server/.secrets/SSH/Mallorea/id_ed25519"; + programs.ssh.matchBlocks."*".identityFile = "${home_dir}/.secrets/SSH/Mallorea/id_ed25519"; home.sessionVariables = { NIX_PATH = "${config.xdg.stateHome}/nix/profiles/channels/"; diff --git a/home/zsh/files/fzgo.zsh b/home/zsh/files/fzgo.zsh index 45a8861..0ac5716 100644 --- a/home/zsh/files/fzgo.zsh +++ b/home/zsh/files/fzgo.zsh @@ -47,7 +47,7 @@ function fzgo_update_cache() { if [ -d "$entry" ]; then out_file="$(echo "$entry" | sed 's\/\|\g')" out_file="$XDG_CACHE_HOME/fzgo/entries/$file_type/$out_file" - mkdir -p "$(dirname \"$out_file\")" + mkdir -p "$(dirname $out_file)" fd . "$entry" -t "$file_type" > "$out_file" fi done