-
|
I have a configuration that manages a darwin and nixos configuration and wanted to create a universal theme. My configuration uses the following conditional logic since values like stylix.cursor or stylix.opacity are not in the darwin version. {
pkgs,
lib,
...
}: let
inherit (pkgs.stdenv) isDarwin;
baseStylix = {
enable = true;
polarity = "dark";
# https://github.com/tinted-theming/base16-schemes
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
fonts = {
monospace = {
package = pkgs.nerd-fonts.jetbrains-mono;
name = "JetBrains Mono Nerd Font";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
emoji = {
package = pkgs.noto-fonts-color-emoji;
name = "Noto Color Emoji";
};
};
};
nixosAttrs = {
image = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/orangci/walls-catppuccin-mocha/master/minimalist-black-hole.png";
sha256 = "sha256-UetLf/3ustmNAXTSoNjqAJKug+ZeMnyf2DMTr+h+eU4=";
};
cursor = {
name = "catppuccin-mocha-light-cursors";
package = pkgs.catppuccin-cursors.mochaLight;
size = 24;
};
opacity = {
applications = 0.8;
desktop = 0.8;
terminal = 0.8;
popups = 0.8;
};
};
in {
stylix = baseStylix // lib.optionalAttrs (!isDarwin) nixosAttrs;
}I have also tried the following which should be equivalent. {
pkgs,
lib,
...
}: let
inherit (pkgs.stdenv) isDarwin;
in {
stylix = {
enable = true;
polarity = "dark";
# https://github.com/tinted-theming/base16-schemes
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
fonts = {
monospace = {
package = pkgs.nerd-fonts.jetbrains-mono;
name = "JetBrains Mono Nerd Font";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
emoji = {
package = pkgs.noto-fonts-color-emoji;
name = "Noto Color Emoji";
};
};
image = lib.mkIf (!isDarwin) (pkgs.fetchurl {
url = "https://raw.githubusercontent.com/orangci/walls-catppuccin-mocha/master/minimalist-black-hole.png";
sha256 = "sha256-UetLf/3ustmNAXTSoNjqAJKug+ZeMnyf2DMTr+h+eU4=";
});
cursor = lib.mkIf (!isDarwin) {
name = "catppuccin-mocha-light-cursors";
package = pkgs.catppuccin-cursors.mochaLight;
size = 24;
};
opacity = lib.mkIf (!isDarwin) {
applications = 0.8;
desktop = 0.8;
terminal = 0.8;
popups = 0.8;
};
};
}The error I keep getting is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The options.stylix.cursor = lib.mkIf false (throw "should never be evaluated");
options.stylix.cursor = {
_type = "if";
condition = false;
content = «thunk»;
};The Nixpkgs module system will just not evaluate and extract You should entirely prevent declarations with something like: lib.mkMerge [
(
lib.mkIf false {
options.stylix.cursor = throw "should never be evaluated";
}
)
{ /* Unconditional declarations */ }
]Stylix could make this more convenient by always exposing |
Beta Was this translation helpful? Give feedback.
The
lib.mkIfdeclaration causes the option to be declared:The Nixpkgs module system will just not evaluate and extract
contentwhenconditionisfalse. However, theoptions.stylix.cursoris declared either way, resulting in your error.You should entirely prevent declarations with something like: