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,12 +1,12 @@
|
||||
{ super, root }:
|
||||
|
||||
{
|
||||
icanhazip = super.callPackage ./icanhazip.nix {};
|
||||
icanhazip = super.callPackage ./icanhazip.nix { };
|
||||
invoke = super.callPackage ./invoke.nix { self = root; };
|
||||
git-compose = super.callPackage ./git-compose.nix { self = root; };
|
||||
runbg = super.callPackage ./runbg.nix {};
|
||||
splash = super.callPackage ./splash.nix {};
|
||||
toolbelt = super.callPackage ./toolbelt.nix {};
|
||||
viconf = super.callPackage ./viconf.nix {};
|
||||
vipkg = super.callPackage ./vipkg.nix {};
|
||||
runbg = super.callPackage ./runbg.nix { };
|
||||
splash = super.callPackage ./splash.nix { };
|
||||
toolbelt = super.callPackage ./toolbelt.nix { };
|
||||
viconf = super.callPackage ./viconf.nix { };
|
||||
vipkg = super.callPackage ./vipkg.nix { };
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "icanhazip";
|
||||
runtimeInputs = with pkgs; [ iproute2 curl gawk coreutils ];
|
||||
runtimeInputs = with pkgs; [
|
||||
iproute2
|
||||
curl
|
||||
gawk
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Public IP: $(curl -s icanhazip.com -4)"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, }:
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "runbg";
|
||||
runtimeInputs = with pkgs; [
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "splash";
|
||||
runtimeInputs = with pkgs; [ lolcat toilet coreutils ];
|
||||
runtimeInputs = with pkgs; [
|
||||
lolcat
|
||||
toilet
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
echo "NixOS kernel ver. $(uname -a | awk '{print $3}') x86_64 GNU/Linux"
|
||||
date +"%A %B %-d %Y"
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "viconf";
|
||||
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
];
|
||||
text = ''
|
||||
open_file() {
|
||||
file="$1"
|
||||
if grep -Pq "[^\x00-\x7F]" "$file"; then
|
||||
NIXD_FLAGS="--semantic-tokens=false" nvim "$file"
|
||||
NIXD_FLAGS="--semantic-tokens=false" $EDITOR "$file"
|
||||
else
|
||||
nvim "$file"
|
||||
$EDITOR "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
let
|
||||
nixpkgs_toplevel = pkgs.fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
@@ -6,9 +8,15 @@ let
|
||||
rev = "63dacb46bf939521bdc93981b4cbb7ecb58427a0";
|
||||
hash = "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=";
|
||||
};
|
||||
in pkgs.writeShellApplication {
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "vipkg";
|
||||
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
];
|
||||
text = ''
|
||||
[ ! $# -eq 1 ] && echo "Usage: vipkg <nixpkgs package name>" && exit 1
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{ super, root, host }:
|
||||
{
|
||||
super,
|
||||
root,
|
||||
host,
|
||||
}:
|
||||
|
||||
# We need to fold all of these into a single attribute set
|
||||
import ./commands { inherit super root; } //
|
||||
import ./nix { inherit super host root; } //
|
||||
import ./misc { inherit super; } //
|
||||
import ./wm-controls { inherit super; }
|
||||
import ./commands { inherit super root; }
|
||||
// import ./nix { inherit super host root; }
|
||||
// import ./misc { inherit super; }
|
||||
// import ./wm-controls { inherit super; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ super }:
|
||||
|
||||
{
|
||||
color-commit = super.callPackage ./color-commit.nix {};
|
||||
mntstack = super.callPackage ./mntstack.nix {};
|
||||
color-commit = super.callPackage ./color-commit.nix { };
|
||||
mntstack = super.callPackage ./mntstack.nix { };
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mntstack";
|
||||
runtimeInputs = [];
|
||||
runtimeInputs = [ ];
|
||||
text = ''
|
||||
set -e
|
||||
|
||||
|
||||
@@ -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
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chpaper";
|
||||
runtimeInputs = with pkgs; [ chafa fzf ripgrep findutils coreutils ];
|
||||
runtimeInputs = with pkgs; [
|
||||
chafa
|
||||
fzf
|
||||
ripgrep
|
||||
findutils
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
paper="$\{self}/assets/wallpapers/$(find "$FLAKEPATH"/assets/wallpapers -exec basename {} \; | rg "\.\w+$" | fzf --preview "chafa -s 30x40 $FLAKEPATH/assets/wallpapers/{}")"
|
||||
[ "$paper" = "$\{self}/assets/wallpapers/" ] && echo "Cancelling wallpaper change" && exit 1
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chscheme";
|
||||
runtimeInputs = with pkgs; [ base16-schemes fzf coreutils ];
|
||||
runtimeInputs = with pkgs; [
|
||||
base16-schemes
|
||||
fzf
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
selected_scheme=$(/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
|
||||
sed 's/\.yaml//g' | \
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{ super }:
|
||||
|
||||
{
|
||||
chpaper = super.callPackage ./chpaper.nix {};
|
||||
chscheme = super.callPackage ./chscheme.nix {};
|
||||
keyring = super.callPackage ./keyring.nix {};
|
||||
playshellsound = super.callPackage ./playshellsound.nix {};
|
||||
mkscreenshots = super.callPackage ./mkscreenshots.nix {};
|
||||
moveonscreen = super.callPackage ./moveonscreen.nix {};
|
||||
s_check = super.callPackage ./s_check.nix {};
|
||||
switchmon = super.callPackage ./switchmon.nix {};
|
||||
chpaper = super.callPackage ./chpaper.nix { };
|
||||
chscheme = super.callPackage ./chscheme.nix { };
|
||||
keyring = super.callPackage ./keyring.nix { };
|
||||
playshellsound = super.callPackage ./playshellsound.nix { };
|
||||
mkscreenshots = super.callPackage ./mkscreenshots.nix { };
|
||||
moveonscreen = super.callPackage ./moveonscreen.nix { };
|
||||
s_check = super.callPackage ./s_check.nix { };
|
||||
switchmon = super.callPackage ./switchmon.nix { };
|
||||
}
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mkscreenshots";
|
||||
runtimeInputs = with pkgs; [ jq fastfetch kitty coreutils nemo grimblast git ];
|
||||
runtimeInputs = with pkgs; [
|
||||
jq
|
||||
fastfetch
|
||||
kitty
|
||||
coreutils
|
||||
nemo
|
||||
grimblast
|
||||
git
|
||||
];
|
||||
text = ''
|
||||
if [ -n "$(hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4")')" ]; then
|
||||
echo "There are windows in workspace 4. This script uses workspace 4, so move those windows and run it again."
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "moveonscreen";
|
||||
runtimeInputs = with pkgs; [ hyprland jq coreutils gawk ];
|
||||
runtimeInputs = with pkgs; [
|
||||
hyprland
|
||||
jq
|
||||
coreutils
|
||||
gawk
|
||||
];
|
||||
text = ''
|
||||
center_window=false
|
||||
if [[ ! $# -eq 0 ]] && [[ $1 == "--center" ]]; then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, }:
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "scheck";
|
||||
text = ''
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, }:
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "switchmon";
|
||||
text = ''
|
||||
|
||||
Reference in New Issue
Block a user