added vipkg, a script that allows you to search for a package name to open the derivation file in nixpkgs/pkgs. Very useful for overriding package attributes.

This commit is contained in:
pagedmov
2024-11-07 13:36:30 -05:00
parent 284984b546
commit 12d357419b
6 changed files with 74 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
{inputs, pkgs, lib, config, username, host, ... }: let {inputs, pkgs, lib, config, self, host, ... }: let
desktop = host == "oganesson"; desktop = host == "oganesson";
screenshot_bind = screenshot_bind =
if desktop if desktop
@@ -10,7 +10,9 @@
"super, insert, exec, grimblast copy area" "super, insert, exec, grimblast copy area"
]; ];
scheme = config.lib.stylix.colors; scheme = config.lib.stylix.colors;
in { in {
options = { options = {
movOpts.hyprlandConfig.enable = lib.mkEnableOption "enables my hyprland config"; movOpts.hyprlandConfig.enable = lib.mkEnableOption "enables my hyprland config";
}; };
@@ -56,7 +58,7 @@ in {
"systemctl --user import-environment &" "systemctl --user import-environment &"
"hash dbus-update-activation-environment 2>/dev/null &" "hash dbus-update-activation-environment 2>/dev/null &"
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP &" "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP &"
"aplay /home/${username}/sound/sys/login.wav &" "aplay ${self}/assets/sound/login.wav &"
]; ];
workspace = workspace =

View File

@@ -1,4 +1,4 @@
{lib, config, pkgs, ... }: {lib, config, pkgs, self, ... }:
let let
extraFigletFonts = pkgs.fetchFromGitHub { extraFigletFonts = pkgs.fetchFromGitHub {

View File

@@ -104,14 +104,14 @@ in {
higher_cutoff_freq = 10000; higher_cutoff_freq = 10000;
method = "pulse"; method = "pulse";
source = "auto"; source = "auto";
hide_on_silence = true; hide_on_silence = false;
stereo = true; stereo = true;
reverse = true; reverse = true;
bar_delimiter = 0; bar_delimiter = 0;
monstercat = false; monstercat = false;
waves = false; waves = false;
noise_reduction = 0.77; noise_reduction = 0.77;
input_delay = 2; input_delay = 1;
format-icons = ["" "" "" "" "" "" "" ""]; format-icons = ["" "" "" "" "" "" "" ""];
}; };
@@ -361,6 +361,7 @@ in {
} }
window#waybar.empty #window { window#waybar.empty #window {
background: none; background: none;
border: none;
} }
#workspaces { #workspaces {

View File

@@ -1,4 +1,3 @@
{ pkgs }:
{ {
programs.nixvim = { programs.nixvim = {
plugins = { plugins = {

View File

@@ -0,0 +1,54 @@
{ 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
# Trim the path to show only package directory and .nix file (e.g., package/default.nix)
results=$(echo "$results" | awk -F"${nixpkgs_toplevel}/pkgs/" '{print $2}')
file=$(echo "$results" | fzf)
full_path="${nixpkgs_toplevel}/pkgs/$file"
# Check if the file contains any non-UTF-8 characters
if grep --color='auto' -P -q "[^\x00-\x7F]" "$full_path"; then
NIXD_FLAGS="--semantic-tokens=false" nvim "$full_path"
else
nvim "$full_path"
fi
else
# Trim the path for the single result case
result_path=$(echo "$results" | awk -F"${nixpkgs_toplevel}/pkgs/" '{print $2}')
full_path="${nixpkgs_toplevel}/pkgs/$result_path"
# Check if the file contains any non-UTF-8 characters
if grep --color='auto' -P -q "[^\x00-\x7F]" "$full_path"; then
NIXD_FLAGS="--semantic-tokens=false" nvim "$full_path"
else
nvim "$full_path"
fi
fi
'';
}

View File

@@ -6,6 +6,7 @@
pkgs, pkgs,
... ...
}: let }: let
vipkg = import ./commands/vipkg.nix { inherit pkgs; };
keyring = import ./wm-controls/keyring.nix { inherit pkgs; }; keyring = import ./wm-controls/keyring.nix { inherit pkgs; };
invoke = import ./commands/invoke.nix { inherit pkgs; }; invoke = import ./commands/invoke.nix { inherit pkgs; };
splash = import ./commands/splash.nix { inherit pkgs; }; splash = import ./commands/splash.nix { inherit pkgs; };
@@ -42,7 +43,9 @@ in {
movOpts.movScripts.nixShortcuts.enable = movOpts.movScripts.nixShortcuts.enable =
lib.mkEnableOption "Enables all Nix shortcut scripts"; lib.mkEnableOption "Enables all Nix shortcut scripts";
# Individual options using scriptOverride or mkEnableOption directly # 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 = movOpts.movScripts.commandScripts.icanhazip.enable =
scriptOverride "Enables the icanhazip command" "commandScripts" "icanhazip"; scriptOverride "Enables the icanhazip command" "commandScripts" "icanhazip";
movOpts.movScripts.commandScripts.invoke.enable = movOpts.movScripts.commandScripts.invoke.enable =
@@ -56,6 +59,7 @@ in {
movOpts.movScripts.commandScripts.viconf.enable = movOpts.movScripts.commandScripts.viconf.enable =
scriptOverride "Enables the viconf command" "commandScripts" "viconf"; scriptOverride "Enables the viconf command" "commandScripts" "viconf";
# Hyprland Controls
movOpts.movScripts.hyprlandControls.chpaper.enable = movOpts.movScripts.hyprlandControls.chpaper.enable =
scriptOverride "Enables the chpaper command" "hyprlandControls" "chpaper"; scriptOverride "Enables the chpaper command" "hyprlandControls" "chpaper";
movOpts.movScripts.hyprlandControls.scheck.enable = movOpts.movScripts.hyprlandControls.scheck.enable =
@@ -72,6 +76,7 @@ in {
scriptOverride "Generates screenshots, and updates the README.md with the current rev hash" "hyprlandControls" "switchmon"; scriptOverride "Generates screenshots, and updates the README.md with the current rev hash" "hyprlandControls" "switchmon";
# Nix Shortcuts
movOpts.movScripts.nixShortcuts.garbage-collect.enable = 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 = movOpts.movScripts.nixShortcuts.nsp.enable =
@@ -81,13 +86,17 @@ in {
}; };
config = lib.mkIf config.movOpts.movScripts.enable { config = lib.mkIf config.movOpts.movScripts.enable {
home.packages = lib.optionals config.movOpts.movScripts.commandScripts.invoke.enable [ invoke ] 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.runbg.enable [ runbg ]
++ lib.optionals config.movOpts.movScripts.commandScripts.icanhazip.enable [ icanhazip ] ++ lib.optionals config.movOpts.movScripts.commandScripts.icanhazip.enable [ icanhazip ]
++ lib.optionals config.movOpts.movScripts.commandScripts.splash.enable [ splash ] ++ lib.optionals config.movOpts.movScripts.commandScripts.splash.enable [ splash ]
++ lib.optionals config.movOpts.movScripts.commandScripts.toolbelt.enable [ toolbelt ] ++ lib.optionals config.movOpts.movScripts.commandScripts.toolbelt.enable [ toolbelt ]
++ lib.optionals config.movOpts.movScripts.commandScripts.viconf.enable [ viconf ] ++ 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.chpaper.enable [ chpaper ]
++ lib.optionals config.movOpts.movScripts.hyprlandControls.scheck.enable [ scheck ] ++ lib.optionals config.movOpts.movScripts.hyprlandControls.scheck.enable [ scheck ]
++ lib.optionals config.movOpts.movScripts.hyprlandControls.chscheme.enable [ chscheme ] ++ lib.optionals config.movOpts.movScripts.hyprlandControls.chscheme.enable [ chscheme ]
@@ -96,6 +105,7 @@ in {
++ lib.optionals config.movOpts.movScripts.hyprlandControls.switchmon.enable [ switchmon ] ++ lib.optionals config.movOpts.movScripts.hyprlandControls.switchmon.enable [ switchmon ]
++ lib.optionals config.movOpts.movScripts.hyprlandControls.mkscreenshots.enable [ mkscreenshots ] ++ lib.optionals config.movOpts.movScripts.hyprlandControls.mkscreenshots.enable [ mkscreenshots ]
# Nix Shortcuts Overrides
++ lib.optionals config.movOpts.movScripts.nixShortcuts.garbage-collect.enable [ garbage-collect ] ++ 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.nsp.enable [ nsp ]
++ lib.optionals config.movOpts.movScripts.nixShortcuts.rebuild.enable [ rebuild ]; ++ lib.optionals config.movOpts.movScripts.nixShortcuts.rebuild.enable [ rebuild ];