home/vscode: move extension update timer to separate module
This commit is contained in:
@@ -167,6 +167,7 @@
|
||||
prism-launcher = ./home/modules/programs/prism-launcher;
|
||||
shellAliases = ./home/modules/shellAliases.nix;
|
||||
systemd-tmpfiles = ./home/modules/systemd-tmpfiles.nix;
|
||||
vscode-auto-extension-updater = ./home/modules/programs/vscode/auto-extension-updater.nix;
|
||||
};
|
||||
|
||||
homeConfigurations = {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.vscode;
|
||||
in
|
||||
{
|
||||
options.programs.vscode.autoUpdateExtensions = {
|
||||
enable = lib.mkEnableOption "" // {
|
||||
description = "Whether to automatically update mutably installed vscode extensions.";
|
||||
};
|
||||
|
||||
onCalendar = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "daily";
|
||||
example = "weekly";
|
||||
# TODO: link to systemd manpage for format.
|
||||
description = "How often to update the database.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.enable && cfg.autoUpdateExtensions.enable) {
|
||||
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 = cfg.autoUpdateExtensions.onCalendar;
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.vscode;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
# 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" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -3,10 +3,6 @@ let
|
||||
cfg = config.programs.vscode;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./auto-update-extensions.nix
|
||||
];
|
||||
|
||||
# home.file = let
|
||||
# configDir = {
|
||||
# "vscode" = "Code";
|
||||
@@ -33,6 +29,8 @@ in
|
||||
'';
|
||||
});
|
||||
|
||||
autoUpdateExtensions.enable = true;
|
||||
|
||||
profiles.default = {
|
||||
userSettings = let
|
||||
mapPrefixToSet = prefix: set:
|
||||
|
||||
Reference in New Issue
Block a user