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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitscope: init at 2017-12-28 #33148

Closed
wants to merge 2 commits into from

Conversation

vidbina
Copy link
Contributor

@vidbina vidbina commented Dec 28, 2017

Motivation for this change

BitScope makes some pretty sweet and affordable scopes and logic analysers of which I own a unit that I needed to use recently. Sadly the source doesn't seem to be open (hence the submission with the unfree license), but they at least offer some reference schematics for the hardware.

Several deb and rpm packages, among other formats for other platforms, are available on their website so I figured it made sense to take the deb and package it for use in NixOS. I ended up using a FHS env to get everything up and running and mostly tested the additions with a combination of

nix-shell --pure --show-trace -I nixpkgs=$NIXPKGS -p bitscope.dso bitscope.chart bitscope.meter

which drops me in a shell where I have access to the executables, or

nix-repl -I nixpkgs=$NIXPKGS

from within the nixpkgs directory, loading the whole shebang and inspecting the bitscope set.

The added packages along with the executables they install are:

  • bitscope.chart, 馃敆 accessible through the binary bitscope-chart
  • bitscope.console, accessible through the binary bitscope-console
  • bitscope.display, 馃敆 accessible through the binary bitscope-display
  • bitscope.dso, 馃敆 accessible through the binary bitscope-dso
  • bitscope.logic, 馃敆 accessible through the binary bitscope-logic
  • bitscope.meter, 馃敆 accessible through the binary bitscope-meter
  • bitscope.proto, accessible through the binary bitscope-proto
  • bitscope.server 馃敆, accessible through the binary bitscope-server

Every binary is pinned to the latest stable version as of 2017-12-28 and works on my setup.

