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

fmtlib: add pkgconfig #48960

Merged
merged 3 commits into from Nov 19, 2018
Merged

fmtlib: add pkgconfig #48960

merged 3 commits into from Nov 19, 2018

Conversation

colemickens
Copy link
Member

Motivation for this change

This enables fmt to be usable with meson/pkgconfig.

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/) (Indirectly, via a package in an overlay that uses it.)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

cd /build/source
pc="fmt.pc"
substituteInPlace "$pc" --replace "@out@" "$out"
substituteInPlace "$pc" --replace "@version@" "${version}"
Copy link
Member

Choose a reason for hiding this comment

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

You can use substituteAll here which does the '@variable@' substitution out of the box.

@@ -0,0 +1,30 @@
From 7ad56220fd23cfce7c1c3e3bc269fa88d34070eb Mon Sep 17 00:00:00 2001
Copy link
Member

Choose a reason for hiding this comment

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

This looks like you have send this also upstream? Can you include a link to the pull request if that's the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

(I've now added it next to the patch line in default.nix, if that's okay.)

@colemickens
Copy link
Member Author

I added a link to an upstream PR. I'm not sure it's good though, it has NixOS-isms in it still. I am not very experienced in this area to know how to best have a cmake project spit out a proper pkgconfig file?

@Mic92
Copy link
Member

Mic92 commented Oct 24, 2018

@colemickens I made a suggestion in the pull request.

