Merge pull request #4 from pagedMov/script-overlay-refactor

Moved scripts to the overlay folder to be used as packages
This commit is contained in:
2024-11-16 03:44:50 -05:00
committed by GitHub
27 changed files with 200 additions and 175 deletions

View File

@@ -33,19 +33,22 @@
outputs = { self, home-manager, nixpkgs, nur, nixvim, stylix, ... }@inputs: outputs = { self, home-manager, nixpkgs, nur, nixvim, stylix, ... }@inputs:
let let
system = "x86_64-linux"; system = "x86_64-linux";
username = "pagedmov";
nixpkgsConfig = {
allowUnfree = true;
};
in {
homeConfigurations = {
oganessonHome = let host = "oganesson"; in home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ (import ./overlay/overlay.nix) ]; config = nixpkgsConfig;
overlays = [
(import ./overlay/overlay.nix { inherit host; root = self; })
];
}; };
username = "pagedmov";
in {
inherit pkgs;
homeConfigurations = {
oganessonHome = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = { extraSpecialArgs = {
host = "oganesson"; inherit host self username inputs;
inherit self username inputs;
}; };
modules = [ modules = [
@@ -57,11 +60,16 @@
]; ];
}; };
mercuryHome = home-manager.lib.homeManagerConfiguration { mercuryHome = let host = "mercury"; in home-manager.lib.homeManagerConfiguration {
inherit pkgs; pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [
(import ./overlay/overlay.nix { inherit host; root = self; })
];
};
extraSpecialArgs = { extraSpecialArgs = {
host = "mercury"; inherit host self username inputs;
inherit self username inputs;
}; };
modules = [ modules = [
@@ -73,11 +81,16 @@
]; ];
}; };
xenonHome = home-manager.lib.homeManagerConfiguration { xenonHome = let host = "xenon"; in home-manager.lib.homeManagerConfiguration {
inherit pkgs; pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [
(import ./overlay/overlay.nix { inherit host; root = self; })
];
};
extraSpecialArgs = { extraSpecialArgs = {
host = "xenon"; inherit host self username inputs;
inherit self username inputs;
}; };
modules = [ modules = [
@@ -91,10 +104,15 @@
nixosConfigurations = { nixosConfigurations = {
oganesson = nixpkgs.lib.nixosSystem { oganesson = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
host = "oganesson";
inherit self inputs username; inherit self inputs username;
host = "oganesson";
}; };
inherit system; inherit system;
pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [];
};
modules = [ modules = [
./hosts/desktop/config.nix ./hosts/desktop/config.nix
./modules/sys ./modules/sys
@@ -105,10 +123,15 @@
mercury = nixpkgs.lib.nixosSystem { mercury = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
host = "mercury";
inherit self inputs username; inherit self inputs username;
host = "mercury";
}; };
inherit system; inherit system;
pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [];
};
modules = [ modules = [
./hosts/laptop/config.nix ./hosts/laptop/config.nix
./modules/sys ./modules/sys
@@ -119,10 +142,15 @@
xenon = nixpkgs.lib.nixosSystem { xenon = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
host = "xenon";
inherit self inputs username; inherit self inputs username;
host = "xenon";
}; };
inherit system; inherit system;
pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [];
};
modules = [ modules = [
./hosts/server/config.nix ./hosts/server/config.nix
./modules/sys ./modules/sys
@@ -138,6 +166,11 @@
inherit self inputs; inherit self inputs;
}; };
inherit system; inherit system;
pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
overlays = [];
};
modules = [ ./hosts/installer nixvim.nixosModules.nixvim ]; modules = [ ./hosts/installer nixvim.nixosModules.nixvim ];
}; };
}; };

View File

