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

rambox: build from source #31137

Merged
merged 1 commit into from Nov 7, 2017
Merged

Conversation

lukateras
Copy link
Member

@lukateras lukateras commented Nov 2, 2017

Motivation for this change

This makes rambox build from source. It also includes Sencha Cmd derivation (build tool used by rambox) and fetchNodeModules fetcher both of which are currently not available at top-level (not good enough).

@gnidorah, please check this out and tell if it works for you, and if you see any errors in DevTools console in normal workflow.

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.

@Mic92
Copy link
Member

Mic92 commented Nov 2, 2017

Checksum seems be wrong:

...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-win@2.1.0 (node_modules/7zip-bin-win):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-win@2.1.0: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-win@2.1.0 (node_modules/electron-builder-squirrel-windows/node_modules/7zip-bin-win):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-win@2.1.0: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 908 packages in 52.274s
output path '/nix/store/aknfmf7rqs2kv5wgbslh3q595rjd6q4m-node_modules' has r:sha256 hash '0gllw4zbrx7fagcrqfzsvw3rlzfqvmf4x04436xwfphl1h3pyw5q' when '09z6r17v1nikcfzbs06mvv5pl4zdclf6xcryfiy9iv8nd0rv8nzw' was expected
cannot build derivation '/nix/store/7ngmcvgmfcn5h343h72bqak62h1kqhr8-rambox-bare-0.5.13.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/8p3jb1bwgkp1il3wlvry6q0lva07q3dd-rambox-0.5.13.drv': 1 dependencies couldn't be built
error: build of '/nix/store/8p3jb1bwgkp1il3wlvry6q0lva07q3dd-rambox-0.5.13.drv' failed
The invocation of "nix-shell --keep-going -j4 --option build-use-sandbox true -p rambox" failed

@lukateras
Copy link
Member Author

lukateras commented Nov 2, 2017

@Mic92 Interesting, fetchNodeModules is deterministic for me. When I refetch after removing result and running nixos-collect-garbage, it still has the same checksum.

Could you show the full log? Also I think this relies on f1e8138, NPM until recently was not deterministic, see npm/npm#17979 (comment).

@ghost
Copy link

ghost commented Nov 2, 2017

@yegortimoshenko Wow, you've made a great work!!! 👍 Works fine (aside of url opening under wayland). No errors in console so far.

rm $out/shell-wrapper.sh $out/Uninstaller
'';

