Anyone using Nix packages

I want to augment my running instance using nix packages.

I’ve done some minor tinkering with nix packages on arch in the past, but found it a bit of a pita.

Do nix packages play nice with LL cloud instances?

Did a bit of hacking…

You need to bootstrap your login shell so that you can run your own bashrc (Explained in another post)

In this bashrc add the following:

##########################
# Reseat HOME to the location of this .bashrc
#

# 1. Get the real path of the current .bashrc

REAL_BASHRC="$(readlink -f "${BASH_SOURCE[0]}")"
REAL_HOME="$(dirname "$REAL_BASHRC")"

# 2. Infer persitent mount point using LambdaLabi's mountingconvention, ie. "${HOME}/${persitent_mount_name}"

MOUNT_POINT="${REAL_BASHRC%/home/*}"

if [[ "$MOUNT_POINT" == "$REAL_BASHRC" ]]; then
    echo "Error: Could not find mount point in path: $REAL_BASHRC"
    return 1
fi

# 3. Check if mount point is writable

if ! [[ -r "$MOUNT_POINT" && -w "$MOUNT_POINT" ]]; then
    echo "Error: \"${MOUNT_POINT}\" point not rw"
    return 2
fi

# 4. Store these before changing HOME

export SYSTEM_HOME="$HOME"
export ROOT="$MOUNT_POINT"
export HOME="$REAL_HOME"

# 5. Change to actual home directory

cd "$HOME"

#################  Other stuff

##########################
# Nix
#

export NIX_ROOT="${ROOT}/nix"
export NIX_PROFILE="${HOME}/.nix-profile"

Then login again and install of Nix manually…

sh <(curl -L https://nixos.org/nix/install) --no-daemon

Login again. Afterwards you should be able to do Nix stuff (RTM), eg.

nix-shell -p go

Refer to https://nixos.org/ for more information