mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: add update-checker [WIP]
This commit is contained in:
parent
bbaee7acd8
commit
2da6d3182d
8 changed files with 141 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
secrets/keys/pubring.kbx
|
||||
secrets/keys/private-keys-v1.d/
|
||||
result
|
||||
|
|
|
|||
|
|
@ -4147,6 +4147,7 @@ As such, I also define three additional overlays:
|
|||
waybarupdate = callPackage ./waybarupdate { };
|
||||
opacitytoggle = callPackage ./opacitytoggle { };
|
||||
fs-diff = callPackage ./fs-diff { };
|
||||
update-checker = callPackage ./update-checker { };
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
|
@ -4558,35 +4559,80 @@ done
|
|||
}
|
||||
#+end_src
|
||||
|
||||
**** update-checker
|
||||
|
||||
#+begin_src shell :tangle scripts/update-checker.sh
|
||||
|
||||
updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')"
|
||||
|
||||
alt="has-updates"
|
||||
if [[ $updates -eq 0 ]]; then
|
||||
alt="updated"
|
||||
fi
|
||||
|
||||
tooltip="System updated"
|
||||
if [[ $updates != 0 ]]; then
|
||||
tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' )
|
||||
fi
|
||||
|
||||
echo "{ \"text\":\"$updates\", \"alt\":\"$alt\", \"tooltip\":\"$tooltip\" }"
|
||||
|
||||
#+end_src
|
||||
|
||||
#+begin_src nix :tangle pkgs/update-checker/default.nix
|
||||
{ writeShellApplication, sway}:
|
||||
|
||||
writeShellApplication {
|
||||
name = "update-checker";
|
||||
text = builtins.readFile ../../scripts/update-checker.sh;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
|
||||
*** Overlays
|
||||
|
||||
#+begin_src nix :tangle overlays/default.nix
|
||||
|
||||
{ inputs, ... }: {
|
||||
additions = final: _prev: import ../pkgs { pkgs = final; };
|
||||
modifications = final: _prev: {
|
||||
# example = prev.example.overrideAttrs (oldAttrs: rec {
|
||||
# ...
|
||||
# });
|
||||
{ inputs, ... }: {
|
||||
additions = final: _prev: import ../pkgs { pkgs = final; };
|
||||
modifications = final: _prev: {
|
||||
vesktop = _prev.vesktop.override {
|
||||
withSystemVencord = true;
|
||||
};
|
||||
|
||||
# river = prev.river.overrideAttrs (oldAttrs: rec {
|
||||
# pname = "river";
|
||||
# version = "git";
|
||||
# src = prev.fetchFromGitHub {
|
||||
# owner = "riverwm";
|
||||
# repo = pname;
|
||||
# rev = "c16628c7f57c51d50f2d10a96c265fb0afaddb02";
|
||||
# hash = "sha256-E3Xtv7JeCmafiNmpuS5VuLgh1TDAbibPtMo6A9Pz6EQ=";
|
||||
# fetchSubmodules = true;
|
||||
# };
|
||||
# });
|
||||
};
|
||||
nerdfonts = _prev.nerdfonts.override {
|
||||
fonts = [ "FiraMono" "FiraCode" "NerdFontsSymbolsOnly" ];
|
||||
};
|
||||
|
||||
nixpkgs-stable = final: _prev: {
|
||||
stable = import inputs.nixpkgs-stable { inherit (final) system; };
|
||||
};
|
||||
}
|
||||
firefox = _prev.firefox.override {
|
||||
nativeMessagingHosts = [
|
||||
_prev.tridactyl-native
|
||||
_prev.browserpass
|
||||
_prev.plasma5Packages.plasma-browser-integration
|
||||
];
|
||||
};
|
||||
|
||||
prismlauncher = _prev.prismlauncher.override {
|
||||
glfw = _prev.glfw-wayland-minecraft;
|
||||
};
|
||||
|
||||
# river = prev.river.overrideAttrs (oldAttrs: rec {
|
||||
# pname = "river";
|
||||
# version = "git";
|
||||
# src = prev.fetchFromGitHub {
|
||||
# owner = "riverwm";
|
||||
# repo = pname;
|
||||
# rev = "c16628c7f57c51d50f2d10a96c265fb0afaddb02";
|
||||
# hash = "sha256-E3Xtv7JeCmafiNmpuS5VuLgh1TDAbibPtMo6A9Pz6EQ=";
|
||||
# fetchSubmodules = true;
|
||||
# };
|
||||
# });
|
||||
};
|
||||
|
||||
nixpkgs-stable = final: _prev: {
|
||||
stable = import inputs.nixpkgs-stable { inherit (final) system; };
|
||||
};
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
|
|
@ -6609,6 +6655,7 @@ Programming languages and default lsp's are defined here: [[#h:0e7e8bea-ec58-499
|
|||
waybarupdate
|
||||
opacitytoggle
|
||||
fs-diff
|
||||
update-checker
|
||||
|
||||
(pkgs.writeScriptBin "project" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
|
|
@ -7593,6 +7640,19 @@ The rest of this configuration is found here:
|
|||
interval = 60;
|
||||
};
|
||||
|
||||
"custom/nix-updates" = {
|
||||
exec = "update-checker";
|
||||
on-click = "update-checker && notify-send 'The system has been updated'";
|
||||
interval = 3600;
|
||||
tooltip = true;
|
||||
return-type = "json";
|
||||
format = "{} {icon} ?";
|
||||
format-icons = {
|
||||
has-updates = "";
|
||||
updated= "";
|
||||
};
|
||||
};
|
||||
|
||||
"group/hardware" = {
|
||||
orientation = "inherit";
|
||||
drawer = {
|
||||
|
|
@ -7603,6 +7663,8 @@ The rest of this configuration is found here:
|
|||
"temperature"
|
||||
"power-profiles-daemon"
|
||||
"custom/left-arrow-light"
|
||||
"custom/left-arrow-dark"
|
||||
"custom/left-arrow-light"
|
||||
"disk"
|
||||
"custom/left-arrow-dark"
|
||||
"memory"
|
||||
|
|
@ -8408,10 +8470,12 @@ This tangles the flake.nix file; This block only needs to be touched when updati
|
|||
nixConfig = {
|
||||
extra-substituters = [
|
||||
"https://nix-community.cachix.org"
|
||||
"https://cache.ngi0.nixos.org/"
|
||||
];
|
||||
|
||||
extra-trusted-public-keys = [
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
"cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA="
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@
|
|||
nixConfig = {
|
||||
extra-substituters = [
|
||||
"https://nix-community.cachix.org"
|
||||
"https://cache.ngi0.nixos.org/"
|
||||
];
|
||||
|
||||
extra-trusted-public-keys = [
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
"cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA="
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ in
|
|||
waybarupdate = callPackage ./waybarupdate { };
|
||||
opacitytoggle = callPackage ./opacitytoggle { };
|
||||
fs-diff = callPackage ./fs-diff { };
|
||||
update-checker = callPackage ./update-checker { };
|
||||
}
|
||||
|
|
|
|||
6
pkgs/update-checker/default.nix
Normal file
6
pkgs/update-checker/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{ writeShellApplication, sway }:
|
||||
|
||||
writeShellApplication {
|
||||
name = "update-checker";
|
||||
text = builtins.readFile ../../scripts/update-checker.sh;
|
||||
}
|
||||
|
|
@ -29,6 +29,19 @@
|
|||
interval = 60;
|
||||
};
|
||||
|
||||
"custom/nix-updates" = {
|
||||
exec = "update-checker";
|
||||
on-click = "update-checker && notify-send 'The system has been updated'";
|
||||
interval = 3600;
|
||||
tooltip = true;
|
||||
return-type = "json";
|
||||
format = "{} {icon} ?";
|
||||
format-icons = {
|
||||
has-updates = "";
|
||||
updated = "";
|
||||
};
|
||||
};
|
||||
|
||||
"group/hardware" = {
|
||||
orientation = "inherit";
|
||||
drawer = {
|
||||
|
|
@ -39,6 +52,8 @@
|
|||
"temperature"
|
||||
"power-profiles-daemon"
|
||||
"custom/left-arrow-light"
|
||||
"custom/left-arrow-dark"
|
||||
"custom/left-arrow-light"
|
||||
"disk"
|
||||
"custom/left-arrow-dark"
|
||||
"memory"
|
||||
|
|
@ -159,6 +174,13 @@
|
|||
on-click-right = "kitty -o confirm_os_window_close=0 btm";
|
||||
|
||||
};
|
||||
"custom/vpn" = {
|
||||
format = "VPN ";
|
||||
exec = "echo '{\"class\": \"connected\"}'";
|
||||
exec-if = "test -d /proc/sys/net/ipv4/conf/tun0";
|
||||
return-type = "json";
|
||||
interval = 5;
|
||||
};
|
||||
battery = {
|
||||
states = {
|
||||
"warning" = 60;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ window#waybar.hidden {
|
|||
animation-direction: alternate;
|
||||
}
|
||||
|
||||
#custom-nix-updates {
|
||||
color: white;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
#custom-outer-right-arrow-dark,
|
||||
#custom-outer-left-arrow-dark {
|
||||
color: @background;
|
||||
|
|
@ -95,16 +100,17 @@ window#waybar.hidden {
|
|||
#power-profiles-daemon,
|
||||
#mpris,
|
||||
#tray {
|
||||
background: @background;
|
||||
background: @background;
|
||||
}
|
||||
|
||||
#network,
|
||||
#custom-vpn,
|
||||
#clock.2,
|
||||
#battery,
|
||||
#cpu,
|
||||
#custom-pseudobat,
|
||||
#disk {
|
||||
background: @background-alt;
|
||||
background: @background-alt;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -130,6 +136,7 @@ window#waybar.hidden {
|
|||
background: @foreground-critical;
|
||||
}
|
||||
|
||||
#custom-vpn,
|
||||
#network {
|
||||
color: #cc99c9;
|
||||
}
|
||||
|
|
@ -220,6 +227,7 @@ window#waybar.hidden {
|
|||
#temperature,
|
||||
#power-profiles-daemon,
|
||||
#network,
|
||||
#custom-vpn,
|
||||
#mpris,
|
||||
#battery,
|
||||
#custom-pseudobat,
|
||||
|
|
|
|||
13
scripts/update-checker.sh
Normal file
13
scripts/update-checker.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')"
|
||||
|
||||
alt="has-updates"
|
||||
if [[ $updates -eq 0 ]]; then
|
||||
alt="updated"
|
||||
fi
|
||||
|
||||
tooltip="System updated"
|
||||
if [[ $updates != 0 ]]; then
|
||||
tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' )
|
||||
fi
|
||||
|
||||
echo "{ \"text\":\"$updates\", \"alt\":\"$alt\", \"tooltip\":\"$tooltip\" }"
|
||||
Loading…
Add table
Add a link
Reference in a new issue