Since TrueNAS is quite locked down in what you can do, I figured NIX would be an ideal way to have flexibility of getting any package I want vs. not breaking TrueNAS. People who don’t fully understand this, please familiarize yourself with NIX - its awesome.
To install NIX you need to do few very straight-forward steps :
-
I use single-user mode as it’s very simple.
-
Figure out where you want to place NIX store (I placed it on NVMe array), create
/nix
(you will needmount -o rw,remount /
for this) -
Create systemd mount unit that bind-mounts your chosen NIX store location into
/nix
(google how to create mount unit files, its easy). Enable and start it. -
Since we will be installing NIX as root, you need this :
echo "build-users-group =" > /etc/nix/nix.conf
-
Install NIX
TMPDIR=/root/nix-install sh <(curl -L https://nixos.org/nix/install) --no-daemon
-
Don’t remember if it auto-creates
.bash_profile
but you need below in it. I guess it can also go into.bashrc
:
[[ -f /root/.nix-profile/etc/profile.d/nix.sh ]] && . /root/.nix-profile/etc/profile.d/nix.sh
- I use S3 cache for NIX stuff via MinIO that runs on TrueNAS. To configure you need :
a. install MinIO and create s3 access keys (google how)
b. Create :
.aws/config
[default]
region = us-east-1
s3 =
signature_version = s3v4
endpoint_url = https://<MINIO HOST>:9000
.aws/credentials
[default]
aws_access_key_id = xxxx
aws_secret_access_key = xxxx
c. Create .config/nix/nix.conf
cat .config/nix/nix.conf
substituters = s3://nix-cache?scheme=https&endpoint=<MINIO HOST>:9000 https://cache.nixos.org
experimental-features = nix-command flakes
post-build-hook = /root/bin/upload-to-cache.sh
where upload-to-cache.sh
looks like
# cat /root/bin/upload-to-cache.sh
#!/bin/sh
set -eu
set -f
export IFS=' '
server="<MINIO HOST>:9000"
echo "Uploading paths" $OUT_PATHS
exec nix copy --to "s3://nix-cache?scheme=https&endpoint=${server}&compression=zstd" $OUT_PATHS
-
Source nix-profile
. /root/.nix-profile/etc/profile.d/nix.sh
-
And start installing stuff like there is no tomorrow
nix-env -iA nixpkgs.git
nix-env -iA nixpkgs.awscli
nix-env -iA nixpkgs.hddtemp
Fully functional NIX without breaking TrueNAS at all.