Skip to content

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

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

feat(nix): add homeManagerModule for declarative settings#199
roeybenarieh wants to merge 5 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.
@128bytes8

Copy link
Copy Markdown

Seems like a good pull request, especially for homemanager.

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

2 participants