From dfc0a3728dd2fe9a12e22427eb2b5ba425bfda47 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 12 Aug 2024 17:36:13 +0200 Subject: [PATCH] home/vscode: add timer for extension updates --- home/home.nix | 2 +- .../vscode/auto-update-extensions.nix | 35 +++++++++++++++++++ .../{vscode.nix => vscode/default.nix} | 5 +++ .../extensions}/noop-syslog.c | 0 .../extensions}/vsliveshare.nix | 0 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 home/programs/vscode/auto-update-extensions.nix rename home/programs/{vscode.nix => vscode/default.nix} (99%) rename home/programs/{vscode-extensions => vscode/extensions}/noop-syslog.c (100%) rename home/programs/{vscode-extensions => vscode/extensions}/vsliveshare.nix (100%) diff --git a/home/home.nix b/home/home.nix index 5936541..d454e1c 100644 --- a/home/home.nix +++ b/home/home.nix @@ -39,7 +39,7 @@ in { ./programs/qutebrowser.nix ./programs/rofi.nix ./programs/taskwarrior.nix - ./programs/vscode.nix + ./programs/vscode # ./programs/xmobar ./programs/xmonad ./programs/zathura.nix diff --git a/home/programs/vscode/auto-update-extensions.nix b/home/programs/vscode/auto-update-extensions.nix new file mode 100644 index 0000000..892589c --- /dev/null +++ b/home/programs/vscode/auto-update-extensions.nix @@ -0,0 +1,35 @@ +{ config, lib, ... }: +let + cfg = config.programs.vscode; +in +{ + # TODO: add `dirname` to $PATH upstream + systemd.user.services.update-vscode-extensions = { + Unit = { + Description = "Update vscode extensions"; + }; + + Service = { + Type = "oneshot"; + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + ExecStart = "${lib.getExe cfg.package} --update-extensions"; + }; + }; + + systemd.user.timers.update-vscode-extensions = { + Unit = { + Description = "Update vscode extensions"; + }; + + Timer = { + Unit = "update-vscode-extensions.service"; + OnCalendar = "daily"; + Persistent = true; + }; + + Install = { + WantedBy = [ "timers.target" ]; + }; + }; +} diff --git a/home/programs/vscode.nix b/home/programs/vscode/default.nix similarity index 99% rename from home/programs/vscode.nix rename to home/programs/vscode/default.nix index 6c5e04a..e671ffb 100644 --- a/home/programs/vscode.nix +++ b/home/programs/vscode/default.nix @@ -14,6 +14,11 @@ let configFilePath = "${userDir}/settings.json"; in { + imports = [ + ./auto-update-extensions.nix + # ./extensions + ]; + home.file.${configFilePath} = { target = "${configFilePath}.ro"; onChange = ''install -m660 $(realpath "${configFilePath}.ro") "${configFilePath}"''; diff --git a/home/programs/vscode-extensions/noop-syslog.c b/home/programs/vscode/extensions/noop-syslog.c similarity index 100% rename from home/programs/vscode-extensions/noop-syslog.c rename to home/programs/vscode/extensions/noop-syslog.c diff --git a/home/programs/vscode-extensions/vsliveshare.nix b/home/programs/vscode/extensions/vsliveshare.nix similarity index 100% rename from home/programs/vscode-extensions/vsliveshare.nix rename to home/programs/vscode/extensions/vsliveshare.nix