diff --git a/lib/types/nodev.nix b/lib/types/nodev.nix index f0d3c503..55845c84 100644 --- a/lib/types/nodev.nix +++ b/lib/types/nodev.nix @@ -46,15 +46,20 @@ }; _mount = diskoLib.mkMountOption { inherit config options; - default = lib.optionalAttrs (config.mountpoint != null) { - fs.${config.mountpoint} = '' - if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then - mount -t ${config.fsType} "${config.device}" "${rootMountPoint}${config.mountpoint}" \ - ${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \ - -o X-mount.mkdir - fi - ''; - }; + default = + let + isBindMount = builtins.elem "bind" config.mountOptions; + device = if isBindMount then "${rootMountPoint}${config.device}" else config.device; + in + lib.optionalAttrs (config.mountpoint != null) { + fs.${config.mountpoint} = '' + if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then + mount -t ${config.fsType} "${device}" "${rootMountPoint}${config.mountpoint}" \ + ${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \ + -o X-mount.mkdir + fi + ''; + }; }; _unmount = diskoLib.mkUnmountOption { inherit config options;