-
|
I'm rewamping my config; and if anyone wants to take a look it's here; https://github.com/bbaserdem/NixCats I use my nixCats both in linux and macos. I want to have some runtime dependencies that are system specific (right now specifically only want to require wl-clip on linux platforms; or exclude wl-clip on darwin platforms; but I want to make my config more customizable for sure.) Was wondering what's a good approach to this? Not sure if the system variable is available as inputs to the categoryDefinitions function and packageDefinitions attrset. (I have these abstracted to different files in my config, but this shouldn't change much about the behavior of these definitions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
There are a few approaches. If it is just a few that differ you could put them in their own categories and just enable them based on that. Like you could lspsAndRuntimeDeps = {
system-specific = {
x86_64-linux = [];
aarch64-darwin = [];
};
};and then categories = {
system-specific.${pkgs.system} = true;
};You could also use the extraCats section of your categoryDefinitions documented here if you wanted to set up defaults for things. You can also use any of the values from the arguments to categoryDefinitions in But idk. I honestly don't have a specific way off the top of my head, I am not that organized of a person (for stuff like config anyway, the framework for said config I go all in, to make up for it XD) I just do it the second way listed below. If you think of a cool way to categorize your stuff that works using the extraCats table to toggle other categories based on inclusion of other ones, go right ahead, there's probably some way to do it which is nice. However, the arguments to your category definitions get a LOT of info. at the top of this section, it lists the full list of arguments it can recieve :h nixCats.flake.outputs.categories Your packageDefinitions actually can recieve quite a few things as well, including the pkgs which are shown in the packageDefinitions section of the docs, :h nixCats.flake.outputs.packageDefinitions They are also both shown in the utils set docs in the description for the main builder function. If you wanted to see where they come from, that would be here and here categoryDefinitions = { pkgs, settings, categories, extra, name, mkPlugin, ... }@packageDef: {
lspsAndRuntimeDeps = {
clipboard-stuff = (if pkgs.system == "aarch64-darwin" then [
] else [
pkgs.wl-clip
]) ++ [
];
};
startupPlugins = {
clipboard-stuff = [
# idk maybe you had some clipboard related plugins, just demonstrating that these are categories for onlookers
];
# ...
};
# ...
};You can always just check pkgs.system or ANY of the values from your packageDefinition for this package (the one currently being installed) whenever you want in there. So, instead of checking pkgs.system you could also do something like this if you wanted categoryDefinitions = { pkgs, settings, categories, extra, name, mkPlugin, ... }@packageDef: {
lspsAndRuntimeDeps = {
clipboard-stuff = (if settings.macos or false then [
] else [
pkgs.wl-clip
]) ++ [
];
};
# ...
};
packageDefintions = {
macnvim = { pkgs, name, mkPlugin, luaPath, this, ... }: { # be careful with `this`, it is the result of calling the function
settings = {
aliases = [ "vi" ];
macos = true;
};
# ...
};
# other packages ...
}; |
Beta Was this translation helpful? Give feedback.
There are a few approaches.
If it is just a few that differ you could put them in their own categories and just enable them based on that.
Like you could
and then
You could also use the extraCats section of your categoryDefinitions documented here if you wanted to set up defaults for things.
You can also use any of the values from the arguments to categoryDefinitions in
extraCatstoo, except for thecategoriesvalue within theextraCatssection of categoryDefinitions, all other arguments are safe to use at all tim…