feat: aliases and dekstop switching

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-01-15 19:06:40 -03:00
parent 33530ac1ed
commit 56bd7b1088
7 changed files with 155 additions and 16 deletions

View File

@@ -0,0 +1,14 @@
{ pkgs, config, ... }:
let
cfg = config.desktop;
in
{
imports = [
./scripts/desktop.nix
./scripts/nixi.nix
./scripts/nixx.nix
];
options.desktop = { };
config = { };
}

View File

@@ -0,0 +1,51 @@
{ pkgs, ... }:
let
desktop = pkgs.writeShellScriptBin "desktop" ''
function cat() {
echo $1 | ${pkgs.lolcat}/bin/lolcat
echo ""
}
flakeDir="/home/guz"
function nix-build() {
local env="$2"
if [[ "$env" -ne "" ]]; then
cat "Building the $env desktop!"
sudo nixos-rebuild switch --flake "$flakeDir/.nix#desktop@$env"
else
cat "Building the desktop!"
sudo nixos-rebuild switch --flake "$flakeDir/.nix#desktop@default"
fi
}
# command for switching desktop environments/modes
function desktop-switch() {
local env="$1"
if [[ "$env" == "--build" ]]; then
nix-build $env $2
else
cat "Switching to $1 desktop!"
# this will be used a lot, that's why "test" and --fast is passed
# for building to a new configuration, use nix-build instead
sudo nixos-rebuild test --fast --flake "$flakeDir/.nix#desktop@$env"
fi
}
desktop-switch $1 $2
echo ""
cat "Done!"
echo "Restarting zsh"
exec zsh
'';
in
{
home.packages = [
desktop
];
}

View File

@@ -0,0 +1,19 @@
{ pkgs, ... }:
let
nixi = pkgs.writeShellScriptBin "nixi" ''
# npm-like command for nix
function nix-shell() {
local pkg="$1"
nix shell "nixpkgs#$pkg"
}
nix-shell $1
'';
in
{
home.packages = [
nixi
];
}

View File

@@ -0,0 +1,17 @@
{ pkgs, ... }:
let
nixx = pkgs.writeShellScriptBin "nixx" ''
# npx-like command for nix
function nix-run() {
local pkg="$1"
nix run "nixpkgs#$pkg"
}
nix-run $1
'';
in
{
home.packages = [
nixx
];
}

View File

@@ -3,10 +3,11 @@
{
imports = [
../../modules/home-manager/theme.nix
../../modules/home-manager/config/terminal.nix
../../modules/home-manager/programs/librewolf
./terminal.nix
./wm.nix
./keybinds.nix
./.desktop
];
programs.bash = {

View File

@@ -2,12 +2,12 @@
{
imports = [
../programs/starship.nix
../programs/tmux.nix
../programs/wezterm.nix
../programs/zsh.nix
../../modules/home-manager/programs/starship.nix
../../modules/home-manager/programs/tmux.nix
../../modules/home-manager/programs/wezterm.nix
../../modules/home-manager/programs/zsh.nix
];
options = { };
options.terminal = { };
config = {
starship.enable = true;
starship.enableZsh = true;

View File

@@ -4,24 +4,61 @@ let
cfg = config.zsh;
in
{
options.zsh = {
enable = lib.mkEnableOption "Enable Zsh shell";
options.zsh = with lib; with lib.types; {
enable = mkEnableOption "Enable Zsh shell";
plugins = {
suggestions.enable = lib.mkOption {
type = lib.types.bool;
suggestions.enable = mkOption {
type = bool;
default = true;
};
completion.enable = lib.mkOption {
type = lib.types.bool;
completion.enable = mkOption {
type = bool;
default = true;
};
};
extraConfig = {
init = mkOption {
type = lines;
default = "";
};
beforeComp = mkOption {
type = lines;
default = "";
};
first = mkOption {
type = lines;
default = "";
};
};
loginExtra = mkOption {
type = lines;
default = "";
};
logoutExtra = mkOption {
type = lines;
default = "";
};
variables = mkOption {
type = attrsOf str;
default = { };
};
};
config = lib.mkIf cfg.enable {
programs.zsh.enable = true;
programs.zsh.oh-my-zsh.enable = true;
programs.zsh = {
enable = true;
oh-my-zsh.enable = true;
programs.zsh.enableAutosuggestions = lib.mkIf (cfg.plugins.suggestions.enable) true;
programs.zsh.enableCompletion = lib.mkIf (cfg.plugins.completion.enable) true;
loginExtra = cfg.loginExtra;
logoutExtra = cfg.logoutExtra;
initExtra = cfg.extraConfig.init;
initExtraBeforeCompInit = cfg.extraConfig.beforeComp;
initExtraFirst = cfg.extraConfig.first;
localVariables = cfg.variables;
enableAutosuggestions = lib.mkIf (cfg.plugins.suggestions.enable) true;
enableCompletion = lib.mkIf (cfg.plugins.completion.enable) true;
};
};
}