stylix: restrict access to config while using mkTarget (#1368)
Link: https://github.com/nix-community/stylix/pull/1368 Reviewed-by: Flameopathic <64027365+Flameopathic@users.noreply.github.com> Reviewed-by: Matt Sturgeon <matt@sturgeon.me.uk> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
parent
85d84607b2
commit
dea0337e0b
4 changed files with 46 additions and 33 deletions
|
|
@ -1,20 +1,17 @@
|
|||
{
|
||||
mkTarget,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{ mkTarget, lib, ... }:
|
||||
mkTarget {
|
||||
name = "bemenu";
|
||||
humanName = "bemenu";
|
||||
|
||||
extraOptions = {
|
||||
extraOptions =
|
||||
{ fonts }:
|
||||
{
|
||||
fontSize = lib.mkOption {
|
||||
description = ''
|
||||
Font size used for bemenu.
|
||||
'';
|
||||
type = with lib.types; nullOr int;
|
||||
default = config.stylix.fonts.sizes.popups;
|
||||
default = fonts.sizes.popups;
|
||||
defaultText = lib.literalExpression "config.stylix.fonts.sizes.popups";
|
||||
}; # optional argument
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,16 @@
|
|||
mkTarget {
|
||||
name = "hyprland";
|
||||
humanName = "Hyprland";
|
||||
extraOptions.hyprpaper.enable = config.lib.stylix.mkEnableTargetWith {
|
||||
extraOptions =
|
||||
{ image }:
|
||||
{
|
||||
hyprpaper.enable = config.lib.stylix.mkEnableTargetWith {
|
||||
name = "Hyprpaper";
|
||||
autoEnable = config.stylix.image != null;
|
||||
autoEnable = image != null;
|
||||
autoEnableExpr = "config.stylix.image != null";
|
||||
};
|
||||
};
|
||||
|
||||
configElements = [
|
||||
(
|
||||
{ colors }:
|
||||
|
|
|
|||
|
|
@ -42,7 +42,19 @@ builtins.concatLists (
|
|||
{
|
||||
key = file;
|
||||
_file = file;
|
||||
imports = [ (module (args // extraArgs // { inherit mkTarget; })) ];
|
||||
imports = [
|
||||
(module (
|
||||
args
|
||||
// extraArgs
|
||||
// {
|
||||
inherit mkTarget;
|
||||
config = lib.recursiveUpdate config {
|
||||
stylix = throw "stylix: unguareded `config.stylix` accessed while using mkTarget";
|
||||
lib.stylix.colors = throw "stylix: unguareded `config.lib.stylix.colors` accessed while using mkTarget";
|
||||
};
|
||||
}
|
||||
))
|
||||
];
|
||||
}
|
||||
else
|
||||
file
|
||||
|
|
|
|||
|
|
@ -241,7 +241,9 @@ let
|
|||
c;
|
||||
in
|
||||
{
|
||||
inherit imports;
|
||||
imports = imports ++ [
|
||||
{ options.stylix.targets.${name} = mkConfig (lib.toFunction extraOptions); }
|
||||
];
|
||||
|
||||
options.stylix.targets.${name}.enable =
|
||||
let
|
||||
|
|
@ -273,8 +275,5 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
{ options.stylix.targets.${name} = extraOptions; }
|
||||
module
|
||||
];
|
||||
imports = [ module ];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue