Restructure flake.nix to use a nixpkgs overlay
parent
d1f2ea427e
commit
a0a31fa548
183
flake.nix
183
flake.nix
|
@ -13,77 +13,12 @@
|
|||
|
||||
outputs = { self, genode-depot, nixpkgs, nixpkgsUpstream }:
|
||||
let
|
||||
mkOutput = { system, localSystem, crossSystem }:
|
||||
let thisSystem = builtins.getAttr system;
|
||||
in rec {
|
||||
|
||||
lib = (nixpkgs.lib) // (import ./lib {
|
||||
inherit system localSystem crossSystem;
|
||||
inherit apps nixpkgs genode-depot;
|
||||
genodepkgs = self;
|
||||
});
|
||||
|
||||
legacyPackages = thisSystem nixpkgs.legacyPackages;
|
||||
# pass thru Nixpkgs
|
||||
|
||||
packages = import ./packages {
|
||||
inherit system legacyPackages apps;
|
||||
localPackages = nixpkgsUpstream.legacyPackages.${localSystem};
|
||||
depot = thisSystem genode-depot.packages;
|
||||
};
|
||||
|
||||
devShell = let
|
||||
pkgs = nixpkgsUpstream.legacyPackages.x86_64-linux;
|
||||
fhs = pkgs.buildFHSUserEnv {
|
||||
name = "genode-env";
|
||||
targetPkgs = pkgs:
|
||||
(with pkgs; [
|
||||
binutils
|
||||
bison
|
||||
expect
|
||||
flex
|
||||
git
|
||||
glibc.dev
|
||||
gnumake
|
||||
libxml2
|
||||
qemu
|
||||
tcl
|
||||
which
|
||||
xorriso
|
||||
]);
|
||||
runScript = "bash";
|
||||
extraBuildCommands = let
|
||||
toolchain = pkgs.fetchzip {
|
||||
url = "file:///" + packages.genodeSources.toolchain.src;
|
||||
hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o=";
|
||||
};
|
||||
in "ln -s ${toolchain}/local usr/local";
|
||||
};
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
name = "genode-fhs-shell";
|
||||
nativeBuildInputs = [ fhs ];
|
||||
shellHook = "exec genode-env";
|
||||
};
|
||||
|
||||
apps = import ./apps {
|
||||
self = self.apps.${localSystem};
|
||||
nixpkgs = legacyPackages;
|
||||
nixpkgsLocal = nixpkgsUpstream.legacyPackages.${localSystem};
|
||||
inherit packages;
|
||||
};
|
||||
|
||||
checks = import ./tests {
|
||||
inherit system localSystem crossSystem;
|
||||
inherit self nixpkgs genode-depot;
|
||||
inherit apps lib;
|
||||
genodepkgs = thisSystem self.packages;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
localSystems = [ "x86_64-linux" ];
|
||||
crossSystems = [ "x86_64-genode" ];
|
||||
|
||||
forAllLocalSystems = f:
|
||||
nixpkgs.lib.genAttrs localSystems (system: f system);
|
||||
|
||||
forAllCrossSystems = f:
|
||||
with builtins;
|
||||
let
|
||||
|
@ -97,26 +32,102 @@
|
|||
attrSet = listToAttrs list;
|
||||
in attrSet;
|
||||
|
||||
finalize = outputs:
|
||||
with builtins;
|
||||
forAllSystems = f:
|
||||
(forAllCrossSystems f) // (forAllLocalSystems (system:
|
||||
f {
|
||||
inherit system;
|
||||
localSystem = system;
|
||||
crossSystem = system;
|
||||
}));
|
||||
|
||||
nixpkgsFor = forAllSystems ({ system, localSystem, crossSystem }:
|
||||
if localSystem == crossSystem then
|
||||
import nixpkgsUpstream {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
}
|
||||
else
|
||||
import nixpkgs {
|
||||
inherit localSystem crossSystem;
|
||||
config.allowUnsupportedSystem = true;
|
||||
overlays = [ self.overlay ];
|
||||
});
|
||||
|
||||
in rec {
|
||||
|
||||
overlay = import ./overlay;
|
||||
|
||||
lib = forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
(nixpkgs.lib) // (import ./lib {
|
||||
inherit system localSystem crossSystem;
|
||||
apps = self.apps.${system};
|
||||
nixpkgs = nixpkgsFor.${system};
|
||||
genode-depot = genode-depot.packages.${system};
|
||||
genodepkgs = self;
|
||||
}));
|
||||
|
||||
legacyPackages = forAllSystems
|
||||
({ system, localSystem, crossSystem }: nixpkgsFor.${system});
|
||||
# pass thru Nixpkgs
|
||||
|
||||
packages = forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
import ./packages {
|
||||
inherit system;
|
||||
legacyPackages = self.legacyPackages.${system};
|
||||
apps = self.apps.${system};
|
||||
localPackages = nixpkgsUpstream.legacyPackages.${localSystem};
|
||||
depot = genode-depot.packages.${system};
|
||||
});
|
||||
|
||||
devShell = forAllLocalSystems (system:
|
||||
let
|
||||
outputs' = outputs // {
|
||||
x86_64-linux = getAttr "x86_64-linux-x86_64-genode" outputs;
|
||||
pkgs = nixpkgsFor.${system};
|
||||
fhs = pkgs.buildFHSUserEnv {
|
||||
name = "genode-env";
|
||||
targetPkgs = pkgs:
|
||||
(with pkgs; [
|
||||
binutils
|
||||
bison
|
||||
expect
|
||||
flex
|
||||
git
|
||||
glibc.dev
|
||||
gnumake
|
||||
libxml2
|
||||
qemu
|
||||
tcl
|
||||
which
|
||||
xorriso
|
||||
]);
|
||||
runScript = "bash";
|
||||
extraBuildCommands = let
|
||||
toolchain = pkgs.fetchzip {
|
||||
url = "file://${packages.x86_64-linux-x86_64-genode.genodeSources.toolchain.src}";
|
||||
hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o=";
|
||||
};
|
||||
in "ln -s ${toolchain}/local usr/local";
|
||||
};
|
||||
systems = attrNames outputs';
|
||||
outputAttrs = attrNames (head (attrValues outputs'));
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
name = "genode-fhs-shell";
|
||||
nativeBuildInputs = [ fhs ];
|
||||
shellHook = "exec genode-env";
|
||||
});
|
||||
|
||||
list = map (attr: {
|
||||
name = attr;
|
||||
value = listToAttrs (map (system: {
|
||||
name = system;
|
||||
value = getAttr attr (getAttr system outputs');
|
||||
}) systems);
|
||||
}) outputAttrs;
|
||||
apps = forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
import ./apps {
|
||||
self = self.apps.${system};
|
||||
nixpkgs = self.legacyPackages.${system};
|
||||
nixpkgsLocal = nixpkgsFor.${localSystem};
|
||||
packages = self.packages.${system};
|
||||
});
|
||||
|
||||
in listToAttrs list;
|
||||
|
||||
final = finalize (forAllCrossSystems mkOutput);
|
||||
|
||||
in final;
|
||||
checks = forAllCrossSystems ({ system, localSystem, crossSystem }:
|
||||
import ./tests {
|
||||
inherit system localSystem crossSystem;
|
||||
inherit self nixpkgs genode-depot;
|
||||
apps = self.apps.${system};
|
||||
lib = self.lib.${system};
|
||||
genodepkgs = self.packages.${system};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ in {
|
|||
'';
|
||||
|
||||
mergeManifests = inputs:
|
||||
nixpkgs.legacyPackages.${localSystem}.writeTextFile {
|
||||
nixpkgs.writeTextFile {
|
||||
name = "manifest.dhall";
|
||||
text = with builtins;
|
||||
let
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
|
||||
}
|
|
@ -33,9 +33,11 @@ let
|
|||
"echo REPOSITORIES += ${genodeWorld} >> build/etc/build.conf";
|
||||
});
|
||||
|
||||
genodeTupRules = ./Tuprules.tup;
|
||||
|
||||
in rec {
|
||||
inherit (legacyPackages) stdenv;
|
||||
inherit (genodeLabs) genodeSources;
|
||||
inherit (genodeLabs) genodeSources; # toolchain;
|
||||
|
||||
base-hw-pc = buildUpstream {
|
||||
name = "base-hw-pc";
|
||||
|
@ -111,5 +113,4 @@ in rec {
|
|||
sotest-producer = callPackage' ./sotest-producer { };
|
||||
|
||||
stdcxx = callPackage' ./stdcxx { };
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ let
|
|||
testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})";
|
||||
testEnv' = {
|
||||
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
|
||||
MANIFEST = manifest;
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
} // testEnv;
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ let
|
|||
testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})";
|
||||
env' = {
|
||||
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
|
||||
MANIFEST = manifest;
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
} // env;
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ let
|
|||
testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})";
|
||||
testEnv' = {
|
||||
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
|
||||
MANIFEST = manifest;
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
} // testEnv;
|
||||
|
||||
|
|
Loading…
Reference in New Issue