formatted all files with nixfmt, added env variable to hold secrets

This commit is contained in:
pagedmov
2024-11-09 16:20:27 -05:00
parent d38da56ba2
commit 2a1ba18c09
93 changed files with 948 additions and 1254 deletions

View File

@@ -2,12 +2,7 @@
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)"

View File

@@ -1,6 +1,4 @@
{
pkgs
}:
{ pkgs }:
pkgs.writeShellApplication {
name = "invoke";
text = ''

View File

@@ -1,12 +1,10 @@
{
pkgs,
}:
{ pkgs, }:
pkgs.writeShellApplication {
name = "runbg";
runtimeInputs = with pkgs; [
coreutils # Provides `basename`, `which`, etc.
bash # Provides the Bash shell
util-linux # Provides `tty`
coreutils # Provides `basename`, `which`, etc.
bash # Provides the Bash shell
util-linux # Provides `tty`
];
text = ''
#!/usr/bin/env bash

View File

@@ -1,13 +1,7 @@
{
pkgs
}:
{ 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"

View File

@@ -1,4 +1,4 @@
{pkgs}:
{ pkgs }:
pkgs.writeShellApplication {
name = "toolbelt";
runtimeInputs = with pkgs; [

View File

@@ -1,12 +1,7 @@
{pkgs}:
{ pkgs }:
pkgs.writeShellApplication {
name = "viconf";
runtimeInputs = with pkgs; [
coreutils
fd
ripgrep
fzf
];
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
text = ''
#!/usr/bin/env bash

View File

@@ -6,15 +6,9 @@ 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

View File

@@ -1,40 +1,32 @@
{
host,
lib,
config,
self,
pkgs,
...
}: let
{ 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; };
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;
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";
movOpts.movScripts.enable =
lib.mkEnableOption "Enables all pagedmov's scripts";
# Enable or disable by group
movOpts.movScripts.commandScripts.enable =
@@ -45,16 +37,20 @@ in {
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.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";
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";
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";
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 =
@@ -66,52 +62,78 @@ in {
movOpts.movScripts.hyprlandControls.scheck.enable =
scriptOverride "Enables the scheck command" "hyprlandControls" "scheck";
movOpts.movScripts.hyprlandControls.chscheme.enable =
scriptOverride "Enables the chscheme command" "hyprlandControls" "chscheme";
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";
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";
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.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";
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";
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 ]
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 ]
# 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 ];
# 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 ];
};
}

View File

@@ -2,37 +2,35 @@
pkgs.writeShellApplication {
name = "fetchfromgh";
runtimeInputs = [
pkgs.nix-prefetch-scripts
];
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"
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
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")
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 '"')
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"
output="\
src = pkgs.fetchFromGitHub {
owner = \"$owner\";
repo = \"$repo\";
rev = \"$rev\";
hash = \"$hash\";
};
"
echo "$output"
'';
}

View File

@@ -1,6 +1,4 @@
{
pkgs
}:
{ pkgs }:
pkgs.writeShellApplication {
name = "garbage-collect";
runtimeInputs = with pkgs; [

View File

@@ -1,6 +1,4 @@
{
pkgs
}:
{ pkgs }:
pkgs.writeShellApplication {
name = "nsp";
text = ''

View File

@@ -1,8 +1,4 @@
{
host,
self,
pkgs,
}:
{ host, self, pkgs, }:
pkgs.writeShellApplication {
name = "rebuild";
text = ''

View File

@@ -1,13 +1,7 @@
{pkgs}:
{ 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

View File

@@ -1,10 +1,7 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "chscheme";
runtimeInputs = with pkgs; [
fzf
coreutils
];
runtimeInputs = with pkgs; [ fzf coreutils ];
text = ''
selected_scheme=$(/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
sed 's/\.yaml//g' | \

View File

@@ -1,6 +1,4 @@
{
pkgs
}:
{ pkgs }:
pkgs.writeShellApplication {
name = "keyring";
runtimeInputs = with pkgs; [

View File

@@ -2,15 +2,7 @@
pkgs.writeShellApplication {
name = "mkscreenshots";
runtimeInputs = with pkgs; [
jq
neofetch
kitty
coreutils
nemo
grimblast
git
];
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."

View File

@@ -1,12 +1,7 @@
{pkgs}:
{ 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

View File

@@ -1,6 +1,4 @@
{
pkgs,
}:
{ pkgs, }:
pkgs.writeShellApplication {
name = "scheck";
text = ''

View File

@@ -1,6 +1,4 @@
{
pkgs,
}:
{ pkgs, }:
pkgs.writeShellApplication {
name = "switchmon";
text = ''