treewide: remove use of with lib (#425)

This commit is contained in:
Daniel Thwaites 2024-06-14 22:36:25 +01:00 committed by GitHub
parent 73c6955b45
commit 76d6ca2224
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 91 additions and 101 deletions

View file

@ -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";

View file

@ -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

View file

@ -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 ];
};

View file

@ -1,7 +1,5 @@
{ pkgs, config, lib, ... }:
with lib;
let
themeFile = config.lib.stylix.colors {
templateRepo = config.lib.stylix.templates.base16-vim;