Merge branch 'master' of https://git.nixy.moe/nixy/dotfiles
This commit is contained in:
commit
790c132e07
@ -24,11 +24,12 @@ fi
|
|||||||
export PS1="${green}\$${no_color} "
|
export PS1="${green}\$${no_color} "
|
||||||
export DIRENV_PS1="${red}\$${no_color} "
|
export DIRENV_PS1="${red}\$${no_color} "
|
||||||
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
|
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
|
||||||
|
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
|
||||||
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
|
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
|
||||||
DIRENV_PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
|
|
||||||
fi
|
fi
|
||||||
export ORIG_PS1=${PS1}
|
export ORIG_PS1=${PS1}
|
||||||
|
|
||||||
|
if which direnv &> /dev/null; then
|
||||||
update_prompt() {
|
update_prompt() {
|
||||||
if direnv status | grep -iq 'RC allowed true'; then
|
if direnv status | grep -iq 'RC allowed true'; then
|
||||||
PS1=${DIRENV_PS1}
|
PS1=${DIRENV_PS1}
|
||||||
@ -37,6 +38,7 @@ update_prompt() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
|
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
|
||||||
|
fi
|
||||||
|
|
||||||
# Continuation Prompt: "> " in cyan
|
# Continuation Prompt: "> " in cyan
|
||||||
export PS2="${cyan}>${no_color} "
|
export PS2="${cyan}>${no_color} "
|
||||||
|
|||||||
11
install.sh
11
install.sh
@ -6,14 +6,17 @@ set -ex
|
|||||||
echo "PWD: $PWD"
|
echo "PWD: $PWD"
|
||||||
# Coder dotfiles (and most other ways of doing this) will not do a recursive clone, so do that in install script.
|
# 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
|
git submodule init && git submodule update
|
||||||
|
# Match case insensitively to make things easier for this part
|
||||||
|
shopt -s nocasematch
|
||||||
|
|
||||||
echo "Installing dotfiles..."
|
echo "Installing dotfiles..."
|
||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
echo "Idenitfying OS to install GNU stow..."
|
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 "You've got Debian!";
|
echo "Detected OS as Ubuntu, using apt";
|
||||||
sudo apt-get update;
|
sudo apt-get update;
|
||||||
sudo apt-get install -y stow;
|
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
|
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!";
|
echo "You've got RedHat (or maybe Fedora)! Which is unsupported right now sorry!";
|
||||||
# sudo yum install -y stow;
|
# sudo yum install -y stow;
|
||||||
@ -28,9 +31,13 @@ if [ -f /etc/os-release ]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
else
|
else
|
||||||
|
if [ "${CODER_TEMPLATE_TYPE}" == "Devcontainer" ]; then
|
||||||
|
installers/install-nix.sh
|
||||||
|
fi
|
||||||
echo "ERROR: Unable to find '/etc/os-release' information!" 1>&2;
|
echo "ERROR: Unable to find '/etc/os-release' information!" 1>&2;
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
shopt -u nocasematch
|
||||||
|
|
||||||
# Apply the dotfiles with stow
|
# Apply the dotfiles with stow
|
||||||
echo "Running apply dotfiles"
|
echo "Running apply dotfiles"
|
||||||
|
|||||||
109
installers/install-nix-packages-flake.sh
Executable file
109
installers/install-nix-packages-flake.sh
Executable file
@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Installs packages to the nix profile using nix profile
|
||||||
|
# Reference: https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
nix_packages=(
|
||||||
|
# Personal tools
|
||||||
|
"vimHugeX"
|
||||||
|
"ranger"
|
||||||
|
"jq"
|
||||||
|
"yq"
|
||||||
|
|
||||||
|
# Neovim + Plugin dependencies
|
||||||
|
"neovim"
|
||||||
|
"ripgrep"
|
||||||
|
"fzf"
|
||||||
|
|
||||||
|
# Language servers
|
||||||
|
"helm-ls"
|
||||||
|
"yaml-language-server"
|
||||||
|
"lua-language-server"
|
||||||
|
|
||||||
|
# ProgrammingLanguages
|
||||||
|
"lua52Packages.lua"
|
||||||
|
|
||||||
|
"pass"
|
||||||
|
"gnupg"
|
||||||
|
|
||||||
|
# Professional tools
|
||||||
|
"skopeo"
|
||||||
|
"awscli2"
|
||||||
|
|
||||||
|
"kubectl"
|
||||||
|
"kubernetes-helm"
|
||||||
|
"rancher"
|
||||||
|
|
||||||
|
#"terraform"
|
||||||
|
"opentofu"
|
||||||
|
"terragrunt"
|
||||||
|
)
|
||||||
|
unstable_packages=(
|
||||||
|
# CVE in NixOS stable version of vault
|
||||||
|
"vault"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p ~/.config/nixpkgs/
|
||||||
|
templated_insert=$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; done)
|
||||||
|
|
||||||
|
|
||||||
|
# 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";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; # also possible: nixos-unstable
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
|
||||||
|
# Generate a user-friendly version number.
|
||||||
|
version = builtins.substring 0 8 self.lastModifiedDate;
|
||||||
|
|
||||||
|
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
|
||||||
|
# Nixpkgs instantiated for supported system types.
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
|
in {
|
||||||
|
packages = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgsFor.\${system};
|
||||||
|
in {
|
||||||
|
default = self.packages.\${system}.myPackageCollection;
|
||||||
|
myPackageCollection = # libs and clis
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.\${system}; # here we need just legacy packages
|
||||||
|
in pkgs.buildEnv {
|
||||||
|
name = "myPackages";
|
||||||
|
paths = with pkgs; [
|
||||||
|
${templated_insert}
|
||||||
|
];
|
||||||
|
|
||||||
|
extraOutputsToInstall = [ "man" "doc" ];
|
||||||
|
};
|
||||||
|
}); # packages
|
||||||
|
}; # outputs
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
install_nix_packages()
|
||||||
|
{
|
||||||
|
# The name of the package we are going to install, needed to check for presence/uninstall
|
||||||
|
package_name=packages.x86_64-linux.myPackageCollection
|
||||||
|
if [ "${nix_packages[*]}" ]; then
|
||||||
|
if nix profile list | cut -d' ' -f 2 | grep -q "${package_name}"; then
|
||||||
|
echo "Removing previous version of profile"
|
||||||
|
nix profile remove "${package_name}"
|
||||||
|
fi
|
||||||
|
echo "Installing profile"
|
||||||
|
nix profile install "${HOME}/.config/nixpkgs/flake.nix#myPackageCollection"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_nix_packages
|
||||||
41
installers/install-nix.sh
Executable file
41
installers/install-nix.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Install the Nix package manager as a secondary package manager.
|
||||||
|
# This can sometimes be useful for getting more recent packages.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# Abort installation if Nix is already installed
|
||||||
|
if [ -d /nix ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Workaround to make a single user install work as root
|
||||||
|
if [ "${USER:-}" == "root" ] || [ "${UID:-}" == "0" ]; then
|
||||||
|
mkdir -p /etc/nix
|
||||||
|
echo "build-users-group =" > /etc/nix/nix.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download the Nix installer and it's signature from NixOS.org
|
||||||
|
curl -so install-nix https://releases.nixos.org/nix/nix-2.18.1/install
|
||||||
|
|
||||||
|
# Run the installer
|
||||||
|
sh ./install-nix
|
||||||
|
|
||||||
|
# Source the nix profile
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Remove the installer and signature
|
||||||
|
rm -f ./install-nix
|
||||||
|
|
||||||
|
# Enable flakes and the nix command
|
||||||
|
mkdir -p ~/.config/nix
|
||||||
|
cat <<EOF > ~/.config/nix/nix.conf
|
||||||
|
experimental-features = flakes nix-command
|
||||||
|
EOF
|
||||||
@ -34,7 +34,8 @@ ls.config.set_config {
|
|||||||
|
|
||||||
-- Expand if expandable, or jump forward if jumpable
|
-- Expand if expandable, or jump forward if jumpable
|
||||||
-- If neither, do nothing queitly
|
-- If neither, do nothing queitly
|
||||||
vim.keymap.set({ "i", "s" }, "<C-K>", function()
|
-- vim.keymap.set({ "i", "s" }, "<C-K>", function()
|
||||||
|
vim.keymap.set({ "i", "s" }, "<Tab>", function()
|
||||||
if ls.expand_or_jumpable() then
|
if ls.expand_or_jumpable() then
|
||||||
ls.expand_or_jump()
|
ls.expand_or_jump()
|
||||||
end
|
end
|
||||||
@ -42,23 +43,37 @@ end, { silent = true })
|
|||||||
-- end, { silent = true })
|
-- end, { silent = true })
|
||||||
|
|
||||||
-- Jump backwards to the previous jumpable point
|
-- Jump backwards to the previous jumpable point
|
||||||
vim.keymap.set({ "i", "s" }, "<C-J>", function()
|
-- vim.keymap.set({ "i", "s" }, "<C-J>", function()
|
||||||
|
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
||||||
if ls.jumpable(-1) then
|
if ls.jumpable(-1) then
|
||||||
ls.jump(-1)
|
ls.jump(-1)
|
||||||
end
|
end
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
|
|
||||||
-- Selecting from a list of options in a choice node
|
-- Selecting from a list of options in a choice node
|
||||||
vim.keymap.set({ "i" }, "<C-L>", function()
|
-- vim.keymap.set({ "i" }, "<C-L>", function()
|
||||||
|
vim.keymap.set({ "i" }, "<A-Tab>", function()
|
||||||
if ls.choice_active() then
|
if ls.choice_active() then
|
||||||
ls.change_choice(1)
|
ls.change_choice(1)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Allow us to hot reload snippets
|
-- Allow us to hot reload snippets by unloading snippets then resourcing file
|
||||||
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/user/luasnip.lua<CR>")
|
local ls_cleanup = function()
|
||||||
|
ls.cleanup()
|
||||||
|
vim.cmd("source ~/.config/nvim/lua/user/luasnip.lua")
|
||||||
|
end
|
||||||
|
vim.keymap.set("n", "<leader><leader>s", ls_cleanup)
|
||||||
|
|
||||||
ls.add_snippets('lua', {
|
ls.add_snippets(nil, {
|
||||||
|
terraform = {
|
||||||
|
ls.parser.parse_snippet("res", "resource \"$1\" \"$2\" {\n $3\n}"),
|
||||||
|
ls.parser.parse_snippet("dat", "data \"$1\" \"$2\" {\n $3\n}"),
|
||||||
|
ls.parser.parse_snippet("var", "variable \"$1\" {\n type = $2\n description = $3\n}"),
|
||||||
|
ls.parser.parse_snippet("loc", "locals {\n $1\n}"),
|
||||||
|
ls.parser.parse_snippet("mod", "module {\n source = $1\n}"),
|
||||||
|
},
|
||||||
|
lua = {
|
||||||
ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
|
ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
|
||||||
ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend"),
|
ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend"),
|
||||||
ls.parser.parse_snippet("mf", "$1.$2 = function($3)\n $0\nend"),
|
ls.parser.parse_snippet("mf", "$1.$2 = function($3)\n $0\nend"),
|
||||||
@ -79,4 +94,5 @@ ls.add_snippets('lua', {
|
|||||||
rep(1)
|
rep(1)
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user