diff --git a/modules/plymouth/nixos.nix b/modules/plymouth/nixos.nix index 5fd29d40..acb1c48d 100644 --- a/modules/plymouth/nixos.nix +++ b/modules/plymouth/nixos.nix @@ -1,46 +1,14 @@ { - config, + mkTarget, pkgs, lib, ... -}@args: - -let - cfg = config.stylix.targets.plymouth; - - themeScript = import ./theme-script.nix args; - - theme = pkgs.runCommand "stylix-plymouth" { } '' - themeDir="$out/share/plymouth/themes/stylix" - mkdir -p $themeDir - - ${lib.getExe' pkgs.imagemagick "convert"} \ - -background transparent \ - -bordercolor transparent \ - ${ - # A transparent border ensures the image is not clipped when rotated - lib.optionalString cfg.logoAnimated "-border 42%" - } \ - ${cfg.logo} \ - $themeDir/logo.png - - cp ${themeScript} $themeDir/stylix.script - - echo " - [Plymouth Theme] - Name=Stylix - ModuleName=script - - [script] - ImageDir=$themeDir - ScriptFile=$themeDir/stylix.script - " > $themeDir/stylix.plymouth - ''; -in -{ - options.stylix.targets.plymouth = { - enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true; +}: +mkTarget { + name = "plymouth"; + humanName = "the Plymouth boot screen"; + extraOptions = { logo = lib.mkOption { description = "Logo to be used on the boot screen."; type = with lib.types; either path package; @@ -67,8 +35,42 @@ in ) ]; - config.boot.plymouth = lib.mkIf cfg.enable { - theme = "stylix"; - themePackages = [ theme ]; - }; + configElements = + { cfg, colors }: + let + themeScript = import ./theme-script.nix { inherit lib cfg colors; }; + + theme = pkgs.runCommand "stylix-plymouth" { } '' + themeDir="$out/share/plymouth/themes/stylix" + mkdir -p $themeDir + + ${lib.getExe' pkgs.imagemagick "convert"} \ + -background transparent \ + -bordercolor transparent \ + ${ + # A transparent border ensures the image is not clipped when rotated + lib.optionalString cfg.logoAnimated "-border 42%" + } \ + ${cfg.logo} \ + $themeDir/logo.png + + cp ${themeScript} $themeDir/stylix.script + + echo " + [Plymouth Theme] + Name=Stylix + ModuleName=script + + [script] + ImageDir=$themeDir + ScriptFile=$themeDir/stylix.script + " > $themeDir/stylix.plymouth + ''; + in + { + boot.plymouth = { + theme = "stylix"; + themePackages = [ theme ]; + }; + }; } diff --git a/modules/plymouth/theme-script.nix b/modules/plymouth/theme-script.nix index 54f4ca9f..f42d3af1 100644 --- a/modules/plymouth/theme-script.nix +++ b/modules/plymouth/theme-script.nix @@ -1,17 +1,15 @@ { lib, - config, - ... + cfg, + colors, }: let - cfg = config.stylix.targets.plymouth; - backgroundColor = - with config.lib.stylix.colors; + with colors; "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}"; foregroundColor = - with config.lib.stylix.colors; + with colors; "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}"; in builtins.toFile "stylix-plymouth-theme" ''