chore: refactor user modules
This commit is contained in:
25
users/modules/cli/bat.nix
Normal file
25
users/modules/cli/bat.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli.bat;
|
||||
in {
|
||||
options.home.cli.bat.extras = mkEnableOption "Enables extra packages for bat.";
|
||||
config.programs.bat = {
|
||||
enable = true;
|
||||
config = {
|
||||
theme = "Nord";
|
||||
map-syntax = [
|
||||
".spacemacs*:Lisp"
|
||||
];
|
||||
};
|
||||
extraPackages = mkIf cfg.extras (with pkgs.bat-extras; [
|
||||
batman
|
||||
batpipe
|
||||
batgrep
|
||||
]);
|
||||
};
|
||||
}
|
||||
24
users/modules/cli/btop.nix
Normal file
24
users/modules/cli/btop.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{pkgs, ...}: {
|
||||
programs.btop = {
|
||||
enable = true;
|
||||
package = pkgs.btop.override {
|
||||
rocmSupport = true;
|
||||
cudaSupport = true;
|
||||
};
|
||||
settings = {
|
||||
color_theme = "${pkgs.btop}/share/btop/themes/nord.theme";
|
||||
cpu_bottom = false;
|
||||
cpu_sensor = "auto";
|
||||
io_graph_combined = false;
|
||||
io_mode = true;
|
||||
only_physical = true;
|
||||
proc_tree = true;
|
||||
rounded_corners = true;
|
||||
show_disks = true;
|
||||
show_gpu_info = "on";
|
||||
show_uptime = true;
|
||||
theme_background = true;
|
||||
vim_keys = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
29
users/modules/cli/default.nix
Normal file
29
users/modules/cli/default.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli;
|
||||
in {
|
||||
imports = [
|
||||
./bat.nix
|
||||
./btop.nix
|
||||
./direnv.nix
|
||||
./eza.nix
|
||||
./mu.nix
|
||||
./nh.nix
|
||||
./nix-index.nix
|
||||
./scripts
|
||||
./tealdeer.nix
|
||||
./yt-dlp.nix
|
||||
];
|
||||
|
||||
options.home.cli.fullDesktop = mkEnableOption "Enable all optional modules and options";
|
||||
config.home.cli = {
|
||||
bat.extras = mkDefault cfg.fullDesktop;
|
||||
mu.enable = mkDefault cfg.fullDesktop;
|
||||
scripts.enable = mkDefault cfg.fullDesktop;
|
||||
yt-dlp.enable = mkDefault cfg.fullDesktop;
|
||||
};
|
||||
}
|
||||
10
users/modules/cli/direnv.nix
Normal file
10
users/modules/cli/direnv.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
config.global = {
|
||||
load_dotenv = true;
|
||||
hide_env_diff = true;
|
||||
};
|
||||
nix-direnv.enable = true;
|
||||
};
|
||||
}
|
||||
8
users/modules/cli/eza.nix
Normal file
8
users/modules/cli/eza.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
programs.eza = {
|
||||
enable = true;
|
||||
colors = "auto";
|
||||
icons = "auto";
|
||||
git = true;
|
||||
};
|
||||
}
|
||||
11
users/modules/cli/mu.nix
Normal file
11
users/modules/cli/mu.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli.mu;
|
||||
in {
|
||||
options.home.cli.mu.enable = mkEnableOption "Enable mu";
|
||||
config.programs.mu.enable = cfg.enable;
|
||||
}
|
||||
20
users/modules/cli/nh.nix
Normal file
20
users/modules/cli/nh.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli.nh;
|
||||
in {
|
||||
options.home.cli.nh.flake = mkOption {
|
||||
type = types.path;
|
||||
default = "/home/phundrak/.dotfiles";
|
||||
example = "/etc/nixos";
|
||||
};
|
||||
config.programs.nh = {
|
||||
enable = true;
|
||||
clean.enable = true;
|
||||
clean.extraArgs = "--keep-since 15d --keep 5";
|
||||
inherit (cfg) flake;
|
||||
};
|
||||
}
|
||||
10
users/modules/cli/nix-index.nix
Normal file
10
users/modules/cli/nix-index.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{inputs, ...}: {
|
||||
imports = [
|
||||
inputs.nix-index-database.homeModules.nix-index
|
||||
];
|
||||
|
||||
programs = {
|
||||
nix-index.enable = true;
|
||||
nix-index-database.comma.enable = true;
|
||||
};
|
||||
}
|
||||
3
users/modules/cli/scripts/askpass.nix
Normal file
3
users/modules/cli/scripts/askpass.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "askpass" ''
|
||||
${pkgs.wofi}/bin/wofi -d -P -L 1 -p "$(printf $1 | sed s/://)"''
|
||||
3
users/modules/cli/scripts/backup.nix
Normal file
3
users/modules/cli/scripts/backup.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "backup" ''
|
||||
cp -r "$1" "$1.bak.$(date +%Y%m%d%H%M%S)"''
|
||||
15
users/modules/cli/scripts/default.nix
Normal file
15
users/modules/cli/scripts/default.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli.scripts;
|
||||
files = filesystem.listFilesRecursive ./.;
|
||||
scriptFiles = builtins.filter (path: baseNameOf path != "default.nix") files;
|
||||
scripts = map (file: (import file {inherit pkgs config;})) scriptFiles;
|
||||
in {
|
||||
options.home.cli.scripts.enable = mkEnableOption "Add custom scripts to PATH";
|
||||
config.home.packages = mkIf cfg.enable scripts;
|
||||
}
|
||||
3
users/modules/cli/scripts/keygen.nix
Normal file
3
users/modules/cli/scripts/keygen.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "keygen"
|
||||
"tr -cd '[:alnum:]' < /dev/urandom | fold -w 64 | head -n 1 | tr -d '\n'"
|
||||
10
users/modules/cli/scripts/launch-with-emacsclient.nix
Normal file
10
users/modules/cli/scripts/launch-with-emacsclient.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
pkgs.writeShellScriptBin "launch-with-emacsclient" ''
|
||||
filename="$1"
|
||||
line="$2"
|
||||
column="$3"
|
||||
${config.home.dev.editors.emacs.package}/bin/emacsclient +$line:$column "$filename"''
|
||||
3
users/modules/cli/scripts/mp42webm.nix
Normal file
3
users/modules/cli/scripts/mp42webm.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "mp42webm" ''
|
||||
${pkgs.ffmpeg}/bin/ffmpeg -i "$1" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "$1".webm''
|
||||
16
users/modules/cli/scripts/plock.nix
Normal file
16
users/modules/cli/scripts/plock.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "plock" ''
|
||||
TMPBG="/tmp/screen.png"
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
SCREENER=${pkgs.grim}/bin/grim
|
||||
LOCKER="${pkgs.swaylock}/bin/swaylock -feF"
|
||||
else
|
||||
SCREENER=${pkgs.scrot}/bin/scrot
|
||||
LOCKER="${pkgs.i3lock}/bin/i3lock -ef"
|
||||
fi
|
||||
|
||||
$SCREENER "$TMPBG"
|
||||
${pkgs.corrupter}/bin/corrupter -add 0 "$TMPBG" "$TMPBG"
|
||||
$LOCKER -ti "$TMPBG"
|
||||
rm "$TMPBG"
|
||||
''
|
||||
18
users/modules/cli/scripts/rofi-emoji.nix
Normal file
18
users/modules/cli/scripts/rofi-emoji.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "rofi-emoji" ''
|
||||
SELECTED_EMOJI=$(grep -v "#" ~/.config/emoji | ${pkgs.wofi}/bin/wofi --dmenu -p "Select emoji" -i | awk '{print $1}' | tr -d '\n')
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
printf "%s" "$SELECTED_EMOJI" | ${pkgs.wl-clipboard-rs}/bin/wl-copy
|
||||
else
|
||||
printf "%s" "$SELECTED_EMOJI" | ${pkgs.xclip}/bin/xclip -sel clip
|
||||
fi
|
||||
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]
|
||||
then EMOJI=$(${pkgs.wl-clipboard-rs}/bin/wl-paste)
|
||||
else EMOJI=$(${pkgs.xclip}/bin/xclip -o)
|
||||
fi
|
||||
|
||||
test -z "$EMOJI" && notify-send "No emoji copied" -u low && exit
|
||||
EMOJI="$EMOJI copied to clipboard"
|
||||
${pkgs.libnotify}/bin/notify-send -u low "$EMOJI"
|
||||
''
|
||||
56
users/modules/cli/scripts/screenshot.nix
Normal file
56
users/modules/cli/scripts/screenshot.nix
Normal file
@@ -0,0 +1,56 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "screenshot" ''
|
||||
OUTFILE_BASE="$HOME/Pictures/Screenshots/Screenshot_$(date +%Y-%m-%d_%H.%M.%S)"
|
||||
OUTFILE="$OUTFILE_BASE.png"
|
||||
SUFFIX=0
|
||||
|
||||
while getopts ':cd:egs' OPTION; do
|
||||
case "$OPTION" in
|
||||
c )
|
||||
COPY="yes"
|
||||
;;
|
||||
d )
|
||||
DELAY="$OPTARG"
|
||||
;;
|
||||
e )
|
||||
EDIT="yes"
|
||||
;;
|
||||
g )
|
||||
GIMP="yes"
|
||||
;;
|
||||
s )
|
||||
SELECT="yes"
|
||||
;;
|
||||
? )
|
||||
echo "Usage: $(basename "$0") [-c] [-d DELAY] [-e] [-g] [-s]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$SELECT" = "yes" ]; then
|
||||
AREA="$(${pkgs.slurp}/bin/slurp)"
|
||||
fi
|
||||
|
||||
if [ -n "$DELAY" ]; then
|
||||
sleep "$DELAY"
|
||||
fi
|
||||
|
||||
if [ "$SELECT" = "yes" ]; then
|
||||
${pkgs.grim}/bin/grim -g "$AREA" "$OUTFILE"
|
||||
else
|
||||
${pkgs.grim}/bin/grim "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$EDIT" = "yes" ];then
|
||||
${pkgs.swappy}/bin/swappy -f "$OUTFILE" -o "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$GIMP" = "yes" ]; then
|
||||
${pkgs.gimp}/bin/gimp "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$COPY" = "yes" ]; then
|
||||
${pkgs.wl-clipboard-rs}/bin/wl-copy < "$OUTFILE"
|
||||
fi
|
||||
''
|
||||
3
users/modules/cli/scripts/sshbind.nix
Normal file
3
users/modules/cli/scripts/sshbind.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "sshbind" ''
|
||||
ssh -L "$1:$3:$1" "$2" -N''
|
||||
16
users/modules/cli/scripts/ytplay.nix
Normal file
16
users/modules/cli/scripts/ytplay.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "ytplay" ''
|
||||
URL=$(${pkgs.wofi}/bin/wofi --dmenu -i -p "Video URL")
|
||||
if [ -z "$URL" ]; then
|
||||
echo "You need to provide a URL"
|
||||
exit 1
|
||||
fi
|
||||
RESOLUTION_CHOICE=$(${pkgs.yt-dlp}/bin/yt-dlp --list-formats "$URL" | \
|
||||
grep -E "webm.*[0-9]+x[0-9]" | \
|
||||
awk '{print $3 " " $1}' | \
|
||||
sort -gu | \
|
||||
${pkgs.wofi}/bin/wofi --dmenu -i -p "Resolution")
|
||||
mapfile -t RESOLUTION <<< "$RESOLUTION_CHOICE"
|
||||
RESOLUTION_CODE=''${RESOLUTION[0]}
|
||||
${pkgs.mpv}/bin/mpv --ytdl-format="''${RESOLUTION_CODE}+bestaudio/best" "$URL"
|
||||
''
|
||||
6
users/modules/cli/tealdeer.nix
Normal file
6
users/modules/cli/tealdeer.nix
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
programs.tealdeer = {
|
||||
enable = true;
|
||||
enableAutoUpdates = true;
|
||||
};
|
||||
}
|
||||
18
users/modules/cli/yt-dlp.nix
Normal file
18
users/modules/cli/yt-dlp.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.cli.yt-dlp;
|
||||
in {
|
||||
options.home.cli.yt-dlp.enable = mkEnableOption "Enable yt-dlp";
|
||||
config.programs.yt-dlp = mkIf cfg.enable {
|
||||
inherit (cfg) enable;
|
||||
settings = {
|
||||
embed-thumbnail = true;
|
||||
embed-subs = true;
|
||||
sub-langs = "all";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user