2022-07-25 19:38:43 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2020-12-21 15:10:12 +00:00
|
|
|
|
2021-07-28 14:10:54 +00:00
|
|
|
let
|
2023-04-29 13:47:25 +00:00
|
|
|
cfg = config.stylix.targets.plymouth;
|
|
|
|
|
2022-10-06 18:21:45 +00:00
|
|
|
theme = pkgs.runCommand "stylix-plymouth" { } ''
|
2020-12-21 15:10:12 +00:00
|
|
|
themeDir="$out/share/plymouth/themes/stylix"
|
|
|
|
mkdir -p $themeDir
|
|
|
|
|
2022-10-06 10:55:30 +00:00
|
|
|
${pkgs.imagemagick}/bin/convert \
|
|
|
|
-background transparent \
|
2022-11-17 19:04:28 +00:00
|
|
|
-bordercolor transparent \
|
2023-04-29 13:47:25 +00:00
|
|
|
${
|
|
|
|
# A transparent border ensures the image is not clipped when rotated
|
2024-06-14 21:36:25 +00:00
|
|
|
lib.optionalString cfg.logoAnimated "-border 42%"
|
2023-04-29 13:47:25 +00:00
|
|
|
} \
|
|
|
|
${cfg.logo} \
|
2022-10-06 10:55:30 +00:00
|
|
|
$themeDir/logo.png
|
2020-12-21 15:10:12 +00:00
|
|
|
|
2022-10-07 05:57:54 +00:00
|
|
|
${
|
2023-04-29 13:47:25 +00:00
|
|
|
if cfg.logoAnimated
|
|
|
|
then "cp ${./theme.script} $themeDir/stylix.script"
|
|
|
|
else "cp ${./theme_still.script} $themeDir/stylix.script"
|
|
|
|
}
|
|
|
|
|
2024-06-14 21:36:25 +00:00
|
|
|
${
|
|
|
|
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}"
|
|
|
|
''
|
|
|
|
}
|
2020-12-21 15:10:12 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
[Plymouth Theme]
|
|
|
|
Name=Stylix
|
|
|
|
ModuleName=script
|
|
|
|
|
|
|
|
[script]
|
|
|
|
ImageDir=$themeDir
|
|
|
|
ScriptFile=$themeDir/stylix.script
|
|
|
|
" > $themeDir/stylix.plymouth
|
|
|
|
'';
|
|
|
|
|
|
|
|
in {
|
2022-10-06 10:55:30 +00:00
|
|
|
options.stylix.targets.plymouth = {
|
|
|
|
enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true;
|
|
|
|
|
2024-06-14 21:36:25 +00:00
|
|
|
logo = lib.mkOption {
|
2024-04-22 21:25:40 +00:00
|
|
|
description = "Logo to be used on the boot screen.";
|
2024-06-14 21:36:25 +00:00
|
|
|
type = with lib.types; either path package;
|
|
|
|
defaultText = lib.literalMD "NixOS logo";
|
2024-02-07 11:03:02 +00:00
|
|
|
|
2024-06-16 14:01:57 +00:00
|
|
|
default = "${pkgs.nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png";
|
2022-10-06 10:55:30 +00:00
|
|
|
};
|
2022-10-06 11:19:25 +00:00
|
|
|
|
2024-06-14 21:36:25 +00:00
|
|
|
logoAnimated = lib.mkOption {
|
2024-04-22 21:25:40 +00:00
|
|
|
description = ''
|
2023-04-29 13:47:25 +00:00
|
|
|
Whether to apply a spinning animation to the logo.
|
|
|
|
|
|
|
|
Disabling this allows the use of logos which don't have rotational
|
|
|
|
symmetry.
|
|
|
|
'';
|
2024-06-14 21:36:25 +00:00
|
|
|
type = lib.types.bool;
|
2023-04-29 13:47:25 +00:00
|
|
|
default = true;
|
|
|
|
};
|
2022-10-06 10:55:30 +00:00
|
|
|
};
|
2022-07-25 19:38:43 +00:00
|
|
|
|
2024-03-18 15:11:06 +00:00
|
|
|
imports = [
|
|
|
|
(
|
|
|
|
lib.mkRemovedOptionModule
|
|
|
|
[ "stylix" "targets" "plymouth" "blackBackground" ]
|
|
|
|
"This was removed since it goes against the chosen color scheme. If you want this, consider disabling the target and configuring Plymouth by hand."
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2024-06-14 21:36:25 +00:00
|
|
|
config.boot.plymouth = lib.mkIf cfg.enable {
|
2020-12-21 15:10:12 +00:00
|
|
|
theme = "stylix";
|
|
|
|
themePackages = [ theme ];
|
|
|
|
};
|
|
|
|
}
|