@ -1,10 +1,37 @@
{ nixpkgs }:
{ nixpkgs , addManifest }:
let
inherit ( nixpkgs . genodeHeaders ) version src ;
genodeSources = let
inherit ( nixpkgs ) stdenv ;
platform = stdenv . targetPlatform ;
arch = with platform ;
if isx86_64 then
" x 8 6 _ 6 4 "
else
throw " u n k n o w n G e n o d e a r c h f o r p l a t f o r m ${ platform . system } " ;
toolPrefix = if platform . isx86 then
" g e n o d e - x 8 6 - "
else
throw " u n k n o w n t o o l p r e f i x f o r G e n o d e a r c h ${ arch } " ;
in stdenv . mkDerivation {
pname = " g e n o d e - s o u r c e s " ;
inherit ( nixpkgs . genodeHeaders ) src version ;
nativeBuildInputs = with nixpkgs . buildPackages ; [ expect gnumake tcl ] ;
patches = [ ./init.xsd.patch ./svn-trust-server-cert.patch ] ;
configurePhase = ''
patchShebangs ./tool
substituteInPlace repos/base/etc/tools.conf \
- - replace " / u s r / l o c a l / g e n o d e / t o o l / 1 9 . 0 5 / b i n / " " "
substituteInPlace tool/check_abi \
- - replace " e x e c n m " " e x e c ${ toolPrefix } n m "
'' ;
dontBuild = true ;
installPhase = " c p - a . $ o u t " ;
} ;
sourceForgeToolchain =
nixpkgs . buildPackages . callPackage ./toolchain.nix { } ;
sourceForgeToolchain = nixpkgs . buildPackages . callPackage ./toolchain.nix { } ;
stdenv' =
nixpkgs . stdenvAdapters . overrideCC nixpkgs . stdenv sourceForgeToolchain ;
@ -17,192 +44,114 @@ let
else
throw " u n k n o w n G e n o d e a r c h f o r p l a t f o r m ${ platform . system } " ;
toolPrefix = if platform . isx86 then
" g e n o d e - x 8 6 - "
else
throw " u n k n o w n t o o l p r e f i x f o r G e n o d e a r c h ${ arch } " ;
preparePort = name :
{ hash ? " s h a 2 5 6 - A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A = " , . . . } @ args :
nixpkgs . buildPackages . stdenv . mkDerivation ( args // {
outputHashMode = " r e c u r s i v e " ;
outputHash = hash ;
pname = name ;
inherit ( genodeSources ) version ;
GIT_SSL_CAINFO =
" ${ nixpkgs . buildPackages . cacert } / e t c / s s l / c e r t s / c a - b u n d l e . c r t " ;
VERBOSE = " " ;
# need to build in verbose mode because errors are hidden
impureEnvVars = stdenv' . lib . fetchers . proxyImpureEnvVars
++ [ " G I T _ P R O X Y _ C O M M A N D " " S O C K S _ S E R V E R " ] ;
dontUnpack = true ;
dontConfigure = true ;
nativeBuildInputs = with nixpkgs . buildPackages ;
[ bison flex gitMinimal glibc glibcLocales rsync wget which ]
++ ( args . nativeBuildInputs or [ ] ) ;
buildPhase = ''
runHook preBuild
export CONTRIB_DIR = $ NIX_BUILD_TOP/contrib
mkdir $ CONTRIB_DIR
$ { genodeSources } /tool/ports/prepare_port $ pname
runHook postBuild
'' ;
installPhase = ''
runHook preInstall
rsync $ CONTRIB_DIR /* $ o u t / \
- lr - - copy-unsafe-links \
- - exclude ' * . git' \
- - exclude ' * . svn' \
- - exclude ' * . gz' \
- - exclude ' * . xz' \
runHook postInstall
'' ;
} ) ;
ports =
nixpkgs . lib . mapAttrs preparePort ( import ./ports.nix nixpkgs . buildPackages ) ;
buildUpstream = { name , targets , portInputs ? [ ] , nativeBuildInputs ? [ ]
, . . . } @ extraAttrs :
mkPort = { name , hash , nativeBuildInputs ? [ ] }:
let
value = stdenv' . mkDerivation {
dr v = stdenv' . mkDerivation ( extraAttrs // {
pname = name ;
inherit src version ;
inherit ( genodeSources ) version ;
inherit targets ;
outputHashMode = " r e c u r s i v e " ;
outputHash = hash ;
dontUnpack = true ;
nativeBuildInputs = with nixpkgs . buildPackages ;
[ bison glibc flex gitMinimal subversion glibcLocales which wget ]
++ nativeBuildInputs ;
[ binutils bison flex stdenv . cc tcl which ] ++ nativeBuildInputs ;
patches = [ ./svn-trust-server-cert.patch ] ;
enableParallelBuilding = true ;
configurePhase = ''
configurePhase = let
linkPorts = toString
( builtins . map ( drv : " l n - s v ${ drv } / * c o n t r i b / ; " ) portInputs ) ;
in ''
runHook preConfigure
patchShebangs ./tool/ports
export CONTRIB_DIR = $ NIX_BUILD_TOP/contrib
export BUILD_DIR = $ NIX_BUILD_TOP/build
$ { genodeSources } /tool/create_builddir $ { arch }
substituteInPlace build/etc/build.conf \
- - replace " # R E P O S I T O R I E S " " R E P O S I T O R I E S "
mkdir $ CONTRIB_DIR ; $ { linkPorts }
runHook postConfigure
'' ;
buildPhase = ''
export CONTRIB_DIR = $ out
./tool/ports/prepare_port $ pname
makeFlags = [ " - C b u i l d " ] ++ targets ;
installPhase = ''
runHook preInstall
find build/bin - name ' * . xsd' - delete
find build/bin - follow - type f - exec install - Dt $ out ' { } ' \ ;
runHook postInstall
'' ;
} ) ;
in addManifest drv ;
buildOverrides = import ./targets.nix {
inherit ( nixpkgs ) buildPackages ;
inherit ports ;
} ;
dontInstall = true ;
GIT_SSL_CAINFO =
" ${ nixpkgs . buildPackages . cacert } / e t c / s s l / c e r t s / c a - b u n d l e . c r t " ;
impureEnvVars = stdenv' . lib . fetchers . proxyImpureEnvVars
++ [ " G I T _ P R O X Y _ C O M M A N D " " S O C K S _ S E R V E R " ] ;
} ;
in { inherit name value ; } ;
portDrvs = with nixpkgs . buildPackages ; builtins . listToAttrs ( builtins . map mkPort [
{
name = " s t b " ;
hash = " s h a 2 5 6 - R Q K F / H 3 w s K y 6 Z T 9 P L v 4 v z e r J l + 0 B e 2 w q N j q s U B Y Z U 6 U = " ;
}
{
name = " l i b c " ;
hash = " s h a 2 5 6 - y x 5 j G J I 1 w 6 K A w S 2 J P H h W p P F E e E y O v 7 y f I e X L R g Q M 7 l 8 = " ;
}
{
name = " x 8 6 e m u " ;
hash = " s h a 2 5 6 - f K U a b / H f l r c Z q z S k / c z / Q i m P t P I L G w v X g H k w E 4 y 2 u Q c = " ;
}
{
name = " l w i p " ;
hash = " s h a 2 5 6 - 1 o O J o C M E 8 N 1 n Q K U x G 7 v R B F R t J 9 M a u s r I f n o 9 1 Q c h M E U = " ;
}
{
name = " d d e _ l i n u x " ;
hash = " s h a 2 5 6 - 9 x D + p I j Y e L 9 W / 2 H s O p J C G J s 5 + R g M 2 g m w x X C + h 1 Y c 9 0 Y = " ;
}
{
name = " d d e _ b s d " ;
hash = " s h a 2 5 6 - Z c F 6 L 4 m a C 1 v B 5 I P 1 j R 6 L 4 C W l a N f 5 Q u 4 x V j q I T K 3 Y t 0 w = " ;
}
{
name = " d d e _ r u m p " ;
hash = " s h a 2 5 6 - a U 5 s + s f 9 / b Z x z S X 7 + 9 w N E n 3 6 9 3 y x D J B / d N V W M L u J k Q I = " ;
}
{
name = " d d e _ i p x e " ;
hash = " s h a 2 5 6 - U I w C 0 O 5 I l x N W Q K B J Y E 9 h 5 e k V W P 1 8 U T v e j s g b 1 i 6 K H C s = " ;
}
{
name = " o p e n s s l " ;
hash = " s h a 2 5 6 - e Z Y d D T 4 L 3 R 6 4 m h U K G A i i Q U O F 9 G g e E H D Z l s D Z b I 4 B M 5 8 = " ;
}
{
name = " l i b i c o n v " ;
hash = " s h a 2 5 6 - T N 3 c Z A o 7 z q 7 O L X X B 2 l L x O n M 5 c 9 8 a A 0 G k s E 7 A C r y m V v E = " ;
}
{
name = " q e m u - u s b " ;
hash = " s h a 2 5 6 - a w B o u S z 5 M B B c 9 H u H Z i Z J K 7 j b a b N S y q B Q M X 2 N P X H v R 0 I = " ;
}
{
name = " s t d c x x " ;
hash = " s h a 2 5 6 - h X R d T 6 f 2 p r K s C X D S J 4 H M F 1 M N a R h 0 / E o N M r J U B u H Q e y I = " ;
}
{
name = " v i r t u a l b o x 5 " ;
hash = " s h a 2 5 6 - V Z P X y F L z L F C m x b b B q m Z 9 H P 0 y 6 E + 1 I + v / + R t 2 2 I j l O r I = " ;
nativeBuildInputs = [
iasl
libxslt
unzip
yasm
] ;
}
{
name = " e x p a t " ;
hash = " s h a 2 5 6 - C C M x M n 2 D p z r I k W 9 W M B a X 1 T 7 7 T / G E C y 8 p V l s T + B p b s Q s = " ;
}
{
name = " j p e g " ;
hash = " s h a 2 5 6 - Z U M u N V 9 l t G q Z h n y 6 L A n / D o 1 o j b y p n S H a 9 d f Q 0 Z V Z h U E = " ;
}
{
name = " l z 4 " ;
hash = " s h a 2 5 6 - x Y o h P u O w q i F B H k q w P / q 0 f M a f m W z M g 4 r t 3 q Y Z q O 6 2 4 w k = " ;
}
{
name = " m e s a " ;
hash = " s h a 2 5 6 - h o 8 t + 7 j F z Y P i 8 n m H i 4 u s F N u n w H s b S B d t v V O t A l b z 9 O c = " ;
nativeBuildInputs = [ python ] ;
}
{
name = " m u p d f " ;
hash = " s h a 2 5 6 - 7 z l 2 D K F I P z Q d X / p o F 0 j x e j n 8 1 O C W r h 7 Q f T u N m t O A 4 W A = " ;
}
{
name = " j i t t e r e n t r o p y " ;
hash = " s h a 2 5 6 - F n L u T D O C y Q 9 / j p Q f x 0 v t y r b U y m W 7 G 3 B u S M + N I N K O x K 4 = " ;
}
{
name = " l i b p n g " ;
hash = " s h a 2 5 6 - Y 3 D j I 7 m 1 k Y G b H X 8 h R o b 3 R Y n T T T X 4 L t e O t 5 Y q z l c q / t Q = " ;
}
{
name = " l i b s s h " ;
hash = " s h a 2 5 6 - I j H v + c b v A U 7 R V c K J S v H J m G 8 Z D U L p E A a w r 7 s n P z W d M s U = " ;
}
{
name = " z l i b " ;
hash = " s h a 2 5 6 - g W v 8 R K l c 3 T a c C 4 s H P K X y h q V D R k M 6 M I X u W L q E x 5 g H z 7 s = " ;
}
] ) ;
in { name , targets , ports ? [ ] , nativeBuildInputs ? [ ] , . . . } @ extraAttrs :
let ports' = builtins . map ( name : builtins . getAttr name portDrvs ) ports ;
in stdenv' . mkDerivation ( extraAttrs // {
pname = name ;
inherit version targets ;
src = nixpkgs . fetchFromGitHub {
owner = " g e n o d e l a b s " ;
repo = " g e n o d e " ;
rev = version ;
sha256 = " 0 i d k 9 2 i b r a s l a 0 y 2 x k r m y h 4 9 d x 0 n z g 9 6 g q k c m n 6 r 3 w 5 r 3 f d p s f j y " ;
in {
inherit buildUpstream ;
genodeSources = genodeSources // {
make = target :
with builtins ;
let
attrs = if hasAttr target buildOverrides then
getAttr target buildOverrides
else
{ } ;
in buildUpstream ( {
name = builtins . replaceStrings [ " / " ] [ " - " ] target ;
targets = [ target ] ;
} // attrs ) ;
inherit ports ;
} ;
nativeBuildInputs = with nixpkgs . buildPackages ;
[ binutils bison flex stdenv . cc tcl which ] ++ nativeBuildInputs ;
enableParallelBuilding = true ;
configurePhase = ''
runHook preConfigure
patchShebangs ./tool/check_abi
patchShebangs ./tool/create_builddir
substituteInPlace repos/base/etc/tools.conf \
- - replace " / u s r / l o c a l / g e n o d e / t o o l / 1 9 . 0 5 / b i n / " " "
substituteInPlace tool/check_abi \
- - replace " e x e c n m " " e x e c ${ toolPrefix } n m "
./tool/create_builddir $ { arch } BUILD_DIR = build
substituteInPlace build/etc/build.conf \
- - replace " # R E P O S I T O R I E S " " R E P O S I T O R I E S "
runHook postConfigure
'' + ( i f p o r t s ! = [ ] t h e n
" m k d i r c o n t r i b ; "
+ toString ( builtins . map ( drv : " l n - s v ${ drv } / * c o n t r i b / ; " ) ports' )
else
" " ) ;
makeFlags = [ " - C b u i l d " ] ++ targets ;
installPhase = ''
runHook preInstall
find build/bin - name ' * . xsd' - delete
find build/bin - name ' * . lib . so' - exec install - Dt $ out/lib ' { } ' \ ; - delete
find build/bin - exec install - Dt $ out/bin ' { } ' \ ;
runHook postInstall
'' ;
passthru . ports = portDrvs ;
} )
}