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: add derivation flags to enable some official patches #43579

Closed
wants to merge 1 commit into from

Conversation

k0ral
Copy link
Contributor

@k0ral k0ral commented Jul 15, 2018

Motivation for this change

Make it easier to enable official patches available here: https://st.suckless.org/patches/

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@Mic92
Copy link
Member

Mic92 commented Jul 15, 2018

cc @viric @andsild

@matthewbauer
Copy link
Member

I have mixed feelings about this. There are a ton of patches to st and it might not make sense to add all of them.

Currently you should be able to override this in an overlay. Maybe we just need documentation explaining how to do this with st?

@oxij
Copy link
Member

oxij commented Jul 18, 2018 via email

@matthewbauer
Copy link
Member

Why add an overlay when you can just add an option? Personally, I like this.

Well currently I would say discovering the patches directly through suckless.org is much easier than discovering the package arguments. We definitely can't list all of the patches at http://st.suckless.org/patches/ but we can show users how to apply any on their own. You can do something like this fairly easily:

let
  patch-dir = ./my-st-patch-dir;
in self: super: {
  st = super.st.override (old: {
    patches = (old.patches or []) ++ [
      (builtins.fetchurl http://st.suckless.org/patches/right_click_to_plumb/right_click_to_plumb.diff)
      ./my-custom-mod.patch
    ] ++ (map (file: patch-dir + ./. + file) (builtins.attrNames (builtins.readDir patch-dir)));
  });
}

If we ever get something like the module system for package flags having these here this might be worth it. But right now I would much prefer better documentation to obscure flags.

@oxij
Copy link
Member

oxij commented Jul 18, 2018 via email

@k0ral
Copy link
Contributor Author

k0ral commented Jul 18, 2018

Just discovered overlays thanks to you :) .
Here is what I was able to write:

self: super:

let
  stVersion = "0.8.1";

  alphaPatch = self.fetchpatch {
    name = "st-alpha.patch";
    url = "https://st.suckless.org/patches/alpha/st-alpha-${stVersion}.diff";
    sha256 = "18iw0bzmagcchlf5m5dfvdryn47kpdbcs1j1waq8vl1w2wvcg5al";
  };

  clipboardPatch = self.fetchpatch {
    name = "clipboard.patch";
    url = "https://st.suckless.org/patches/clipboard/st-clipboard-${stVersion}.diff";
    sha256 = "0gdjgzg2a98fph4sn4w210p39401mm4imkrllfyhc836bjyhi5pc";
  };

  hidecursorPatch = self.fetchpatch {
    name = "hidecursor.patch";
    url = "https://st.suckless.org/patches/hidecursor/st-hidecursor-${stVersion}.diff";
    sha256 = "02b4h375c2vd79f7cagki5fnx1ipygywlxn25c62kg529d7zfck0";
  };

in
{
  st = super.st.override {
    conf = import ./st.nix;
    patches = [alphaPatch clipboardPatch hidecursorPatch];
  };
}

It seems to work on my side. Can this be improved ? Is there any pattern we could extract and integrate into st derivation to make it easier for users to add patches ?

@k0ral k0ral closed this Jul 21, 2018
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

5 participants