2017-12-28-183236_3200x1800_scrot

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
    • 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/)
  • Fits CONTRIBUTING.md.

};
in {
dso = let
name = "${toolName}_${version}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip: If package name and version is separated with a dash, Nix will know how to parse it. This currently uses underscore, so Nix will not know the version.

inherit name toolName version;

meta.description = "Communications program designed to make it easy to talk to any model BitScope";
meta.longDescription = "BitScope Console is a communications program designed to make it easy to talk to any model BitScope via any supported communications link (serial, USB, LAN, Internet etc). Use it to interrogate the BitScope Virtual Machine to help write your own software for BitScope. It uses BitScope Link Library to facilitate communication. Note: you don't need the program to talk to most BitScopes, a simple terminal program will do but Console makes connection easier, uses the probe file specification and supports downstream communications to connected port adapters.";
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use double single-quotes, you can create a multi-line string of this longDescription that wraps at 80 chars.

Copy link
Contributor

@bjornfor bjornfor left a comment

Choose a reason for hiding this comment

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

Looks good. Just nitpicks:

  • Use dash instead of underscore in derivation names, so that Nix can parse the version.
  • Rewrite the branch to be two commits: (1) adding yourself to lib/maintainers.nix and (2) adding the bitscope packages.

@vidbina vidbina force-pushed the add/bitscope-mergeable branch 2 times, most recently from fbea3e9 to 8dcb841 Compare December 28, 2017 23:56
@vidbina
Copy link
Contributor Author

vidbina commented Dec 28, 2017

@bjornfor requests honored 馃槈 and force pushed

@@ -0,0 +1,54 @@
{ stdenv, fetchurl, buildFHSUserEnv, makeWrapper, writeScriptBin, pkgs }:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please list each dependency as function parameter instead of taking the whole 'pkgs' set.

@bjornfor
Copy link
Contributor

I think you misunderstood what I meant about the maintainers commit. I meant to have one commit, the first, that only adds you to lib/maintainers.nix, followed by a commit that adds the bitscope package (with you as maintainer). Currently the separation I was looking for is not there -- both commits touch the bitscope package.

Also, the new commit message for adding bitscope could use some cleanup:

    bitscope: init at 2017-12-28

    bitscope: init at 2017-12-28

    bitscope: init at 2017-12-28

    One of my professors used to say "Meten is weten" so here goes...

    bitscope: refactored, re-ordered set members

    bitscope: refactored, shared helper to common.nix

    bitscope: fix underscores in name to dash

    bitscope: refactor, defining name in common

Let me know if you'd like me to rebase / amend / edit commit messages before applying to master.

@vidbina
Copy link
Contributor Author

vidbina commented Dec 29, 2017

Thanks for clarifying. I hope I wont cost you much more time due to confusion on my side or failure to get 馃挬 right.
Here goes another shot 馃榿

@vidbina vidbina changed the title Add/bitscope mergeable bitscope: init at 2017-12-28 Dec 29, 2017
dpkg,
fetchurl,
gdk_pixbuf,
glib,
Copy link
Contributor

Choose a reason for hiding this comment

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

One more nitpick! These parameters are commonly written in nixpkgs with comma-first style:

{ atk
, buildFHSUserEnv
, cairo
...

@bjornfor
Copy link
Contributor

Thank you!

I'm testing this on my NixOS machine and all tools have this startup error:

$ nix-build -A bitscope.chart && ./result/bin/bitscope-*
/nix/store/g9lyph13gh0v0cqpfazw5246g9yz3a9v-bitscope-chart
/nix/store/ga7m0s53w9ck5i7rdg1a6mbv6g1pcf7f-bitscope-chart-2.0.FK22M/bin/bitscope-chart: relocation error: /usr/lib/libc.so.6: symbol __tunable_get_val, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

I also tried running with clean environment (env -i ./result/bin/bitscope-*), no change.

My system: NixOS 17.09, x86_64-linux.

What system do you have?

Copy link
Contributor

@bjornfor bjornfor left a comment

Choose a reason for hiding this comment

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

I'd like to know why I'm unable to run the tools. (Also, tiny coding style commented earlier.)

@vidbina
Copy link
Contributor Author

vidbina commented Dec 30, 2017

Dammit. I am costing you more time after all 馃槤. Anyways my systems is 17.09.2320.68a8b335c86 (Hummingbird) with kernel 4.9.67 and arch x86_64.

Post-nixos-collect-garbage, I built the entire circus and get working binaries (see example below for bitscope.chart) but I am downloading the demo VirtualBox image to try it in there as well. Hopefully I can reproduce the error message to investigate this matter (from another machine). Might be that I need to add glibc to the library inputs. I was hoping that testing it in nix-shell --pure would guarantee that I would have everything necessary included in my package, but let's see if that's the case.

asciicast

@vidbina
Copy link
Contributor Author

vidbina commented Dec 30, 2017

I managed to build all bitscope tools in the provided demo vm.

@bjornfor, please advise on next steps. If I'm able to reproduce the problem I can at least attempt to fix the package. Otherwise I'm shooting blanks. Are there perhaps best-practices that I overlooked that could contribute to this?

P.S.: I've taken care of the style-compliance issue @FRidh mentioned 馃槈

bitscope-all

meta = with stdenv.lib; {
homepage = http://bitscope.com/software/;
license = licenses.unfree;
platforms = [ "i686-linux" "x86_64-linux" ];
Copy link
Member

Choose a reason for hiding this comment

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

We no longer support i686. Are you sure you want to provide i686 packages?

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 just took it out. Not sure at all and if it isn't supported anymore I don't see the point keeping it there 馃槈. Thanks for pointing that out.

Copy link
Member

Choose a reason for hiding this comment

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

so all the

else if stdenv.system == "i686-linux" then fetchurl

can be dropped as well then, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A few minutes after the push it dawned upon me that I had those obsolete stdenv.system checks in there. They're gone now. 馃槈

@bjornfor
Copy link
Contributor

(Then I guess the problem is on my side. I'll leave that problem for another time.)

Applied to master (8dbfe69, 810ec3f). Thanks!

@bjornfor bjornfor closed this Dec 30, 2017
@vidbina
Copy link
Contributor Author

vidbina commented Dec 30, 2017

@bjornfor isn't this one of the problems Nix aims to eliminate? I'm really curious to know what's different on your box because packages should either build everywhere or fail everywhere, right? These packages may be worthless to you but if your curiosity every sparks you to explore this further at that other time give me a shout. This kind of bugs me out because it ruins the Nix dream for me.

@bjornfor
Copy link
Contributor

@vidbina: Yes, you are absolutely right about Nix. But no, these packages are not worthless to me.

The thing is that Nix only cares about the build environment. I may have a different runtime environment than you, based on what packages and services I have on my system. The build worked just fine, it was the runtime that broke.

As a quick test I did try to run one of the bitscope packages in a clean environment (env -i ...) but no success. I'll have bisect my config to find what causes the breakage.

@vidbina
Copy link
Contributor Author

vidbina commented Dec 31, 2017

@bjornfor thanks for clearing that up. I'm slowly but surely getting a better hang of this. Wasn't too aware that Nix only guaranteed "buildability" across setups and not "runability".

Also, when I run something in nix-shell --pure, I'm basically somewhat decoupling my system's weird quircks from that newly spawned "pure shell", that "pure shell" should produce the same behavior for anyone given similar inputs, right? Doesn't that constitute a runtime environment and shouldn't that therefore be able to provide us some confidence about our abilities to "run" something in that environment without any issues?

Perhaps there is something in the way in which I called wrapProgram or buildFHSUserEnv that could be a problem? I was wondering if adding glibc to the libs list and or changing the versions of the glib and glibc packages in that very same list resolves the issue. Doesn't make a damn bit of difference for me, but then again I don't have an environment that reproduces this issue for me to be able to tell the difference. Read something about glibc, an LD_LIBRARY_PATH env var and/or possibly incompatible libs version-wise after a preliminary online search 1 2 3 hence that train of thought.

@bjornfor
Copy link
Contributor

that "pure shell" should produce the same behavior for anyone given similar inputs, right?

Right. Except I think it still sources ~/.bashrc or something that is impure. (I think there is a bug about it but I didn't find it.)

Yes, LD_LIBRARY_PATH is an example of a variable that can mess up a lot (at runtime).

Btw, I tested this on two another NixOS 17.09 system of mine, one running KDE the other GNOME. No problem. So I must have some kind of impurity on my main system that I must find myself :-/

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