Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st: copy config file in 'prePatch' instead of 'preBuild' #85055

Closed
wants to merge 1 commit into from
Closed

st: copy config file in 'prePatch' instead of 'preBuild' #85055

wants to merge 1 commit into from

Conversation

nschoe
Copy link
Contributor

@nschoe nschoe commented Apr 12, 2020

The patch phase runs after the build phase. Which means than when
using an override to override both conf and patches to provide
a custom config file and apply some patches, it doesn't work:

  • first the patches applied (optionally changing config.def.h)
  • then preBuild is run which overrides config.def.h with the user
    supplied one (effectively cancelling previously applied patches)

By copying the config file in the prePatch phase instead, changes
are kept and applied in order.

This is my first ever contribution to nixpkgs, so I hope I'm not mistaken.

cc @andsild

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

The patch phase runs after the build phase. Which means than when
using an override to override both 'conf' and 'patches' to provide
a custom config file and apply some patches, it doesn't work:
- first the patches applied (optionally changing config.def.h)
- then preBuild is run which overrides config.def.h with the user
supplied one (effectively cancelling previously applied patches)

By copying the config file in the prePatch phase instead, changes
are kept and applied in order.
@worldofpeace
Copy link
Contributor

@nschoe Hi, it seems you've opened your PR to merge into nixos-20.03 which is protected and updated for the nixos channels. New contributions should target master.

@andsild
Copy link
Contributor

andsild commented Apr 15, 2020

I've tested that it builds and works with WSL and nix.

If you fix the target branch (mentioned by @worldofpeace ) I'm good with the change.

@worldofpeace
Copy link
Contributor

@andsild I'm confused why though, the ordering of phases "The patch phase runs after the build phase." isn't true for genericBuild. https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L1261 patchPhase -> configurePhase -> buildPhase

@nschoe
Copy link
Contributor Author

nschoe commented Apr 17, 2020

@worldofpeace thanks for answering. Sorry I was not sure if I had to target master or the branch I was basing this on.

I guess i have to rebase first when targetting master, right? it's been a while since i used rebase, I'll have to look it up.

@Mic92 hum... I see what you mean, I'm not an expert on this. But if the patches don't change the same parts the user changed himself, it should be fine. Otherwise, I believe this to be a git conflict, and well... it requires manual intervention I guess.

I guess @andsild might be the one able to answer?

FWIW, I've used this in my systemPackages :

(st.override {
      # st is configured with a config.h file, use this one
      conf = builtins.readFile /home/nschoe/.config/st/config.h;

      patches = [
        # Allows scrolling the screen with Shift+Pg{Up,Down}
        (builtins.fetchurl { url = https://st.suckless.org/patches/scrollback/st-scrollback-0.8.2.diff ; })

        # Allows scrolling the screen with Shift+Mouse{Up,Down}
	(builtins.fetchurl { url = https://st.suckless.org/patches/scrollback/st-scrollback-mouse-0.8.2.diff ; })

	# Two patches to install solarized themes
	(builtins.fetchurl { url = https://st.suckless.org/patches/solarized/st-no_bold_colors-0.8.1.diff ; })
	(builtins.fetchurl { url = https://st.suckless.org/patches/solarized/st-solarized-both-20190128-3be4cf1.diff ; })
      ];
    })

I have modified the config.h file to my desires, and as you can see, I'm running 4 patches, and it build and works fine.

Well as I said: this is my first ever contribution to nixpkgs, so if I'm doing this wrong, no issues I'll remove this PR!

Thanks to you all.

@Mic92
Copy link
Member

Mic92 commented Apr 17, 2020

I rebased your patch to master: #85443

@Mic92 Mic92 closed this Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants