feat: aliases and dekstop switching
This commit is contained in:
14
hosts/desktop/.desktop/default.nix
Normal file
14
hosts/desktop/.desktop/default.nix
Normal 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 = { };
|
||||
}
|
||||
51
hosts/desktop/.desktop/scripts/desktop.nix
Normal file
51
hosts/desktop/.desktop/scripts/desktop.nix
Normal 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
|
||||
];
|
||||
}
|
||||
|
||||
19
hosts/desktop/.desktop/scripts/nixi.nix
Normal file
19
hosts/desktop/.desktop/scripts/nixi.nix
Normal 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
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
17
hosts/desktop/.desktop/scripts/nixx.nix
Normal file
17
hosts/desktop/.desktop/scripts/nixx.nix
Normal 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
|
||||
];
|
||||
}
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user