Optionalize mkTarget's 'humanName' and 'name' arguments by inferring 'humanName' from the 'name' attribute in the /modules/<MODULE>/meta.nix file, and 'name' from the /modules/<NAME>/ directory name. Inferring the 'humanName' and 'name' arguments ensures consistency and reduces boilerplate. The 'humanName' and 'name' arguments are optionalized instead of removed because complex modules generating target derivations need to distinguish between them. Closes: https://github.com/nix-community/stylix/issues/1661
91 lines
2.8 KiB
Nix
91 lines
2.8 KiB
Nix
{ mkTarget, lib, ... }:
|
|
mkTarget {
|
|
options.vaultNames = lib.mkOption {
|
|
description = "The obsidian vault names to apply styling on.";
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
};
|
|
|
|
config = [
|
|
(
|
|
{ cfg, fonts }:
|
|
{
|
|
programs.obsidian = {
|
|
defaultSettings.appearance = {
|
|
"interfaceFontFamily" = fonts.sansSerif.name;
|
|
"monospaceFontFamily" = fonts.monospace.name;
|
|
"baseFontSize" = fonts.sizes.applications;
|
|
};
|
|
vaults = lib.genAttrs cfg.vaultNames (_: {
|
|
settings.appearance = {
|
|
"interfaceFontFamily" = fonts.sansSerif.name;
|
|
"monospaceFontFamily" = fonts.monospace.name;
|
|
"baseFontSize" = fonts.sizes.applications;
|
|
};
|
|
});
|
|
};
|
|
}
|
|
)
|
|
(
|
|
{
|
|
cfg,
|
|
colors,
|
|
polarity,
|
|
}:
|
|
{
|
|
programs.obsidian.defaultSettings.cssSnippets = with colors.withHashtag; [
|
|
{
|
|
name = "Stylix Config";
|
|
text = ''
|
|
.theme-${polarity} {
|
|
/* Base Colors */
|
|
--color-base-00: ${base00};
|
|
--color-base-05: ${base00};
|
|
--color-base-10: ${base00};
|
|
--color-base-20: ${base01};
|
|
--color-base-25: ${base01};
|
|
--color-base-30: ${base02};
|
|
--color-base-35: ${base02};
|
|
--color-base-40: ${base03};
|
|
--color-base-50: ${base03};
|
|
--color-base-60: ${base04};
|
|
--color-base-70: ${base04};
|
|
--color-base-100: ${base05};
|
|
|
|
--color-accent: ${base0E};
|
|
--color-accent-1: ${base0E};
|
|
}
|
|
'';
|
|
}
|
|
];
|
|
programs.obsidian.vaults = lib.genAttrs cfg.vaultNames (_: {
|
|
settings.cssSnippets = with colors.withHashtag; [
|
|
{
|
|
name = "Stylix Config";
|
|
text = ''
|
|
.theme-${polarity} {
|
|
/* Base Colors */
|
|
--color-base-00: ${base00};
|
|
--color-base-05: ${base00};
|
|
--color-base-10: ${base00};
|
|
--color-base-20: ${base01};
|
|
--color-base-25: ${base01};
|
|
--color-base-30: ${base02};
|
|
--color-base-35: ${base02};
|
|
--color-base-40: ${base03};
|
|
--color-base-50: ${base03};
|
|
--color-base-60: ${base04};
|
|
--color-base-70: ${base04};
|
|
--color-base-100: ${base05};
|
|
|
|
--color-accent: ${base0E};
|
|
--color-accent-1: ${base0E};
|
|
}
|
|
'';
|
|
}
|
|
];
|
|
});
|
|
}
|
|
)
|
|
];
|
|
}
|