How to create/generate additional file (e.g. custom theme file for Albert)

Hi all!

I’m learning Nix/Nixos and I can’t find information how can I create/generate a custom file in configuration.nix or with home-manager

I want to create a custom file with theme for Albert. I found out that themes live in /nix/store/iq70lggb6ysjqm6nd86mlcwsb5bjfda7-home-manager-path/share/albert/org.albert.frontend.widgetboxmodel/themes/.

Is it possible to declare a custom file in Nixos config?

Many nixpkgs derivations for programs with plugin functionality provide a method to build a version of the program that has additional plugins/themes/extras available, however the albert derivation doesn’t seem to be made that way. It could be that it can find its themes if they’re installed as separate packages, or it could be that it was packaged without regard for that aspect of the program.

Even if it was packaged without regard for that aspect, you can still likely deal with it if you’re willing to learn how it builds and where it expects to find the theme. You can overrideAttrs the albert derivation to add some extra files into $out during postInstall.

Hi tejing! Thanks for the answer!

Can you share any example of such overrides? I’m new to Nix/NixOS, so it would be easier for me to understand

Here’s a toy example that adds a file to the hello package:

nixpkgs.overlays = [
  (final: prev: {
      hello = prev.hello.overrideAttrs (old: {
        postInstall = ''
          ${old.postInstall or ""}
          mkdir -p $out/foo
          echo test > $out/foo/bar
        '';
      });
  })
];