[Nix-dev] Custom directories

Arnold Krille arnold at arnoldarts.de
Wed May 25 22:14:58 CEST 2016


On Wed, 25 May 2016 17:26:24 +0300 Daniel Hlynskyi
<abcz2.uprola at gmail.com> wrote:
> Hi. What's canonical Nixos way to specify custom directories?
> 
> I'm playing with containers. Here is excerpt of my config:
> 
>   fileSystems."/media/logs" = { fsType = "ext4";  label = "logs"; };
>   boot.initrd.postMountCommands = ''
>     chmod 777 /media/logs
>   '';
> 
>   containers.dwarfs =
>     { bindMounts."/media/logs/dwarfs".hostPath = "/media/logs/dwarfs";
>       bindMounts."/media/logs/dwarfs".isReadOnly = false;
>       config =
>    { config, pkgs, ... }:
>    {
>          boot.postBootCommands = ''
>                 chmod 777 /media/logs/dwarfs
>              '';
> 
> I'd like for directory /media/logs/dwarfs to exist, but I don't know
> where to put _the_ mkdir.
> 
> boot.initrd.postMountCommands is not exactly what I want, because I
> need to remount drive or reboot host for changes to apply, but plain
> nixos-rebuild switch doesn't execute postMountCommands.
> 
> Also I'd like to change directory mask in containers without container
> restart (instead of boot.postBootCommands)

Here is how one of my containers has its data dir in a special
partition with special permissions:
https://github.com/kampfschlaefer/nixconfig/blob/master/portal/containers/mpd.nix
Note that the directory is created by systemd before mounting partition.

But maybe the bindMounts of containers need to be extended so they also
create the target directory with the permissions you want. But what
happens when you want a userid for permissions that exists only inside
the container? Current bindmount stuff is outside the container…

- Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160525/491397b6/attachment.bin 


More information about the nix-dev mailing list