[Nix-dev] How to ensure that a directory exists via configuration.nix

Guillaume Maudoux (Layus) layus.on at gmail.com
Fri Feb 10 02:31:58 CET 2017


Hi Mark,

This is usually handled by systemd units. When a service requires a 
directory, we add ExecBefore scripts to setup the directory. There are 
plenty such examples in nixos modules.
If you need it for you as a user, you could make a service required by 
multiuser.target.

On the other hand, there are plenty of places where you can insert such 
commands on the initialization path.
For example, you could insert that command in the activate script 
executed on every boot and every `nixos-rebuild switch`
See the option `system.activationScripts` for details.

I would go for the second option if you need /mnt.

-- layus.

On 10/02/17 01:59, Mark Gardner wrote:
> I have searched the manual and options, as well as the Internet, and 
> have not found how to specify in configuration.nix that a directory 
> should exist, in this case /mnt, creating it if not. One might put "if 
> [ ! -d /mnt ] ; then mkdir /mnt; fi" in rc.local. What is the NixOS 
> way to do this (or anything else that one might put in rc.local)?
>
> Mark
> -- 
> Mark Gardner
> --
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170210/72681f4f/attachment.html>


More information about the nix-dev mailing list