[feat] Update flake.lock and add start-tmux script

This commit is contained in:
Uttarayan
2024-02-15 01:56:27 +05:30
parent 5261d5be5f
commit 58084329f5
3 changed files with 232 additions and 183 deletions

30
config/nix/flake.lock generated
View File

@@ -44,11 +44,11 @@
]
},
"locked": {
"lastModified": 1704982712,
"narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=",
"lastModified": 1706830856,
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "07f6395285469419cf9d078f59b5b49993198c00",
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
"type": "github"
},
"original": {
@@ -125,11 +125,11 @@
]
},
"locked": {
"lastModified": 1707683400,
"narHash": "sha256-Zc+J3UO1Xpx+NL8UB6woPHyttEy9cXXtm+0uWwzuYDc=",
"lastModified": 1707919853,
"narHash": "sha256-qxmBGDzutuJ/tsX4gp+Mr7fjxOZBbeT9ixhS5o4iFOw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "21b078306a2ab68748abf72650db313d646cf2ca",
"rev": "043ba285c6dc20f36441d48525402bcb9743c498",
"type": "github"
},
"original": {
@@ -148,11 +148,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1706140641,
"narHash": "sha256-H1qHhkf7sF7yrG2rb9Ks1Y4EtLY3cXGp16KCGveJWY4=",
"lastModified": 1707868264,
"narHash": "sha256-Ewc5fxKb09XQeO6LeKmko0x7MxKmVCGUYwKq7w8sZD0=",
"owner": "neovim",
"repo": "neovim",
"rev": "4e59422e1d4950a3042bad41a7b81c8db4f8b648",
"rev": "a376d979bda103fa9998d05c3cc4ba56d3c3cece",
"type": "github"
},
"original": {
@@ -171,11 +171,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1706141075,
"narHash": "sha256-o66/XFTXmcJSpEcO508V5r765HtgT8qtr+H4LRIB9BY=",
"lastModified": 1707935913,
"narHash": "sha256-uAkWeyJUNyZS9/u9huCoAJXyTiHw1F+5a91IDujPppk=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "1da2e054a16309d7d7f7669438c8b9a5ef1b4642",
"rev": "b57bf64254630de4920177333f06b341653b1f28",
"type": "github"
},
"original": {
@@ -186,11 +186,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1706006310,
"narHash": "sha256-nDPz0fj0IFcDhSTlXBU2aixcnGs2Jm4Zcuoj0QtmiXQ=",
"lastModified": 1707877513,
"narHash": "sha256-sp0w2apswd3wv0sAEF7StOGHkns3XUQaO5erhWFZWXk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b43bb235efeab5324c5e486882ef46749188eee2",
"rev": "89653a03e0915e4a872788d10680e7eec92f8600",
"type": "github"
},
"original": {

View File

@@ -2,177 +2,178 @@
config,
pkgs,
...
}:
# https://mipmip.github.io/home-manager-option-search/
{
imports = [
# Include the results of the hardware scan.
./tmux.nix
./wezterm.nix
./hyprland.nix
];
programs = {
fish = {
enable = true;
shellAbbrs = {
vim = "nvim";
vi = "nvim";
nv = "nvim";
g = "git";
cd = "z";
ls = "exa";
};
interactiveShellInit = ''
set fish_greeting
${pkgs.macchina.outPath}/bin/macchina
'';
};
nushell = {
enable = true;
shellAliases = {
"cd" = "z";
};
package = pkgs.nushellFull;
configFile.text = ''
$env.config = {
show_banner: false,
}
'';
};
zoxide = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
starship = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
eza = {
enable = true;
enableAliases = true;
git = true;
icons = true;
};
carapace = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
fzf = {
enable = true;
package = pkgs.fzf;
enableFishIntegration = true;
tmux.enableShellIntegration = true;
};
keychain = {
enable = true;
keys = ["id_ed25519"];
enableFishIntegration = true;
enableNushellIntegration = true;
};
yazi = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
foot = {
enable = pkgs.stdenv.isLinux;
server.enable = true;
settings = {
main = {
shell = "${pkgs.fish.outPath}/bin/fish";
font = "Hasklug Nerd Font Mono:size=13";
initial-window-size-pixels = "1440x800";
};
colors = {
foreground = "f8f8f2";
background = 000000;
alpha = 0.8;
"136" = "af8700";
regular0 = "21222c";
regular1 = "ff5555";
regular2 = "50fa7b";
regular3 = "f1fa8c";
regular4 = "bd93f9";
regular5 = "ff79c6";
regular6 = "8be9fd";
regular7 = "f8f8f2";
bright0 = "6272a4";
bright1 = "ff6e6e";
bright2 = "69ff94";
bright3 = "ffffa5";
bright4 = "d6acff";
bright5 = "ff92df";
bright6 = "a4ffff";
bright7 = "ffffff";
};
};
};
# Let Home Manager install and manage itself.
home-manager = {
enable = true;
};
};
home = {
# Home Manager needs a bit of information about you and the paths it should
# manage.
username = "fs0c131y";
homeDirectory = "/home/fs0c131y";
stateVersion = "23.11";
packages = [
pkgs.macchina
pkgs.alejandra
pkgs.neovim-nightly
pkgs.cachix
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
}: let
start-tmux = (import ./scripts/start-tmux.nix) pkgs;
in
# https://mipmip.github.io/home-manager-option-search/
{
imports = [
# Include the results of the hardware scan.
./tmux.nix
./wezterm.nix
./hyprland.nix
];
file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
programs = {
fish = {
enable = true;
shellAbbrs = {
vim = "nvim";
vi = "nvim";
nv = "nvim";
g = "git";
cd = "z";
ls = "exa";
t = "${start-tmux}";
};
interactiveShellInit = ''
set fish_greeting
${pkgs.macchina.outPath}/bin/macchina
'';
};
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
nushell = {
enable = true;
shellAliases = {
"cd" = "z";
};
package = pkgs.nushellFull;
configFile.text = ''
$env.config = {
show_banner: false,
}
'';
};
zoxide = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
starship = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
eza = {
enable = true;
enableAliases = true;
git = true;
icons = true;
};
carapace = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
fzf = {
enable = true;
package = pkgs.fzf;
enableFishIntegration = true;
tmux.enableShellIntegration = true;
};
keychain = {
enable = true;
keys = ["id_ed25519"];
enableFishIntegration = true;
enableNushellIntegration = true;
};
yazi = {
enable = true;
enableFishIntegration = true;
enableNushellIntegration = true;
};
foot = {
enable = pkgs.stdenv.isLinux;
server.enable = true;
settings = {
main = {
shell = "${pkgs.fish.outPath}/bin/fish";
font = "Hasklug Nerd Font Mono:size=13";
initial-window-size-pixels = "1440x800";
};
colors = {
foreground = "f8f8f2";
background = 000000;
alpha = 0.8;
"136" = "af8700";
regular0 = "21222c";
regular1 = "ff5555";
regular2 = "50fa7b";
regular3 = "f1fa8c";
regular4 = "bd93f9";
regular5 = "ff79c6";
regular6 = "8be9fd";
regular7 = "f8f8f2";
bright0 = "6272a4";
bright1 = "ff6e6e";
bright2 = "69ff94";
bright3 = "ffffa5";
bright4 = "d6acff";
bright5 = "ff92df";
bright6 = "a4ffff";
bright7 = "ffffff";
};
};
};
# Let Home Manager install and manage itself.
home-manager = {
enable = true;
};
};
sessionVariables = {
EDITOR = "nvim";
SHELL = "${pkgs.fish.outPath}/bin/fish";
home = {
# Home Manager needs a bit of information about you and the paths it should
# manage.
username = "fs0c131y";
homeDirectory = "/home/fs0c131y";
stateVersion = "23.11";
packages = [
pkgs.macchina
pkgs.alejandra
pkgs.neovim-nightly
pkgs.cachix
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
file = {
".config/tmux/sessions".source = ../tmux/sessions;
".config/nvim".source = ../nvim;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
sessionVariables = {
EDITOR = "nvim";
SHELL = "${pkgs.fish.outPath}/bin/fish";
};
sessionPath = [
"${config.home.homeDirectory}/.local/bin"
"${config.home.homeDirectory}/.nix-profile/bin"
];
};
sessionPath = [
"${config.home.homeDirectory}/.local/bin"
"${config.home.homeDirectory}/.nix-profile/bin"
];
};
}
}

View File

@@ -0,0 +1,48 @@
{
pkgs,
...
}:
pkgs.writeShellScript "start-tmux" ''
live_sessions=$(${pkgs.tmux}/bin/tmux list-sessions 2>/dev/null)
all_sessions=$(${pkgs.findutils}/bin/find -L ~/.config/tmux/sessions -type f -executable -printf '%f\n'| sort)
TMUX_SESSIONS="$HOME/.config/tmux/sessions"
# for some reason ~/.config/tmux/session doesn't work if made with quotes
# TMUX_SESSIONS=$XDG_CONFIG_HOME/tmux/sessions
if ! [ -z "$TMUX" ];then
echo "Nested tmux sessions are a bad idea?"
echo "If you want to really do this unset TMUX environment variable"
exit 1
fi
IFS=$'\n'
for live_session in $live_sessions;do
live_session_name=$(echo $live_session | ${pkgs.coreutils}/bin/cut -d: -f1)
if [ -z "''\${all_sessions##*$live_session_name*}" ];then # see https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash
all_sessions="$(echo "$all_sessions" | sed "s/$live_session_name/$live_session/g")"
else
all_sessions=$(echo -e "$all_sessions\n$live_session")
# Okay I know this is ugly it is 5:13 my brain is not working
fi
session=$(echo "''\$all_sessions" | fzf)
session_name=$(echo $session | cut -d: -f1)
if [ -z "$session" ];then
exit 0
fi
if ! [ -z "''\${session##*created*}" ];then
if [ -x "$TMUX_SESSIONS/$session_name" ];then
source $TMUX_SESSIONS/$session_name
else
echo $TMUX_SESSIONS/$session_name not found or is not executable
exit 1
fi
fi
if [ -z "''\${session##*attached*}" ];then
read -r -p "The session is already attached somewhere else. Attach it here too ? (y/N): " choice
if [ "$choice" == "y" ] || [ "$choice" == "Y" ];then
tmux attach-session -t$session_name
fi
else
tmux attach-session -t$session_name
fi
done
''