Compare commits
67 Commits
blesh
...
27d202b0c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27d202b0c2 | ||
|
|
4353a79f16 | ||
| 6d2ebcb505 | |||
|
|
b3cecbaf22 | ||
|
|
f72d1050d3 | ||
| c2e40ce9df | |||
| 6c09b2c11b | |||
| 8ff319f8de | |||
| 561297d305 | |||
| 7fbe76430d | |||
|
|
ed643a06f9 | ||
|
|
c460081637 | ||
|
|
2f971627bd | ||
|
|
55141b696b | ||
|
|
bee634eb79 | ||
|
|
bc63202425 | ||
|
|
119c751ea3 | ||
|
|
722352e607 | ||
|
|
e1d39feb7d | ||
| f64da797ce | |||
|
|
ec19718182 | ||
|
|
6e88e2b333 | ||
|
|
4c312cfa58 | ||
|
|
11e8bf4bec | ||
| a16b49a394 | |||
| 829e53d3cc | |||
| e02cdd0b66 | |||
| c2ebab9a41 | |||
| 5426e96bed | |||
| 51b8138cf3 | |||
| 790c132e07 | |||
| 008d3720ff | |||
| 85cee95c2e | |||
| 7360e32a08 | |||
| c2286bb299 | |||
| 4c48565a8f | |||
| edd3b72430 | |||
| 772da66b96 | |||
| ac168d66d7 | |||
| 8937b9f566 | |||
| c73a495540 | |||
| 406c50b4a5 | |||
| 4360067486 | |||
| b156901695 | |||
| bc00f7a310 | |||
| 16545b322f | |||
| dafc207f96 | |||
| f81ee2834a | |||
| b7ce819dba | |||
| f7b5147450 | |||
| 6246e75d81 | |||
| d901efe31a | |||
| e15f254143 | |||
| fa7af5ee1f | |||
| 819c41de45 | |||
| c97ef61d30 | |||
| 0d5d35d5e1 | |||
| 8c379c558a | |||
| 8ce45fc87c | |||
| ed9e0d4419 | |||
| dd35fe3b20 | |||
| c26f6a6bf5 | |||
| 08713c254f | |||
| 2d14e91f81 | |||
| 8dda8c7fbc | |||
| 7d67ff0662 | |||
|
|
a2076fd6f1 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -58,9 +58,3 @@
|
||||
[submodule "vim/.vim/bundle/vim-gitgutter"]
|
||||
path = vim/.vim/bundle/vim-gitgutter
|
||||
url = https://github.com/airblade/vim-gitgutter.git
|
||||
[submodule "vim/.vim/nvim-bundle/zk-nvim"]
|
||||
path = vim/.vim/nvim-bundle/zk-nvim
|
||||
url = https://github.com/zk-org/zk-nvim.git
|
||||
[submodule "vim/.vim/bundle/vim-helm"]
|
||||
path = vim/.vim/bundle/vim-helm
|
||||
url = https://github.com/towolf/vim-helm.git
|
||||
|
||||
@@ -17,9 +17,6 @@ apply_dotfile sh
|
||||
apply_dotfile readline
|
||||
apply_dotfile screen
|
||||
|
||||
apply_dotfile git
|
||||
apply_dotfile xdg
|
||||
|
||||
apply_dotfile vim
|
||||
|
||||
apply_dotfile ruby
|
||||
|
||||
125
bash/.bashrc
125
bash/.bashrc
@@ -1,46 +1,5 @@
|
||||
#{- ~/.bashrc -}#
|
||||
|
||||
#{- SOURCING -}#
|
||||
|
||||
# Source profile, if it hasn't already been loaded
|
||||
if [ -z "$__PROFILE_DONE" ]; then
|
||||
. $HOME/.profile
|
||||
fi
|
||||
|
||||
# Source .env to extend with secret/sensitive environment variables if it exists
|
||||
if [ -r "$HOME/.env" ]; then
|
||||
. "$HOME/.env"
|
||||
fi
|
||||
|
||||
if [ -r "$HOME/.config/xdg/env" ]; then
|
||||
. "$HOME/.config/xdg/env"
|
||||
fi
|
||||
|
||||
# Source aliases, if they exist
|
||||
if [ -f "$HOME/.aliases" ] && [ -r "$HOME/.aliases" ]; then
|
||||
. "$HOME/.aliases"
|
||||
fi
|
||||
|
||||
# Source private aliases, if they exist
|
||||
if [ -f "$HOME/.private_aliases" ] && [ -r "$HOME/.private_aliases" ]; then
|
||||
. "$HOME/.private_aliases"
|
||||
fi
|
||||
|
||||
# Source functions, if they exist
|
||||
if [ -f "$HOME/.functions" ] && [ -r "$HOME/.functions" ]; then
|
||||
. "$HOME/.functions"
|
||||
fi
|
||||
|
||||
# Source private functions, if they exist
|
||||
if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then
|
||||
. "$HOME/.private_functions"
|
||||
fi
|
||||
|
||||
if blesh-available; then
|
||||
# blesh-activate
|
||||
:
|
||||
fi
|
||||
|
||||
#{- PROMPT -}#
|
||||
|
||||
if which tput &> /dev/null && tput bold &> /dev/null; then
|
||||
@@ -61,27 +20,14 @@ else
|
||||
no_color="\[\033[0m\]"
|
||||
fi
|
||||
|
||||
|
||||
export PS1="${green}"'\$'"${no_color} "
|
||||
export DIRENV_PS1="${red}"'\$'"${no_color} "
|
||||
export NIX_SHELL_PS1="${blue}"'λ'"${no_color} "
|
||||
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${CONTAINER_ID}" != "" ] || [ "${SSH_TTY}" != "" ]; then
|
||||
if [ "${CONTAINER_ID}" ]; then
|
||||
OLD_HOSTNAME="${HOSTNAME}"
|
||||
HOSTNAME="${CONTAINER_ID}"
|
||||
fi
|
||||
|
||||
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
|
||||
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
|
||||
NIX_SHELL_PS1="${NIX_SHELL_PS1}${green}${HOSTNAME} ${NIX_SHELL_PS1}"
|
||||
|
||||
if [ "${CONTAINER_ID}" ]; then
|
||||
PS1="${PS1}${magenta}${HOSTNAME} ${PS1}"
|
||||
else
|
||||
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
|
||||
fi
|
||||
|
||||
if [ "${CONTAINER_ID}" ]; then
|
||||
HOSTNAME="${OLD_HOSTNAME}"
|
||||
fi
|
||||
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
|
||||
fi
|
||||
export ORIG_PS1=${PS1}
|
||||
|
||||
@@ -95,7 +41,7 @@ if which direnv &> /dev/null; then
|
||||
PS1=${ORIG_PS1}
|
||||
fi
|
||||
}
|
||||
prompt_command_prepend "update_prompt"
|
||||
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
|
||||
fi
|
||||
|
||||
# Continuation Prompt: "> " in cyan
|
||||
@@ -105,14 +51,8 @@ export PS4="${blue}#${no_color} "
|
||||
|
||||
#{- HISTORY -}#
|
||||
|
||||
if blesh-attached; then
|
||||
bleopt history_share=1
|
||||
else
|
||||
prompt_command_prepend "history -r"
|
||||
prompt_command_prepend "history -c"
|
||||
prompt_command_prepend "history -w"
|
||||
prompt_command_prepend "history -n"
|
||||
fi
|
||||
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
|
||||
# PROMPT_COMMAND="echo hist1; history; history -n; echo hist2; history; history -w; echo hist3; history; history -c; echo hist4; history; history -r; echo hist5; history; $PROMPT_COMMAND"
|
||||
export HISTFILE="$HOME/.history/bash"
|
||||
export HISTTIMEFORMAT="%F %T "
|
||||
export HISTCONTROL="erasedups:ignoreboth"
|
||||
@@ -139,17 +79,42 @@ log_bash_persistent_history()
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_command_prepend "log_bash_persistent_history"
|
||||
PROMPT_COMMAND="log_bash_persistent_history; $PROMPT_COMMAND"
|
||||
|
||||
# Source bash completion, this file will then lazy load all other completions
|
||||
source_completions() {
|
||||
if [ -r "/usr/share/bash-completion/bash_completion" ]; then
|
||||
. "/usr/share/bash-completion/bash_completion"
|
||||
elif [ -r "/etc/bash_completion" ]; then
|
||||
. "/etc/bash_completion"
|
||||
fi
|
||||
}
|
||||
source_completions
|
||||
|
||||
#{- SOURCING -}#
|
||||
|
||||
|
||||
# Source profile, if it hasn't already been loaded
|
||||
if [ -z "$__PROFILE_DONE" ]; then
|
||||
. $HOME/.profile
|
||||
fi
|
||||
|
||||
# Source .env to extend with secret/sensitive environment variables if it exists
|
||||
if [ -r "$HOME/.env" ]; then
|
||||
. "$HOME/.env"
|
||||
fi
|
||||
|
||||
|
||||
# Source aliases, if they exist
|
||||
if [ -f "$HOME/.aliases" ] && [ -r "$HOME/.aliases" ]; then
|
||||
. "$HOME/.aliases"
|
||||
fi
|
||||
|
||||
# Source private aliases, if they exist
|
||||
if [ -f "$HOME/.private_aliases" ] && [ -r "$HOME/.private_aliases" ]; then
|
||||
. "$HOME/.private_aliases"
|
||||
fi
|
||||
|
||||
# Source functions, if they exist
|
||||
if [ -f "$HOME/.functions" ] && [ -r "$HOME/.functions" ]; then
|
||||
. "$HOME/.functions"
|
||||
fi
|
||||
|
||||
# Source private functions, if they exist
|
||||
if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then
|
||||
. "$HOME/.private_functions"
|
||||
fi
|
||||
|
||||
# Preserve the usefulness of set -x by attempting to hide everything that
|
||||
# happens in prompt_command
|
||||
@@ -166,12 +131,8 @@ preserve_xtrace_reset() {
|
||||
fi
|
||||
} 2>/dev/null
|
||||
|
||||
prompt_command_prepend "preserve_xtrace"
|
||||
prompt_command_append "preserve_xtrace_reset"
|
||||
PROMPT_COMMAND="preserve_xtrace; $PROMPT_COMMAND preserve_xtrace_reset"
|
||||
|
||||
if $(which direnv &> /dev/null); then
|
||||
# Only if direnv isn't already defined in our prompt_command
|
||||
if ! grep -q _direnv_hook <<< $PROMPT_COMMAND; then
|
||||
eval "$(direnv hook bash)"
|
||||
fi
|
||||
eval "$(direnv hook bash)"
|
||||
fi
|
||||
|
||||
@@ -18,85 +18,6 @@ maths()
|
||||
|
||||
cat_with_newline()
|
||||
{
|
||||
\cat "$@" && echo
|
||||
cat "$@" && echo
|
||||
}
|
||||
alias cat="cat_with_newline"
|
||||
|
||||
k_prompt()
|
||||
{
|
||||
set -x
|
||||
if [ -z ${KUBE_PROMPT+x} ]; then
|
||||
export KUBE_PROMPT=1
|
||||
else
|
||||
unset KUBE_PROMPT
|
||||
fi
|
||||
set +x
|
||||
}
|
||||
|
||||
kube_prompt()
|
||||
{
|
||||
set -x
|
||||
if ! [ -z ${KUBE_PROMPT+x} ]; then
|
||||
context=$(\cat ${KUBECONFIG} \
|
||||
| grep "current-context: " \
|
||||
| sed "s/current-context: //")
|
||||
echo {$context}
|
||||
fi
|
||||
set +x
|
||||
}
|
||||
|
||||
g_prompt()
|
||||
{
|
||||
if ! [ -z ${GIT_PROMPT+x} ]; then
|
||||
export GIT_PROMPT=1
|
||||
else
|
||||
unset GIT_PROMPT
|
||||
fi
|
||||
}
|
||||
|
||||
git_prompt()
|
||||
{
|
||||
if ! [ -z ${GIT_PROMPT+x} ]; then
|
||||
# Determine if we are in a git repository
|
||||
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
echo [$branch]
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_command_append() {
|
||||
arg=${1}
|
||||
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}"${arg}"
|
||||
}
|
||||
|
||||
prompt_command_prepend() {
|
||||
arg=${1}
|
||||
PROMPT_COMMAND="${arg}"${PROMPT_COMMAND:+"; $PROMPT_COMMAND"}
|
||||
}
|
||||
|
||||
blesh-activate()
|
||||
{
|
||||
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
|
||||
if [ -r $BLESH_PATH ]; then
|
||||
[[ $- == *i* ]] && . $HOME/.nix-profile/share/blesh/ble.sh
|
||||
[[ ! ${BLE_VERSION-} ]] || ble-attach
|
||||
fi
|
||||
}
|
||||
|
||||
blesh-available() {
|
||||
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
|
||||
if [ -r $BLESH_PATH ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
blesh-attached () {
|
||||
if [ -z ${BLE_VERSION:+x} ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
[branch]
|
||||
sort = -committerdate
|
||||
[column]
|
||||
ui = auto
|
||||
[tag]
|
||||
sort = version:refname
|
||||
[init]
|
||||
defaultBranch = main
|
||||
[diff]
|
||||
algorithm = histogram
|
||||
colorMoved = plain
|
||||
mnemonicPrefix = true
|
||||
renames = true
|
||||
[push]
|
||||
default = simple
|
||||
autoSetupRemote = true
|
||||
followTags = true
|
||||
[fetch]
|
||||
prune = true
|
||||
pruneTags = true
|
||||
all = true
|
||||
[commit]
|
||||
verbose = true
|
||||
[core]
|
||||
excludefiles = ~/.config/git/ignore
|
||||
38
install.sh
38
install.sh
@@ -6,36 +6,17 @@ set -ex
|
||||
echo "PWD: $PWD"
|
||||
# Coder dotfiles (and most other ways of doing this) will not do a recursive clone, so do that in install script.
|
||||
git submodule init && git submodule update
|
||||
|
||||
# Match case insensitively to make things easier for this part
|
||||
shopt -s nocasematch
|
||||
|
||||
echo "Installing dotfiles..."
|
||||
|
||||
if [ "${CODER_TEMPLATE_TYPE}" == "Devcontainer" ]; then
|
||||
installers/install-nix.sh
|
||||
installers/install-nix-packages-flake.sh
|
||||
if [ -r "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
|
||||
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
|
||||
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
|
||||
. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
|
||||
fi
|
||||
elif [ "${CODER_OS_FAMILY:-}" == "Ubuntu" ]; then
|
||||
echo "Detected OS as Ubuntu, using apt";
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -y stow;
|
||||
installers/install-nix.sh
|
||||
if [ -r "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
|
||||
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
|
||||
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
|
||||
. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
|
||||
fi
|
||||
elif [ -f /etc/os-release ]; then
|
||||
if [ -f /etc/os-release ]; then
|
||||
echo "Idenitfying OS to install GNU stow..."
|
||||
if grep -q -i debian /etc/os-release; then
|
||||
if [ "${CODER_OS_FAMILY:-}" == "Ubuntu" ] || grep -q -i debian /etc/os-release; then
|
||||
echo "Detected OS as Ubuntu, using apt";
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -y stow;
|
||||
installers/install-nix.sh
|
||||
elif grep -q -i rhel /etc/os-release || grep -q -i fedora /etc/os-release; then
|
||||
echo "You've got RedHat (or maybe Fedora)! Which is unsupported right now sorry!";
|
||||
# sudo yum install -y stow;
|
||||
@@ -50,20 +31,15 @@ elif [ -f /etc/os-release ]; then
|
||||
exit 1;
|
||||
fi;
|
||||
else
|
||||
if [ "${CODER_TEMPLATE_TYPE}" == "Devcontainer" ]; then
|
||||
installers/install-nix.sh
|
||||
fi
|
||||
echo "ERROR: Unable to find '/etc/os-release' information!" 1>&2;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
shopt -u nocasematch
|
||||
|
||||
# Apply the dotfiles with stow
|
||||
echo "Running apply dotfiles"
|
||||
if which stow &> /dev/null; then
|
||||
./apply-dotfiles
|
||||
elif which nix &> /dev/null; then
|
||||
./apply-dotfiles-nix
|
||||
else
|
||||
echo "Tools for installing dotfiles are unavailable, failing..."
|
||||
exit 1
|
||||
fi
|
||||
./apply-dotfiles
|
||||
echo "Dotfiles applied successfully"
|
||||
|
||||
@@ -2,31 +2,16 @@
|
||||
# Installs packages to the nix profile using nix profile
|
||||
# Reference: https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management
|
||||
|
||||
set -e
|
||||
|
||||
FLAKE_PATH="${HOME}/.config/nix/flakes/my-package-collection"
|
||||
FLAKE_NAME="flake.nix"
|
||||
ARCHIVE_PATH="${FLAKE_PATH}/archive.nar"
|
||||
|
||||
if ! which nix &>/dev/null; then
|
||||
if [ -r "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
|
||||
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
|
||||
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
|
||||
. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
|
||||
else
|
||||
echo "Nix isn't available. Exiting now!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
set -ex
|
||||
|
||||
nix_packages=(
|
||||
# Personal tools
|
||||
"vimHugeX"
|
||||
"ranger"
|
||||
"jq"
|
||||
"yq"
|
||||
"screen"
|
||||
"xdg-utils" # For xdg-open
|
||||
"zk"
|
||||
|
||||
"shellcheck"
|
||||
|
||||
# Neovim + Plugin dependencies
|
||||
"neovim"
|
||||
@@ -38,11 +23,7 @@ nix_packages=(
|
||||
"yaml-language-server" # Yaml
|
||||
"lua-language-server" # Lua
|
||||
"solargraph" # Ruby
|
||||
# Terraform
|
||||
"terraform-ls"
|
||||
"tflint"
|
||||
"python3Packages.python-lsp-server" # Python
|
||||
"shellcheck"
|
||||
|
||||
# ProgrammingLanguages
|
||||
"lua52Packages.lua"
|
||||
@@ -63,8 +44,6 @@ nix_packages=(
|
||||
"rancher"
|
||||
"gitlab-ci-local"
|
||||
|
||||
"distrobox"
|
||||
|
||||
# Remote programming tools
|
||||
"lemonade"
|
||||
)
|
||||
@@ -81,13 +60,13 @@ unstable_packages=(
|
||||
)
|
||||
|
||||
|
||||
generate_flake() {
|
||||
mkdir -p "${FLAKE_PATH}"
|
||||
templated_insert="$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; echo; done)"
|
||||
templated_insert=${templated_insert}$(for unstable_package in ${unstable_packages[@]}; do echo; echo " unstablePkgs.$unstable_package"; done)
|
||||
mkdir -p ~/.config/nixpkgs/
|
||||
templated_insert="$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; echo; done)"
|
||||
templated_insert=${templated_insert}$(for unstable_package in ${unstable_packages[@]}; do echo; echo " unstablePkgs.$unstable_package"; done)
|
||||
|
||||
# Reference: https://discourse.nixos.org/t/nix-profile-in-combination-with-declarative-package-management/21228/9
|
||||
cat <<EOF > "${FLAKE_PATH}/${FLAKE_NAME}"
|
||||
|
||||
# Reference: https://discourse.nixos.org/t/nix-profile-in-combination-with-declarative-package-management/21228/9
|
||||
cat << EOF > ~/.config/nixpkgs/flake.nix
|
||||
{
|
||||
description = "A declarative system installation";
|
||||
|
||||
@@ -119,7 +98,7 @@ cat <<EOF > "${FLAKE_PATH}/${FLAKE_NAME}"
|
||||
pkgs = nixpkgs.legacyPackages.\${system}; # here we need just legacy packages
|
||||
unstablePkgs = import unstable { inherit system; config.allowUnfree = true; };
|
||||
in pkgs.buildEnv {
|
||||
name = "myPackageCollection";
|
||||
name = "myPackages";
|
||||
paths = with pkgs; [
|
||||
${templated_insert}
|
||||
];
|
||||
@@ -130,19 +109,6 @@ ${templated_insert}
|
||||
}; # outputs
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
lock_flake() {
|
||||
nix flake lock "${FLAKE_PATH}"
|
||||
}
|
||||
|
||||
flake_lock_exists() {
|
||||
if [ -r "${FLAKE_PATH}/flake.lock" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_nix_packages()
|
||||
{
|
||||
@@ -151,48 +117,13 @@ install_nix_packages()
|
||||
if [ "${nix_packages[*]}" ]; then
|
||||
# Updated to process new nix profile format, proper processing probably needs JQ
|
||||
# But JQ would be another dependency and this is good enough for now
|
||||
# Okay we are installing jq to do stuff now but I don't feel like reworking this
|
||||
if nix profile list --json | grep -qi "\"attrPath\":\"${package_name}\""; then
|
||||
if nix profile list --json | grep -i "\"attrPath\":\"${package_name}\""; then
|
||||
echo "Removing previous version of profile"
|
||||
store_path=$(nix profile list --json | nix-shell --quiet -p jq --run 'jq -r .elements.myPackageCollection.storePaths[0]')
|
||||
nix profile remove "${store_path}"
|
||||
nix profile remove "${package_name}"
|
||||
fi
|
||||
echo "Installing profile"
|
||||
nix profile install "${FLAKE_PATH}/#myPackageCollection"
|
||||
nix profile install "${HOME}/.config/nixpkgs/flake.nix#myPackageCollection"
|
||||
fi
|
||||
}
|
||||
|
||||
get_store_path() {
|
||||
# This is only called post successful installation so jq is available
|
||||
nix profile list --json | jq -r .elements.myPackageCollection.storePaths[0]
|
||||
}
|
||||
|
||||
export_archive() {
|
||||
store_path="${1}"
|
||||
mkdir -p "$(dirname ${ARCHIVE_PATH})"
|
||||
nix-store --export $(nix-store --query --requisites ${store_path}) > "${ARCHIVE_PATH}"
|
||||
}
|
||||
|
||||
import_archive() {
|
||||
nix-store --import < "${ARCHIVE_PATH}" > /dev/null
|
||||
}
|
||||
|
||||
archive_exists() {
|
||||
if [ -r "${ARCHIVE_PATH}" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if archive_exists; then
|
||||
import_archive
|
||||
fi
|
||||
generate_flake
|
||||
if ! flake_lock_exists; then
|
||||
lock_flake
|
||||
fi
|
||||
install_nix_packages
|
||||
if ! archive_exists; then
|
||||
export_archive "$(get_store_path)"
|
||||
fi
|
||||
|
||||
@@ -7,12 +7,8 @@ set -e
|
||||
set -x
|
||||
|
||||
# Abort installation if Nix is already installed
|
||||
if [ -d /nix/store ]; then
|
||||
if [ -d /nix ]; then
|
||||
exit 0
|
||||
elif [ -d /nix ] && ! [ -O /nix ]; then
|
||||
# If we don't own /nix use sudo to chown it.
|
||||
# If we can't sudo then nothing we do here will work so we just let this fail
|
||||
sudo chown $UID /nix
|
||||
fi
|
||||
|
||||
# Workaround to make a single user install work as root
|
||||
@@ -22,7 +18,7 @@ if [ "${USER:-}" == "root" ] || [ "${UID:-}" == "0" ]; then
|
||||
fi
|
||||
|
||||
# Download the Nix installer and it's signature from NixOS.org
|
||||
curl -so install-nix https://releases.nixos.org/nix/nix-2.24.12/install
|
||||
curl -so install-nix https://releases.nixos.org/nix/nix-2.18.7/install
|
||||
|
||||
# Run the installer
|
||||
sh ./install-nix
|
||||
@@ -32,8 +28,6 @@ cat << EOF > ~/.bashrc
|
||||
# Source nix if it's installed
|
||||
if [ -r ~/.nix-profile/etc/profile.d/nix.sh ]; then
|
||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
||||
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
|
||||
. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
|
||||
fi
|
||||
EOF
|
||||
|
||||
@@ -46,7 +40,6 @@ NIX_CONF_FILE=${NIX_CONF_DIR}/nix.conf
|
||||
mkdir -p ${NIX_CONF_DIR}
|
||||
cat <<EOF > ${NIX_CONF_FILE}
|
||||
experimental-features = flakes nix-command
|
||||
use-xdg-base-directories = true
|
||||
EOF
|
||||
# Conditionally add a link to system certificates for nix
|
||||
if [ -f /etc/ssl/certs/ca-certificates.crt ]; then
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Defaults to using bash as the shell
|
||||
defshell $SHELL
|
||||
# Extend scrollback buffer
|
||||
defscrollback 100000
|
||||
# Disable startup message
|
||||
@@ -50,6 +50,4 @@ export HISTFILESIZE=10000
|
||||
|
||||
if [ -r "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
|
||||
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
|
||||
elif [ -r "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]; then
|
||||
. "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
|
||||
fi
|
||||
|
||||
@@ -18,8 +18,7 @@ end
|
||||
require('user.lspconfig')
|
||||
require('user.indentblanklines')
|
||||
require('user.luasnip')
|
||||
require('user.terraform')
|
||||
require('user.zk')
|
||||
|
||||
EOF
|
||||
|
||||
nnoremap <leader>ib <cmd>IBLToggle<cr>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
-- Enable terraform language server
|
||||
local lsp = require('lspconfig')
|
||||
lsp.tflint.setup{}
|
||||
lsp.terraformls.setup{}
|
||||
|
||||
-- Enable filetype detection for terraform related files
|
||||
vim.cmd([[silent! autocmd! filetypedetect BufRead,BufNewFile *.tf]])
|
||||
vim.cmd([[autocmd BufRead,BufNewFile *.hcl set filetype=hcl]])
|
||||
vim.cmd([[autocmd BufRead,BufNewFile .terraformrc,terraform.rc set filetype=hcl]])
|
||||
vim.cmd([[autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform]])
|
||||
vim.cmd([[autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json]])
|
||||
|
||||
-- Automatically format on save
|
||||
vim.cmd([[let g:terraform_fmt_on_save=1]])
|
||||
vim.cmd([[let g:terraform_align=1]])
|
||||
|
||||
-- Shorten function name
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Open a terminal in a split to run commands rather than use !
|
||||
keymap("n", "<leader>ti", ":split term://terraform init<CR>", opts)
|
||||
keymap("n", "<leader>tv", ":split term://terraform validate<CR>", opts)
|
||||
keymap("n", "<leader>tp", ":split term://terraform plan<CR>", opts)
|
||||
keymap("n", "<leader>taa", ":split term://terraform apply -auto-approve<CR>", opts)
|
||||
@@ -1,4 +0,0 @@
|
||||
-- Configure the zk neovim plugin
|
||||
require("zk").setup({
|
||||
picker = "fzf"
|
||||
})
|
||||
Submodule vim/.vim/bundle/vim-helm deleted from ae1ebc160d
Submodule vim/.vim/nvim-bundle/zk-nvim deleted from 10089c398d
@@ -1,14 +0,0 @@
|
||||
export XDG_DATA_HOME="${HOME}/.local/share"
|
||||
export XDG_CONFIG_HOME="${HOME}/.config"
|
||||
export XDG_STATE_HOME="${HOME}/.local/state"
|
||||
export XDG_CACHE_HOME="${HOME}/.cache"
|
||||
|
||||
# Set environment variables to force programs to respect XDG that do not by default
|
||||
export SCREENRC="${XDG_CONFIG_HOME}/screen/screenrc"
|
||||
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
||||
export MYSQL_HISTFILE="$XDG_DATA_HOME"/mysql_history
|
||||
export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc
|
||||
export IRBRC="$XDG_CONFIG_HOME/irb/irbrc"
|
||||
|
||||
export KUBECONFIG="${XDG_CONFIG_HOME}/kube/config"
|
||||
mkdir -p "$(dirname ${KUBECONFIG})"
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# For older systems that don't support newer versions of programs that may
|
||||
# support XDG config paths natively we have to symlink to the new paths from
|
||||
# the expected locations of the older paths.
|
||||
|
||||
# This can also be used to support migrations from systems before we started XDGifying
|
||||
|
||||
ln -s "${XDG_CONFIG_HOME}/screen/screenrc" "${HOME}/.screenrc"
|
||||
ln -s "${XDG_DATA_HOME}/.gnupg" "${HOME}/.gnupg"
|
||||
ln -s "${XDG_DATA_HOME}/mysql_history" "${HOME}/.mysql_history"
|
||||
ln -s "${XDG_CONFIG_HOME}/readline/inputrc" "${HOME}/.inputrc"
|
||||
ln -s "${XDG_CONFIG_HOME}/irb/irbc" "${HOME}/.irbrc"
|
||||
ln -s "${XDG_CONFIG_HOME}/kube/config" "${HOME}/.kubeconfig"
|
||||
Reference in New Issue
Block a user