forked from nico/dots
chore: add alias 'flakeup' using direnv to quickly upgrade nix packages
This commit is contained in:
parent
2cdd49b396
commit
1acc767910
1 changed files with 32 additions and 0 deletions
32
.envrc
Normal file
32
.envrc
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# ~/.direnvrc
|
||||||
|
|
||||||
|
# Clear existing aliases when entering a directory
|
||||||
|
|
||||||
|
export tmpdir="$(mktemp -d -t dots-alias-direnv.XXXXXX)"
|
||||||
|
rm -rf "/tmp/dots-alias-direnv.*"
|
||||||
|
|
||||||
|
export_alias() {
|
||||||
|
# Create a new alias
|
||||||
|
local name=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
local alias_dir="$tmpdir/.envrc-aliases"
|
||||||
|
local alias_file="$alias_dir/$name"
|
||||||
|
local oldpath="$PATH"
|
||||||
|
|
||||||
|
# If this is the first time we're calling export_alias, add to PATH once
|
||||||
|
if ! [[ ":$PATH:" == *":$alias_dir:"* ]]; then
|
||||||
|
mkdir -p "$alias_dir"
|
||||||
|
PATH_add "$alias_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write the alias file
|
||||||
|
cat <<EOT >$alias_file
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
PATH="$oldpath"
|
||||||
|
$@
|
||||||
|
EOT
|
||||||
|
chmod +x "$alias_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
export_alias flakeup 'nix flake update && git commit flake.lock -m "nix: update flake to latest unstable nixpkgs" && FLAKE=$PWD nh os switch'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue