Skip to content

Instantly share code, notes, and snippets.

@sodiboo
Last active November 9, 2024 20:50
Show Gist options
  • Select an option

  • Save sodiboo/29c4803f189cd81f298702559f24b7ab to your computer and use it in GitHub Desktop.

Select an option

Save sodiboo/29c4803f189cd81f298702559f24b7ab to your computer and use it in GitHub Desktop.
# this is a home-manager module
{lib, options, ...}: let
settings-binds-type = let
traverse = v:
if (v ? _type && v._type == "option")
then
{
${lib.concatStringsSep "." v.loc} = v;
}
// traverse (v.type.getSubOptions v.loc)
else lib.concatMapAttrs (lib.const traverse) (lib.filterAttrs (name: lib.const (name != "_module")) v);
in
# based on global attr path if you run home manager as a nixos module
# (traverse options.programs.niri.settings)."home-manager.users.sodiboo.programs.niri.settings.binds".type;
# manually specify the base path
# (traverse (options.programs.niri.settings.type.getSubOptions ["settings"]))."settings.binds".type;
# shortest
(traverse (options.programs.niri.settings.type.getSubOptions []))."binds".type;
in {
# ... configuration making use of above type
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment