diff --git a/flake.nix b/flake.nix index 7e654c0bd..ef52072c3 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,11 @@ programs.ambxst.package = lib.mkDefault self.packages.${pkgs.system}.default; }; + homeManagerModules.default = { pkgs, ... }: { + imports = [ ./nix/modules/home.nix ]; + _module.args.ambxstPackage = self.packages.${pkgs.system}.default; + }; + packages = ambxstLib.forAllSystems (system: let pkgs = import nixpkgs { diff --git a/nix/modules/home.nix b/nix/modules/home.nix new file mode 100644 index 000000000..bbdddc28a --- /dev/null +++ b/nix/modules/home.nix @@ -0,0 +1,52 @@ +{ config, lib, ambxstPackage, ... }: + +let + cfg = config.programs.ambxst; +in { + options.programs.ambxst = { + enable = lib.mkEnableOption "Ambxst shell"; + + settings = lib.mkOption { + type = lib.types.attrsOf lib.types.anything; + default = {}; + example = lib.literalExpression '' + { + bar = { + position = "top"; + use12hFormat = true; + }; + theme = { + roundness = 8; + font = "Roboto"; + }; + compositor = { + gapsIn = 4; + blurEnabled = true; + }; + } + ''; + description = '' + Declarative Ambxst configuration. Each attribute name corresponds to a + configuration module and its value is written as JSON to + ''${XDG_CONFIG_HOME}/ambxst/config/.json. + + Available modules: bar, theme, system, compositor, performance, + weather, desktop, lockscreen, prefix, dock, ai, workspaces, + notch, overview. + + Note: declared files are managed as read-only symlinks into the Nix + store. The GUI settings menu cannot persist changes to managed files. + Undeclared modules continue to use their GUI-editable defaults. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + xdg.configFile = lib.mapAttrs' (name: value: + lib.nameValuePair "ambxst/config/${name}.json" { + text = builtins.toJSON value; + onChange = "${lib.getExe ambxstPackage} reload || true"; + } + ) cfg.settings; + }; +}