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

packr: init at 2.1.0 #59054

Closed
wants to merge 2 commits into from
Closed

Conversation

thefloweringash
Copy link
Member

Motivation for this change

New package, and a build dependency for the current version of the Circle CI command line package circleci-cli.

This requires some changes to buildGoModule, but I don't think what I have here is a very nice expression of that (help wanted).

I also could not make go mod download actually download all required modules.

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 nix-review --run "nix-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@kalbasit kalbasit left a comment

Choose a reason for hiding this comment

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

I'll test it out locally by EOD.

version = "2.1.0";
in
buildGoModule 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.

buildGoModule does support pname, so you may skip setting the name all together.

@@ -10,6 +10,8 @@
# modSha256 is the sha256 of the vendored dependencies
, modSha256

, modAttrs ? {}
Copy link
Member

Choose a reason for hiding this comment

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

Please add a description of what modAttrs is to help other people reading the expression.

Copy link
Member Author

Choose a reason for hiding this comment

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

This part of the interface is the part I think could be improved. As is, it's a set of attributes to add to the mkDerviation call. Something closer to .override and .overrideAttrs would make it more consistent with the rest of nixpkgs.

The naive way to do this is to pass those two functions as attributes, and then apply them to go-modules like so:

{
# ...
, modOverrides ? {}
, modAttrOverrides ? attrs: {}
}:
# ...
let go-modules' = (go-modules.override modOverrides).overrideAttrs modAttrOverrides;
in ...

But maybe there's a cleaner way where the go-modules are an optional attribute to the main builder.

let defaultBuildGoModules = attrs:  buildGoModules {
    inherit (attrs) src sourceRoot;
    sha256 = attrs.modSha256;
  };
in
{
# ...
go-modules ? defaultBuildGoModules attrs
}@attrs:

in which case the caller can use

let
  src = fetchFromGitHub {};
  sourceRoot = "source/v2";
in
  buildGoModule {
    inherit src sourceRoot;
    go-modules = buildGoModules { 
      inherit src sourceRoot;
      sha256 = "...";
      postBuild = "...";
    };
}

Since there's a space to put postBuild in the buildGoModules call, .override and .overrideAttrs aren't required. Since the call is explicit, they're still available if necessary.

The other direction to go, is to assert that the modules build step should be kept simple, and instead only offer an extra modPostBuild attribute, a bit like fetchurl only offering a postFetch hook.

Do any of these seem like better options to you?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer modAttrs to be honest. Although allowing the users to provide their own go-modules derivation is quite powerful, it does add unnecessary complexity to a fairly simple build process.

@thefloweringash thefloweringash changed the title [WIP] packr: init at 2.1.0 packr: init at 2.1.0 Apr 14, 2019
@thefloweringash
Copy link
Member Author

packr was added by #63886

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

3 participants