Open pmorch opened 6 months ago
I also think there is something fishy with the locale setup on a Synology.
This fixes it (and I put it in my ~/.bashrc):
$ export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"
# before
$ nix-shell -p hello --run hello
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
Hello, world!
$ export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"
# after
$ nix-shell -p hello --run hello
Hello, world!
And don't fall for Locales - NixOS Wiki's suggestion of export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
- that file from Synology is not up to the task.
I just tried to install multi-user Nix on a test Synology installation using vdsm/virtual-dsm: Virtual DSM in a Docker container, and it seems it would be an uphill battle getting multi-user Nix to work:
$ sh pmorch-nix-install --daemon
<snip>
~~> Setting up the build group nixbld
---- sudo execution ------------------------------------------------------------
I am executing:
$ sudo groupadd -g 30000 --system nixbld
Create the Nix build group, nixbld
sudo: groupadd: command not found
---- oh no! --------------------------------------------------------------------
Oh no, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.
:(
We'd love to help if you need it.
You can open an issue at
https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md
Or get in touch with the community: https://nixos.org/community
And yes, Synology DSM does not provide groupadd
or useradd
. Go figure.
Feel free to close this issue. I just wanted to document this for the next poor bastard that wants to try it. If there is a better place for me to put this, let me know.
@pmorch You are a personal saint to me, if i should ever give birth to progeny. I will give them your name as one of their middle names.
Based on @pmorch's work. Here are some instructions for getting up and running with nix
on synology NAS.
admin
. It may likely be the same on your box. On my machine, there's folders owned by me, and my ex, and a shared folder we both have access to. This folder is /volume1/MobyX/SD2
. So to satisfy this requirement, while under my regular account whose user ID is std
. I ran the following commands.
mkdir /volume1/MobyX/SD2/nix /volume1/MobyX/SD2/tmp
sudo chown -r admin:users /volume1/MobyX/SD2/nix /volume1/MobyX/SD2/tmp
cd /volume1/MobyX/SD2/nix
Then, I wrote the following script and saved it as /volume1/MobyX/SD2/nix/tasty-nix-init
#!/bin/sh
TEMP_DIR="/volume1/MobyX/SD2/tmp"
NIX_DIR="/volume1/MobyX/SD2/nix"
USER_UID="std"
ADMIN_UID="admin"
ADMIN_GROUP="users"
oops() { echo "$0:" "$@" >&2 exit 1 }
if [ "$(id -u)" -ne 0 ]; then oops "This script must be run as root. Please run with sudo or as the root user." fi
mkdir -p "$TEMP_DIR" || oops "Failed to create temporary directory $TEMP_DIR" chmod 1777 "$TEMP_DIR" || oops "Failed to set permissions on $TEMP_DIR."
mkdir -p "$NIX_DIR" || oops "Failed to create Nix directory $NIX_DIR" chmod -R go+rx "$NIX_DIR"|| oops "Failed to set permissions on $NIX_DIR" chown -R "$ADMIN_UID:$ADMIN_GROUP" "$NIX_DIR"
if ! grep -q "$NIX_DIR /nix none bind 0 0" /etc/fstab; then echo "$NIX_DIR /nix none bind 0 0" >> /etc/fstab || oops "Failed to add /nix bind mount to /etc/fstab" fi
echo "Setup complete. Now running the main installer script as $USER_UID..."
su - "$ADMIN_UID" -c "export TMPDIR=\"$TEMP_DIR\"; sh /nix/tasty-nix-install"
3. Then I downloaded the official installer. `curl -L -o tasty-nix-install https://nixos.org/nix/install`
4. At this point, if you run `sudo sh tasty-nix-init`. Everything should run without a hitch. If you run into issues, read the error, dissect the problem, get sleep, and try again, then ask around.
@pmorch The only difference from your instructions is just packaging it to be easier for others to use, and making sure that /nix
was in the fstab
otherwise the nix installation would be bonked on the next reboot.
Its probably worth mentioning why i went bananas over this issue. I love synology. One thing that's keeping me from doing more on it, is the ethereal nature of the whole configuration. Beyond the settings that would be backed up via synology internals (which relate to services that synology officially makes available), there's a whole world of 100s if not 1000s of micro-services and daemons that run through the portainer
ecosystem. I get about 3 tutorials a week in my feed about how to install some service on synology via portainer. I'm fully aware of the magnitude of what you can do with portainer.
But its those instructions themselves that are precisely why i don't want to do any of it. I have to follow a set of bespoke instructions for just about every single service. There's not like a synology-community install mopidy
. And that automatically sets up a portainer stack with all the correct variables and drops you into the admin interface under yournas.address/mopidy
. Even if there were, there are many questions.
So, I haven't quite addressed the ability to run a command to just add a package and configure it and drop you into a UI. But the settings storage and persistence, and the blender question are things i've answered on all of my dev environments through nix.
I generally never run anything like brew install mopidy
. Instead i have a git repo on my machine's , there's a nix flake in there that describes how all the machines i touch are configured. This includes what packages are installed, and how each package is configured. This basically makes huge portions of my configuration deterministic and nearly immutable. When something is broken, i can't end up in a state where fragments of previous attempts to fix the issue are lingering around causing unspeakable havoc where among the edges of subsequent issues, through interacting via terrifying and elusive nuances which might take me days of further compromising my system integrity – to even discover.
Every change to my configuration is a change to the code that configures everything. Everything is in source-control. I can bissect the historical state of how things are configured. In the case of mopidy, a rich abstraction already exists that's even easier than portainer's approach. I just edit the nix configuration and add a section like this (https://github.com/TuringTestTwister/mediaserver/blob/10b54b8959cf142d1f65e9611943c938d8be7f3b/profiles/mopidy.nix#L3).
I can share huge swaths of customization and configuration between completely different operating systems. I can unify how i handle dependencies on a per-client, per-language, per-project, or per-machine basis. If i want to augment my home's security with a few extra cameras, but i am low on funds, but have plenty of raspberry pi's and webcams sitting in the dust. I can write a nix-configuration snippet to generate an ISO image that i can flash onto any of my PIs. That image might have a streamlined version of my favorite vim settings. A few yolo models to recognize my cats and interact with some cloud services that streamline my object-detection classifier checkpoints. And that's because generating ISO images, or generating container descriptions (E.g. generating a dockerfile or docker compose trees) is exactly the same semantics s my own local machine.
This is all possible through nix.
With just plain portainer, i'm reliant on replicating state via following sequences of steps with only loose predictability based on any kind of source-controllable configuration.
With nix, i'm now free to install whatever constellations of containers i want through a variety of approaches https://github.com/aksiksi/compose2nix https://docs.hercules-ci.com/arion/ https://gitlab.com/cbleslie/portainer-on-nixos
and be certain that so long as i've configured all my constellations through one of these methods, that i am free to toss my NAS into a shredder and standup a new synology NAS. Follow the instructions in this issue thread, pull down my NAS configuration from source control and run build and have my system precisely as it was (less any non-infrastructure data that was on the NAS... like... the content; movies, tv-shows, database contents etc...)
FYI. My solution with running the installer as admin
is dubious. Here's how i have to invoke nix-shell
sudo su - admin -c "nix-shell -p hello --run hello"
😭
Describe the bug
Steps To Reproduce
/bin/sh
on Synology is weird, apparentlyTrying to run:
So instead I downloaded and ran the script the old fashioned way.
/tmp
mountednoexec
Permission denied
is because/tmp
on a synology is mountednoexec
:So I created
/var/services/homes/peteradmin/nixtmpdir
and modified the script:Partition
/
runs fullAnd now "No space left on device":
And yes, partition
/
is tiny.Workaround:
Installation (mostly) works now
I'm not sure what line I should add to my
~/.profile
, but I assume it is:Test