How to modify source code of a package before building

Hi, I’m trying to use waybar with hyprland.

There is a section in the hyprland wiki explaining how to do this, but it requires modifying the source of waybar (waybar uses swaymsg for some commands, but hyprland requires using its own hyprctl tool) - the exact command is:

sed -i -e 's/zext_workspace_handle_v1_activate(workspace_handle_);/const std::string command = "hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());/g' src/modules/wlr/workspace_manager.cpp

Is there an elegant way to go about this in nix? In the past, I’ve been able to override certain parts of the build process (e.g. with overrideAttrs) but I’m struggling to see a way to just say “run this command before building”.

Thanks :pray:

you can try adding a patch file to patches or adding a postPatch hook

yes a hook is just a string of commands to run

1 Like