meta = with stdenv.lib; {
Copy link

Choose a reason for hiding this comment

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

sencha license?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it should be licenses.unfree.

description = "Free and Open Source messaging and emailing app that combines common web applications into one";
homepage = http://rambox.pro;
license = licenses.mit;
maintainers = [ maintainers.gnidorah ];
Copy link

Choose a reason for hiding this comment

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

you don't want to add yourself to maintainers? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

👺


postFixup = ''
paxmark m $out/opt/Rambox/rambox
wrapProgram $out/opt/Rambox/rambox --prefix PATH : ${xdg_utils}/bin
Copy link

Choose a reason for hiding this comment

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

this is still needed for url opening under wayland, since xdg-utils is not a part of e.g. sway compositor

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@@ -0,0 +1 @@
var auth0Cfg={clientID:"y9am0DVawe2tvlA3ucD7OufpJHZZMjsO",domain:"rambox.auth0.com"};
Copy link
Member

Choose a reason for hiding this comment

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

are we allowed to put this client ID in our repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, not explicitly.

A new client ID requires an account at https://auth0.com/. I could register one on my own but I'm not sure if that's appropriate. Chromium derivation also has API credentials:

# Google API keys, see:
# http://www.chromium.org/developers/how-tos/api-keys
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
# please get your own set of keys.
google_api_key = "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI";
google_default_client_id = "404761575300.apps.googleusercontent.com";
google_default_client_secret = "9rIFQjfnkykEmqb6FfjJQD1D";

Are they registered using a special email address or is it just someone who happens to maintain the derivation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nevermind, used my own account for now. Fixed!

@Mic92
Copy link
Member

Mic92 commented Nov 2, 2017

@yegortimoshenko I have build you pull request both rebased against master and your pull request branch:

https://gist.github.com/Mic92/f47265189009d4cbd202c2dafec3ecaf

The only difference I can spot is that I use nixUnstable, which is also used on hydra.

@lukateras lukateras force-pushed the rambox/build-from-source branch 2 times, most recently from 597a258 to e7fc6fd Compare November 2, 2017 20:37
@lukateras
Copy link
Member Author

lukateras commented Nov 2, 2017

@Mic92 This is probably due to some install script. I've disabled those and forced npm to install only production dependencies (reduces size and potentially less prone to breakage) but for all platforms (previously e.g. Linux-specific dependency would not be fetched on macOS which leads to a different checksum).

Now there should be very little surface for non-determinism. Could you please try again?

@lukateras lukateras force-pushed the rambox/build-from-source branch 2 times, most recently from 8e96d14 to d48662b Compare November 2, 2017 22:41
@lukateras
Copy link
Member Author

lukateras commented Nov 2, 2017

I've made a few other fixes: switched file layout/naming, added another patch to completely disable auto-update functionality along with passing --without-update flag, added assertion to fetchNodeModules, fixed locale support.

@Mic92
Copy link
Member

Mic92 commented Nov 3, 2017

Now I get:

building path(s) '/nix/store/shm37242gb6m7nvnjg27a1x83ib6vrcz-node_modules'
building '/nix/store/fx8113433ghsr1y8d8j5j2kid41w1shi-node_modules.drv'...
npm WARN using --force I sure hope you know what you are doing.
added 107 packages in 7.064s
output path '/nix/store/shm37242gb6m7nvnjg27a1x83ib6vrcz-node_modules' has r:sha256 hash '04wmwnjm5010n564gq7l8w1cs411wy3p4hk05a2s63z7waxsaw63' when '0w912a3pmd87rwxi5kq248b2yicissvzyq6iafim6ckvvcvky5xf' was expected
cannot build derivation '/nix/store/249wmafhwzfv5b20j0197scix58bi7sj-rambox-bare-0.5.13.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/9x5fhfxah9iwr6p5r74i5jijghv9irz3-rambox-0.5.13.drv': 1 dependencies couldn't be built
error: build of '/nix/store/9x5fhfxah9iwr6p5r74i5jijghv9irz3-rambox-0.5.13.drv' failed

I have uploaded node-modules for inspection: https://dl.thalheim.io/wCrMmJa1V6fYMGbzdZ7IUw/node-modules.tar.gz

$ tar --xattrs -czpf node-modules.tar.gz /tmp/nix-build-node_modules.drv-0

You can diff it with diffoscope

@lukateras
Copy link
Member Author

lukateras commented Nov 3, 2017

Could you show /nix/store/shm37242gb6m7nvnjg27a1x83ib6vrcz-node_modules?

fetchNodeModules moves rather than copies to $out. Or this line could be replaced with cp -r node_modules $out so that build directory has the output.

homepage = http://rambox.pro;
license = licenses.gpl3;
maintainers = with maintainers; [ gnidorah ];
platforms = platforms.linux;
Copy link

Choose a reason for hiding this comment

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

someone with Mac to test it there? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

That'd take some effort: Sencha CMD derivation should be extended to Darwin first. And I'd wager that most macOS users are more comfortable with packaging native to their platform anyway.

Copy link

@ghost ghost Nov 5, 2017

Choose a reason for hiding this comment

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

I agree with you. Just some offtopic: some nixpkgs macOS users don't agree, see discussion #20670 (comment)

@Mic92
Copy link
Member

Mic92 commented Nov 3, 2017

@yegortimoshenko

$ tar --xattrs -czpf ~/upload/node-modules.tar.gz /nix/store/mfb04xbqdmbh5cpmwqrhvq8jbmfb81lx-node_modules

https://dl.thalheim.io/wCrMmJa1V6fYMGbzdZ7IUw/node-modules.tar.gz

@lukateras
Copy link
Member Author

lukateras commented Nov 3, 2017

@Mic92 Thanks a lot! My build dir is different from yours for some reason:

diff -urNZ /nix/store/shm37242gb6m7nvnjg27a1x83ib6vrcz-node_modules/asap/package.json nix/store/mfb04xbqdmbh5cpmwqrhvq8jbmfb81lx-node_modules/asap/package.json
--- /nix/store/shm37242gb6m7nvnjg27a1x83ib6vrcz-node_modules/asap/package.json	1970-01-01 00:00:01.000000000 +0000
+++ nix/store/mfb04xbqdmbh5cpmwqrhvq8jbmfb81lx-node_modules/asap/package.json	1970-01-01 00:00:01.000000000 +0000
@@ -2,7 +2,7 @@
   "_args": [
     [
       "asap@2.0.6",
-      "/tmp/nix-build-node_modules.drv-0"
+      "/build"
     ]
   ],
   "_from": "asap@2.0.6",
@@ -26,7 +26,7 @@
   ],
   "_resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
   "_spec": "2.0.6",
