From cead964f881173c72c6f2438e4fda4eb5c5addf9 Mon Sep 17 00:00:00 2001 From: Roey Ben Arieh Date: Fri, 5 Jun 2026 00:09:38 +0300 Subject: [PATCH 1/5] feat(nix): add homeManagerModule for declarative settings Adds a homeManagerModules.default flake output that exposes a programs.ambxst.settings option. Each attribute maps to a JSON file written to $XDG_CONFIG_HOME/ambxst/config/.json, allowing users to declaratively configure any ambxst module (bar, theme, compositor, dock, etc.) from their Nix config. Closes #172 --- flake.nix | 4 ++++ nix/modules/home.nix | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 nix/modules/home.nix diff --git a/flake.nix b/flake.nix index 7e654c0bd..229cac14c 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,10 @@ programs.ambxst.package = lib.mkDefault self.packages.${pkgs.system}.default; }; + homeManagerModules.default = { ... }: { + imports = [ ./nix/modules/home.nix ]; + }; + 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..7e33c4564 --- /dev/null +++ b/nix/modules/home.nix @@ -0,0 +1,51 @@ +{ config, lib, ... }: + +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 { + home.file = lib.mapAttrs' (name: value: + lib.nameValuePair ".config/ambxst/config/${name}.json" { + text = builtins.toJSON value; + } + ) cfg.settings; + }; +} From e45ef0953bebc6d904e87b216b2abe64753b69ee Mon Sep 17 00:00:00 2001 From: Roey Ben Arieh Date: Fri, 5 Jun 2026 00:41:40 +0300 Subject: [PATCH 2/5] feat(nix/home): reload ambxst when settings change Switch from home.file to xdg.configFile so we can use the onChange hook to run `ambxst reload` whenever a managed config file changes. The reload is guarded by a PID check so it only fires when ambxst is actually running. --- nix/modules/home.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nix/modules/home.nix b/nix/modules/home.nix index 7e33c4564..b63afc1f1 100644 --- a/nix/modules/home.nix +++ b/nix/modules/home.nix @@ -42,9 +42,14 @@ in { }; config = lib.mkIf cfg.enable { - home.file = lib.mapAttrs' (name: value: - lib.nameValuePair ".config/ambxst/config/${name}.json" { + xdg.configFile = lib.mapAttrs' (name: value: + lib.nameValuePair "ambxst/config/${name}.json" { text = builtins.toJSON value; + onChange = '' + if [ -f /tmp/ambxst.pid ] && kill -0 "$(cat /tmp/ambxst.pid 2>/dev/null)" 2>/dev/null; then + ambxst reload + fi + ''; } ) cfg.settings; }; From 7cd49ae51b92172c68dfc830107ac9c757755c68 Mon Sep 17 00:00:00 2001 From: Roey Ben Arieh Date: Fri, 5 Jun 2026 00:55:33 +0300 Subject: [PATCH 3/5] fix(nix/home): don't fail activation if ambxst reload fails ambxst reload may not be in PATH inside the systemd service environment that runs HM activation. Adding || true ensures a failed reload never aborts the build. --- nix/modules/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/modules/home.nix b/nix/modules/home.nix index b63afc1f1..ce849cf9a 100644 --- a/nix/modules/home.nix +++ b/nix/modules/home.nix @@ -47,7 +47,7 @@ in { text = builtins.toJSON value; onChange = '' if [ -f /tmp/ambxst.pid ] && kill -0 "$(cat /tmp/ambxst.pid 2>/dev/null)" 2>/dev/null; then - ambxst reload + ambxst reload || true fi ''; } From a2c50e7863d957d37d3d2cebadd0f6fb4194b6bc Mon Sep 17 00:00:00 2001 From: Roey Ben Arieh Date: Fri, 5 Jun 2026 01:09:20 +0300 Subject: [PATCH 4/5] fix(nix/home): use full ambxst binary path for onChange reload Pass the flake's ambxst package via _module.args so home.nix can use lib.getExe to get the correct store path. This fixes the reload failing silently because ambxst was not in PATH during HM activation. --- flake.nix | 3 ++- nix/modules/home.nix | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 229cac14c..ef52072c3 100644 --- a/flake.nix +++ b/flake.nix @@ -21,8 +21,9 @@ programs.ambxst.package = lib.mkDefault self.packages.${pkgs.system}.default; }; - homeManagerModules.default = { ... }: { + homeManagerModules.default = { pkgs, ... }: { imports = [ ./nix/modules/home.nix ]; + _module.args.ambxstPackage = self.packages.${pkgs.system}.default; }; packages = ambxstLib.forAllSystems (system: diff --git a/nix/modules/home.nix b/nix/modules/home.nix index ce849cf9a..604d6fe26 100644 --- a/nix/modules/home.nix +++ b/nix/modules/home.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, ambxstPackage, ... }: let cfg = config.programs.ambxst; @@ -47,7 +47,7 @@ in { text = builtins.toJSON value; onChange = '' if [ -f /tmp/ambxst.pid ] && kill -0 "$(cat /tmp/ambxst.pid 2>/dev/null)" 2>/dev/null; then - ambxst reload || true + ${lib.getExe ambxstPackage} reload || true fi ''; } From 5a06cc3116de00584d6c3fa32a19fcd354e493ca Mon Sep 17 00:00:00 2001 From: Roey Ben Arieh Date: Fri, 5 Jun 2026 01:12:41 +0300 Subject: [PATCH 5/5] fix(nix/home): always run ambxst reload on settings change --- nix/modules/home.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nix/modules/home.nix b/nix/modules/home.nix index 604d6fe26..bbdddc28a 100644 --- a/nix/modules/home.nix +++ b/nix/modules/home.nix @@ -45,11 +45,7 @@ in { xdg.configFile = lib.mapAttrs' (name: value: lib.nameValuePair "ambxst/config/${name}.json" { text = builtins.toJSON value; - onChange = '' - if [ -f /tmp/ambxst.pid ] && kill -0 "$(cat /tmp/ambxst.pid 2>/dev/null)" 2>/dev/null; then - ${lib.getExe ambxstPackage} reload || true - fi - ''; + onChange = "${lib.getExe ambxstPackage} reload || true"; } ) cfg.settings; };