Moved scripts to the overlay folder to be used as packages
All scripts have been moved to the overlay folder in the top level directory Overlay is now instantiated per configuration to make use of the host variable
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
{ env, inputs, nixpkgs, config, self, username, host, lib, ... }: {
|
||||
imports = [ ./programs ./environment ./scripts ./files.nix ];
|
||||
imports = [ ./programs ./environment ./files.nix ];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,26 @@ let
|
||||
cp -r ${extraFigletFonts}/* $out/share/figlet
|
||||
'';
|
||||
});
|
||||
scripts = with pkgs; [
|
||||
myScripts.icanhazip
|
||||
myScripts.invoke
|
||||
myScripts.runbg
|
||||
myScripts.splash
|
||||
myScripts.toolbelt
|
||||
myScripts.viconf
|
||||
myScripts.vipkg
|
||||
myScripts.fetchfromgh
|
||||
myScripts.garbage-collect
|
||||
myScripts.nsp
|
||||
myScripts.rebuild
|
||||
myScripts.chpaper
|
||||
myScripts.chscheme
|
||||
myScripts.keyring
|
||||
myScripts.mkscreenshots
|
||||
myScripts.moveonscreen
|
||||
myScripts.s_check
|
||||
myScripts.switchmon
|
||||
];
|
||||
in {
|
||||
options = {
|
||||
movOpts.envConfig.userPkgs.enable =
|
||||
@@ -47,6 +67,6 @@ in {
|
||||
toilet-extrafonts
|
||||
python3
|
||||
chafa
|
||||
];
|
||||
] ++ scripts;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
runbg aplay "$1"
|
||||
fi
|
||||
}
|
||||
grimblast() {
|
||||
command grimblast "$@"
|
||||
playshellsound ${self}/assets/sound/screenshot.wav
|
||||
}
|
||||
ssh() { # reverts ssh theme upon returning
|
||||
command ssh "$@"
|
||||
kitty_ssh_theme
|
||||
@@ -33,6 +29,11 @@
|
||||
kitty @ set-colors -a ~/.config/kitty/default-theme.conf
|
||||
fi
|
||||
}
|
||||
grimblast() {
|
||||
if grimblast "$@"; then
|
||||
playshellsound ${self}/assets/sound/screenshot.wav
|
||||
fi
|
||||
}
|
||||
gitcheckout_sfx() {
|
||||
if git checkout "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitcheckout.wav
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "icanhazip";
|
||||
runtimeInputs = with pkgs; [ iproute2 curl gawk coreutils ];
|
||||
text = ''
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Public IP: $(curl -s icanhazip.com -4)"
|
||||
ip route | awk '/default/ {print "Default Gateway: " $3} /src/ {print "Local IP: " $9}' | head -n 2
|
||||
else case $1 in
|
||||
"-p" ) echo "Public IP: $(curl -s icanhazip.com -4)";;
|
||||
"-d" ) ip route | awk '/default/ {print $3}';;
|
||||
"-l" ) ip route | awk '/src/ {print $9}';;
|
||||
* ) echo "Options: -p, -d or -l for public ip, default gateway, and local ip respectively"; echo "i.e. icanhazip -p"
|
||||
esac
|
||||
fi
|
||||
'';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "invoke";
|
||||
text = ''
|
||||
cmd="$1"
|
||||
shift
|
||||
nix run nixpkgs#"$cmd" -- "$@"
|
||||
'';
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{ pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "runbg";
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils # Provides `basename`, `which`, etc.
|
||||
bash # Provides the Bash shell
|
||||
util-linux # Provides `tty`
|
||||
];
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[ $# -eq 0 ] && { # $# is number of args
|
||||
echo "$(basename "$0"): missing command" >&2
|
||||
exit 1
|
||||
}
|
||||
prog="$(which "$1")" # see below
|
||||
[ -z "$prog" ] && {
|
||||
echo "$(basename "$0"): unknown command: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
shift # remove $1, now $prog, from args
|
||||
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
|
||||
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
|
||||
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
|
||||
"$prog" "$@" & # $@ is all args
|
||||
'';
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "splash";
|
||||
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"
|
||||
echo
|
||||
echo " NixOS" | toilet -f 3d | lolcat -S 25
|
||||
echo
|
||||
'';
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "toolbelt";
|
||||
runtimeInputs = with pkgs; [
|
||||
cliphist
|
||||
fzf
|
||||
ripgrep
|
||||
gawk
|
||||
wl-clipboard
|
||||
hyprland
|
||||
alsa-utils
|
||||
btop
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
cliphistory() {
|
||||
selection=$(cliphist list | fzf --preview="
|
||||
index=\$(echo {} | awk '{print \$1}'); \
|
||||
mime=\$(cliphist decode \$index | file -i -); \
|
||||
if echo \"\$mime\" | grep -q 'image'; then \
|
||||
echo \$(cliphist list | rg \"^\$index\" | cut -d ' ' -f 2- | fmt -w 30); \
|
||||
else \
|
||||
cliphist decode \"\$index\" | fmt -w 30; \
|
||||
fi" --prompt="> " | awk '{print $1}')
|
||||
[ -z "$selection" ] && return 1
|
||||
cliphist decode "$selection" | wl-copy
|
||||
}
|
||||
btop_cmd() {
|
||||
|
||||
if [ "$(cat /etc/hostname)" = "oganesson" ]; then
|
||||
hyprctl dispatch resizeactive 20% 155% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
else
|
||||
hyprctl dispatch resizeactive exact 60% 68% &&
|
||||
moveonscreen --center &&
|
||||
btop &&
|
||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||
moveonscreen
|
||||
fi
|
||||
}
|
||||
|
||||
running=true
|
||||
|
||||
declare -A commands=(
|
||||
["Change Wallpaper"]="moveonscreen --center && if chpaper; then running=false; else moveonscreen; fi"
|
||||
["Change System Color Scheme"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && if chscheme; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["Open System Monitor"]="btop_cmd"
|
||||
["Open Volume Controls"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && alsamixer && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||
["Open Keyring"]="hyprctl dispatch resizeactive -300 0 && moveonscreen && if keyring; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
["View Clipboard History"]="hyprctl dispatch resizeactive 45% 120% && moveonscreen --center && if cliphistory;then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||
)
|
||||
|
||||
ordered_commands=(
|
||||
"Open Keyring"
|
||||
"Open System Monitor"
|
||||
"Open Volume Controls"
|
||||
"Change Wallpaper"
|
||||
"Change System Color Scheme"
|
||||
"View Clipboard History"
|
||||
)
|
||||
|
||||
# Use fzf to select a command with preview
|
||||
while $running; do
|
||||
selected_command=$(printf "%s\n" "''${ordered_commands[@]}" | fzf --preview="
|
||||
cleaned_key=\$(echo {} | tr -d \"'\"); \
|
||||
echo \"Cleaned key: \$cleaned_key\"; \
|
||||
declare -A descriptions=(
|
||||
[\"Change Wallpaper\"]=\"Choose a wallpaper to switch to from the assets/wallpapers folder in the system flake directory. Requires rebuilding the system and restarting hyprpaper.\"
|
||||
[\"Change System Color Scheme\"]=\"Changes the base16 color scheme used by stylix to color system applications.\"
|
||||
[\"Open System Monitor\"]=\"Opens a btop window.\"
|
||||
[\"Open Volume Controls\"]=\"Opens alsamixer.\"
|
||||
[\"Open Keyring\"]=\"Opens a fuzzy finder with all of the paths held in ~/.password-store. Selecting one uses pass to copy that password to the clipboard. Password is cleared from clipboard after 45 seconds, and isn't saved to clipboard history.\"
|
||||
[\"View Clipboard History\"]=\"Opens clipboard history. Selecting an item copies it to the clipboard.\"
|
||||
); \
|
||||
if [[ -v descriptions[\$cleaned_key] ]]; then \
|
||||
clear; \
|
||||
echo \''${descriptions[\$cleaned_key]} | fmt -w 28; \
|
||||
else \
|
||||
clear; \
|
||||
echo \"No description available\"; \
|
||||
fi" --prompt="> ")
|
||||
|
||||
|
||||
#Execute the selected command if selection is not empty
|
||||
if [[ -n $selected_command ]]; then
|
||||
eval "''${commands[$selected_command]}"
|
||||
else
|
||||
running=false
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "viconf";
|
||||
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[ ! $# -eq 1 ] && echo "Usage: viconf <*.nix>" && exit 1
|
||||
|
||||
results=$(find "$FLAKEPATH" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$')
|
||||
numresults=$(echo "$results" | wc -l)
|
||||
|
||||
[ "$numresults" -eq 0 ] && echo "$1 not found in \$FLAKEPATH" && exit 1
|
||||
|
||||
if [ "$numresults" -gt 1 ]; then
|
||||
# cut up the paths to give shorter path names to fuzzy finder
|
||||
results_prefix=$(echo "$results" | tail -n 1 | cut -d'/' -f-3)
|
||||
results=$(echo "$results" | cut -d'/' -f4-)
|
||||
results=$(echo "$results" | grep "$1")
|
||||
|
||||
file=$(echo "$results" | tr ' ' '\n' | fzf)
|
||||
file="$results_prefix/$file"
|
||||
|
||||
# Check if the file contains any non-UTF-8 characters
|
||||
if grep --color='auto' -P -q "[^\x00-\x7F]" "$file"; then
|
||||
NIXD_FLAGS="--semantic-tokens=false" nvim "$results_prefix"/"$file"
|
||||
else
|
||||
nvim "$file"
|
||||
fi
|
||||
|
||||
else
|
||||
# Check if the file contains any non-UTF-8 characters
|
||||
if grep --color='auto' -P -q "[^\x00-\x7F]" "$results"; then
|
||||
NIXD_FLAGS="--semantic-tokens=false" nvim "$results"
|
||||
else
|
||||
nvim "$results"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
let
|
||||
nixpkgs_toplevel = pkgs.fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
rev = "63dacb46bf939521bdc93981b4cbb7ecb58427a0";
|
||||
hash = "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=";
|
||||
};
|
||||
in pkgs.writeShellApplication {
|
||||
name = "vipkg";
|
||||
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
|
||||
text = ''
|
||||
[ ! $# -eq 1 ] && echo "Usage: vipkg <nixpkgs package name>" && exit 1
|
||||
|
||||
results=$(find "${nixpkgs_toplevel}/pkgs" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$')
|
||||
numresults=$(echo "$results" | wc -l)
|
||||
|
||||
[ "$numresults" -eq 0 ] && echo "$1 not found in ${nixpkgs_toplevel}/pkgs" && exit 1
|
||||
|
||||
if [ "$numresults" -gt 1 ]; then
|
||||
results=$(echo "$results" | awk -F"${nixpkgs_toplevel}/pkgs/" '{print $2}')
|
||||
|
||||
file=$(echo "$results" | fzf)
|
||||
|
||||
full_path="${nixpkgs_toplevel}/pkgs/$file"
|
||||
|
||||
nvim "$full_path"
|
||||
|
||||
else
|
||||
result_path=$(echo "$results" | awk -F"${nixpkgs_toplevel}/pkgs/" '{print $2}')
|
||||
full_path="${nixpkgs_toplevel}/pkgs/$result_path"
|
||||
nvim "$full_path"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
@@ -1,139 +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; };
|
||||
scriptOverride = doc: group: name:
|
||||
lib.mkEnableOption "${doc}" // {
|
||||
default = config.movOpts.movScripts.enable
|
||||
&& config.movOpts.movScripts.${group}.enable;
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
movOpts.movScripts.enable =
|
||||
lib.mkEnableOption "Enables all pagedmov's scripts";
|
||||
|
||||
# Enable or disable by group
|
||||
movOpts.movScripts.commandScripts.enable =
|
||||
lib.mkEnableOption "Enables all command scripts";
|
||||
movOpts.movScripts.hyprlandControls.enable =
|
||||
lib.mkEnableOption "Enables all Hyprland control scripts";
|
||||
movOpts.movScripts.nixShortcuts.enable =
|
||||
lib.mkEnableOption "Enables all Nix shortcut scripts";
|
||||
|
||||
# Command Scripts
|
||||
movOpts.movScripts.commandScripts.vipkg.enable = scriptOverride
|
||||
"Search through the nixpkgs/pkgs directory for a package derivation. Useful for overrides."
|
||||
"commandScripts" "vipkg";
|
||||
movOpts.movScripts.commandScripts.icanhazip.enable =
|
||||
scriptOverride "Enables the icanhazip command" "commandScripts"
|
||||
"icanhazip";
|
||||
movOpts.movScripts.commandScripts.invoke.enable =
|
||||
scriptOverride "Enables the invoke command" "commandScripts" "invoke";
|
||||
movOpts.movScripts.commandScripts.runbg.enable =
|
||||
scriptOverride "Enables the runbg command - written by FrostPhoenix"
|
||||
"commandScripts" "runbg";
|
||||
movOpts.movScripts.commandScripts.splash.enable =
|
||||
scriptOverride "Enables the splash screen when opening a terminal"
|
||||
"commandScripts" "splash";
|
||||
movOpts.movScripts.commandScripts.toolbelt.enable =
|
||||
scriptOverride "Enables the toolbelt command" "commandScripts" "toolbelt";
|
||||
movOpts.movScripts.commandScripts.viconf.enable =
|
||||
scriptOverride "Enables the viconf command" "commandScripts" "viconf";
|
||||
|
||||
# Hyprland Controls
|
||||
movOpts.movScripts.hyprlandControls.chpaper.enable =
|
||||
scriptOverride "Enables the chpaper command" "hyprlandControls" "chpaper";
|
||||
movOpts.movScripts.hyprlandControls.scheck.enable =
|
||||
scriptOverride "Enables the scheck command" "hyprlandControls" "scheck";
|
||||
movOpts.movScripts.hyprlandControls.chscheme.enable =
|
||||
scriptOverride "Enables the chscheme command" "hyprlandControls"
|
||||
"chscheme";
|
||||
movOpts.movScripts.hyprlandControls.keyring.enable =
|
||||
scriptOverride "Enables the keyring command" "hyprlandControls" "keyring";
|
||||
movOpts.movScripts.hyprlandControls.moveonscreen.enable =
|
||||
scriptOverride "Ensures floating windows remain on screen"
|
||||
"hyprlandControls" "moveonscreen";
|
||||
movOpts.movScripts.hyprlandControls.switchmon.enable =
|
||||
scriptOverride "Moves cursor to the center of the second monitor"
|
||||
"hyprlandControls" "switchmon";
|
||||
movOpts.movScripts.hyprlandControls.mkscreenshots.enable = scriptOverride
|
||||
"Generates screenshots, and updates the README.md with the current rev hash"
|
||||
"hyprlandControls" "switchmon";
|
||||
|
||||
# Nix Shortcuts
|
||||
movOpts.movScripts.nixShortcuts.fetchfromgh.enable = scriptOverride
|
||||
"Provides a full pkgs.fetchFromGitHub call from a repository url"
|
||||
"nixShortcuts" "fetchfromgh";
|
||||
movOpts.movScripts.nixShortcuts.garbage-collect.enable =
|
||||
scriptOverride "Enables the garbage-collect script" "nixShortcuts"
|
||||
"garbage-collect";
|
||||
movOpts.movScripts.nixShortcuts.nsp.enable =
|
||||
scriptOverride "Enables nsp as an alias for 'nix-shell -p'" "nixShortcuts"
|
||||
"nsp";
|
||||
movOpts.movScripts.nixShortcuts.rebuild.enable = scriptOverride
|
||||
"Enables rebuild as an alias for 'sudo nixos-rebuild switch'"
|
||||
"nixShortcuts" "rebuild";
|
||||
};
|
||||
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "fetchfromgh";
|
||||
runtimeInputs = [ pkgs.nix-prefetch-scripts ];
|
||||
text = ''
|
||||
if [ $# -ne 1 ] || ! echo "$1" | grep -qE "[A-Za-z0-9_-]+/[A-Za-z0-9_-]+"; then
|
||||
echo "Usage: fetchfromgh someuser/somerepo"
|
||||
echo " - i.e. fetchfromgh pagedMov/nixos-config"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! curl -s -o /dev/null -w "%{http_code}" "https://github.com/$1" | grep -q "200"; then
|
||||
echo "Couldn't find that repository, curl returned 404."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
json=$(nix-prefetch-git --quiet "https://github.com/$1")
|
||||
|
||||
url=$(echo "$json" | jq '.url' | tr -d '"')
|
||||
owner=$(echo "$url" | awk -F'/' '{print $(NF-1)}')
|
||||
repo=$(echo "$url" | awk -F'/' '{print $NF}')
|
||||
rev=$(echo "$json" | jq '.rev' | tr -d '"')
|
||||
hash=$(echo "$json" | jq '.hash' | tr -d '"')
|
||||
|
||||
output="\
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = \"$owner\";
|
||||
repo = \"$repo\";
|
||||
rev = \"$rev\";
|
||||
hash = \"$hash\";
|
||||
};
|
||||
"
|
||||
echo "$output"
|
||||
'';
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "garbage-collect";
|
||||
runtimeInputs = with pkgs; [
|
||||
bash
|
||||
coreutils
|
||||
gnugrep
|
||||
bc
|
||||
alsa-utils
|
||||
findutils
|
||||
nix
|
||||
];
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
|
||||
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
|
||||
select yn in "Yes" "No"; do
|
||||
case $yn in
|
||||
Yes ) echo "Sweeping system..."; scheck && runbg aplay "$HOME/assets/sound/sys/collectgarbage.wav"; break;;
|
||||
No ) echo "Canceling garbage collection."; return;;
|
||||
esac
|
||||
done
|
||||
|
||||
output=$(nix-collect-garbage | tee /dev/tty)
|
||||
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
|
||||
|
||||
# Get the size of the trash folder before deleting
|
||||
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
|
||||
rm_freed=$(du -sm ~/.local/share/Trash/files | awk '{print $1}')
|
||||
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files/* # Verbose output
|
||||
mkdir -p ~/.local/share/Trash/files
|
||||
else
|
||||
rm_freed="0"
|
||||
fi
|
||||
|
||||
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
|
||||
|
||||
units=("MB" "GB" "TB" "PB")
|
||||
divisions=0
|
||||
while [ "$(echo "$total_freed >= 1024.0" | bc -l)" -eq 1 ]; do
|
||||
total_freed=$(echo "scale=2; $total_freed / 1024" | bc -l)
|
||||
divisions=$((divisions + 1))
|
||||
done
|
||||
|
||||
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed ''${units[$divisions]}\033[0m in total"
|
||||
|
||||
scheck && runbg aplay "$HOME/assets/sound/sys/rm.wav"
|
||||
'';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "nsp";
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
nix-shell -p "$@" --run zsh
|
||||
'';
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{ host, self, pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "rebuild";
|
||||
text = ''
|
||||
hooray() { scheck && runbg aplay ${self}/assets/sound/update.wav; }
|
||||
damn() { scheck && runbg aplay ${self}/assets/sound/error.wav; }
|
||||
[ $# -eq 0 ] && echo -e "\033[1;4;38;2;243;139;168mUsage\033[0m: rebuild -h for home config, rebuild -s for sys config, rebuild -a for both. Adding 'n' before the flag does a dry run, i.e. rebuild -nh" && damn && exit 1
|
||||
scheck && runbg aplay ${self}/assets/sound/nixswitch-start.wav
|
||||
case $1 in
|
||||
"-h" ) if nh home switch -c ${host}Home "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
"-s" ) if nh os switch -H ${host} "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
"-a" ) if sudo sleep 0.1 && nh os switch -H ${host} "$FLAKEPATH" && nh home switch -c ${host}Home "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
"-nh" ) if nh home switch -n -c ${host}Home "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
"-ns" ) if nh os switch -n -H ${host} "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
"-na" ) if sudo sleep 0.1 && nh os switch -n -H ${host} "$FLAKEPATH" && nh home switch -n -c ${host}Home "$FLAKEPATH"; then hooray; else damn; fi;;
|
||||
* ) echo -e "\033[1;4;38;2;243;139;168mUsage\033[0m: rebuild -h for home config, rebuild -s for sys config. Adding 'n' before the flag does a dry run, i.e. rebuild -nh" && damn && exit 1;;
|
||||
esac
|
||||
'';
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chpaper";
|
||||
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
|
||||
echo "$paper" | xargs -I {} sed -i '/wallpaper =/s|"[^"]*"|"{}"|' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
||||
echo "Successfully changed wallpaper. Rebuild now?" && \
|
||||
select choice in "Yes" "No"; do
|
||||
case $choice in
|
||||
"Yes")
|
||||
rebuild;systemctl --user restart hyprpaper;exit 0;;
|
||||
"No")
|
||||
echo "Exiting...";exit 0;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "chscheme";
|
||||
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' | \
|
||||
fzf --preview "cat $(nix-build '<nixpkgs>' -A base16-schemes)/share/themes/{}.yaml | \
|
||||
while IFS=\": \" read -r key value; do \
|
||||
if [[ \$key =~ base0[0-9A-F] ]]; then \
|
||||
clean_value=\$(echo \"\$value\" | tr -d '\"'); \
|
||||
r=\$((16#\''${clean_value:0:2})); \
|
||||
g=\$((16#\''${clean_value:2:2})); \
|
||||
b=\$((16#\''${clean_value:4:2})); \
|
||||
printf \"\\033[48;2;%d;%d;%dm %-20s %s \\033[0m\\n\" \$r \$g \$b \$key \$clean_value; \
|
||||
fi; \
|
||||
done")
|
||||
|
||||
if [[ -z "$selected_scheme" ]]; then
|
||||
echo "Aborting color scheme change."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! echo "$selected_scheme" | xargs -I {} sed -i '/^[[:space:]]*scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/modules/sys/environment/stylix.nix; then
|
||||
echo "Failed to change color scheme."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully changed system color scheme. Rebuild now?"
|
||||
select choice in "Yes" "No"; do
|
||||
case $choice in
|
||||
"Yes")
|
||||
rebuild
|
||||
exit 0
|
||||
;;
|
||||
"No")
|
||||
echo "Exiting..."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "keyring";
|
||||
runtimeInputs = with pkgs; [
|
||||
pass
|
||||
findutils
|
||||
ripgrep
|
||||
fzf
|
||||
wl-clipboard
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
# prevent multiple instances, conditional check happens in the hyprland bind
|
||||
touch /tmp/keyringfile
|
||||
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
|
||||
|
||||
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
|
||||
pass_string=$(find "$HOME"/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
|
||||
|
||||
# prevents cliphist from writing passwords to the clipboard history
|
||||
pkill -STOP wl-paste
|
||||
|
||||
# copy password
|
||||
pass -c "$pass_string" > /dev/null
|
||||
echo "Password copied. Clearing clipboard in 10 seconds."
|
||||
|
||||
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
|
||||
nohup bash <<-EOF > /dev/null &
|
||||
sleep 10
|
||||
wl-copy -c
|
||||
pkill -CONT wl-paste
|
||||
EOF
|
||||
|
||||
/run/current-system/sw/bin/rm /tmp/keyringfile
|
||||
sleep 0.5
|
||||
exit 0
|
||||
'';
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mkscreenshots";
|
||||
runtimeInputs = with pkgs; [ jq neofetch 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."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prev_workspace=$(hyprctl activeworkspace -j | jq '.id')
|
||||
|
||||
hyprctl dispatch focusmonitor 0
|
||||
|
||||
screenshotfetch() {
|
||||
neofetch
|
||||
|
||||
kitty @ scroll-window 20-
|
||||
|
||||
exec sleep infinity
|
||||
}
|
||||
|
||||
closewindows() {
|
||||
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
||||
hyprctl dispatch closewindow address:"$addr"
|
||||
done
|
||||
}
|
||||
|
||||
temp_script=$(mktemp)
|
||||
screenshotfetch_var=$(declare -f screenshotfetch)
|
||||
echo "$screenshotfetch_var" > "$temp_script"
|
||||
echo "screenshotfetch" >> "$temp_script"
|
||||
chmod +x "$temp_script"
|
||||
|
||||
hyprctl dispatch workspace 4
|
||||
hyprctl dispatch exec "[float;size 40% 25%;move 1% 66%] kitty bash -c '$temp_script'"
|
||||
hyprctl dispatch exec "[float;size 40% 50%;move 57% 8%] nemo"
|
||||
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.png
|
||||
|
||||
closewindows
|
||||
|
||||
hyprctl dispatch exec 'kitty nvim'
|
||||
hyprctl dispatch exec 'kitty yazi'
|
||||
hyprctl dispatch exec 'kitty'
|
||||
|
||||
sleep 1
|
||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-busy.png
|
||||
|
||||
(
|
||||
cd "$FLAKEPATH"
|
||||
latest_hash=$(git rev-parse HEAD)
|
||||
sed -i "s|\(https://github.com/pagedMov/nixos-config/commit/\)[a-f0-9]\{40\}|\1$latest_hash|" "$FLAKEPATH"/README.md
|
||||
)
|
||||
|
||||
closewindows
|
||||
|
||||
hyprctl dispatch workspace "$prev_workspace"
|
||||
'';
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "moveonscreen";
|
||||
runtimeInputs = with pkgs; [ hyprland jq coreutils gawk ];
|
||||
text = ''
|
||||
center_window=false
|
||||
if [[ ! $# -eq 0 ]] && [[ $1 == "--center" ]]; then
|
||||
center_window=true
|
||||
fi
|
||||
|
||||
cursor_pos=$(hyprctl cursorpos | sed 's/,//')
|
||||
cursor_x=$(echo "$cursor_pos" | awk '{print $1}')
|
||||
cursor_y=$(echo "$cursor_pos" | awk '{print $2}')
|
||||
|
||||
|
||||
window_info=$(hyprctl activewindow -j)
|
||||
window_width=$(echo "$window_info" | jq ".size[0]")
|
||||
window_height=$(echo "$window_info" | jq ".size[1]")
|
||||
|
||||
|
||||
if [ "$center_window" = true ]; then
|
||||
cursor_x=$((cursor_x - window_width / 2))
|
||||
cursor_y=$((cursor_y - window_height / 2))
|
||||
|
||||
if (( cursor_x < 10 )); then
|
||||
cursor_x=10
|
||||
fi
|
||||
if (( cursor_y < 54 )); then
|
||||
cursor_y=54
|
||||
fi
|
||||
fi
|
||||
|
||||
monitors=$(hyprctl monitors -j)
|
||||
|
||||
monitor_x_min=0
|
||||
monitor_x_max=0
|
||||
monitor_y_min=0
|
||||
monitor_y_max=0
|
||||
focused_monitor=-1
|
||||
|
||||
for ((i = 0; i < $(echo "$monitors" | jq 'length'); i++)); do
|
||||
mon_x=$(echo "$monitors" | jq ".[$i].x")
|
||||
mon_y=$(echo "$monitors" | jq ".[$i].y")
|
||||
mon_width=$(echo "$monitors" | jq ".[$i].width")
|
||||
mon_height=$(echo "$monitors" | jq ".[$i].height")
|
||||
is_focused=$(echo "$monitors" | jq ".[$i].focused")
|
||||
|
||||
if [ "$is_focused" = true ]; then
|
||||
monitor_x_min=$((mon_x + 10))
|
||||
monitor_x_max=$((mon_x + mon_width - 10))
|
||||
monitor_y_min=$((mon_y + 10))
|
||||
monitor_y_max=$((mon_y + mon_height - 10))
|
||||
focused_monitor=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$focused_monitor" -eq -1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( cursor_x < monitor_x_min )); then
|
||||
adjusted_x=$monitor_x_min
|
||||
elif (( cursor_x + window_width > monitor_x_max )); then
|
||||
adjusted_x=$((monitor_x_max - window_width))
|
||||
else
|
||||
adjusted_x=$cursor_x
|
||||
fi
|
||||
|
||||
if (( cursor_y < monitor_y_min )); then
|
||||
adjusted_y=$monitor_y_min
|
||||
elif (( cursor_y + window_height > monitor_y_max )); then
|
||||
adjusted_y=$((monitor_y_max - window_height))
|
||||
else
|
||||
adjusted_y=$cursor_y
|
||||
fi
|
||||
|
||||
hyprctl dispatch moveactive exact "$adjusted_x $adjusted_y" > /dev/null 2>&1
|
||||
'';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "scheck";
|
||||
text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
[ "$SOUNDS_ENABLED" -eq 1 ]
|
||||
'';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ pkgs, }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "switchmon";
|
||||
text = ''
|
||||
#!/bin/zsh
|
||||
|
||||
hyprctl dispatch focusmonitor "$(hyprctl -j monitors | jq -r '.[] | select(.focused == false) | .name')"
|
||||
'';
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
};
|
||||
config = lib.mkIf config.movOpts.sysEnv.nixSettings.enable {
|
||||
system.stateVersion = "24.05";
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
nix = {
|
||||
settings = {
|
||||
auto-optimise-store = true;
|
||||
|
||||
Reference in New Issue
Block a user