add uv and direnv supp

This commit is contained in:
Tao Tien 2024-08-28 13:49:15 -07:00
parent a0feface3f
commit d599c438a0
7 changed files with 46 additions and 19 deletions

View file

@ -6,6 +6,7 @@
...
}: {
users.users.tao.packages = with pkgs; [
nufmt
freerdp
nixos-anywhere
cloud-hypervisor

View file

@ -22,6 +22,7 @@ in {
source = ./autostart;
recursive = true;
};
home.file.".config/direnv/lib/uv.sh".source = ./uv.sh;
programs = {
bat = {

View file

@ -52,7 +52,7 @@
};
};
languages = {
use-grammars.only = ["rust" "c" "cpp" "typst" "nix" "html" "toml" "markdown" "just"];
use-grammars.only = ["rust" "c" "cpp" "typst" "nix" "html" "toml" "markdown" "just" "bash"];
language = [
{
name = "arduino";

View file

@ -1,5 +1,7 @@
task
task
alias xo = xdg-open
alias h = hx (sk)
alias b = btm
alias cringe = sudo bootctl set-oneshot auto-windows
alias fetch = fastfetch
@ -10,13 +12,11 @@ alias zl = zellij
alias snapper = snapper -c home
alias quiet = sudo ectool fanduty 42
alias loud = sudo ectool autofanctl
alias jd = jj diff
alias jc = jj desc
alias js = jj status
alias jp = jj git push
alias jm = jj branch set main
def c [path: path = "~"] {
export-env {cd $path}
l
@ -37,11 +37,9 @@ def l [
}
| sort-by type name -i -n
}
def srg [pattern] {
sk --ansi -i -c 'rg --color=always --line-number "{}"'
}
alias nd = nix develop
def ns [package] {
nix shell $"nixpkgs#($package)"
@ -49,7 +47,6 @@ def ns [package] {
def nr [package] {
nix search nixpkgs $package
}
def rebuild [subcommand] {
sudo nice -n19 nixos-rebuild $subcommand --flake /home/tao/projects/NOflake/ --impure --verbose
}
@ -70,15 +67,14 @@ def bump [] {
alias rb = rebuild boot
alias rs = rebuild switch
alias gc = nh clean all
def check-mullvad [] {
loop {
print "checking connection status"
http get https://am.i.mullvad.net/json
| if $in.mullvad_exit_ip == true {break}
sleep 1sec
}
}
def tse [exit_node: string = ""] {
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
print "stop summoning first!"
@ -86,7 +82,9 @@ def tse [exit_node: string = ""] {
} else {
tailscale set --exit-node $exit_node
}
check-mullvad
if ($exit_node | is-not-empty) {
check-mullvad
}
}
def tsp [] {
tailscale exit-node list
@ -133,17 +131,14 @@ alias tsu = tailscale up
alias tsd = tailscale down
alias tsx = tailscale exit-node list
alias tsa = tailscale exit-node suggest
def "config stuff" [] {
hx ~/projects/NOflake/users/tao/nushell/stuff.nu
}
def deluge-gtk [] {
tsr
deluge-gtk
}
alias deluge = deluge-gtk
def fixme [] {
rg TODO --json
| lines
@ -154,6 +149,5 @@ def fixme [] {
| each {$"($in.text):($in.line_number)"}
| hx ...$in
}
source ~/.cache/starship/init.nu
source ~/.zoxide.nu

23
users/tao/uv.sh Normal file
View file

@ -0,0 +1,23 @@
layout_python_uv() {
local python=${1:-python}
[[ $# -gt 0 ]] && shift
unset PYTHONHOME
local python_version=$($python -V | cut -d " " -f 2 | cut -d . -f 1-2)
if [[ -z $python_version ]]; then
log_error "Could not find python's version"
return 1
fi
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
local REPLY
realpath.absolute "$VIRTUAL_ENV"
VIRTUAL_ENV=$REPLY
else
VIRTUAL_ENV=$(direnv_layout_dir)/python-$python_version
fi
if [[ ! -d $VIRTUAL_ENV ]]; then
uv venv -p $python "$@" "$VIRTUAL_ENV"
fi
export VIRTUAL_ENV
PATH_add "$VIRTUAL_ENV/bin"
}