mkosi.nspawn is not honoured during mkosi.postinst
When the mkosi.postint script is being run, the values in mkosi.nspawn are not honoured, specifically I was hoping to get some of the Bind= directives during postinst.
Using mkosi.nspawn for both postinst and actual running might introduce other issues. We could perhaps add a --postinst-bind option to support this instead. Could you explain your use case a bit more?
I'm trying to create a user in the container that matches an existing user on the host to be able to have a persistent home directory which is accessible from both host and container.
I've approached this by placing the following in mkosi.extra/etc/sysusers.d/user.conf:
u user /var/lib/user "User" /var/lib/user
g user /var/lib/user
I had then hoped that on first booting the container with /var/lib/user bound from host, the new user would be created with the uid/gid from the hosts /var/lib/user.
Unfortunately, since postinst doesn't bind, the created user did not have the right ids.
Hmm, so sysusers is not recommended to create normal users. Instead, maybe we should just add an option to create regular users to mkosi itself. Then you could just specify Users=user:group in the config file. Would that work for you?
The advantage of using the Bind and sysusers is that it is more portable, i.e. the created user will have the same id as the folder that is going to be bound.
A Users=user:group I suppose will also provide a --users, that could be used to script the uid/gid selection.
For now, I'm hardcoding the uid in the sysusers file. Which also works.
Not relevant anymore since we don't use nspawn anymore for postinst scripts