mirror of
https://github.com/danth/stylix
synced 2024-11-10 06:34:15 +00:00
treewide: remove use of with lib
(#425)
This commit is contained in:
parent
73c6955b45
commit
76d6ca2224
10 changed files with 91 additions and 101 deletions
|
@ -1,12 +1,15 @@
|
|||
{ pkgs, config, lib, ... }@args:
|
||||
|
||||
with lib;
|
||||
let
|
||||
inherit (config.stylix.fonts) sansSerif serif monospace;
|
||||
fontSize = toString config.stylix.fonts.sizes.applications;
|
||||
documentFontSize = toString (config.stylix.fonts.sizes.applications - 1);
|
||||
|
||||
{
|
||||
in {
|
||||
options.stylix.targets.gnome.enable =
|
||||
config.lib.stylix.mkEnableTarget "GNOME" true;
|
||||
|
||||
config = mkIf (config.stylix.enable && config.stylix.targets.gnome.enable) {
|
||||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.gnome.enable) {
|
||||
dconf.settings = {
|
||||
"org/gnome/desktop/background" = {
|
||||
color-shading-type = "solid";
|
||||
|
@ -15,7 +18,7 @@ with lib;
|
|||
picture-uri-dark = "file://${config.stylix.image}";
|
||||
};
|
||||
|
||||
"org/gnome/desktop/interface" = with config.stylix.fonts ; {
|
||||
"org/gnome/desktop/interface" = {
|
||||
# We show the same colours regardless of this setting, and the quick
|
||||
# settings tile is removed. The value is still used by Epiphany to
|
||||
# request dark mode for websites which support it.
|
||||
|
@ -26,9 +29,9 @@ with lib;
|
|||
|
||||
# Some GTK apps will use these font settings if they exist.
|
||||
# i.e emacs-pgtk.
|
||||
font-name = "${sansSerif.name} ${toString sizes.applications}";
|
||||
document-font-name = "${serif.name} ${toString (sizes.applications - 1)}";
|
||||
monospace-font-name = "${monospace.name} ${toString sizes.applications}";
|
||||
font-name = "${sansSerif.name} ${fontSize}";
|
||||
document-font-name = "${serif.name} ${documentFontSize}";
|
||||
monospace-font-name = "${monospace.name} ${fontSize}";
|
||||
};
|
||||
|
||||
"org/gnome/shell/extensions/user-theme".name = "Stylix";
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.gtk;
|
||||
|
||||
|
@ -12,7 +10,7 @@ let
|
|||
|
||||
finalCss = pkgs.runCommandLocal "gtk.css" {} ''
|
||||
cat ${baseCss} >>$out
|
||||
echo ${escapeShellArg cfg.extraCss} >>$out
|
||||
echo ${lib.escapeShellArg cfg.extraCss} >>$out
|
||||
'';
|
||||
|
||||
in {
|
||||
|
@ -20,11 +18,11 @@ in {
|
|||
enable = config.lib.stylix.mkEnableTarget
|
||||
"all GTK3, GTK4 and Libadwaita apps" true;
|
||||
|
||||
extraCss = mkOption {
|
||||
extraCss = lib.mkOption {
|
||||
description = ''
|
||||
Extra code added to `gtk-3.0/gtk.css` and `gtk-4.0/gtk.css`.
|
||||
'';
|
||||
type = types.lines;
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
// Remove rounded corners
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
with config.lib.stylix.colors;
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.plymouth;
|
||||
|
||||
|
@ -15,7 +12,7 @@ let
|
|||
-bordercolor transparent \
|
||||
${
|
||||
# A transparent border ensures the image is not clipped when rotated
|
||||
optionalString cfg.logoAnimated "-border 42%"
|
||||
lib.optionalString cfg.logoAnimated "-border 42%"
|
||||
} \
|
||||
${cfg.logo} \
|
||||
$themeDir/logo.png
|
||||
|
@ -26,9 +23,14 @@ let
|
|||
else "cp ${./theme_still.script} $themeDir/stylix.script"
|
||||
}
|
||||
|
||||
substituteInPlace $themeDir/stylix.script \
|
||||
--replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \
|
||||
--replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}"
|
||||
${
|
||||
with config.lib.stylix.colors;
|
||||
''
|
||||
substituteInPlace $themeDir/stylix.script \
|
||||
--replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \
|
||||
--replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}"
|
||||
''
|
||||
}
|
||||
|
||||
echo "
|
||||
[Plymouth Theme]
|
||||
|
@ -45,10 +47,10 @@ in {
|
|||
options.stylix.targets.plymouth = {
|
||||
enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true;
|
||||
|
||||
logo = mkOption {
|
||||
logo = lib.mkOption {
|
||||
description = "Logo to be used on the boot screen.";
|
||||
type = with types; either path package;
|
||||
defaultText = literalMD "NixOS logo";
|
||||
type = with lib.types; either path package;
|
||||
defaultText = lib.literalMD "NixOS logo";
|
||||
|
||||
# Considering that Flake inputs are currently unable to fetch individual
|
||||
# files, the SVG file is fetched with `pkgs.fetchurl` to avoid downloading
|
||||
|
@ -59,14 +61,14 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
logoAnimated = mkOption {
|
||||
logoAnimated = lib.mkOption {
|
||||
description = ''
|
||||
Whether to apply a spinning animation to the logo.
|
||||
|
||||
Disabling this allows the use of logos which don't have rotational
|
||||
symmetry.
|
||||
'';
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
@ -79,7 +81,7 @@ in {
|
|||
)
|
||||
];
|
||||
|
||||
config.boot.plymouth = mkIf cfg.enable {
|
||||
config.boot.plymouth = lib.mkIf cfg.enable {
|
||||
theme = "stylix";
|
||||
themePackages = [ theme ];
|
||||
};
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
themeFile = config.lib.stylix.colors {
|
||||
templateRepo = config.lib.stylix.templates.base16-vim;
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
{ pkgs, lib, ... } @ args:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.stylix.cursor = {
|
||||
name = mkOption {
|
||||
name = lib.mkOption {
|
||||
description = "The cursor name within the package.";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
default = "Vanilla-DMZ";
|
||||
};
|
||||
package = mkOption {
|
||||
package = lib.mkOption {
|
||||
description = "Package providing the cursor theme.";
|
||||
type = types.package;
|
||||
type = lib.types.package;
|
||||
default = pkgs.vanilla-dmz;
|
||||
};
|
||||
size = mkOption {
|
||||
size = lib.mkOption {
|
||||
description = "The cursor size.";
|
||||
type = types.int;
|
||||
type = lib.types.int;
|
||||
default = 32;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
{ pkgs, config, lib, ... } @ args:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.stylix.fonts;
|
||||
|
||||
fontType = types.submodule {
|
||||
fontType = lib.types.submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
package = lib.mkOption {
|
||||
description = "Package providing the font.";
|
||||
type = types.package;
|
||||
type = lib.types.package;
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
name = lib.mkOption {
|
||||
description = "Name of the font within the package.";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options.stylix.fonts = {
|
||||
serif = mkOption {
|
||||
serif = lib.mkOption {
|
||||
description = "Serif font.";
|
||||
type = fontType;
|
||||
default = {
|
||||
|
@ -30,7 +28,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
sansSerif = mkOption {
|
||||
sansSerif = lib.mkOption {
|
||||
description = "Sans-serif font.";
|
||||
type = fontType;
|
||||
default = {
|
||||
|
@ -39,7 +37,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
monospace = mkOption {
|
||||
monospace = lib.mkOption {
|
||||
description = "Monospace font.";
|
||||
type = fontType;
|
||||
default = {
|
||||
|
@ -48,7 +46,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
emoji = mkOption {
|
||||
emoji = lib.mkOption {
|
||||
description = "Emoji font.";
|
||||
type = fontType;
|
||||
default = {
|
||||
|
@ -58,46 +56,46 @@ in {
|
|||
};
|
||||
|
||||
sizes = {
|
||||
desktop = mkOption {
|
||||
desktop = lib.mkOption {
|
||||
description = ''
|
||||
The font size used in window titles/bars/widgets elements of
|
||||
the desktop.
|
||||
'';
|
||||
type = types.ints.unsigned;
|
||||
type = lib.types.ints.unsigned;
|
||||
default = 10;
|
||||
};
|
||||
|
||||
applications = mkOption {
|
||||
applications = lib.mkOption {
|
||||
description = ''
|
||||
The font size used by applications.
|
||||
'';
|
||||
type = types.ints.unsigned;
|
||||
type = lib.types.ints.unsigned;
|
||||
default = 12;
|
||||
};
|
||||
|
||||
terminal = mkOption {
|
||||
terminal = lib.mkOption {
|
||||
description = ''
|
||||
The font size for terminals/text editors.
|
||||
'';
|
||||
type = types.ints.unsigned;
|
||||
type = lib.types.ints.unsigned;
|
||||
default = cfg.sizes.applications;
|
||||
};
|
||||
|
||||
popups = mkOption {
|
||||
popups = lib.mkOption {
|
||||
description = ''
|
||||
The font size for notifications/popups and in general overlay
|
||||
elements of the desktop.
|
||||
'';
|
||||
type = types.ints.unsigned;
|
||||
type = lib.types.ints.unsigned;
|
||||
default = cfg.sizes.desktop;
|
||||
};
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
packages = lib.mkOption {
|
||||
description = ''
|
||||
A list of all the font packages that will be installed.
|
||||
'';
|
||||
type = types.listOf types.package;
|
||||
type = lib.types.listOf lib.types.package;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.stylix.cursor;
|
||||
|
||||
in {
|
||||
imports = [ ../cursor.nix ];
|
||||
|
||||
config = mkIf (config.stylix.enable && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
config = lib.mkIf (config.stylix.enable && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
home.pointerCursor = {
|
||||
name = cfg.name;
|
||||
package = cfg.package;
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
{ lib, ... } @ args:
|
||||
|
||||
with lib;
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.stylix.opacity = {
|
||||
desktop = mkOption {
|
||||
desktop = lib.mkOption {
|
||||
description = "The opacity of the windows of bars/widgets, the amount of applications supported is currently limited";
|
||||
type = types.float;
|
||||
type = lib.types.float;
|
||||
default = 1.0;
|
||||
};
|
||||
applications = mkOption {
|
||||
applications = lib.mkOption {
|
||||
description = "The opacity of the windows of applications, the amount of applications supported is currently limited";
|
||||
type = types.float;
|
||||
type = lib.types.float;
|
||||
default = 1.0;
|
||||
};
|
||||
terminal = mkOption {
|
||||
terminal = lib.mkOption {
|
||||
description = "The opacity of the windows of terminals, this works across all terminals supported by stylix";
|
||||
type = types.float;
|
||||
type = lib.types.float;
|
||||
default = 1.0;
|
||||
};
|
||||
popups = mkOption {
|
||||
popups = lib.mkOption {
|
||||
description = "The opacity of the windows of notifications/popups, the amount of applications supported is currently limited";
|
||||
type = types.float;
|
||||
type = lib.types.float;
|
||||
default = 1.0;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{ palette-generator, base16 }:
|
||||
{ pkgs, lib, config, ... }@args:
|
||||
|
||||
with lib;
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
cfg = config.stylix;
|
||||
|
@ -13,14 +11,14 @@ let
|
|||
${lib.escapeShellArg "${cfg.image}"} \
|
||||
"$out"
|
||||
'';
|
||||
palette = importJSON generatedJSON;
|
||||
palette = lib.importJSON generatedJSON;
|
||||
scheme = base16.mkSchemeAttrs palette;
|
||||
json = scheme {
|
||||
template = ./palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
in json;
|
||||
generatedScheme = importJSON paletteJSON;
|
||||
generatedScheme = lib.importJSON paletteJSON;
|
||||
|
||||
in {
|
||||
# TODO link to doc on how to do instead
|
||||
|
@ -44,8 +42,8 @@ in {
|
|||
];
|
||||
|
||||
options.stylix = {
|
||||
polarity = mkOption {
|
||||
type = types.enum [ "either" "light" "dark" ];
|
||||
polarity = lib.mkOption {
|
||||
type = lib.types.enum [ "either" "light" "dark" ];
|
||||
default = "either";
|
||||
description = ''
|
||||
Use this option to force a light or dark theme.
|
||||
|
@ -56,8 +54,8 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
image = mkOption {
|
||||
type = types.coercedTo types.package toString types.path;
|
||||
image = lib.mkOption {
|
||||
type = with lib.types; coercedTo package toString path;
|
||||
description = ''
|
||||
Wallpaper image.
|
||||
|
||||
|
@ -66,8 +64,8 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
imageScalingMode = mkOption {
|
||||
type = types.enum [ "stretch" "fill" "fit" "center" "tile" ];
|
||||
imageScalingMode = lib.mkOption {
|
||||
type = lib.types.enum [ "stretch" "fill" "fit" "center" "tile" ];
|
||||
default = "fill";
|
||||
description = ''
|
||||
Wallpaper scaling mode;
|
||||
|
@ -78,39 +76,39 @@ in {
|
|||
};
|
||||
|
||||
generated = {
|
||||
json = mkOption {
|
||||
type = types.path;
|
||||
json = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "The result of palette-generator.";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default = paletteJSON;
|
||||
};
|
||||
|
||||
palette = mkOption {
|
||||
type = types.attrs;
|
||||
palette = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "The imported json";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default = generatedScheme;
|
||||
};
|
||||
|
||||
fileTree = mkOption {
|
||||
type = types.raw;
|
||||
fileTree = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
description = "The files storing the palettes in json and html.";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
|
||||
base16Scheme = mkOption {
|
||||
base16Scheme = lib.mkOption {
|
||||
description = ''
|
||||
A scheme following the base16 standard.
|
||||
|
||||
This can be a path to a file, a string of YAML, or an attribute set.
|
||||
'';
|
||||
type = with types; oneOf [ path lines attrs ];
|
||||
type = with lib.types; oneOf [ path lines attrs ];
|
||||
default = generatedScheme;
|
||||
defaultText = literalMD ''
|
||||
defaultText = lib.literalMD ''
|
||||
The colors used in the theming.
|
||||
|
||||
Those are automatically selected from the background image by default,
|
||||
|
@ -118,7 +116,7 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
override = mkOption {
|
||||
override = lib.mkOption {
|
||||
description = ''
|
||||
An override that will be applied to stylix.base16Scheme when generating
|
||||
lib.stylix.colors.
|
||||
|
@ -126,7 +124,7 @@ in {
|
|||
Takes anything that a scheme generated by base16nix can take as argument
|
||||
to override.
|
||||
'';
|
||||
type = types.attrs;
|
||||
type = lib.types.attrs;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
{ config, lib, ... }@args:
|
||||
|
||||
with lib;
|
||||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
options.stylix = {
|
||||
enable = mkOption {
|
||||
enable = lib.mkOption {
|
||||
description = ''
|
||||
Whether to enable Stylix.
|
||||
|
||||
When this is `false`, all theming is disabled and all other options
|
||||
are ignored.
|
||||
'';
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
|
||||
autoEnable = mkOption {
|
||||
autoEnable = lib.mkOption {
|
||||
description = ''
|
||||
Whether to enable targets by default.
|
||||
|
||||
|
@ -27,7 +25,7 @@ with lib;
|
|||
they are only applicable in specific circumstances which cannot be
|
||||
detected automatically.
|
||||
'';
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
|
@ -38,13 +36,13 @@ with lib;
|
|||
in
|
||||
humanName:
|
||||
autoEnable:
|
||||
mkEnableOption
|
||||
lib.mkEnableOption
|
||||
"theming for ${humanName}"
|
||||
// {
|
||||
default = cfg.enable && cfg.autoEnable && autoEnable;
|
||||
example = !autoEnable;
|
||||
}
|
||||
// optionalAttrs autoEnable {
|
||||
defaultText = literalMD "same as [`stylix.autoEnable`](#stylixautoenable)";
|
||||
// lib.optionalAttrs autoEnable {
|
||||
defaultText = lib.literalMD "same as [`stylix.autoEnable`](#stylixautoenable)";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue