vms: Add basic user home for all vms

* .guix/rekahsoft/guix-config/home.scm: Exports %home and %home-manifest; %home is the guix
home configuration and %home-manifest is a manifest containing the packages that are
installed as part of the home profile.
* .guix/rekahsoft/guix-config/proxmox-vm-lvm-minimal.scm: Uses new guix-home-service-type to
manage a user home installation as part of the system profile.
* channels.scm: Updated guix channel
* user-config/tmux/.tmux.conf: Basic tmux configuration (taken from dotfiles)
* user-config/zsh/.config/spaceship.zsh: Spaceship prompt configuration (taken from dotfiles)
* user-config/zsh/.zprofile: zsh zprofile (taken from dotfiles)
* user-config/zsh/.zshenv: zsh env variables (taken, and adjusted from dotfiles)
* user-config/zsh/.zshrc: zsh configuration (taken from dotfiles)
This commit is contained in:
Collin J. Doering 2024-05-18 20:05:50 -04:00
parent 8cbb465a8f
commit 5bf9e716c7
Signed by: rekahsoft
GPG Key ID: F77E319397CDA716
8 changed files with 536 additions and 2 deletions

View File

@ -0,0 +1,93 @@
;; (C) Copyright Collin J. Doering 2024
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(define-module (rekahsoft guix-config home)
#:use-module (gnu home)
#:use-module (gnu packages)
#:use-module (gnu services)
#:use-module (guix profiles)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (gnu home services)
#:use-module (gnu home services shells)
#:use-module (gnu home services ssh)
#:use-module (rekahsoft-gnu packages shellutils)
#:export (%home %home-manifest))
(define-public %home-manifest
(concatenate-manifests
(list
(packages->manifest
(list
;; TODO: this was added upstream (as "go-github-com-junegunn-fzf") but is not as complete as my existing package
fzf
;; Remaining packages from the rekahsoft-guix channel
spaceship-prompt))
(specifications->manifest
'("bat"
"bind:utils" ;; for dig
"bmon"
"curl"
"direnv"
"eza"
"fd"
"gawk"
"git"
"git-lfs"
"git:send-email"
"git:subtree"
"glibc-locales"
"htop"
"jq"
"nmap"
"recutils"
"rhash"
"ripgrep"
"sh-z"
"tmux"
"zsh-autosuggestions"
"zsh-syntax-highlighting")))))
(define %home
(home-environment
(packages
(map (lambda (m)
(list (manifest-entry-item m)
(manifest-entry-output m)))
(manifest-entries %home-manifest)))
(services
(list
(service home-bash-service-type
(home-bash-configuration
(environment-variables '(("PS1" . "[\\u@\\h \\W]\\$ ")))))
(service home-zsh-service-type
(home-zsh-configuration
(zshenv (list (local-file "../../../user-config/zsh/.zshenv" "zshenv")))
(zprofile (list (local-file "../../../user-config/zsh/.zprofile" "zprofile")))
(zshrc (list (local-file "../../../user-config/zsh/.zshrc" "zshrc")))))
(service home-openssh-service-type
(home-openssh-configuration
(hosts
(list (openssh-host (name "*.home.rekahsoft.ca rekahsoft.ca")
(forward-agent? #t))))
(authorized-keys (list))))
(simple-service
'extra-xdg-configuration-files-service
home-xdg-configuration-files-service-type
`(("spaceship.zsh" ,(local-file "../../../user-config/zsh/.config/spaceship.zsh"))
("tmux/tmux.conf" ,(local-file "../../../user-config/tmux/.tmux.conf" "tmux.conf"))))))))

View File

@ -6,6 +6,7 @@
#:use-module (gnu services dbus)
#:use-module (gnu services desktop)
#:use-module (gnu services guix)
#:use-module (gnu services networking)
#:use-module (gnu services monitoring)
#:use-module (gnu services shepherd)
@ -14,6 +15,7 @@
#:use-module (gnu packages admin)
#:use-module (gnu packages bash)
#:use-module (gnu packages shells)
#:use-module (rekahsoft guix-config home)
#:export (%proxmox-vm-lvm-minimal-services
proxmox-vm-lvm-minimal))
@ -84,7 +86,9 @@ mail.* -/var/log/maillog
;; services, an error will be recieved about an abiguous-service called 'system.
(define %proxmox-vm-lvm-minimal-services
(append
(list (service openssh-service-type
(list (service guix-home-service-type
`(("collin" ,%home)))
(service openssh-service-type
(openssh-configuration
(password-authentication? #f)
(authorized-keys

View File

@ -3,7 +3,7 @@
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"360fea15cb25d0cdf55ec55488956257a0219fe4")
"703ae431f4ad28658e34675310b4fdf58685ccdd")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"

View File

@ -0,0 +1,30 @@
# File: .tmux.conf
# Author: Collin J. Doering <rekahsoft@gmail.com>
# Date: Jan 18, 2014
# Set prefix key to C-t instead of default C-b
unbind C-b
set -g prefix C-t
# Mimic 256 colors
set -g default-terminal "screen-256color"
# Toggle last window like screen
bind-key C-t last-window
# Rebind clock-mode to "prefix T"
unbind t
bind-key T clock-mode
# Send prefix to underlying application using "prefix t"
bind-key t send-prefix
# Setup pane movement
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
# session initialization
#new -s default -n zsh zsh
#neww -n weechat weechat-curses
#neww -n emacs emacsclient
#selectw -t 1

View File

@ -0,0 +1,73 @@
# Display time
SPACESHIP_TIME_SHOW=true
# Don't display username
SPACESHIP_USER_SHOW=false
# Do not truncate path in repos
SPACESHIP_DIR_TRUNC_REPO=false
SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_PROMPT_SEPARATE_LINE=true
SPACESHIP_KUBECONTEXT_SYMBOL="☸️ " # Two spaces are used instead of one in prompt; this forces use of only one
SPACESHIP_PROMPT_ASYNC=false
SPACESHIP_PROMPT_ORDER=(
time # Time stamps section
user # Username section
dir # Current directory section
host # Hostname section
git # Git section (git_branch + git_status)
hg # Mercurial section (hg_branch + hg_status)
package # Package version
node # Node.js section
bun # Bun section
deno # Deno section
ruby # Ruby section
python # Python section
elm # Elm section
elixir # Elixir section
xcode # Xcode section
swift # Swift section
golang # Go section
perl # Perl section
php # PHP section
rust # Rust section
haskell # Haskell Stack section
scala # Scala section
kotlin # Kotlin section
java # Java section
lua # Lua section
dart # Dart section
julia # Julia section
crystal # Crystal section
docker # Docker section
docker_compose # Docker section
aws # Amazon Web Services section
gcloud # Google Cloud Platform section
azure # Azure section
venv # virtualenv section
conda # conda virtualenv section
dotnet # .NET section
ocaml # OCaml section
vlang # V section
zig # Zig section
purescript # PureScript section
erlang # Erlang section
kubectl # Kubectl context section
ansible # Ansible section
terraform # Terraform workspace section
pulumi # Pulumi stack section
ibmcloud # IBM Cloud section
nix_shell # Nix shell
gnu_screen # GNU Screen section
exec_time # Execution time
async # Async jobs indicator
line_sep # Line break
battery # Battery level and status
jobs # Background jobs indicator
exit_code # Exit code section
sudo # Sudo indicator
char # Prompt character
)

View File

@ -0,0 +1,5 @@
# Setup guix profile locales
export GUIX_LOCPATH=${HOME}/.guix-home/profile/lib/locale
# Add local binaries to PATH
export PATH="${PATH}:$HOME/.bin"

9
user-config/zsh/.zshenv Normal file
View File

@ -0,0 +1,9 @@
# All commands in this file MUST not produce output
# Default editor
export EDITOR="emacsclient -t -a emacs"
export VISUAL="emacsclient -a emacs"
# Set aws-vault default backend
export AWS_VAULT_BACKEND=pass
export AWS_VAULT_PASS_PREFIX=aws-vault

320
user-config/zsh/.zshrc Normal file
View File

@ -0,0 +1,320 @@
# File: ~/.zshrc
# Description: zsh configuration file
source ~/.guix-home/profile/bin/z.sh
precmd () {
z --add "$(pwd -P)"
}
# Use zsh-autosuggestions (requires pacman package)
source ~/.guix-home/profile/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# TODO: temporary
fpath=( ~/.guix-home/profile/share/zsh/site-functions "${fpath[@]}" )
# The following lines were added by compinstall
zstyle ':completion:*' completer _list _expand _complete _ignored _match _correct _approximate _prefix
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-/,+]=** r:|=**' 'l:|=* r:|=*'
zstyle ':completion:*' max-errors 5
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle :compinstall filename '/home/collin/.zshrc'
autoload -Uz compinit
compinit
autoload -U promptinit; promptinit
prompt spaceship
# End of lines added by compinstall
# Lines for zsh setup
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000000
SAVEHIST=10000000
setopt AUTO_CD # Change directories without cd
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
setopt COMPLETE_ALIASES # Complete command line switches for aliases
# End of zsh history setup
# Use emacs keybindings
bindkey -e
# Lines to add fzf fuzzy completion widgets supplied by fzf package
source ~/.guix-home/profile/share/fzf/key-bindings.zsh
source ~/.guix-home/profile/share/fzf/completion.zsh
# Rebind C-t for fzf-file-widget to ESC-t
bindkey -r '^T'
bindkey '\et' fzf-file-widget
# Rebind C-r for ffz-history-widget to ESC-r
bindkey -r '^R'
bindkey '\er' fzf-history-widget
export FZF_DEFAULT_OPTS='--no-height --no-reverse'
export FZF_ALT_C_COMMAND="find -L . -mindepth 1 \\( -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune -o -type d -print 2> /dev/null | cut -b3-"
#export FZF_CTRL_T_COMMAND="find -L . -mindepth 1 \\( -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-"
export FZF_CTRL_T_COMMAND="ag --hidden --ignore .git -g '' 2> /dev/null"
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden --bind '?:toggle-preview'"
# End of zsh fzf widget setup
# Check for a tramp session and set a compatible PS1
# See: https://www.emacswiki.org/emacs/TrampMode
[[ $TERM == "tramp" ]] && unsetopt zle && PS1='$ ' && return
# Check for an interactive session
[ -z "$PS1" ] && return
# Preferably, setup of man/info would be automatically be handled by 'guix shell' itself,
# however this is not the case, as the profile hook for man/info pages will not be triggered
# unless man or info respectively is also explicitly included in the profile.
if [ ! -z "$GUIX_ENVIRONMENT" ]; then
# When using guix shell (formally environment) command, automatically add the temporary
# environments man page directory to MANPATH, if it exists.
if [ -d "$GUIX_ENVIRONMENT/share/man" ]; then
export MANPATH="$GUIX_ENVIRONMENT/share/man:$MANPATH"
fi
# Similarly to man, automatically add the temporary environments info page directory to
# INFOPATH, if it exists.
if [ -d "$GUIX_ENVIRONMENT/share/info" ]; then
export INFOPATH="$GUIX_ENVIRONMENT/share/info:$INFOPATH"
fi
fi
# Alias' to make command output prettier (use color with some commands by default)
alias ls='ls --color=auto'
alias ll='ls -l'
alias la='ls -a'
alias lla='ls -al'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias f='find'
compdef f='find'
alias b='bat'
# #compdef b='bat' # No completions for bat installed/available
alias x='eza'
alias xs='eza'
alias xl='eza -l'
alias xla='eza -la'
alias xx='x -alT --git'
compdef x='eza'
compdef xs='eza'
compdef xl='eza'
compdef xla='eza'
compdef xx='eza'
alias av='aws-vault'
alias avl='aws-vault login ${AWS_PROFILE:-default}'
alias ave='aws-vault exec ${AWS_PROFILE:-default} --'
alias aven='aws-vault exec --no-session ${AWS_PROFILE:-default} --'
compdef av='aws-vault'
compdef avl='aws-vault'
compdef ave='aws-vault'
compdef aven='aws-vault'
AWS_ALIAS='aws-vault exec --no-session ${AWS_PROFILE:-default} -- aws'
AWS_SHELL_ALIAS='aws-vault exec --no-session ${AWS_PROFILE:-default} -- aws-shell'
alias aws="$AWS_ALIAS"
alias aws-shell="$AWS_SHELL_ALIAS"
alias unaws='unset AWS_{PROFILE,SECRET_ACCESS_KEY,ACCESS_KEY_ID,SDK_LOAD_CONFIG}'
alias alias-aws="alias aws='${AWS_ALIAS}'; alias aws-shell='${AWS_SHELL_ALIAS}'"
alias unalias-aws='unalias aws; unalias aws-shell'
alias ff='firefox'
alias ffp='firefox --private-window'
alias e='emacsclient -t'
alias kssh='kitty +kitten ssh'
alias qemu="qemu-system-$(uname -m) -enable-kvm"
alias lock='cmatrix; clear; vlock'
alias vv="remote-viewer --connect qemu:///session"
alias xc="xclip -selection clipboard"
# alias mplayer-ascii='mplayer -vo aa:driver=curses -monitorpixelaspect 0.5 -really-quiet'
alias s='sudo'
alias si='sudo -i'
compdef s='sudo'
compdef si='sudo'
# Use colordiff in place of diff
#alias diff='colordiff'
#
# TODO: uncomment
#
# # Shortcuts for ssh
# function ssht() {
# if [ "$#" -lt 1 ]; then
# echo Invalid use of ssht
# return 1
# else
# hostname="$1"
# shift
# other_options="$*"
# ssh -t $other_options $hostname -- /bin/sh -c 'tmux attach || (echo tmux not found, trying screen. && screen -R || echo No terminal multiplexer found. Have a shell. && $SHELL)'
# fi
# }
# # Set colors to use with grep
# export GREP_COLOR="1;33"
# # Use source-highlight to make code in less syntax highlighted
# export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
# export LESS=' -R '
# # Set text/background colors for ls
# export LS_COLORS="di=01;37"
# Turn off noscroll
stty stop undef
# Setup direnv hook
eval "$(direnv hook zsh)"
# Use zsh-source-highlight
source ~/.guix-home/profile/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Setup nix package manager
source /run/current-system/profile/etc/profile.d/nix.sh
# TODO: not packaged on guix
# # Initialize nvm for managing node environments
# source /usr/share/nvm/init-nvm.sh
# TODO: not packaged on guix
# # Use hub completion
# eval "$(hub alias -s zsh)"
# # Use aws-cli completion
# source /usr/bin/aws_zsh_completer.sh
# TODO: not packaged on guix
# # Use doctl completion
# source <(doctl completion zsh)
# TODO: not packaged on guix
# # Use kubectl completion
# source <(kubectl completion zsh)
# TODO: not packaged on guix
# # Use helm completion
# source <(helm completion zsh)
# # Set GOPATH and add $GOPATH/bin to PATH
# export GOPATH=~/.go
# export PATH="${PATH}:${GOPATH}/bin"
# # Use gcloud completion
# source /opt/google-cloud-sdk/completion.zsh.inc
# # Setup libvirt default session uri
# export LIBVIRT_DEFAULT_URI=qemu:///system
# # Set default vagrant provider to libvirt
# export VAGRANT_DEFAULT_PROVIDER=libvirt
# # Setup ESP-32 sdk
# export IDF_PATH=/opt/esp-idf-sdk
# . ${IDF_PATH}/add_path.sh > /dev/null 2>&1
# Access pem ssh keys from password store
pass-ssh() {
psw="$1"
shift
key_file="$(mktemp)"
pass "$psw" > "$key_file"
ssh -i "$key_file" $@
rm "$key_file"
}
# Alias shell scripts in ~/.bin directory
for i in ~/.bin/*.sh; do
alias $(basename $i | sed -E 's/^(.*)\.sh$/\1/')=$i
done
# Startx when on tty1
if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
exec ~/.bin/startx.sh
fi
# Required for emacs vterm
# See: https://github.com/akermu/emacs-libvterm
vterm_printf(){
if [ -n "$TMUX" ]; then
# Tell tmux to pass the escape sequences through
# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "${TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
# Ease message passing to vterm
vterm_cmd() {
local vterm_elisp
vterm_elisp=""
while [ $# -gt 0 ]; do
vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
shift
done
vterm_printf "51;E$vterm_elisp"
}
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
# Override man to run emacs man
man() {
vterm_cmd man "$@"
}
# Override info to run emacs info
info() {
vterm_cmd info "$@"
}
find-file() {
vterm_cmd find-file "$@"
}
message() {
vterm_cmd message "$@"
}
vterm-clear-scrollback() {
vterm_cmd vterm-clear-scrollback "$@"
}
# For emacs vterm directory and prompt tracking
# https://github.com/akermu/emacs-libvterm#directory-tracking-and-prompt-tracking
vterm_prompt_end() {
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)";
}
setopt PROMPT_SUBST
PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'
fi