How to create class/module like structures in a home-manager config? #7464
Unanswered
jackerschott
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was wondering how home-manager is intended in the following situation: I want e.g. my editor config to be agnostic to which specific editor I use. Let's say e.g. I want to use neovim on one machine and emacs on another machine. But I want to be able to have a shortcut in my desktop environment that opens an obsidian vault in the active text editor, so I want something like
editor.obsidian.buildVaultOpenCommand
that takes the name of the vault as a string and returns a command string that I can execute in a script. But possibly I also want something likeeditor.buildFileOpenCommand
that works similarly. Now I tried to implement this with_module.args
, such that I have aneditor
attribute set that I can access globally, but I can't specify_module.args.editor
both in myeditor/neovim/default.nix
and myeditor/neovim/plugins/obsidian.nix
which would be the canonical way to do it (since the default.nix should not know about the details of the obsidian config), since apparently they don't get merged automatically? And if I uselib.mkDefault
in my neovimdefault.nix
, theeditor.buildFileOpenCommand
just gets overriden, because it's not in the_module.args.editor
from theobsidian.nix
.Long story short: I'm not sure if that is the intended usecase for
_module.args
. If yes, than this would be a bug report / feature request I guess. But if not, then how can I do something like this? I.e. how can you create a module/class like structure that one is used from other programming languages like C/Rust/Python/etc., i.e. something I can import and use functions from. In pure nix, I would imagine this can be achieved by having a special attribute like_functions
in every attribute set that I write some part of the config in, that get's ignored for the configuration, but that I can use in other parts of the config, which I guess is exactly what_module.args
can achieve theoretically?Beta Was this translation helpful? Give feedback.
All reactions