check_updates now in scripts, removed redundant pkgs argument passage in overlay.nix
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
{ host, lib, config, self, pkgs, ... }:
|
||||
let
|
||||
fetchfromgh = import ./nix/fetchfromgh.nix { inherit pkgs; };
|
||||
vipkg = import ./commands/vipkg.nix { inherit pkgs; };
|
||||
keyring = import ./wm-controls/keyring.nix { inherit pkgs; };
|
||||
invoke = import ./commands/invoke.nix { inherit pkgs; };
|
||||
splash = import ./commands/splash.nix { inherit pkgs; };
|
||||
runbg = import ./commands/runbg.nix { inherit pkgs; };
|
||||
icanhazip = import ./commands/icanhazip.nix { inherit pkgs; };
|
||||
garbage-collect = import ./nix/garbage-collect.nix { inherit pkgs; };
|
||||
nsp = import ./nix/nsp.nix { inherit pkgs; };
|
||||
scheck = import ./wm-controls/s_check.nix { inherit pkgs; };
|
||||
switchmon = import ./wm-controls/switchmon.nix { inherit pkgs; };
|
||||
rebuild = import ./nix/rebuild.nix { inherit host self pkgs; };
|
||||
moveonscreen = import ./wm-controls/moveonscreen.nix { inherit pkgs; };
|
||||
toolbelt = import ./commands/toolbelt.nix { inherit pkgs; };
|
||||
viconf = import ./commands/viconf.nix { inherit pkgs; };
|
||||
chscheme = import ./wm-controls/chscheme.nix { inherit pkgs; };
|
||||
chpaper = import ./wm-controls/chpaper.nix { inherit pkgs; };
|
||||
mkscreenshots = import ./wm-controls/mkscreenshots.nix { inherit pkgs; };
|
||||
scriptList = [
|
||||
fetchfromgh
|
||||
vipkg
|
||||
keyring
|
||||
invoke
|
||||
splash
|
||||
runbg
|
||||
icanhazip
|
||||
garbage-collect
|
||||
nsp
|
||||
scheck
|
||||
switchmon
|
||||
rebuild
|
||||
moveonscreen
|
||||
toolbelt
|
||||
viconf
|
||||
chscheme
|
||||
chpaper
|
||||
mkscreenshots
|
||||
];
|
||||
loadScript = scriptName:
|
||||
lib.foldl' (acc: dir:
|
||||
if builtins.pathExists "${dir}/${scriptName}.nix"
|
||||
then acc // { inherit (import "${dir}/${scriptName}.nix" { inherit pkgs; }) scriptName; }
|
||||
else acc
|
||||
) {} scriptList;
|
||||
in {
|
||||
options = {
|
||||
movOpts.enabledScripts =
|
||||
};
|
||||
|
||||
config = lib.mkIf config.movOpts.movScripts.enable {
|
||||
home.packages =
|
||||
lib.optionals config.movOpts.movScripts.commandScripts.invoke.enable [
|
||||
invoke
|
||||
]
|
||||
# Command Scripts Overrides
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.vipkg.enable
|
||||
[ vipkg ]
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.runbg.enable
|
||||
[ runbg ]
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.icanhazip.enable
|
||||
[ icanhazip ]
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.splash.enable
|
||||
[ splash ]
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.toolbelt.enable
|
||||
[ toolbelt ]
|
||||
++ lib.optionals config.movOpts.movScripts.commandScripts.viconf.enable [
|
||||
viconf
|
||||
]
|
||||
|
||||
# Hyprland Controls Overrides
|
||||
++ lib.optionals config.movOpts.movScripts.hyprlandControls.chpaper.enable
|
||||
[ chpaper ]
|
||||
++ lib.optionals config.movOpts.movScripts.hyprlandControls.scheck.enable
|
||||
[ scheck ] ++ lib.optionals
|
||||
config.movOpts.movScripts.hyprlandControls.chscheme.enable [ chscheme ]
|
||||
++ lib.optionals config.movOpts.movScripts.hyprlandControls.keyring.enable
|
||||
[ keyring ] ++ lib.optionals
|
||||
config.movOpts.movScripts.hyprlandControls.moveonscreen.enable
|
||||
[ moveonscreen ] ++ lib.optionals
|
||||
config.movOpts.movScripts.hyprlandControls.switchmon.enable [ switchmon ]
|
||||
++ lib.optionals
|
||||
config.movOpts.movScripts.hyprlandControls.mkscreenshots.enable [
|
||||
mkscreenshots
|
||||
]
|
||||
|
||||
# Nix Shortcuts Overrides
|
||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.fetchfromgh.enable
|
||||
[ fetchfromgh ] ++ lib.optionals
|
||||
config.movOpts.movScripts.nixShortcuts.garbage-collect.enable
|
||||
[ garbage-collect ]
|
||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.nsp.enable [ nsp ]
|
||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.rebuild.enable
|
||||
[ rebuild ];
|
||||
};
|
||||
}
|
||||
91
overlay/scripts/nix/check_updates.nix
Normal file
91
overlay/scripts/nix/check_updates.nix
Normal file
@@ -0,0 +1,91 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "pkg_maintenance_check";
|
||||
version = "1.0";
|
||||
src = ./.;
|
||||
buildPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/checkupdates.py <<- EOF
|
||||
import json
|
||||
import subprocess
|
||||
import requests
|
||||
def get_packages_by_maintainer(target_maintainer):
|
||||
try:
|
||||
nix_env_command = [
|
||||
"nix-env", "--meta", "--json", "-qaP"
|
||||
]
|
||||
jq_query = (
|
||||
'to_entries[] | select(.value.meta.maintainers? // [] | '
|
||||
f'any(.github == "{target_maintainer}")) | .value'
|
||||
)
|
||||
result = subprocess.run(
|
||||
nix_env_command,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
filtered_packages = subprocess.run(
|
||||
["jq", "-r", "-c", jq_query],
|
||||
input=result.stdout,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
return [json.loads(pkg) for pkg in filtered_packages.stdout.strip().split('\n') if pkg]
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error running nix-env or jq: {e}")
|
||||
return []
|
||||
|
||||
def check_github_releases(maintained_packages):
|
||||
github_api_template = "https://api.github.com/repos/{owner}/{repo}/releases/latest"
|
||||
updates = []
|
||||
|
||||
for package in maintained_packages:
|
||||
pname = package.get("pname", "unknown")
|
||||
repo_url = package.get("meta", {}).get("homepage", "")
|
||||
current_version = package.get("version", "unknown")
|
||||
|
||||
if "github.com" in repo_url:
|
||||
owner_repo = repo_url.split("github.com/")[1].rstrip('/')
|
||||
owner, repo = owner_repo.split('/')
|
||||
api_url = github_api_template.format(owner=owner, repo=repo)
|
||||
|
||||
response = requests.get(api_url)
|
||||
if response.status_code == 200:
|
||||
latest_release = response.json()
|
||||
latest_version = latest_release.get("tag_name", "").lstrip('v')
|
||||
if latest_version and latest_version != current_version:
|
||||
updates.append({"pkg": pname, "version": latest_version})
|
||||
else:
|
||||
print(f"{pname} is up to date.\n")
|
||||
else:
|
||||
print(f"Failed to check version for {pname} (HTTP {response.status_code}).\n")
|
||||
else:
|
||||
print(f"Skipping non-GitHub repository for {pname}.\n")
|
||||
return updates
|
||||
|
||||
def notify_updates(updates):
|
||||
if updates:
|
||||
update_string = '\n'.join([f" {update['pkg']} -> {update['version']}" for update in updates])
|
||||
subprocess.run([
|
||||
"notify-send",
|
||||
"--icon=/home/pagedmov/.sysflake/assets/images/nixos-icon-generic.png",
|
||||
"Maintenance Update",
|
||||
f"Package updates found:\n{update_string}"
|
||||
])
|
||||
subprocess.run(["aplay", "-q", "-N", "/home/pagedmov/.sysflake/assets/sound/login.wav"])
|
||||
|
||||
target_maintainer = "pagedMov"
|
||||
maintained_packages = get_packages_by_maintainer(target_maintainer)
|
||||
|
||||
if maintained_packages:
|
||||
updates = check_github_releases(maintained_packages)
|
||||
notify_updates(updates)
|
||||
else:
|
||||
print(f"No packages maintained by {target_maintainer} were found.")
|
||||
EOF
|
||||
'';
|
||||
buildInputs = with pkgs; [ python3Packages.requests jq ];
|
||||
installPhase = ":";
|
||||
}
|
||||
Reference in New Issue
Block a user