# Using custom plymouth theme on nixos

Contents

Almost anything you can think of to do with your linux system, can possibly be done in nixos. And it would also be reproducible at that. So i set out to get a custom theme for my boot up screen which is usually provided by plymouth in linux. Since we need to add a new theme to the system we should do that by creating a new package for the same. Nixos doesn’t allow you to write to the nix store, since we want reproducible system, which would not happen if you could go ahead and modify the store files.

## Write an overlay

First thing you need is an overlay. An overlay is a concept i got familiar with on gentoo linux. An overlay is, as the name suggests, an addon set of packages for your system. So here let’s define a simple overlay with just one package. I would be using the lore theme from adi1090x/plymouth-themes . Also he produces some amazing designs, do check him out. This is what the lore theme looks like.

Anyway, let’s get back to the code. I create a directory at /etc/nixos/packages for my overlay, where i write this file at default.nix.

 1 2 3 4  self: super: { adi1090x-plymouth = super.callPackage ./adi1090x-plymouth { }; } 

All it says is, there is a package at the directory ./adi1090x-plymouth.

In the /etc/nixos/configuration.nix file add the following line to activate the overlay.

 1  nixpkgs.overlays = [ (import ./packages) ]; 

## Package Recipe

Now let’s define a simple package at /etc/nixos/packages/adi1090x-plymouth. We need to create this directory and add a file called default.nix with the following contents.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  { pkgs ? import {} }: pkgs.stdenv.mkDerivation rec { pname = "adi1090x-plymouth"; version = "0.0.1"; src = builtins.fetchGit { url = "https://github.com/adi1090x/plymouth-themes"; }; buildInputs = [ pkgs.git ]; configurePhase = '' mkdir -p $out/share/plymouth/themes/ ''; buildPhase = '' ''; installPhase = '' cp -r pack_3/lone$out/share/plymouth/themes cat pack_3/lone/lone.plymouth | sed "s@\/usr\/@$out\/@" >$out/share/plymouth/themes/lone/lone.plymouth ''; } 

This simple packages derivations says get the source files from github. Make a directory \$out/share/plymouth/themes (this is where plymouth expects your theme to be at). Then copy the lone theme folder to this directory. Rewrite the lone.plymouth file, adjusted for nixos store path rather than /usr/. And that’s it for our package.

## Applying in configuration.nix

Now in the configuration.nix file, add the following lines. Make sure you do not have any other boot.plymouth line or adjust according to what you need.

 1 2 3 4 5  boot.plymouth = { enable = true; themePackages = [ pkgs.adi1090x-plymouth ]; theme = "lone"; }; 

## Conclusion

Now finally execute the command nixos-rebuild switch and reboot your system. Is your theme working? Please write your comments in the comment section.