40 lines
1.2 KiB
Fish
40 lines
1.2 KiB
Fish
begin
|
|
set -l dir (status dirname)
|
|
set -l config "$dir/config.fish"
|
|
set nixPkgsDir /nix/var/nix/profiles/per-user/root/channels/nixpkgs
|
|
|
|
function __isNixModule -a path
|
|
nix-instantiate --eval --expr "{ path }: import path" --argstr path "$path" &>/dev/null
|
|
end
|
|
|
|
function downloadNixPkgs -V config
|
|
source "$config"
|
|
|
|
if ! __isNixModule "$nixPkgsCache"
|
|
rm -rf "$nixPkgsCache"
|
|
and mkdir -p "$nixPkgsCache"
|
|
and git -C "$nixPkgsCache" init
|
|
and git -C "$nixPkgsCache" remote add origin https://github.com/NixOS/nixpkgs.git
|
|
and git -C "$nixPkgsCache" fetch --depth=1 origin "$nixPkgsVersion"
|
|
and git -C "$nixPkgsCache" reset --hard FETCH_HEAD
|
|
and rm -rf "$nixPkgsCache/.git"
|
|
end
|
|
end
|
|
|
|
function installNixPkgs -V config -V nixPkgsDir
|
|
source "$config"
|
|
|
|
if ! __isNixModule "$nixPkgsDir"
|
|
if ! __isNixModule "$nixPkgsCache"
|
|
downloadNixPkgs
|
|
end
|
|
|
|
sudo mkdir -p "$nixPkgsDir"
|
|
sudo cp -r "$nixPkgsCache"/* "$nixPkgsDir"
|
|
end
|
|
end
|
|
|
|
function uninstallNixPkgs -V nixPkgsDir
|
|
sudo rm -rf (dirname "$nixPkgsDir")
|
|
end
|
|
end
|