Skip to content

Commit

Permalink
nix: Improve clarify of Microkit expressions
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jun 24, 2024
1 parent 92e782f commit d732058
Showing 1 changed file with 37 additions and 41 deletions.
78 changes: 37 additions & 41 deletions hacking/nix/scope/microkit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ let
'';
};

vendoredLockfile = vendorLockfile {
inherit rustToolchain;
lockfile = microkitSource + "/tool/microkit/Cargo.lock";
};

cargoConfigFile = toTOMLFile "config.toml" vendoredLockfile.configFragment;

sdk = stdenv.mkDerivation {
name = "microkit-sdk-without-tool";

Expand Down Expand Up @@ -90,43 +83,45 @@ let
'';
};

tool = stdenv.mkDerivation {
name = "microkit-sdk-just-tool";
tool =
let
vendoredLockfile = vendorLockfile {
inherit rustToolchain;
lockfile = microkitSource + "/tool/microkit/Cargo.lock";
};

src = lib.cleanSource (microkitSource + "/tool/microkit");
cargoConfigFile = toTOMLFile "config.toml" vendoredLockfile.configFragment;

nativeBuildInputs = [
rustToolchain
];
in
stdenv.mkDerivation {
name = "microkit-sdk-just-tool";

depsBuildBuild = [
buildPackages.stdenv.cc
];
src = lib.cleanSource (microkitSource + "/tool/microkit");

dontInstall = true;
dontFixup = true;
nativeBuildInputs = [
rustToolchain
];

configurePhase = ''
d=.cargo
mkdir $d
cp ${cargoConfigFile} $d/config.toml
'';
depsBuildBuild = [
buildPackages.stdenv.cc
];

buildPhase = ''
cargo build -Z unstable-options --frozen --out-dir $out/bin
'';
};
dontInstall = true;
dontFixup = true;

mkSystem = { searchPath, systemXML }:
lib.fix (self: runCommand "system" {
MICROKIT_SDK = sdk;
MICROKIT_BOARD = board;
MICROKIT_CONFIG = config;
configurePhase = ''
d=.cargo
mkdir $d
cp ${cargoConfigFile} $d/config.toml
'';

nativeBuildInputs = [
python3Packages.sel4-deps
];
buildPhase = ''
cargo build -Z unstable-options --frozen --config ${cargoConfigFile} --out-dir $out/bin
'';
};

mkSystem = { searchPath, systemXML }:
lib.fix (self: runCommand "system" {
passthru = rec {
inherit systemXML;
loader = "${self}/loader.img";
Expand All @@ -140,12 +135,13 @@ let
};
} ''
mkdir $out
${tool}/bin/microkit ${systemXML} \
--search-path ${searchPath} \
--board $MICROKIT_BOARD \
--config $MICROKIT_CONFIG \
-o $out/loader.img \
-r $out/report.txt
MICROKIT_SDK=${sdk} \
${tool}/bin/microkit ${systemXML} \
--search-path ${searchPath} \
--board ${board} \
--config ${config} \
-o $out/loader.img \
-r $out/report.txt
'');

in rec {
Expand Down

0 comments on commit d732058

Please sign in to comment.