@@ -9,6 +9,10 @@ stdenv.mkDerivation rec {
rev = "${version}";
sha256 = "1cd8yq8va457iir1hlf17ksx11fx2hlb8i4jml8gj1875pizm0pk";
};
patches = [
# https://github.com/fmtlib/fmt/pull/916
Copy link
Member

Choose a reason for hiding this comment

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

Might use something like the following then:

patches = [
  (fetchPatch {
    name = "0001-add-fmt";
    url = "https://github.com/fmtlib/fmt/pull/916.patch";
    sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxx";
  })
];

Copy link
Member

Choose a reason for hiding this comment

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

Instead of the pull request please create a dedicated branch in this case, so the patch never changes, if upstreams wants you to change the pull request.

Copy link
Member

Choose a reason for hiding this comment

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

Could do https://github.com/fmtlib/fmt/pull/916/commits/0dbf735fe3a54b78b2e35122baa5a9c0e7216445.patch in that case

Copy link
Member

Choose a reason for hiding this comment

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

@colemickens
Copy link
Member Author

Thanks for the review and suggestions @Synthetica9 @Mic92.

I've made the suggestion change upstream, tested it with this PR and waybar which uses fmt, and can confirm this all works. Also, this has the nice benefit of being self-documenting via the patch/PR url.

For additional verification, and/or in case it's of interest, I have this and some related things in an overlay (built for nixos-unstable), which is also how I'm testing this: https://github.com/colemickens/nix-overlay-sway (fmt/default.nix has the same fetchpatch)

@colemickens
Copy link
Member Author

$ cd /etc/nix-overlay-sway
$ cat $(nix-build build.nix | grep fmt)/share/pkgconfig/fmt.pc
prefix=/nix/store/6vdylp1wysqkk2szkwxgwafgkckvnj6z-fmt-5.2.1
exec_prefix=/nix/store/6vdylp1wysqkk2szkwxgwafgkckvnj6z-fmt-5.2.1
libdir=/nix/store/6vdylp1wysqkk2szkwxgwafgkckvnj6z-fmt-5.2.1/lib
includedir=/nix/store/6vdylp1wysqkk2szkwxgwafgkckvnj6z-fmt-5.2.1/include

Name: fmt
Description: A modern formatting library
Version: 5.2.1
Libs: -L${libdir} -lfmt
Cflags: -I${includedir}

@@ -9,6 +9,12 @@ stdenv.mkDerivation rec {
rev = "${version}";
sha256 = "1cd8yq8va457iir1hlf17ksx11fx2hlb8i4jml8gj1875pizm0pk";
};
patches = [
pkgs.fetchpatch {
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 parentheses here, otherwise it is interpreted as being two elements of an array instead of a call.

@@ -9,6 +9,12 @@ stdenv.mkDerivation rec {
rev = "${version}";
sha256 = "1cd8yq8va457iir1hlf17ksx11fx2hlb8i4jml8gj1875pizm0pk";
};
patches = [
pkgs.fetchpatch {
Copy link
Member

Choose a reason for hiding this comment

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

pkgs.fetchpatch is also not in scope, so you need to add it to your arguments (I'd reccomend removing the pkgs, and adding fetchpatch as an argument.)

@@ -9,6 +9,12 @@ stdenv.mkDerivation rec {
rev = "${version}";
sha256 = "1cd8yq8va457iir1hlf17ksx11fx2hlb8i4jml8gj1875pizm0pk";
};
patches = [
pkgs.fetchpatch {
url = "https://github.com/fmtlib/fmt/pull/916/commits/57ae5189351665715c98b3b6ca8595b30d83033f.patch";
Copy link
Member

Choose a reason for hiding this comment

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

Now that the patch is merged you can also pull from master.

@colemickens
Copy link
Member Author

Thanks again to all. I took a stab at it. It's pointing at the latest commit from fmtlib/fmt master with my pkgconfig change included. I left the version string alone, though, please advise if I should change it.

What's the general nixpkgs guidance on something like with changes like this (aka, pinning to a non-tagged/released revision)?

For example, in this case, especially with such a speedy upstream merge, I don't mind carrying this override in my fork/overlay; it feels almost hasty to do this here, now, especially since I won't be sending a PR for the dependent package yet due to there being no release.

@Mic92
Copy link
Member

Mic92 commented Oct 25, 2018

So basically you are waiting for the next release?

@colemickens
Copy link
Member Author

@Mic92 I went ahead and already updated this PR to pull from fmt's master, I just don't know if it's prudent or appropriate for nixpkgs. I'm looking for some encouragement one way or the other.

@c0bw3b
Copy link
Contributor

c0bw3b commented Nov 19, 2018

@GrahamcOfBorg build fmt

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: fmt

Partial log (click to expand)

strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/xrpnlaqqzmyl8kkchl6yfigrm2n5z021-fmt-5.2.1/lib
patching script interpreter paths in /nix/store/xrpnlaqqzmyl8kkchl6yfigrm2n5z021-fmt-5.2.1
checking for references to /build in /nix/store/xrpnlaqqzmyl8kkchl6yfigrm2n5z021-fmt-5.2.1...
shrinking RPATHs of ELF executables and libraries in /nix/store/b61mcp9pbzyv5q6n87851hdprzqgx5fp-fmt-5.2.1-dev
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/b61mcp9pbzyv5q6n87851hdprzqgx5fp-fmt-5.2.1-dev/lib
patching script interpreter paths in /nix/store/b61mcp9pbzyv5q6n87851hdprzqgx5fp-fmt-5.2.1-dev
checking for references to /build in /nix/store/b61mcp9pbzyv5q6n87851hdprzqgx5fp-fmt-5.2.1-dev...
/nix/store/xrpnlaqqzmyl8kkchl6yfigrm2n5z021-fmt-5.2.1

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: fmt

Partial log (click to expand)

strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/kd8ji5p3s643fb520khp7nl5j5z1gfp0-fmt-5.2.1/lib
patching script interpreter paths in /nix/store/kd8ji5p3s643fb520khp7nl5j5z1gfp0-fmt-5.2.1
checking for references to /build in /nix/store/kd8ji5p3s643fb520khp7nl5j5z1gfp0-fmt-5.2.1...
shrinking RPATHs of ELF executables and libraries in /nix/store/183q3v20c0g44x30z3zwr474py98iy6g-fmt-5.2.1-dev
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/183q3v20c0g44x30z3zwr474py98iy6g-fmt-5.2.1-dev/lib
patching script interpreter paths in /nix/store/183q3v20c0g44x30z3zwr474py98iy6g-fmt-5.2.1-dev
checking for references to /build in /nix/store/183q3v20c0g44x30z3zwr474py98iy6g-fmt-5.2.1-dev...
/nix/store/kd8ji5p3s643fb520khp7nl5j5z1gfp0-fmt-5.2.1

@c0bw3b c0bw3b merged commit 719feb8 into NixOS:master Nov 19, 2018
@colemickens colemickens deleted the pr-fmt branch January 30, 2020 09:37
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