begin
    set -l dir (status dirname)
    set -l config "$dir/config.fish"
    set nixPkgsDir "/nix/var/nix/profiles/per-user/root/channels/nixpkgs"

    function downloadNixPkgs -V config
        source "$config"

        if [ ! -d "$nixPkgsCache" ]
            mkdir -p "$nixPkgsCache"
            and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixPkgsVersion" "$nixPkgsCache"
            and rm -rf "$nixPkgsCache/.git"
        end
    end

    function installNixPkgs -V config -V nixPkgsDir
        source "$config"
        downloadNixPkgs
        mkdir -p "$nixPkgsDir"
        cp -r "$nixPkgsCache"/* "$nixPkgsDir"
    end

    function uninstallNixPkgs -V nixPkgsDir
        rm -rf "$nixPkgsDir"
    end
end