Customizable package (theming a flake-managed widget bar)
Customizable package (theming a flake-managed widget bar)
I just want to know from you how you (or how you would) pass options to packages you develop with flakes.
I am currently writing a widget bar using Astal and then import the flake in my NixOS flake and use the package.default output in home.packages. I'd like to also style this bar according to my Stylix theme, how do you do something like this?
I usually provide a NixOS/home-manager module together with my flake, that can then be imported and customized by setting the config options.
can you provide me with a simple example, and syntax. I have tried, but failed. I want that the astal config uses a custom colorscheme which i configure somehow that can be given as option when importing that flake in the main nixos system.
I'm afraid it's difficult to provide a simple example as there are a bunch of moving parts.
In essence, you create a file (e.g.
module.nix
) in your package repo:Then you make sure your program reads the colors from
~/.config/my-package/colors.toml
(you can use whatever format or path you want, but adjust the module accordingly), and uses those colorsFinally, you add
homeModules.default = import ./module.nix self;
to your package flake, andimports = [ inputs.my-package.homeModules.default ]; programs.my-package.enable = true; stylix.targets.my-package.enable = true;
to your home-manager configuration. You will need to adjust a lot of stuff depending on how exactly you want to do this but this should get you started.All of this is a bit complicated but I think for a good reason; this setup is really quite flexible and will allow you to expand easily in the future should you continue work on the project. And if not, it gives you a chance to learn about a lot of different Nix concepts that will come in useful later :)