-  "_where": "/tmp/nix-build-node_modules.drv-0",
+  "_where": "/build",
   "browser": {
     "./asap": "./browser-asap.js",
     "./asap.js": "./browser-asap.js",

Of course this metadata should not affect the checksum. I've updated the fetcher to strip it using jq.
Also see npm/npm#10393.

@Mic92
Copy link
Member

Mic92 commented Nov 3, 2017

@yegortimoshenko this is due nixUnstable, I suppose. Hydra will have the same build path. But looks like it could be normalized. Why do they store this information at all?

@lukateras
Copy link
Member Author

lukateras commented Nov 4, 2017

They store this information to speed up next npm install invocations. This should be ready to merge.

@Mic92
Copy link
Member

Mic92 commented Nov 4, 2017

But it will not build in hydra because the wrong checksum.

@lukateras
Copy link
Member Author

lukateras commented Nov 4, 2017

But checks have passed. I've already fixed the fetcher, it now normalizes package.json files. Could you please link me to the failing build? Can't find it on hydra.nixos.org.

@ghost
Copy link

ghost commented Nov 5, 2017

@Mic92 Will hydra build it? Rambox dependency Sencha is unfree. We can "build" w/o Sencha, like Rambox CI scripts do https://github.com/NixOS/nixpkgs/pull/20657/files#diff-5a9e329a438665eff30913e6b6d5bb72R46 but that's not cool

@Mic92
Copy link
Member

Mic92 commented Nov 7, 2017

@yegortimoshenko thanks, with the normalization it works. @gnidorah hydra will not build it with sencha beeing marked as unfree. But the build seems pretty fast to me, so maybe it does not matter.

jq -S 'delpaths(keys | map(select(startswith("_")) | [.]))' $f > $f.tmp
mv $f.tmp $f
done
mv node_modules $out
Copy link
Member

Choose a reason for hiding this comment

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

This snippet is actually pretty cool. We can use it to build other node.js applications without adding thousands of npm dependencies to nixpkgs.

Copy link
Member Author

@lukateras lukateras Nov 7, 2017

Choose a reason for hiding this comment

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

@Mic92 Thanks! I'll test it with another package or two and then I'll move it to build-support. Pretty sure it's deterministic now, but ignoring scripts might be a problem with some builds. Running scripts will likely cause different checksums for different platforms/architectures.

I also have a fetcher for Maven/Leiningen project dependencies:
https://github.com/yegortimoshenko/overlay/blob/master/pkgs/fetchMaven/default.nix

@Mic92 Mic92 merged commit 1925b4c into NixOS:master Nov 7, 2017
@ghost
Copy link

ghost commented Nov 7, 2017

@yegortimoshenko Thank you much!

@ghost ghost mentioned this pull request Nov 22, 2017
@lukateras lukateras deleted the rambox/build-from-source branch December 18, 2017 05:38
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