zsh: port to sane.programs

This commit is contained in:
2024-05-18 08:01:06 +00:00
parent c987f13ef0
commit 3361f2bbe7
4 changed files with 232 additions and 238 deletions

View File

@@ -21,7 +21,7 @@
sane.roles.client = true; sane.roles.client = true;
sane.roles.handheld = true; sane.roles.handheld = true;
sane.zsh.showDeadlines = false; # unlikely to act on them when in shell sane.programs.zsh.config.showDeadlines = false; # unlikely to act on them when in shell
sane.services.wg-home.enable = true; sane.services.wg-home.enable = true;
sane.services.wg-home.ip = config.sane.hosts.by-name."moby".wg-home.ip; sane.services.wg-home.ip = config.sane.hosts.by-name."moby".wg-home.ip;

View File

@@ -15,7 +15,7 @@
}; };
sane.roles.build-machine.enable = true; sane.roles.build-machine.enable = true;
sane.zsh.showDeadlines = false; # ~/knowledge doesn't always exist sane.programs.zsh.config.showDeadlines = false; # ~/knowledge doesn't always exist
sane.programs.consoleUtils.suggestedPrograms = [ sane.programs.consoleUtils.suggestedPrograms = [
"consoleMediaUtils" # notably, for go2tv / casting "consoleMediaUtils" # notably, for go2tv / casting
"pcConsoleUtils" "pcConsoleUtils"

View File

@@ -19,27 +19,28 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (lib) mkIf mkMerge mkOption types; cfg = config.sane.programs.zsh;
cfg = config.sane.zsh;
in in
{ {
imports = [ imports = [
./starship.nix ./starship.nix
]; ];
options = {
# TODO: port to sane.programs options sane.programs.zsh = {
sane.zsh = { configOption = with lib; mkOption {
showDeadlines = mkOption { default = {};
type = types.submodule {
options.showDeadlines = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "show upcoming deadlines (from my PKM) upon shell init"; description = "show upcoming deadlines (from my PKM) upon shell init";
}; };
starship = mkOption { options.starship = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "enable starship prompt"; description = "enable starship prompt";
}; };
guiIntegrations = mkOption { options.guiIntegrations = mkOption {
type = types.bool; type = types.bool;
default = config.sane.programs.guiApps.enabled; default = config.sane.programs.guiApps.enabled;
description = '' description = ''
@@ -50,9 +51,6 @@ in
}; };
}; };
config = mkMerge [
({
sane.programs.zsh = {
sandbox.enable = false; # TODO: i could at least sandbox the prompt (starship)! sandbox.enable = false; # TODO: i could at least sandbox the prompt (starship)!
persist.byStore.private = [ persist.byStore.private = [
# we don't need to full zsh dir -- just the history file -- # we don't need to full zsh dir -- just the history file --
@@ -63,7 +61,7 @@ in
fs.".config/zsh/.zshrc".symlink.text = '' fs.".config/zsh/.zshrc".symlink.text = ''
# zsh/prezto complains if zshrc doesn't exist or is empty; # zsh/prezto complains if zshrc doesn't exist or is empty;
# preserve this comment to prevent that from ever happening. # preserve this comment to prevent that from ever happening.
'' + lib.optionalString cfg.showDeadlines '' '' + lib.optionalString cfg.config.showDeadlines ''
${pkgs.sane-scripts.deadlines}/bin/sane-deadlines ${pkgs.sane-scripts.deadlines}/bin/sane-deadlines
'' + '' '' + ''
@@ -109,12 +107,12 @@ in
test -e ~/.profile && source ~/.profile test -e ~/.profile && source ~/.profile
''; '';
}; };
})
(mkIf config.sane.programs.zsh.enabled {
# enable zsh completions
environment.pathsToLink = [ "/share/zsh" ];
programs.zsh = {
# enable zsh completions
environment.pathsToLink = lib.mkIf cfg.enabled [ "/share/zsh" ];
programs.zsh = lib.mkIf cfg.enabled {
enable = true; enable = true;
shellAliases = { shellAliases = {
":q" = "exit"; ":q" = "exit";
@@ -193,12 +191,10 @@ in
''; '';
syntaxHighlighting.enable = true; syntaxHighlighting.enable = true;
vteIntegration = cfg.guiIntegrations; vteIntegration = cfg.config.guiIntegrations;
}; };
# enable a command-not-found hook to show nix packages that might provide the binary typed. # enable a command-not-found hook to show nix packages that might provide the binary typed.
# programs.nix-index.enableZshIntegration = true; # programs.nix-index.enableZshIntegration = lib.mkIf cfg.enabled true;
programs.command-not-found.enable = false; programs.command-not-found.enable = lib.mkIf cfg.enabled false;
})
];
} }

View File

@@ -4,7 +4,7 @@
{ config, lib, pkgs, ...}: { config, lib, pkgs, ...}:
let let
enabled = config.sane.zsh.starship; enabled = config.sane.programs.zsh.config.starship;
toml = pkgs.formats.toml {}; toml = pkgs.formats.toml {};
colors = { colors = {
# colors sorted by the order they appear in the status bar # colors sorted by the order they appear in the status bar
@@ -16,12 +16,11 @@ let
_06_blue = "#33658A"; _06_blue = "#33658A";
}; };
in { in {
config = lib.mkIf config.sane.zsh.starship { sane.programs.zsh.fs = lib.mkIf enabled {
sane.programs.zsh = lib.mkIf enabled { ".config/zsh/.zshrc".symlink.text = ''
fs.".config/zsh/.zshrc".symlink.text = ''
eval "$(${pkgs.starship}/bin/starship init zsh)" eval "$(${pkgs.starship}/bin/starship init zsh)"
''; '';
fs.".config/starship.toml".symlink.target = toml.generate "starship.toml" { ".config/starship.toml".symlink.target = toml.generate "starship.toml" {
format = builtins.concatStringsSep "" [ format = builtins.concatStringsSep "" [
"[](${colors._01_purple})" "[](${colors._01_purple})"
"$os" "$os"
@@ -97,5 +96,4 @@ in {
status.format = "[$symbol]($style)"; status.format = "[$symbol]($style)";
}; };
}; };
};
} }