How do people work on Plymouth themes on NixOS?

I’ve looked into creating a Plymouth theme, but normally, tutorials use the command plymouth-set-default-theme to switch to the custom theme.
This however modifies /etc/plymouth/plymouthd.conf (I think), which does not work, of course.

Is there a way to start plymouthd and point it to some project directory as its theme directory that I am not aware of? There seem to be people who design plymouth themes for NixOS, how do you do this?

From what I see, NixOS has a boot.plymouth option that includes a way to set the theme. Did you try that already?

It appears you can also add theme packages via boot.plymouth.themePackages

And there are some plymouth themes already in nixpkgs.

So when you create your own, use maybe one of these derivations as a template, create an overlay for nixpkgs in your configuration.nix and use your custom theme as a themePackage.

Ah yes of course, but I would like to avoid rebuilding my system every time I make a change.

Yes, I can see how that might be a problem on NixOS. Can you run plymouth with a custom config in another location maybe? I don’t use it, so there goes my limited knowledge I guess…

I’m currently trying to use buildFHSEnvBubblewrap to build an environment where /etc/plymouth is replaced, lets see how that works out.

What I am using now is

{
	inputs = {
		nixpkgs.url = "nixpkgs/nixos-23.11";
		fu.url = "github:numtide/flake-utils";
	};

	outputs = { self, nixpkgs, fu }: fu.lib.eachDefaultSystem (system: let
		projectPath = builtins.toString ./.;
		pkgs = nixpkgs.legacyPackages.${system};

		plymouthConfPackage = pkgs.runCommand "build-plymouth-conf-package" {} ''
			mkdir $out
			mkdir -p $out/etc/plymouth/themes/testing
			cat <<EOF > "$out/etc/plymouth/plymouthd.conf" 
[Daemon]
ShowDelay=0
DeviceTimeout=8
Theme=testing
EOF
			ln -s ${pkgs.plymouth}/lib/plymouth $out/etc/plymouth/plugins
			ln -s ${pkgs.plymouth}/share/plymouth/plymouthd.defaults $out/etc/plymouth/plymouthd.defaults
		'';

		env = pkgs.buildFHSEnvBubblewrap {
			name = "plymouthFHSEnv";
			targetPkgs = p: with p; [
				plymouth
			];
			runScript = ''
				bash
			'';
			extraBwrapArgs = [
				"--ro-bind" "${plymouthConfPackage}/etc/plymouth" "/etc/plymouth" 
				"--ro-bind" "${projectPath}/" "/etc/plymouth/themes/testing"
			];
		};
	in {
		devShells.default = env.env;
	});
}

Then switch to a different tty, go to your project dir, sudo nix develop, plymouthd --no-daemon --debug.
This still requires manual restarting of plymouthd after every change.
I will post an update if I build something more comfortable.

3 Likes

Randomly wanted to make another theme after reading this post.

Sadly the solution failed for me, plymouth service was giving errors within flake’s chroot. What I did was to modify /etc/plymouth (it’s all symlinks to /etc/static and nix store, you can replace them with real files) and run sudo systemctl start plymouth-start.service on a tty to test it.