Implemented custom system for creating and distributing color schemes based on wallpapers, and also cycling through wallpapers.
nixfmt'd the codebase
This commit is contained in:
@@ -1,91 +1,94 @@
|
||||
{ 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 []
|
||||
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 = []
|
||||
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")
|
||||
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)
|
||||
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})
|
||||
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"{pname} is up to date.\n")
|
||||
print(f"Failed to check version for {pname} (HTTP {response.status_code}).\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
|
||||
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"])
|
||||
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)
|
||||
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 = ":";
|
||||
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 = ":";
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
{ super, host, root }:
|
||||
{
|
||||
super,
|
||||
host,
|
||||
root,
|
||||
}:
|
||||
|
||||
{
|
||||
fetchfromgh = super.callPackage ./templates/fetchfromgh.nix {};
|
||||
mkshell = super.callPackage ./templates/mkshell.nix {};
|
||||
garbage-collect = super.callPackage ./garbage-collect.nix {};
|
||||
check_updates = super.callPackage ./check_updates.nix {};
|
||||
rebuild = super.callPackage ./rebuild.nix { inherit host; self = root; };
|
||||
fetchfromgh = super.callPackage ./templates/fetchfromgh.nix { };
|
||||
mkshell = super.callPackage ./templates/mkshell.nix { };
|
||||
garbage-collect = super.callPackage ./garbage-collect.nix { };
|
||||
check_updates = super.callPackage ./check_updates.nix { };
|
||||
rebuild = super.callPackage ./rebuild.nix {
|
||||
inherit host;
|
||||
self = root;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{ host, self, pkgs, }:
|
||||
{
|
||||
host,
|
||||
self,
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellApplication {
|
||||
name = "rebuild";
|
||||
runtimeInputs = [
|
||||
@@ -30,11 +34,8 @@ pkgs.writeShellApplication {
|
||||
dry=false
|
||||
update=false
|
||||
|
||||
played_start=false
|
||||
|
||||
hooray() { playshellsound "${self}/assets/sound/update.wav"; }
|
||||
damn() { playshellsound "${self}/assets/sound/error.wav"; }
|
||||
start() { [ "$played_start" = false ] && playshellsound "${self}/assets/sound/nixswitch-start.wav" && played_start=true || true; }
|
||||
update_done() { playshellsound "${self}/assets/sound/update_alt.wav"; }
|
||||
|
||||
usage="\033[1;4;38;2;243;139;168mUsage\033[0m: rebuild -h for home config, rebuild -s for sys config, rebuild -a for both. Including 'n' with the flag does a dry run, i.e. rebuild -nh"
|
||||
@@ -49,10 +50,10 @@ pkgs.writeShellApplication {
|
||||
dry_flag=""
|
||||
[ "$dry" = true ] && dry_flag="-n"
|
||||
|
||||
[ "$update" = true ] && start && (cd "$FLAKEPATH" && nix flake update) && update_done
|
||||
[ "$update" = true ] && (cd "$FLAKEPATH" && nix flake update) && update_done
|
||||
|
||||
[ "$all" = true ] && if sudo sleep 0.1 && start && nh os switch $dry_flag -H "${host}" "$FLAKEPATH" && nh home switch $dry_flag -c "${host}Home" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
[ "$system" = true ] && start && if nh os switch $dry_flag -H "${host}" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
[ "$home" = true ] && start && if nh home switch $dry_flag -c "${host}Home" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
[ "$all" = true ] && if sudo sleep 0.1 && nh os switch $dry_flag -H "${host}" "$FLAKEPATH" && nh home switch $dry_flag -c "${host}Home" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
[ "$system" = true ] && if nh os switch $dry_flag -H "${host}" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
[ "$home" = true ] && if nh home switch $dry_flag -c "${host}Home" "$FLAKEPATH"; then hooray; else damn; fi
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "fetchfromgh";
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mkshell";
|
||||
runtimeInputs = [];
|
||||
runtimeInputs = [ ];
|
||||
text = ''
|
||||
command cat <<EOF
|
||||
devShells.\''${system}.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
];
|
||||
command cat <<EOF
|
||||
devShells.\''${system}.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
];
|
||||
|
||||
shellHook = '''
|
||||
export SHELL=\''${pkgs.zsh}/bin/zsh
|
||||
exec \''${pkgs.zsh}/bin/zsh
|
||||
''';
|
||||
};
|
||||
EOF
|
||||
shellHook = '''
|
||||
export SHELL=\''${pkgs.zsh}/bin/zsh
|
||||
exec \''${pkgs.zsh}/bin/zsh
|
||||
''';
|
||||
};
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user