ma home-manager: init direnv,bat and more
move old zsh confi to home-manager
This commit is contained in:
parent
a65ccabeb1
commit
8802a2928e
|
@ -1,4 +1,5 @@
|
|||
{pkgs, ... }: {
|
||||
imports = [ ./zsh.nix ];
|
||||
home-manager.users.makefu = {
|
||||
services.gpg-agent = {
|
||||
enable = true;
|
||||
|
@ -9,7 +10,34 @@
|
|||
enableSshSupport = true;
|
||||
enableScDaemon = true;
|
||||
};
|
||||
programs.fzf.enable = true; # alt-c
|
||||
programs.direnv = {
|
||||
stdlib = ''
|
||||
use_nix() {
|
||||
local cache=".direnv.$(nixos-version --hash)"
|
||||
|
||||
if [[ ! -e "$cache" ]] || \
|
||||
[[ "$HOME/.direnvrc" -nt "$cache" ]] || \
|
||||
[[ ".envrc" -nt "$cache" ]] || \
|
||||
[[ "default.nix" -nt "$cache" ]] || \
|
||||
[[ "shell.nix" -nt "$cache" ]];
|
||||
then
|
||||
local tmp="$(mktemp "$${cache}.tmp-XXXXXXXX")"
|
||||
trap "rm -rf '$tmp' >/dev/null" EXIT
|
||||
nix-shell --show-trace "$@" --run 'direnv dump' > "$tmp" && \
|
||||
mv "$tmp" "$cache"
|
||||
fi
|
||||
|
||||
direnv_load cat "$cache"
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
watch_file default.nix
|
||||
watch_file shell.nix
|
||||
rm direnv.* 2>/dev/null
|
||||
fi
|
||||
}
|
||||
'';
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
};
|
||||
services.udev.packages = [
|
||||
pkgs.libu2f-host
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
users.users.makefu.packages = with pkgs;[ bat direnv ];
|
||||
home-manager.users.makefu = {
|
||||
programs.browserpass = { browsers = [ "firefox" ] ; enable = true; };
|
||||
programs.firefox.enable = true;
|
||||
programs.obs-studio.enable = true;
|
||||
xdg.enable = true;
|
||||
services.network-manager-applet.enable = true;
|
||||
systemd.user.services.network-manager-applet.Service.Environment = ''XDG_DATA_DIRS=/etc/profiles/per-user/makefu/share GDK_PIXBUF_MODULE_FILE=${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'';
|
||||
services.blueman-applet.enable = true;
|
||||
services.pasystray.enable = true;
|
||||
systemd.user.services.pasystray.Service.Environment = "PATH=" + (lib.makeBinPath (with pkgs;[ pavucontrol paprefs /* pavumeter */ /* paman */ ]) );
|
||||
|
@ -34,7 +36,6 @@
|
|||
};
|
||||
|
||||
Service = {
|
||||
Environment = ''XDG_DATA_DIRS=/etc/profiles/per-user/makefu/share GDK_PIXBUF_MODULE_FILE=${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'';
|
||||
ExecStart = "${pkgs.clipit}/bin/clipit";
|
||||
Restart = "on-abort";
|
||||
};
|
||||
|
|
126
2configs/home-manager/zsh.nix
Normal file
126
2configs/home-manager/zsh.nix
Normal file
|
@ -0,0 +1,126 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
{ #direnv
|
||||
home-manager.users.makefu.home.packages = [ pkgs.direnv ];
|
||||
home-manager.users.makefu.home.file.".direnvrc".text = ''
|
||||
use_nix() {
|
||||
local path="$(nix-instantiate --find-file nixpkgs)"
|
||||
|
||||
if [ -f "$${path}/.version-suffix" ]; then
|
||||
local version="$(< $path/.version-suffix)"
|
||||
elif [ -f "$path/.version" ]; then
|
||||
local version="$(< $path/.version)"
|
||||
else
|
||||
local version="$(< $(< $path/.git/HEAD))"
|
||||
fi
|
||||
|
||||
local cache=".direnv/cache-''${version:-unknown}"
|
||||
|
||||
if [[ ! -e "$cache" ]] || \
|
||||
[[ "$HOME/.direnvrc" -nt "$cache" ]] || \
|
||||
[[ .envrc -nt "$cache" ]] || \
|
||||
[[ default.nix -nt "$cache" ]] || \
|
||||
[[ shell.nix -nt "$cache" ]];
|
||||
then
|
||||
[ -d .direnv ] || mkdir .direnv
|
||||
local tmp=$(nix-shell --show-trace "$@" \
|
||||
--run "\"$direnv\" dump bash")
|
||||
echo "$tmp" > "$cache"
|
||||
fi
|
||||
|
||||
local path_backup=$PATH term_backup=$TERM
|
||||
direnv_load cat "$cache"
|
||||
|
||||
export PATH=$PATH:$path_backup TERM=$term_backup
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
watch_file default.nix
|
||||
watch_file shell.nix
|
||||
fi
|
||||
}
|
||||
'';
|
||||
home-manager.users.makefu.programs.zsh.initExtra = ''
|
||||
nixify() {
|
||||
if [ ! -e ./.envrc ]; then
|
||||
echo "use nix" > .envrc
|
||||
direnv allow
|
||||
fi
|
||||
if [ ! -e default.nix ]; then
|
||||
cat > default.nix <<'EOF'
|
||||
with import <nixpkgs> {};
|
||||
stdenv.mkDerivation {
|
||||
name = "env";
|
||||
buildInputs = [
|
||||
bashInteractive
|
||||
];
|
||||
}
|
||||
EOF
|
||||
${EDITOR:-vim} default.nix
|
||||
fi
|
||||
}
|
||||
eval "$(direnv hook zsh)"
|
||||
'';
|
||||
}
|
||||
{ # bat
|
||||
home-manager.users.makefu.home.packages = [ pkgs.bat ];
|
||||
home-manager.users.makefu.programs.zsh.shellAliases = {
|
||||
cat = "bat";
|
||||
catn = "${pkgs.coreutils}/bin/cat";
|
||||
};
|
||||
}
|
||||
];
|
||||
environment.pathsToLink = [ "/share/zsh" ];
|
||||
home-manager.users.makefu = {
|
||||
programs.fzf.enable = false; # alt-c
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableAutosuggestions = false;
|
||||
enableCompletion = true;
|
||||
oh-my-zsh.enable = false;
|
||||
history = {
|
||||
size = 900001;
|
||||
save = 900001;
|
||||
ignoreDups = true;
|
||||
extended = true;
|
||||
share = true;
|
||||
};
|
||||
sessionVariables = {
|
||||
TERM = "rxvt-unicode-256color";
|
||||
LANG = "en_US.UTF8";
|
||||
LS_COLORS = ":di=1;31:";
|
||||
EDITOR = "vim";
|
||||
};
|
||||
shellAliases = {
|
||||
lsl = "ls -lAtr";
|
||||
t = "task";
|
||||
xo = "mimeopen";
|
||||
nmap = "nmap -oN $HOME/loot/scan-`date +\%s`.nmap -oX $HOME/loot/scan-`date +%s`.xml";
|
||||
};
|
||||
initExtra = ''
|
||||
bindkey -e
|
||||
# shift-tab
|
||||
bindkey '^[[Z' reverse-menu-complete
|
||||
bindkey "\e[3~" delete-char
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
|
||||
unset SSH_AGENT_PID
|
||||
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
||||
compdef _pass brain
|
||||
zstyle ':completion::complete:brain::' prefix "$HOME/brain"
|
||||
compdef _pass secrets
|
||||
zstyle ':completion::complete:secrets::' prefix "$HOME/.secrets-pass/"
|
||||
|
||||
# ctrl-x ctrl-e
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '^xe' edit-command-line
|
||||
bindkey '^x^e' edit-command-line
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,83 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
##
|
||||
with import <stockholm/lib>;
|
||||
let
|
||||
mainUser = config.krebs.build.user.name;
|
||||
in
|
||||
{
|
||||
users.extraUsers.${mainUser}.shell = "/run/current-system/sw/bin/zsh";
|
||||
programs.zsh= {
|
||||
enable = true;
|
||||
enableCompletion = true ; #manually at the end
|
||||
interactiveShellInit = ''
|
||||
HISTSIZE=900001
|
||||
HISTFILESIZE=$HISTSIZE
|
||||
SAVEHIST=$HISTSIZE
|
||||
HISTFILE=$HOME/.zsh_history
|
||||
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
bindkey -e
|
||||
# shift-tab
|
||||
bindkey '^[[Z' reverse-menu-complete
|
||||
bindkey "\e[3~" delete-char
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
${pkgs.gnupg}/bin/gpg-connect-agent updatestartuptty /bye >/dev/null
|
||||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
LS_COLORS=$LS_COLORS:'di=1;31:' ; export LS_COLORS
|
||||
|
||||
unset SSH_AGENT_PID
|
||||
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
||||
|
||||
# fzf
|
||||
__fsel_fzf() {
|
||||
local cmd="''${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||
-o -type f -print \
|
||||
-o -type d -print \
|
||||
-o -type l -print 2> /dev/null | cut -b3-"}"
|
||||
setopt localoptions pipefail 2> /dev/null
|
||||
eval "$cmd" | FZF_DEFAULT_OPTS="--height ''${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
|
||||
echo -n "''${(q)item} "
|
||||
done
|
||||
local ret=$?
|
||||
echo
|
||||
return $ret
|
||||
}
|
||||
|
||||
__fzf_use_tmux__() {
|
||||
[ -n "$TMUX_PANE" ] && [ "''${FZF_TMUX:-0}" != 0 ] && [ ''${LINES:-40} -gt 15 ]
|
||||
}
|
||||
|
||||
__fzfcmd() {
|
||||
__fzf_use_tmux__ &&
|
||||
echo "fzf-tmux -d''${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
|
||||
}
|
||||
|
||||
fzf-file-widget() {
|
||||
LBUFFER="''${LBUFFER}$(__fsel_fzf)"
|
||||
local ret=$?
|
||||
zle redisplay
|
||||
typeset -f zle-line-init >/dev/null && zle zle-line-init
|
||||
return $ret
|
||||
}
|
||||
zle -N fzf-file-widget
|
||||
bindkey '^T' fzf-file-widget
|
||||
|
||||
compdef _pass brain
|
||||
zstyle ':completion::complete:brain::' prefix "$HOME/brain"
|
||||
compdef _pass secrets
|
||||
zstyle ':completion::complete:secrets::' prefix "$HOME/.secrets-pass/"
|
||||
|
||||
# ctrl-x ctrl-e
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '^xe' edit-command-line
|
||||
bindkey '^x^e' edit-command-line
|
||||
|
||||
'';
|
||||
enableCompletion = false; #manually at the end
|
||||
|
||||
promptInit = ''
|
||||
RPROMPT=""
|
||||
|
@ -93,8 +21,8 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
users.users.${mainUser}.packages = [
|
||||
pkgs.nix-zsh-completions
|
||||
pkgs.fzf
|
||||
];
|
||||
users.users.${mainUser} = {
|
||||
shell = "/run/current-system/sw/bin/zsh";
|
||||
packages = [ pkgs.nix-zsh-completions ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue