mirror of
https://codeberg.org/muon/home.git
synced 2026-07-04 07:59:33 +00:00
Compare commits
No commits in common. "08293858022458d157c56e0cfc1a411cb792da2e" and "1d2696b05ab28adb991b0b22eaca5fb56d21572d" have entirely different histories.
0829385802
...
1d2696b05a
3 changed files with 0 additions and 110 deletions
|
|
@ -17,7 +17,6 @@
|
||||||
./zellij
|
./zellij
|
||||||
./opencode
|
./opencode
|
||||||
./gh.nix
|
./gh.nix
|
||||||
./worktrunk.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
config = lib.mkIf osConfig.mods.desktop.enable {
|
config = lib.mkIf osConfig.mods.desktop.enable {
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,6 @@ in {
|
||||||
enableNushellIntegration = lib.mkIf config.mods.terminal.nushell.enable true;
|
enableNushellIntegration = lib.mkIf config.mods.terminal.nushell.enable true;
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.worktrunk = {
|
|
||||||
enable = true;
|
|
||||||
enableZshIntegration = lib.mkIf config.mods.terminal.zsh.enable true;
|
|
||||||
enableNushellIntegration = lib.mkIf config.mods.terminal.nushell.enable true;
|
|
||||||
};
|
|
||||||
|
|
||||||
home.sessionVariables.EDITOR = "nvim";
|
home.sessionVariables.EDITOR = "nvim";
|
||||||
programs.zsh.sessionVariables = lib.mkIf config.mods.terminal.zsh.enable {
|
programs.zsh.sessionVariables = lib.mkIf config.mods.terminal.zsh.enable {
|
||||||
EDITOR = "nvim";
|
EDITOR = "nvim";
|
||||||
|
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) mkIf types;
|
|
||||||
|
|
||||||
cfg = config.programs.worktrunk;
|
|
||||||
in {
|
|
||||||
options.programs.worktrunk = {
|
|
||||||
enable = lib.mkEnableOption "worktrunk, a CLI tool for managing work sessions";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "worktrunk" {nullable = true;};
|
|
||||||
|
|
||||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption {inherit config;};
|
|
||||||
|
|
||||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption {inherit config;};
|
|
||||||
|
|
||||||
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption {inherit config;};
|
|
||||||
|
|
||||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption {inherit config;};
|
|
||||||
|
|
||||||
shellWrapperName = lib.mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "wt";
|
|
||||||
example = "wt";
|
|
||||||
description = ''
|
|
||||||
Name of the shell wrapper to be called.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
home.packages = mkIf (cfg.package != null) [cfg.package];
|
|
||||||
|
|
||||||
programs = let
|
|
||||||
bashIntegration = ''
|
|
||||||
${cfg.shellWrapperName}() {
|
|
||||||
local directive_file=$(mktemp)
|
|
||||||
WORKTRUNK_DIRECTIVE_FILE="$directive_file" command ${
|
|
||||||
if cfg.shellWrapperName != "wt"
|
|
||||||
then "wt"
|
|
||||||
else "\${WORKTRUNK_BIN:-wt}"
|
|
||||||
} "$@"
|
|
||||||
if [[ -s "$directive_file" ]]; then
|
|
||||||
source "$directive_file"
|
|
||||||
fi
|
|
||||||
rm -f "$directive_file"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
fishIntegration = ''
|
|
||||||
set -l directive_file (mktemp)
|
|
||||||
${
|
|
||||||
if cfg.shellWrapperName != "wt"
|
|
||||||
then ''
|
|
||||||
env WORKTRUNK_DIRECTIVE_FILE=$directive_file wt $argv''
|
|
||||||
else ''
|
|
||||||
set -q WORKTRUNK_BIN; or set -l WORKTRUNK_BIN wt
|
|
||||||
env WORKTRUNK_DIRECTIVE_FILE=$directive_file $WORKTRUNK_BIN $argv''
|
|
||||||
}
|
|
||||||
if test -s "$directive_file"
|
|
||||||
set -l directive (string collect < "$directive_file")
|
|
||||||
eval $directive
|
|
||||||
end
|
|
||||||
command rm -f "$directive_file"
|
|
||||||
'';
|
|
||||||
|
|
||||||
nushellIntegration = ''
|
|
||||||
def --env --wrapped ${cfg.shellWrapperName} [...args] {
|
|
||||||
let directive_file = (mktemp --tmpdir)
|
|
||||||
let worktrunk_bin = (${
|
|
||||||
if cfg.shellWrapperName != "wt"
|
|
||||||
then "'wt'"
|
|
||||||
else "$env.WORKTRUNK_BIN? | default 'wt'"
|
|
||||||
})
|
|
||||||
with-env { WORKTRUNK_DIRECTIVE_FILE: $directive_file } {
|
|
||||||
^$worktrunk_bin ...$args
|
|
||||||
}
|
|
||||||
if ($directive_file | path exists) {
|
|
||||||
let directives = open $directive_file --raw | str trim | lines
|
|
||||||
for directive in $directives {
|
|
||||||
if ($directive | str starts-with "cd '") {
|
|
||||||
let target_dir = $directive | str substring 4..-2
|
|
||||||
cd $target_dir
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rm -f $directive_file
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
|
|
||||||
|
|
||||||
zsh.initContent = mkIf cfg.enableZshIntegration bashIntegration;
|
|
||||||
|
|
||||||
fish.functions.${cfg.shellWrapperName} = mkIf cfg.enableFishIntegration fishIntegration;
|
|
||||||
|
|
||||||
nushell.extraConfig = mkIf cfg.enableNushellIntegration nushellIntegration;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue