summaryrefslogtreecommitdiffstats
path: root/lass/3modules
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2021-01-02 01:00:31 +0100
committerlassulus <lassulus@lassul.us>2021-01-02 01:00:31 +0100
commitd6f3d8832d2dd876323d6d6d17dcec17987b47fe (patch)
tree7fcfbfcffbd8eca94b30787eb06399ee810ee14e /lass/3modules
parent70b1653aacdfe8695bfb7ab23525cc5e5cf4d9b7 (diff)
l: add bindfs module
Diffstat (limited to 'lass/3modules')
-rw-r--r--lass/3modules/bindfs.nix51
-rw-r--r--lass/3modules/default.nix1
2 files changed, 52 insertions, 0 deletions
diff --git a/lass/3modules/bindfs.nix b/lass/3modules/bindfs.nix
new file mode 100644
index 00000000..5c8df8dc
--- /dev/null
+++ b/lass/3modules/bindfs.nix
@@ -0,0 +1,51 @@
+with import <stockholm/lib>;
+{ config, pkgs, ... }:
+let
+ cfg = config.lass.bindfs;
+in {
+ options.lass.bindfs = mkOption {
+ type = types.attrsOf (types.submodule ({ config, ... }: {
+ options = {
+ target = mkOption {
+ description = ''
+ destination where bindfs mounts to.
+ second positional argument to bindfs.
+ '';
+ default = config._module.args.name;
+ type = types.absolute-pathname;
+ };
+ source = mkOption {
+ description = ''
+ source folder where the mounted directory is originally.
+ first positional argument to bindfs.
+ '';
+ type = types.absolute-pathname;
+ };
+ options = mkOption {
+ description = ''
+ additional arguments to bindfs
+ '';
+ type = types.listOf types.str;
+ default = [];
+ };
+ };
+ }));
+ default = {};
+ };
+
+ config = mkIf (cfg != {}) {
+ systemd.services = mapAttrs' (n: mount: let
+ name = replaceStrings [ "/" ] [ "_" ] n;
+ in nameValuePair "bindfs-${name}" {
+ wantedBy = [ "local-fs.target" ];
+ path = [ pkgs.coreutils ];
+ serviceConfig = {
+ ExecStartPre = pkgs.writeDash "bindfs-init-${name}" ''
+ mkdir -p '${mount.source}'
+ mkdir -p '${mount.target}'
+ '';
+ ExecStart = "${pkgs.bindfs}/bin/bindfs -f ${concatStringsSep " " mount.options} ${mount.source} ${mount.target}";
+ };
+ }) cfg;
+ };
+}
diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix
index c3c73bdc..5a1a12f8 100644
--- a/lass/3modules/default.nix
+++ b/lass/3modules/default.nix
@@ -1,6 +1,7 @@
_:
{
imports = [
+ ./bindfs.nix
./dnsmasq.nix
./ejabberd
./folderPerms.nix