treewide: use lib.getExe (#1241)

This commit is contained in:
awwpotato 2025-05-10 04:07:43 -07:00 committed by GitHub
parent 6690180c17
commit 1c71f3bde2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 22 additions and 16 deletions

View file

@ -7,7 +7,7 @@ If you want to use a background image for your desktop but find it too bright or
Here's an example Nix expression that takes an input image, applies a brightness/contrast adjustment to it, and saves the result as a new image file:
```nix
{ pkgs, ... }:
{ pkgs, lib, ... }:
let
inputImage = ./path/to/image.jpg;
brightness = -30;
@ -16,7 +16,7 @@ let
in
{
stylix.image = pkgs.runCommand "dimmed-background.png" { } ''
${pkgs.imagemagick}/bin/convert "${inputImage}" -brightness-contrast ${brightness},${contrast} -fill ${fillColor} $out
${lib.getExe' pkgs.imagemagick "convert"} "${inputImage}" -brightness-contrast ${brightness},${contrast} -fill ${fillColor} $out
'';
}
```
@ -27,12 +27,12 @@ With imagemagick, you can also dynamically generate wallpapers based on the sele
Similarly, you can use a template image and repaint it for the current theme.
```nix
{ pkgs, ... }:
{ pkgs, lib, ... }:
let
theme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml";
wallpaper = pkgs.runCommand "image.png" { } ''
COLOR=$(${pkgs.yq}/bin/yq -r .palette.base00 ${theme})
${pkgs.imagemagick}/bin/magick -size 1920x1080 xc:$COLOR $out
COLOR=$(${lib.getExe pkgs.yq} -r .palette.base00 ${theme})
${lib.getExe pkgs.imagemagick} -size 1920x1080 xc:$COLOR $out
'';
in
{

View file

@ -44,6 +44,6 @@ in
else
"--bg-max";
in
"${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}"
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${config.stylix.image}"
);
}

View file

@ -37,6 +37,6 @@ in
else
"--bg-max";
in
"${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}"
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${config.stylix.image}"
);
}

View file

@ -26,7 +26,7 @@ let
)
# Convert to .pf2
${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString fonts.sizes.applications}
${lib.getExe' pkgs.grub2 "grub-mkfont"} $font --output $out --size ${toString fonts.sizes.applications}
'';
image-scale =
@ -135,7 +135,7 @@ in
cfg.useWallpaper
# Make sure the background image is .png by asking to convert it
then
"${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png"
"${lib.getExe' pkgs.imagemagick "convert"} ${config.stylix.image} png32:$out/background.png"
else
"cp ${pixel "base00"} $out/background.png"
}

View file

@ -228,7 +228,7 @@ let
write_text "$lookAndFeelDefaults" "$look_and_feel/contents/defaults"
''
''
PATH="${pkgs.imagemagick}/bin:$PATH"
PATH="${lib.getBin pkgs.imagemagick}/bin:$PATH"
mkdir --parents "$wallpaper/contents/images"

View file

@ -14,7 +14,7 @@ let
themeDir="$out/share/plymouth/themes/stylix"
mkdir -p $themeDir
${pkgs.imagemagick}/bin/convert \
${lib.getExe' pkgs.imagemagick "convert"} \
-background transparent \
-bordercolor transparent \
${

View file

@ -27,7 +27,7 @@ in
&&
# defined in https://github.com/NixOS/nixpkgs/blob/8f3e1f807051e32d8c95cd12b9b421623850a34d/nixos/modules/programs/regreet.nix#L153
config.services.greetd.settings.default_session.command
!= "${pkgs.dbus}/bin/dbus-run-session ${lib.getExe pkgs.cage} ${lib.escapeShellArgs cfg.cageArgs} -- ${lib.getExe cfg.package}"
!= "${lib.getExe' pkgs.dbus "dbus-run-session"} ${lib.getExe pkgs.cage} ${lib.escapeShellArgs cfg.cageArgs} -- ${lib.getExe cfg.package}"
)
"stylix: regreet: custom services.greetd.settings.default_session.command value may not work: ${config.services.greetd.settings.default_session.command}";
programs.regreet = {

View file

@ -39,4 +39,6 @@ stdenvNoCC.mkDerivation {
'';
passthru = { inherit docs; };
meta.mainProgram = "palette-generator";
}

View file

@ -79,7 +79,7 @@ in
# the output of the palette generator will not be protected from
# garbage collection.
default = pkgs.runCommand "palette.json" { } ''
${cfg.paletteGenerator}/bin/palette-generator \
${lib.getExe cfg.paletteGenerator} \
"${cfg.polarity}" \
${lib.escapeShellArg "${cfg.image}"} \
"$out"

View file

@ -1,10 +1,14 @@
{ pkgs, config, ... }:
{
pkgs,
config,
lib,
...
}:
{
# Generate a PNG image containing a named color
config.lib.stylix.pixel =
color:
pkgs.runCommand "${color}-pixel.png" {
color = config.lib.stylix.colors.withHashtag.${color};
} "${pkgs.imagemagick}/bin/convert xc:$color png32:$out";
} "${lib.getExe' pkgs.imagemagick "convert"} xc:$color png32:$out";
}