Created
August 6, 2022 12:36
-
-
Save bonds/1cb0ae202dbe409aebb81b1f1feacbc4 to your computer and use it in GitHub Desktop.
wrappers for nix+flakes to make un/installing software easier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.config/fish/functions/nin.fish | |
function nin | |
set installed (nix profile list) | |
if string match "" "$argv" | |
set argv (cat ~/.config/nix/nin.conf) | |
end | |
for item in $argv | |
source ~/.config/fish/functions/_nin_patterns.fish | |
if string match --quiet "$pattern" $installed | |
echo skipping $item | |
continue | |
else | |
echo installing $item | |
if nix profile install $name | |
echo $item >> $config | |
sed -i -n '/^$/d' $config # remove blank lines | |
sort --unique --output $config $config | |
end | |
end | |
end | |
end | |
# ~/.config/fish/functions/nun.fish | |
function nun | |
set installed (nix profile list) | |
for item in $argv | |
source ~/.config/fish/functions/_nin_patterns.fish | |
if string match --quiet "$pattern" $installed | |
echo uninstalling $item | |
set line (string match "$pattern" $installed | string split " ") | |
set number $line[1] | |
if nix profile remove $number | |
sed -i -n "/$item/d" "$config" | |
sed -i -n '/^$/d' $config # remove blank lines | |
end | |
else | |
echo skipping $item | |
continue | |
end | |
end | |
end | |
# ~/.config/fish/functions/nup.fish | |
function nup | |
nix profile upgrade ".*" $argv; | |
end | |
# ~/.config/fish/functions/_nin_patterns.fish | |
set config ~/.config/nix/nin.conf | |
if string match "github*" $item | |
set pattern "*$item*" | |
set name "$item" | |
else if string match "*/*" $item | |
set pattern "*github:$item*" | |
set name "github:$item" | |
else | |
set pattern "*-$item-*" | |
set name "nixpkgs#$item" | |
end | |
# ~/.config/nix/nin.conf | |
hugo | |
fd | |
fish | |
fzf | |
idris-lang/Idris2 | |
iterm2 | |
ripgrep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment