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

@ -1,5 +1,6 @@
{pkgs, ...}: { {pkgs, ...}: {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
bash-language-server
qemu qemu
# quickemu # quickemu
# lychee # link checker # lychee # link checker
@ -47,12 +48,13 @@
nil nil
alejandra alejandra
# # python # python
# pypy3 pypy3
# python3 python3
# python310Packages.python-lsp-server # python310Packages.python-lsp-server
# ruff uv
# ruff-lsp ruff
ruff-lsp
# go # go
go go

View file

@ -78,6 +78,12 @@
programs.ssh.startAgent = true; programs.ssh.startAgent = true;
services.printing.enable = lib.mkDefault true; services.printing.enable = lib.mkDefault true;
services.printing.drivers = with pkgs; [hplip hplipWithPlugin gutenprint gutenprintBin];
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
services.tailscale.enable = true; services.tailscale.enable = true;

View file

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

View file

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

View file

@ -52,7 +52,7 @@
}; };
}; };
languages = { 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 = [ language = [
{ {
name = "arduino"; name = "arduino";

View file

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