@@ -48,14 +48,6 @@
passConfig.enable = true; passConfig.enable = true;
batConfig.enable = true; batConfig.enable = true;
}; };
# modules/home/scripts
movScripts = {
enable = true;
commandScripts.enable = true;
hyprlandControls.enable = true;
nixShortcuts.enable = true;
};
}; };
dconf.settings = { dconf.settings = {

View File

@@ -1,3 +1,3 @@
{ env, inputs, nixpkgs, config, self, username, host, lib, ... }: { { env, inputs, nixpkgs, config, self, username, host, lib, ... }: {
imports = [ ./programs ./environment ./scripts ./files.nix ]; imports = [ ./programs ./environment ./files.nix ];
} }

View File

@@ -16,6 +16,26 @@ let
cp -r ${extraFigletFonts}/* $out/share/figlet 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 { in {
options = { options = {
movOpts.envConfig.userPkgs.enable = movOpts.envConfig.userPkgs.enable =
@@ -47,6 +67,6 @@ in {
toilet-extrafonts toilet-extrafonts
python3 python3
chafa chafa
]; ] ++ scripts;
}; };
} }

View File

@@ -18,10 +18,6 @@
runbg aplay "$1" runbg aplay "$1"
fi fi
} }
grimblast() {
command grimblast "$@"
playshellsound ${self}/assets/sound/screenshot.wav
}
ssh() { # reverts ssh theme upon returning ssh() { # reverts ssh theme upon returning
command ssh "$@" command ssh "$@"
kitty_ssh_theme kitty_ssh_theme
@@ -33,6 +29,11 @@
kitty @ set-colors -a ~/.config/kitty/default-theme.conf kitty @ set-colors -a ~/.config/kitty/default-theme.conf
fi fi
} }
grimblast() {
if grimblast "$@"; then
playshellsound ${self}/assets/sound/screenshot.wav
fi
}
gitcheckout_sfx() { gitcheckout_sfx() {
if git checkout "$@"; then if git checkout "$@"; then
playshellsound ${self}/assets/sound/gitcheckout.wav playshellsound ${self}/assets/sound/gitcheckout.wav

View File

@@ -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 ];
};
}

View File

@@ -5,7 +5,6 @@
}; };
config = lib.mkIf config.movOpts.sysEnv.nixSettings.enable { config = lib.mkIf config.movOpts.sysEnv.nixSettings.enable {
system.stateVersion = "24.05"; system.stateVersion = "24.05";
nixpkgs.config.allowUnfree = true;
nix = { nix = {
settings = { settings = {
auto-optimise-store = true; auto-optimise-store = true;

View File

@@ -1,8 +1,30 @@
self: super: { { host, root, ... }: self: super:
{
myPkgs = { myPkgs = {
# Packages that I've made # Packages that I've made
tinyfetch = super.callPackage ./tinyfetch/package.nix {}; tinyfetch = super.callPackage ./tinyfetch/package.nix {};
breezex-cursor = super.callPackage ./breezex-cursor/package.nix {}; breezex-cursor = super.callPackage ./breezex-cursor/package.nix {};
check_updates = super.callPackage ./check_updates/package.nix {}; check_updates = super.callPackage ./check_updates/package.nix {};
}; };
myScripts = {
# Scripts written using pkgs.writeShellApplication
icanhazip = super.callPackage ./scripts/commands/icanhazip.nix { pkgs = super; };
invoke = super.callPackage ./scripts/commands/invoke.nix { pkgs = super; };
runbg = super.callPackage ./scripts/commands/runbg.nix { pkgs = super; };
splash = super.callPackage ./scripts/commands/splash.nix { pkgs = super; };
toolbelt = super.callPackage ./scripts/commands/toolbelt.nix { pkgs = super; };
viconf = super.callPackage ./scripts/commands/viconf.nix { pkgs = super; };
vipkg = super.callPackage ./scripts/commands/vipkg.nix { pkgs = super; };
fetchfromgh = super.callPackage ./scripts/nix/fetchfromgh.nix { pkgs = super; };
garbage-collect = super.callPackage ./scripts/nix/garbage-collect.nix { pkgs = super; };
nsp = super.callPackage ./scripts/nix/nsp.nix { pkgs = super; };
rebuild = super.callPackage ./scripts/nix/rebuild.nix { inherit host; self = root; pkgs = super; };
chpaper = super.callPackage ./scripts/wm-controls/chpaper.nix { pkgs = super; };
chscheme = super.callPackage ./scripts/wm-controls/chscheme.nix { pkgs = super; };
keyring = super.callPackage ./scripts/wm-controls/keyring.nix { pkgs = super; };
mkscreenshots = super.callPackage ./scripts/wm-controls/mkscreenshots.nix { pkgs = super; };
moveonscreen = super.callPackage ./scripts/wm-controls/moveonscreen.nix { pkgs = super; };
s_check = super.callPackage ./scripts/wm-controls/s_check.nix { pkgs = super; };
switchmon = super.callPackage ./scripts/wm-controls/switchmon.nix { pkgs = super; };
};
} }

97
overlay/scripts/default.nix Executable file
View File

@@ -0,0 +1,97 @@
{ 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; };
scriptList = [
fetchfromgh
vipkg
keyring
invoke
splash
runbg
icanhazip
garbage-collect
nsp
scheck
switchmon
rebuild
moveonscreen
toolbelt
viconf
chscheme
chpaper
mkscreenshots
];
loadScript = scriptName:
lib.foldl' (acc: dir:
if builtins.pathExists "${dir}/${scriptName}.nix"
then acc // { inherit (import "${dir}/${scriptName}.nix" { inherit pkgs; }) scriptName; }
else acc
) {} scriptList;
in {
options = {
movOpts.enabledScripts =
};
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 ];
};
}