Skip to content

Commit

Permalink
update age and sops file initization, add ripgrep in fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
allthatjazzleo committed Jul 28, 2024
1 parent ea9f72e commit 8c9c099
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 36 deletions.
58 changes: 31 additions & 27 deletions cells/homemanager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ in {
home = {
inherit homeDirectory packages;
username = user.username;
stateVersion = "23.05"; # See https://nixos.org/manual/nixpkgs/stable for most recent version
stateVersion = "24.05"; # See https://nixos.org/manual/nixpkgs/stable for most recent version
sessionVariables = {
# DAML_HOME = getPkgOutPath {
# pkgs = packages;
# name = "daml-sdk";
# };
PKG_CONFIG_PATH = "${(getPkgOutPath {
pkgs = packages;
name = "openssl";
Expand All @@ -73,29 +69,37 @@ in {

programs = cell.programs.default homeDirectory user;

age.identityPaths =
options.age.identityPaths.default
++ userAgeIdentityPaths;
age.secrets.ssh-config = {
file = ./secrets/ssh-config.age;
path = "${homeDirectory}/.ssh/config";
};
age.secrets.nix-config = {
file = ./secrets/nix.conf.age;
path = "${homeDirectory}/.config/nix/nix.conf";
};
age.secrets.sops-age-key = {
file = ./secrets/sops-age-key.age;
path = sopsAgeKeyPath;
};
age.identityPaths = userAgeIdentityPaths;

sops = {
age.keyFile = config.age.secrets.sops-age-key.path;
defaultSopsFile = ./secrets/secrets.yaml;
secrets.mysecret = {
path = "${homeDirectory}/.config/mysecret";
};
};
# don't create age and sops secrets if no age key identity paths are provided to avoid errors
age.secrets =
if builtins.length config.age.identityPaths > 0
then {
ssh-config = {
file = ./secrets/ssh-config.age;
path = "${homeDirectory}/.ssh/config";
};
nix-config = {
file = ./secrets/nix.conf.age;
path = "${homeDirectory}/.config/nix/nix.conf";
};
sops-age-key = {
file = ./secrets/sops-age-key.age;
path = sopsAgeKeyPath;
};
}
else {};

sops =
if builtins.length config.age.identityPaths > 0
then {
age.keyFile = config.age.secrets.sops-age-key.path;
defaultSopsFile = ./secrets/secrets.yaml;
secrets.mysecret = {
path = "${homeDirectory}/.config/mysecret";
};
}
else {};

nixpkgs = {
config = {
Expand Down
3 changes: 2 additions & 1 deletion cells/homemanager/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ in {
nixfmt-classic
nodejs-18_x
operator-sdk
open-interpreter
# open-interpreter
openssl_3_2
pkg-config
poetry
Expand All @@ -59,6 +59,7 @@ in {
rustup
shellcheck
smartmontools
sops
starship
terraform
tflint
Expand Down
10 changes: 10 additions & 0 deletions cells/homemanager/programs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ in {
userName = user.github_username;
delta = {
enable = true;
options = {
features = "decorations";
whitespace-error-style = "22 reverse";
line-numbers = true;
decorations = {
commit-decoration-style = "bold yellow box ul";
file-style = "bold yellow ul";
file-decoration-style = "none";
};
};
};
lfs = {
enable = true;
Expand Down
2 changes: 1 addition & 1 deletion cells/homemanager/programs/starship.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
golang = {format = "via [🏎💨 $version](bold cyan) ";};
terraform = {format = "via [🏎💨 $version$workspace]($style) ";};
kubernetes = {
format = "on [⛵ ($user on )($cluster in )$context ($namespace)](dimmed green) ";
format = "on [⛵ ($user on )($cluster in )($namespace)](dimmed green) ";
disabled = false;
context_aliases = {
"dev.local.cluster.k8s" = "dev";
Expand Down
37 changes: 31 additions & 6 deletions cells/homemanager/programs/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,25 @@
};
history = {size = 100000;};
initExtraFirst = ''
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# python
for dir in $(ls -rd $HOME/Library/Python/*); do
for dir in $(ls -rd $HOME/Library/Python/*(N)); do
if [ "$dir" = "." ]; then
continue
fi
export PATH="$dir/bin:$PATH"
done
# End python
# Cargo
export PATH="$HOME/.cargo/bin:$PATH"
# End Cargo
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# Go bin
export PATH="$(go env GOPATH)/bin:$PATH"
# End Go bin
# krew
export PATH="$HOME/.krew/bin:$PATH"
# End krew
Expand All @@ -68,6 +74,22 @@
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
rg) rm -f /tmp/rg-fzf-{r,f}
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="placeholder"
fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.2; $RG_PREFIX {q} || true" \
--bind 'ctrl-t:transform:[[ ! $FZF_PROMPT =~ ripgrep ]] &&
echo "rebind(change)+change-prompt(1. ripgrep> )+disable-search+transform-query:echo \{q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r" ||
echo "unbind(change)+change-prompt(2. fzf> )+enable-search+transform-query:echo \{q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f"' \
--bind 'enter:become(code -g -n {1}:{2}:{3})' \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--prompt '1. ripgrep> ' \
--delimiter : \
--header 'CTRL-T: Switch between ripgrep/fzf' \
--preview-window 'right:60%,+{2}+3/3,~3' \
--preview 'bat --color=always {1} --highlight-line {2}' ;;
*) fzf --preview 'bat -n --color=always {} --line-range :500 {}' "$@" ;;
esac
}
Expand Down Expand Up @@ -135,4 +157,7 @@
enable = true;
enableZshIntegration = true;
};
ripgrep = {
enable = true;
};
}
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
(devshells "devshells")
(data "users")
(functions "configurations")
(functions "modules")
(functions "packages")
(functions "programs")
(functions "home")
Expand Down
5 changes: 5 additions & 0 deletions secrets.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# https://github.com/ryantm/agenix
# Update secrets with agenix cli. When you save that file its content will be encrypted with all the public keys mentioned in the secrets.nix file.
# ```
# agenix -e cells/homemanager/secrets/ssh-config.age -i ~/.ssh/id_ed25519_homemanager
# ```
let
leopang = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJsF4iQmvHnLvSOnAuHMvpFaVww3TpAiNoIR6I1IxfcJ";
workuser = "ssh-ed25519 xxx";
Expand Down

0 comments on commit 8c9c099

Please sign in to comment.