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

moolticute: init at 0.30.8 #54090

Merged
merged 1 commit into from Aug 20, 2019
Merged

moolticute: init at 0.30.8 #54090

merged 1 commit into from Aug 20, 2019

Conversation

kirikaza
Copy link
Contributor

@kirikaza kirikaza commented Jan 16, 2019

Motivation for this change

I need Moolticute (https://github.com/mooltipass/moolticute/) on my laptop since I have Mooltipass device. I hope there are other people with Mooltipass and NixOS -- and they could use it :)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS (there is an official dmg for 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" (no more packages depend on this change)
  • 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.
  • Tested udev rules and communication with Mooltipass device (saving and loading secrets)

meta = with stdenv.lib; {
description = "Mooltipass crossplatform daemon/tools";
longDescription = ''
This project aims to be an easy companion to your Mooltipass device and extend the power of the device to more platform/tools. With it you can manage your Mooltipass with a cross-platform app, as well as provide a daemon service that handle all USB communication with the device.
Copy link
Contributor

Choose a reason for hiding this comment

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

add some newlines, too long line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

meta = with stdenv.lib; {
description = "Udev rules for mooltipass device";
longDescription = ''
This project aims to be an easy companion to your Mooltipass device and extend the power of the device to more platform/tools. With it you can manage your Mooltipass with a cross-platform app, as well as provide a daemon service that handle all USB communication with the device.
Copy link
Contributor

Choose a reason for hiding this comment

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

too long as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

version = "0.30.8";

src = fetchurl {
url = "https://github.com/mooltipass/moolticute/archive/v${version}.tar.gz";
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I see this is same source as above. Why separate derivation then? Can't you install $out/lib/udev/rules.d/50-mooltipass.rules in moolticute derivation?

If it is really needed to have them separated, make separate output udev and install rules there.

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 want moolticute GUI app can be installed for user (nix-env -i) but the udev rules can't be per-user and they are installed into system (/etc/nixos/). That's why I've followed the approach for rfkill / rfkill_udev which have separate derivations. Is there another way to reach the goal? I guess separate output doesn't solve that.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no problem to have udev rules installed into user Nix profile. What is the problem with that? They are not used, but don't harm also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Surely, unused udev rules in user Nix profile are ok. The problem I tried to solve is how to install udev rules into the system if moolticute GUI app is in user Nix profile. My solution is to add services.udev.packages = [ moolticute_udev ] to /etc/nixos/configuration.nix. So the separate moolticute_udev doesn't depend on Qt and other GUI stuff not related with udev rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok then just install udev rules to separate output.

...
outputs = [ "out" "udev" ];
preInstall = ''
    mkdir -p $udev/lib/udev/rules.d
    sed -n '/^ \+cat > "$tmpfile" <<- EOF$/,/^EOF$/p' data/moolticute.sh | sed '1d;$d' \
      > $udev/lib/udev/rules.d/50-mooltipass.rules  
'';
...

Then you can set all-packages as:

  moolticute = libsForQt5.callPackage ../applications/misc/moolticute { };

  moolticute-udev = moolticute.udev; # or maybe just drop this?

Both moolticute and moolticute.udev should work as services.udev.packages packages. The second one won't depend on Qt, you can check that yourself with nix-store -qR $(nix-build -A moolticute.udev)

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 tried to split outputs. The problems is nix-build -A moolticute.udev fetches all the dependencies and builds binaries (although doesn't install them). That's why udev.nix doesn't specify libusb1, qmake, etc. and why it has a line dontBuild = true. Is it possible to specify different dependencies for multiple outputs? and to disable build step for one of them? I haven't found an answer in nixkpgs' manual.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a problem since the package will be fetched from binary cache most of the time and then only the dependencies required by the output will be needed.


buildInputs = [ libusb1 qtbase qtwebsockets ];

doCheck = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this a default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@danbst
Copy link
Contributor

danbst commented Feb 20, 2019

@kirikaza I'll merge this when duplication is finally removed. The src, meta are duplicated for moolticute-udev packages, this smells bad.

If you don't want to go with multiple outputs (even if this perfectly fine in this case, as I'll explain later), you can also define the package as:

{ moolticute, runCommand }:
runCommand "moolticute-udev-${moolticute.version}" {
  inherit (moolticute) version;
} ''
    mkdir -p $out/lib/udev/rules.d
    sed -n '/^ \+cat > "$tmpfile" <<- EOF$/,/^EOF$/p' ${moolticute.src}/data/moolticute.sh | sed '1d;$d' > $out/lib/udev/rules.d/50-mooltipass.rules
''

runCommand is a very simplistic builder, that doesn't even have GCC.

As for dependencies and multiple outputs. Nix distinguishes (very rough) two sets of dependencies: build-time and run-time. Build-time are fetched and used when building derivation. Run-time are determined by Nix automagically (it greps every file in derivation for /nix/store/xxxx... strings). So even if building moolticute.udev requires qmake, etc, those won't be present in run-time dependencies. It will be cheap to install. Also, for Hydra (and by specifying platforms = platforms.linux; you've asked Hydra to build your package) it is better to build multi-output package, than multiple packages.

@kirikaza
Copy link
Contributor Author

kirikaza commented Mar 3, 2019

Thank you for good explanation. And sorry for not responding, I missed your answer. I'll upload the new version soon.

@Lassulus
Copy link
Member

@danbst ready for merge?

@danbst danbst merged commit 8ffb3cc into NixOS:master Aug 20, 2019
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

6 participants