Adding a file to a package

I am aware, that the casual way to add a file to an existing package, would be to override or create an overlay.

Both options seem overly complicated, compared to the simple process it used to be for me on other distros.

Is there maybe some third party tool, or something else, that helps me doing this more painless?

Concrete: I like to add a custom syntax highlighter to Kate. :slight_smile:

It’s been years since I have had to create a .deb, .rpm or similar, but I would wager that it’s far simpler to do via nix:

let
  mySyntaxFile = pkgs.writeText "my-syntax-file" '' contents ''; # or however else you get the file

  kate' = pkgs.kate.overrideAttrs (old: {
    postInstall = (old.postInstall or "") + ''
      install -Dm444 ${mySyntaxFile} $out/share/kate/whereversyntaxfilesgo
    '';
  });

in
{
  environment.systemPackages = [ kate' ];
}

This is a one-time change - you do not ever have to touch this again and it will automatically be rebuilt when needed. You could also use symlinkJoin if you don’t want to have to rebuild kate itself.

1 Like