summaryrefslogtreecommitdiffstats
path: root/lass/3modules/folderPerms.nix
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-07 12:26:31 +0200
committerlassulus <git@lassul.us>2023-09-07 13:50:26 +0200
commitf55307fd73af235069744dd5155fda0bc73fe613 (patch)
treef048d7750a50e48493505a08784c96d07d291f89 /lass/3modules/folderPerms.nix
parent85ae348bf3f53125c8281669a32bf007dc0063be (diff)
lass: migrate away
Diffstat (limited to 'lass/3modules/folderPerms.nix')
-rw-r--r--lass/3modules/folderPerms.nix104
1 files changed, 0 insertions, 104 deletions
diff --git a/lass/3modules/folderPerms.nix b/lass/3modules/folderPerms.nix
deleted file mode 100644
index bb032032..00000000
--- a/lass/3modules/folderPerms.nix
+++ /dev/null
@@ -1,104 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-#TODO: implement recursive mode maybe?
-# enable different mods for files and folders
-
-let
- inherit (pkgs)
- writeScript
- ;
-
- inherit (lib)
- concatMapStringsSep
- concatStringsSep
- mkEnableOption
- mkIf
- mkOption
- types
- ;
-
- cfg = config.lass.folderPerms;
-
- out = {
- options.lass.folderPerms = api;
- config = mkIf cfg.enable imp;
- };
-
- api = {
- enable = mkEnableOption "folder permissions";
- permissions = mkOption {
- type = with types; listOf (submodule ({
- options = {
- path = mkOption {
- type = str;
- };
- permission = mkOption {
- type = nullOr str;
- example = "755";
- description = ''
- basically anything that chmod takes as permission
- '';
- default = null;
- };
- owner = mkOption {
- type = nullOr str;
- example = "root:root";
- description = ''
- basically anything that chown takes as owner
- '';
- default = null;
- };
- };
- }));
- };
- };
-
- imp = {
- systemd.services.lass-folderPerms = {
- description = "lass-folderPerms";
- wantedBy = [ "multi-user.target" ];
-
- path = with pkgs; [
- coreutils
- ];
-
- restartIfChanged = true;
-
- serviceConfig = {
- type = "simple";
- RemainAfterExit = true;
- Restart = "always";
- ExecStart = "@${startScript}";
- };
- };
- };
-
- startScript = writeScript "lass-folderPerms" ''
- ${concatMapStringsSep "\n" writeCommand cfg.permissions}
- '';
-
- writeCommand = fperm:
- concatStringsSep "\n" [
- (buildPermission fperm)
- (buildOwner fperm)
- ];
-
- buildPermission = perm:
- #TODO: create folder maybe
- #TODO: check if permission is valid
- if (perm.permission == null) then
- ""
- else
- "chmod ${perm.permission} ${perm.path}"
- ;
-
- buildOwner = perm:
- #TODO: create folder maybe
- #TODO: check if owner/group valid
- if (perm.owner == null) then
- ""
- else
- "chown ${perm.owner} ${perm.path}"
- ;
-
-in out