2019-04-01 20:07:39 +00:00
{ pkgs , nodejs }:
2019-05-22 16:04:45 +00:00
#
# This expression builds the realm executable that is used for debugging the desktop app (used by ubuntu-server.js)
#
let nodePackages = import ./output { inherit pkgs nodejs ; } ;
2019-04-01 20:07:39 +00:00
realm-version = " 5 . 1 2 . 1 " ;
2019-05-22 16:04:45 +00:00
realm-patched-name = " r e a l m - h t t p s : / / g i t h u b . c o m / s t a t u s - i m / r e a l m - j s / a r c h i v e / v 2 . 2 0 . 1 . t a r . g z " ;
# We download ${realm-core-src} to ${realm-dest-dir} in order to avoid having realm try to download these files on its own (which is disallowed by Nix)
2019-04-01 20:07:39 +00:00
realm-core-src = pkgs . fetchurl (
if builtins . currentSystem == " x 8 6 _ 6 4 - d a r w i n " then {
url = " h t t p s : / / s t a t i c . r e a l m . i o / d o w n l o a d s / c o r e / r e a l m - c o r e - R e l e a s e - v ${ realm-version } - D a r w i n - d e v e l . t a r . g z " ;
sha256 = " 0 5 j i 1 z y s k w j j 8 p 5 i 0 1 k c g 7 h 1 c x d j j 6 2 f c s p 6 h a f 2 f 6 5 q s h p 6 r 4 4 d " ;
} else {
url = " h t t p s : / / s t a t i c . r e a l m . i o / d o w n l o a d s / c o r e / r e a l m - c o r e - R e l e a s e - v ${ realm-version } - L i n u x - d e v e l . t a r . g z " ;
sha256 = " 0 2 p v i 2 8 q n v z d v 7 g h q z f 7 9 b x n 8 i d 9 s 7 m p p 3 g 2 a m b x g 8 j r c r k q f v r 1 " ;
}
) ;
realm-dest-dir = if builtins . currentSystem == " x 8 6 _ 6 4 - d a r w i n " then
2019-05-22 16:04:45 +00:00
" $ o u t / l i b / n o d e _ m o d u l e s / r e a l m / c o m p i l e d / n o d e - v 6 4 _ d a r w i n _ x 6 4 / r e a l m . n o d e " else
" $ o u t / l i b / n o d e _ m o d u l e s / r e a l m / c o m p i l e d / n o d e - v 6 4 _ l i n u x _ x 6 4 / r e a l m . n o d e " ;
2019-04-01 20:07:39 +00:00
in nodePackages // {
2019-06-04 16:50:29 +00:00
" ${ realm-patched-name } " = nodePackages . " ${ realm-patched-name } " . override ( oldAttrs : {
2019-04-01 20:07:39 +00:00
reconstructLock = true ;
preRebuild = ''
# Do not attempt to do any http calls!
substituteInPlace $ out/lib/node_modules/realm/scripts/download-realm.js \
2019-05-22 16:04:45 +00:00
- - replace " ! s h o u l d S k i p A c q u i r e ( r e a l m D i r , r e q u i r e m e n t s , o p t i o n s . f o r c e ) " " f a l s e "
2019-04-01 20:07:39 +00:00
mkdir - p $ { realm-dest-dir }
tar - xzf $ { realm-core-src } - C $ { realm-dest-dir }
'' ;
} ) ;
}