{ config, lib, namespace, ... }: let inherit (lib) mkIf mkEnableOption; inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace mkPersistRootDir; base = "${namespace}.hardware.bluetooth"; cfg = getAttrByNamespace config base; in { options = mkOptionsWithNamespace base { enable = mkEnableOption "bluetooth"; }; config = mkIf cfg.enable { services.blueman.enable = true; hardware.bluetooth = { enable = true; powerOnBoot = true; }; ${namespace}.services.storage.impermanence.folders = [ (mkPersistRootDir config "/var/lib/bluetooth") ]; }; }