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

gitAndTools.pre-commit: init at 1.10.4 #44239

Merged
merged 6 commits into from Jul 31, 2018

Conversation

borisbabic
Copy link
Contributor

Motivation for this change

Add pre-commit - a useful tool for managing and sharing git commit hooks.

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.

@@ -0,0 +1,19 @@
{ lib, buildPythonPackage, fetchPypi, pythonPackages }:
Copy link
Member

Choose a reason for hiding this comment

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

no pythonPackages, list the individual requirements

@@ -0,0 +1,19 @@
{ lib, buildPythonPackage, fetchPypi, pythonPackages }:
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed these issues.

@@ -0,0 +1,30 @@
{ stdenv, pythonPackages, pew }:
with pythonPackages; buildPythonApplication rec {
name = "${pname}-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

The name attribute is added by buildPython* and should therefore be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's not necessary. removed it

description = "A framework for managing and maintaining multi-language pre-commit hooks.";
homepage = https://pre-commit.com/;
license = licenses.mit;
platforms = platforms.all;
Copy link
Member

Choose a reason for hiding this comment

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

drop platforms, is already set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, buildPythonApplication does that? I dropped it.

@@ -186,6 +186,8 @@ in {

asn1crypto = callPackage ../development/python-modules/asn1crypto { };

aspy.yaml = callPackage ../development/python-modules/aspy.yaml { };
Copy link
Member

Choose a reason for hiding this comment

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

The . should be replaced by e.g. _ (also in the commit message).

Copy link
Member

Choose a reason for hiding this comment

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

preferable even a -, so to follow the PEP on normalized names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wasn't sure what to do with the period, I changed it now to -.

propagatedBuildInputs = [ pyyaml ];

meta = with lib; {
description = "A few extensions to pyyaml.";
Copy link
Member

Choose a reason for hiding this comment

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

No period: https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes (also for the other descriptions)

@@ -8420,6 +8420,8 @@ with pkgs;

pyprof2calltree = pythonPackages.callPackage ../development/tools/profiling/pyprof2calltree { };

pre-commit = pythonPackages.callPackage ../development/tools/pre-commit { };
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use pythonPackages here, but as argument in the expression.

Copy link
Member

Choose a reason for hiding this comment

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

Also, since pre-commit seems to support Python 3, please use that if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I don't have to list individual requirements for pre-commit, just for the modules? Or am I misunderstanding something.

I'll use python3. Is the preferred method to do the following here:

  pre-commit = callPackage ../development/tools/pre-commit {
    pythonPackages = python3Packages;
  };

Copy link
Member

Choose a reason for hiding this comment

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

Ye, correctly. The advantage is that applications can override individual packages.
No, the latter is not preferred. I'd just use python3 or python3Packages as argument.

description = "A framework for managing and maintaining multi-language pre-commit hooks.";
homepage = https://pre-commit.com/;
license = licenses.mit;
maintainers = with maintainers; [ borisbabic ];
Copy link
Member

Choose a reason for hiding this comment

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

You need to add yourself to https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix. Please do so in an additional commit.

virtualenv
];

doCheck = false;
Copy link
Member

Choose a reason for hiding this comment

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

Why do you disable tests? Please add a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests fail on python3 due to a windll dependency. I will add a comment explaining, I should have done that right away 😅

@dotlambda
Copy link
Member

There are two final things to do. Sorry that I didn't think of these earlier:

  • The expression for pre-commit should be moved to pkgs/applications/version-management/git-and-tools/pre-commit/default.nix and called from pkgs/applications/version-management/git-and-tools/default.nix.
  • All three newly packaged Python modules seem not ship their testsuite in the PyPI tarball. Please add something like this to their expressions:
# Tests not included in PyPI tarball
doCheck = false;

Anyway, thanks a lot for your work!

@dotlambda
Copy link
Member

@GrahamcOfBorg build pre-commit

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: pre-commit

Partial log (click to expand)

Cannot nix-instantiate `pre-commit' because:
error: attribute 'pre-commit' in selection path 'pre-commit' not found

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: pre-commit

Partial log (click to expand)

Cannot nix-instantiate `pre-commit' because:
error: attribute 'pre-commit' in selection path 'pre-commit' not found

@dotlambda
Copy link
Member

@GrahamcOfBorg build gitAndTools.pre-commit

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: gitAndTools.pre-commit

Partial log (click to expand)

shrinking RPATHs of ELF executables and libraries in /nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4
strip is /nix/store/zrs21zqcchgyabjf4xfimncdq16njizc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/lib  /nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/bin
patching script interpreter paths in /nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4
/nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/lib/python3.6/site-packages/pre_commit/resources/hook-tmpl: interpreter directive changed from "/usr/bin/env python" to "/nix/store/grlcs2s6hzmra5r6sdb2l612q3002ssn-python3-3.6.6/bin/python"
checking for references to /build in /nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4...
wrapping `/nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/bin/pre-commit-validate-manifest'...
wrapping `/nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/bin/pre-commit-validate-config'...
wrapping `/nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4/bin/pre-commit'...
/nix/store/ccnm03kwjb59231p0gws3vvz8799q4sn-pre_commit-1.10.4

@dotlambda dotlambda changed the title Init pre-commit gitAndTools.pre-commit: init at 1.10.4 Jul 31, 2018
@dotlambda dotlambda merged commit e858b28 into NixOS:master Jul 31, 2018
@borisbabic
Copy link
Contributor Author

Oops, I forgot to change pre-commit to gitAndTools.pre-commit.

Thanks everybody for your help and patience!

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