From 100b6fc2438db6ca2c7abe0ad525be3b1dd64895 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 30 Jan 2022 10:47:23 +0100 Subject: move acl module to krebs --- krebs/3modules/acl.nix | 55 +++++++++++++++++++++++++++++++++++++ krebs/3modules/default.nix | 1 + lass/2configs/sync/the_playlist.nix | 6 ++-- lass/3modules/acl.nix | 55 ------------------------------------- lass/3modules/default.nix | 1 - 5 files changed, 59 insertions(+), 59 deletions(-) create mode 100644 krebs/3modules/acl.nix delete mode 100644 lass/3modules/acl.nix diff --git a/krebs/3modules/acl.nix b/krebs/3modules/acl.nix new file mode 100644 index 00000000..9cdbb6cf --- /dev/null +++ b/krebs/3modules/acl.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: let + parents = dir: + if dir == "/" then + [ dir ] + else + [ dir ] ++ parents (builtins.dirOf dir) + ; +in { + options.krebs.acl = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf (lib.types.submodule ({ config, ... }: { + options = { + rule = lib.mkOption { + type = lib.types.str; + default = config._module.args.name; + }; + default = lib.mkOption { + type = lib.types.bool; + default = !config.parents; + }; + recursive = lib.mkOption { + type = lib.types.bool; + default = !config.parents; + }; + parents = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + apply ACL to every parent folder + ''; + }; + }; + }))); + default = {}; + }; + config = { + systemd.services = lib.mapAttrs' (path: rules: lib.nameValuePair "acl-${lib.replaceChars ["/"] ["_"] path}" { + wantedBy = [ "multi-user.target" ]; + path = [ + pkgs.acl + pkgs.coreutils + ]; + serviceConfig = { + ExecStart = pkgs.writers.writeDash "acl" (lib.concatStrings ( + lib.mapAttrsToList (_: rule: '' + setfacl -${lib.optionalString rule.recursive "R"}m ${rule.rule} ${path} + ${lib.optionalString rule.default "setfacl -${lib.optionalString rule.recursive "R"}dm ${rule.rule} ${path}"} + ${lib.optionalString rule.parents (lib.concatMapStringsSep "\n" (folder: "setfacl -m ${rule.rule} ${folder}") (parents path))} + '') rules + )); + RemainAfterExit = true; + Type = "simple"; + }; + }) config.krebs.acl; + }; +} diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index e8f0d35e..fc57d818 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -6,6 +6,7 @@ let out = { imports = [ + ./acl.nix ./airdcpp.nix ./announce-activation.nix ./apt-cacher-ng.nix diff --git a/lass/2configs/sync/the_playlist.nix b/lass/2configs/sync/the_playlist.nix index 5bbf790a..d8b17d23 100644 --- a/lass/2configs/sync/the_playlist.nix +++ b/lass/2configs/sync/the_playlist.nix @@ -3,7 +3,7 @@ path = "/home/lass/tmp/the_playlist"; devices = [ "mors" "phone" "prism" ]; }; - lass.acl."/home/lass/tmp/the_playlist"."u:syncthing:X".parents = true; - lass.acl."/home/lass/tmp/the_playlist"."u:syncthing:rwX" = {}; - lass.acl."/home/lass/tmp/the_playlist"."u:lass:rwX" = {}; + krebs.acl."/home/lass/tmp/the_playlist"."u:syncthing:X".parents = true; + krebs.acl."/home/lass/tmp/the_playlist"."u:syncthing:rwX" = {}; + krebs.acl."/home/lass/tmp/the_playlist"."u:lass:rwX" = {}; } diff --git a/lass/3modules/acl.nix b/lass/3modules/acl.nix deleted file mode 100644 index 81eeae92..00000000 --- a/lass/3modules/acl.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ config, lib, pkgs, ... }: let - parents = dir: - if dir == "/" then - [ dir ] - else - [ dir ] ++ parents (builtins.dirOf dir) - ; -in { - options.lass.acl = lib.mkOption { - type = lib.types.attrsOf (lib.types.attrsOf (lib.types.submodule ({ config, ... }: { - options = { - rule = lib.mkOption { - type = lib.types.str; - default = config._module.args.name; - }; - default = lib.mkOption { - type = lib.types.bool; - default = !config.parents; - }; - recursive = lib.mkOption { - type = lib.types.bool; - default = !config.parents; - }; - parents = lib.mkOption { - type = lib.types.bool; - default = false; - description = '' - apply ACL to every parent folder - ''; - }; - }; - }))); - default = {}; - }; - config = lib.mkIf (config.lass.acl != {}) { - systemd.services = lib.mapAttrs' (path: rules: lib.nameValuePair "acl-${lib.replaceChars ["/"] ["_"] path}" { - wantedBy = [ "multi-user.target" ]; - path = [ - pkgs.acl - pkgs.coreutils - ]; - serviceConfig = { - ExecStart = pkgs.writers.writeDash "acl" (lib.concatStrings ( - lib.mapAttrsToList (_: rule: '' - setfacl -${lib.optionalString rule.recursive "R"}m ${rule.rule} ${path} - ${lib.optionalString rule.default "setfacl -${lib.optionalString rule.recursive "R"}dm ${rule.rule} ${path}"} - ${lib.optionalString rule.parents (lib.concatMapStringsSep "\n" (folder: "setfacl -m ${rule.rule} ${folder}") (parents path))} - '') rules - )); - RemainAfterExit = true; - Type = "simple"; - }; - }) config.lass.acl; - }; -} diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 0373bd44..570bb45b 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -1,7 +1,6 @@ _: { imports = [ - ./acl.nix ./dnsmasq.nix ./folderPerms.nix ./hosts.nix -- cgit v1.2.3