home-manager/programs/sesh: init

This commit is contained in:
Gabriel Arazas 2025-02-14 15:03:05 +08:00
parent b61e0d826a
commit 16b3844fad
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
6 changed files with 111 additions and 0 deletions

View File

@ -6,6 +6,7 @@
./programs/borgmatic.nix
./programs/diceware.nix
./programs/nushell.nix
./programs/sesh.nix
./programs/python.nix
./services/archivebox.nix
./services/borgbackup.nix

View File

@ -0,0 +1,62 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.sesh;
settingsFormat = pkgs.formats.toml { };
in
{
# TODO: Add tmux integrations.
options.programs.sesh = {
enable = lib.mkEnableOption "sesh, a smart session manager";
package = lib.mkPackageOption pkgs "sesh" { };
settings = lib.mkOption {
type = settingsFormat.type;
default = { };
description = ''
Program settings to be generated at
{file}`$XDG_CONFIG_HOME/sesh/sesh.toml`.
'';
example = lib.literalExpression ''
{
default_session = {
startup_command = "nvim -c ':Telescope find_files'";
preview_command = "eza --all --git --icons --color=always {}";
};
session = [
{
name = "Downloads";
path = config.xdg.userDirs.downloads;
startup_command = "ls";
}
{
name = "tmux config";
path = "~/c/dotfiles/tmux_config";
startup_command = "nvim tmux.conf";
preview_command = "bat --color=always ~/c/dotfiles/.config/tmux/tmux.conf";
}
];
}
'';
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
warnings = lib.optionals (!config.programs.zoxide.enable || !config.programs.fzf.enable) ''
You haven't enabled Zoxide nor fzf which is recommended to use alongside sesh.
'';
home.packages = [ cfg.package ];
}
(lib.mkIf (cfg.settings != { }) {
xdg.configFile."sesh/sesh.toml".source =
settingsFormat.generate "sesh-user-settings" cfg.settings;
})
]);
}

View File

@ -51,6 +51,7 @@ in import nmt {
tests = builtins.foldl' (a: b: a // (import b)) { } ([
#./programs/borgmatic
./programs/diceware
./programs/sesh
./programs/pipewire
./programs/pop-launcher
./programs/zed-editor

View File

@ -0,0 +1,32 @@
{ config, lib, ... }: {
programs.sesh = {
enable = true;
settings = {
default_session = {
startup_command = "nvim -c ':Telescope find_files'";
preview_command = "eza --all --git --icons --color=always {}";
};
session = [
{
name = "Downloads";
path = config.xdg.userDirs.downloads;
startup_command = "ls";
}
{
name = "tmux config";
path = "~/c/dotfiles/tmux_config";
startup_command = "nvim tmux.conf";
preview_command = "bat --color=always ~/c/dotfiles/.config/tmux/tmux.conf";
}
];
};
};
test.stubs.sesh = { };
nmt.script = ''
assertFileExists home-files/.config/sesh/sesh.toml
'';
}

View File

@ -0,0 +1,4 @@
{
sesh-basic-settings = ./basic.nix;
sesh-empty-settings = ./empty.nix;
}

View File

@ -0,0 +1,11 @@
{ ... }:
{
programs.diceware.enable = true;
test.stubs.sesh = { };
nmt.script = ''
assertPathNotExists home-files/.config/diceware/diceware.ini
'';
}