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

slock: adds ability to add custom patches #29108

Merged
merged 1 commit into from Sep 24, 2017

Conversation

Gerschtli
Copy link
Contributor

Motivation for this change

I needed to add patches to slock so I added the patches argument.
Usage:

{
  nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.slock.override {
      patches = [ ./patch.diff ];
    };
  };
}
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@Gerschtli, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mt-caret, @astsmtl and @pSub to be potential reviewers.

@Mic92
Copy link
Member

Mic92 commented Sep 8, 2017

How about using:

{
  nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.slock.overrideDerivation (old: {
      patches = [ ./patch.diff ];
    });
  };
}

instead?

patchPhase = "sed -i '/chmod u+s/d' Makefile";
inherit patches;

postPatch = "sed -i '/chmod u+s/d' Makefile";
Copy link
Member

@Mic92 Mic92 Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The postPatch looks good to me though. So I would only remove inherit patches;.

@Gerschtli
Copy link
Contributor Author

@Mic92 This does not work. My current workaround is

{
  nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.lib.overrideDerivation pkgs.slock (attrs: {
      patchPhase = attrs.patchPhase + " && patch < " + ./patch.diff;
    });
  };
}

Not really a nice solution I think..

@Mic92
Copy link
Member

Mic92 commented Sep 8, 2017

To be sure we are on the same page: You say if you rename patchPhase to postPatch, you cannot set patches = [ ./patch.diff ]; in overrideDerivation?

@Gerschtli
Copy link
Contributor Author

That would work, but why use this method if it isn't a problem to make the usage easier without any drawbacks?

@Gerschtli
Copy link
Contributor Author

Hey, whats the status?

@Mic92
Copy link
Member

Mic92 commented Sep 19, 2017

The drawbacks is, that it pulls patches from all-package.nix, where it can have a different value.
We have for example a package called src. See dwm package for alternatives.

@Mic92
Copy link
Member

Mic92 commented Sep 19, 2017

It also promotes an API, where it is unclear, if we can add our own patches. So it should be at least named extraPatches.

@Gerschtli
Copy link
Contributor Author

I can't see the difference why this ( https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/window-managers/dwm/default.nix ) is okay, but here it isn't

@Mic92
Copy link
Member

Mic92 commented Sep 19, 2017

The difference between dwm and this pr is here: https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix#L13962

@Gerschtli
Copy link
Contributor Author

So if I would edit the line for slock in all-packages.nix, would it be okay?

@Mic92
Copy link
Member

Mic92 commented Sep 19, 2017

You can also expose conf the same way and I would still called it config.slock.extraPatches there because we might need to add patches too in future.

@Gerschtli
Copy link
Contributor Author

Gerschtli commented Sep 19, 2017

Sounds good to me. Could you please tell me, where the slock package is called? I can't find the line in all-packages.nix...
EDIT: Found the entry, updating the PR

@Gerschtli
Copy link
Contributor Author

I have updated the PR, but I really can't see the benefit of using extraPatches instead of the widely used patches name..

@oxzi
Copy link
Member

oxzi commented Sep 23, 2017

I'd love to see this PR merged and be available in 17.09. Thanks for creating this patch and reviewing it.

@globin
Copy link
Member

globin commented Sep 23, 2017

I'm strongly opposed to this. I don't want to promote this kind of API.

I'd propose renaming patchPhase to postPatch which is the way it should be and then you can use overrideDerivation/overrideAttrs to add custom patches. There is no need to add a config parameter for this because on could argue the same for each and every package causing huge bloat.

Sorry for not stating this earlier but this PR had slipped past me.

@sifmelcara
Copy link
Member

sifmelcara commented Sep 23, 2017

Is this parameter meant to be used with https://tools.suckless.org/slock/patches/ ?
If yes, IMHO, it is a little bit strange that user need to write something like the following in order to enable extra patches provided by upstream:

{
  nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.slock.overrideDerivation (old: {
      patches = [ (pkgs.fetchurl {
                     url = "https://tools.suckless.org/slock/patches/slock-capscolor.diff" ;
                     sha256 = "0nnakvsnzfvq0s6kyvmf0fql29bnls75hli2vkm8smr1by86c9k6";
                   })];
    });
  };
}

Maybe extra options like enableCapscolor, enableControlClear would be better?

Edit: I mean, to write

{
  nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.slock.overrideDerivation (old: {
      enableCapscolor = true;
      enableControlClear = true;
    });
  };
}

instead.

@oxzi
Copy link
Member

oxzi commented Sep 23, 2017

I'm strongly against adding options for every possible patch out there. This would imply that you know every patch out there (not just the patches on the slock-webpage) and that other patches aren't worth it. I'm a friend of a simple patch-list like in the dwm-package.

@sifmelcara
Copy link
Member

sifmelcara commented Sep 23, 2017

@geistesk I think these patches provided by upstream are more like "extra features" than "extra patches". If we let user to fetch the patches themselves or let user to use their own patches, the patch may not be applicable anymore when slock receive a version update. If we provide options like enableCapscolor and enableControlClear, then who update the slock package can also update the version of these patches provided by upstream.

And if users really need to add custom patches, they can use method mentioned by @globin

@oxzi
Copy link
Member

oxzi commented Sep 23, 2017

@sifmelcara These patches are created against different versions (tags and commits) and are user-submitted. So it's perhaps not possible to merge them automatically into the latest version.
The situation with dwm is similar, where you've got hundreds of patches (against different versions). Some of those patches won't work together.
So I'm against offering those patches. If a user of slock/dwm/… wants to use them, they can apply them manually.

Honestly I don't care how I'll patch it, as long as I'm able to patch it. My current slock-patching looks like this, but this won't work. So I'm overwriting the src

nixpkgs.config.packageOverrides = pkgs: {
    slock = pkgs.slock.overrideAttrs(oldAttrs: rec {
        patches = [ /etc/nixos/patches/slock-dpms-20170923-fa11589.diff ];
    });
};

@Gerschtli
Copy link
Contributor Author

I think the way, I have adapted the PR should be okay because

  1. the conf parameter can not mistakenly be set via callPackage
  2. the ability to add patches with overrideDerivation / overrideAttrs is guaranteed

@globin I understand now why you don't want such interfaces, sounds logical ;)

@Mic92 Mic92 merged commit a75174a into NixOS:master Sep 24, 2017
@Gerschtli Gerschtli deleted the update/slock-patches branch September 24, 2017 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants