Skip to content

feat(nix): add homeManagerModule for declarative settings - #199

Open
roeybenarieh wants to merge 6 commits into
Axenide:mainfrom
roeybenarieh:main
Open

feat(nix): add homeManagerModule for declarative settings#199
roeybenarieh wants to merge 6 commits into
Axenide:mainfrom
roeybenarieh:main

Conversation

@roeybenarieh

Copy link
Copy Markdown

Summary

  • Adds homeManagerModules.default flake output with a programs.ambxst.settings option
  • Each attribute in settings maps to a JSON file at $XDG_CONFIG_HOME/ambxst/config/<name>.json
  • Works with all config modules: bar, theme, compositor, system, performance, weather, desktop, lockscreen, prefix, dock, ai, workspaces, notch, overview

Usage

Add the module to your Home Manager config:

# In your flake.nix
inputs.ambxst.url = "github:Axenide/Ambxst";

# In your home-manager config
{ inputs, ... }: {
  imports = [ inputs.ambxst.homeManagerModules.default ];

  programs.ambxst = {
    enable = true;
    settings = {
      bar = {
        position = "top";
        use12hFormat = true;
      };
      theme = {
        roundness = 8;
        font = "Roboto";
      };
      compositor = {
        gapsIn = 4;
        blurEnabled = true;
      };
    };
  };
}

Notes

  • Declared config files are managed as read-only symlinks into the Nix store. The GUI settings menu cannot persist changes to managed files — this is expected for declarative setups.
  • Undeclared modules (e.g. ai, weather) are untouched and remain editable via the GUI.
  • builtins.toJSON handles all JSON-compatible Nix values: nested attrsets, lists, strings, numbers, booleans, and null.

Closes #172

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/<name>.json,
allowing users to declaratively configure any ambxst module
(bar, theme, compositor, dock, etc.) from their Nix config.

Closes Axenide#172
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.
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.
@roeybenarieh

Copy link
Copy Markdown
Author

Some Notes:
I did everything with AI, I checked it looked ok and changed everything I knew could be better.
After changing the nix settings option, I told nix to run "ambxst reload | true" because by default the command wont return a 0 exit status code and nix need it to tell everything is Ok.
A more correct approach would be that the "ambxst reload" command would return the appropriate exit code.

Would love to hear your thoughts about is PR :-)

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.
@r3dg0d

r3dg0d commented Jun 8, 2026

Copy link
Copy Markdown

Seems like a good pull request, especially for homemanager.

@roeybenarieh

Copy link
Copy Markdown
Author

Would love your help @Axenide

@Axenide

Axenide commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Hi, I'm gonna switch to NixOS soon so I'll be able to test this properly. :)
I'm thinking on making the config declarative but just for the first run (by default) and add a parameter for overwriting.
You see, since Ambxst is mostly customized on the fly with the settings UI, losing those changes on rebuild would be catastrophic. So I thought it could work like nix4nvchad where the config doesn't get ovewritten on rebuild but instead when deleting the nvim config directory. It's not the most nix-way to do it, but I prefer that over newbies losing their rices when updating.

What do y'all think? Since you are more experienced than me on Nix for sure.

@roeybenarieh

Copy link
Copy Markdown
Author

Currently if you configure programs.ambxst.settings.bar to have some value and the bar.json file already exist, an error would appear on rebuild, not overriding of the current file!

In that case the user have 3 choices:

The none declarative approach:

  1. remove the bar nix settings and use the already existing bar.json file.

The declarative approaches:

  1. copy the bar.json to the directory where you manage your nix files. than use:
programs.ambxst.settings.bar = builtins.toJSON ./bar.json
  1. keep the bar nix settings, preferably translate the already existing bar.json to nix format.

My Opinion

If someone is using NixOS you can 100% assume this person knows what he is doing.
let the users do whatever they want.

@Axenide

Axenide commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Thank you very much. I have to fix some things before this but I'll sure work on it soon, maybe even today but can't promise. lol
This week for sure though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nix - declerativly set settings

3 participants