NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.59k forks source link

Enhancement: NixOS options to create NFS/Samba share path if do not exist #326121

Open midirhee12 opened 2 months ago

midirhee12 commented 2 months ago

Motivation

For any given configuration with an NFS or Samba service defined, the configuration cannot be used to install NixOS. The services must be disabled first because the paths that NFS or Samba are trying to share do not exist. This requires the system to have a separate install configuration from their production configuration requiring two rebuilds and some external script to create the paths. This is both annoying to maintain and breaks the chain of reproducibility that NixOS has much success with. I believe its integral to the design of NixOS to favor creating such paths for the ability to install with a single configuration and also to not rely on external scripts.

Issue Description

There should be a NixOS option for both NFS and Samba configuration to automatically create respective share paths. This could be named something like services.nfs.server.autoCreate and services.samba.autoCreate which would either be of an enable option type or a list of paths to create during build. This doesn't seem too outside the scope of NixOS with other configurations such as environment.etc and systemd.tmpfiles / systemd.user.tmpfiles.

eclairevoyant commented 2 months ago

I don't understand the request here; shouldn't that be on the user to ensure that they either have a valid mount configuration and/or make use of systemd-tmpfiles to create paths that don't exist?

midirhee12 commented 2 months ago

Is there something I need to clarify? I can try rewording it maybe if you quote it.

Regarding the second statement, there's a number of reasons:

  1. systemd-tmpfiles is invoked after the NFS and Samba shares are created. This means that the NFS and Samba share options will error out without building correctly. If the directory paths are created ahead of time, the NFS and Samba services will correctly bind to the export path.
  2. Any configuration should be reproducible in NixOS without external factors. If it is not possible in the current state, this should probably be fixed.

If this was possible with tmpfiles, I would agree with you that this is up to user configuration instead of the responsibility of NixOS. But in the current state, this is not true. I can see where you're coming from though.

midirhee12 commented 2 months ago

Forgot to mention: @eclairevoyant . Sorry, you probably wanted the ping.