Skip to content

Commit a4a24e5

Browse files
keep iterating on build
1 parent b7eade0 commit a4a24e5

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

flowey/flowey_lib_common/src/install_nix.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ flowey_request! {
1212
pub enum Request {
1313
/// Automatically install Nix package manager.
1414
///
15-
/// Only supported on Github backend.
15+
/// Supported on Github and ADO backends.
1616
AutoInstall(bool),
1717

1818
/// Ensure that Nix was installed and is available on the $PATH
@@ -26,10 +26,6 @@ impl FlowNode for Node {
2626
fn imports(_ctx: &mut ImportCtx<'_>) {}
2727

2828
fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
29-
if !matches!(ctx.backend(), FlowBackend::Github) {
30-
anyhow::bail!("only supported on the Github backend at this time");
31-
}
32-
3329
let mut ensure_installed = Vec::new();
3430
let mut auto_install = None;
3531

@@ -50,17 +46,38 @@ impl FlowNode for Node {
5046

5147
if !ensure_installed.is_empty() && auto_install {
5248
// Add nix profile bin to PATH first
53-
let added_to_path = ctx.emit_rust_step("add nix profile to path", |_| {
54-
|_| {
49+
let added_to_path = ctx.emit_rust_step("add nix profile to path", |ctx| {
50+
let backend = ctx.backend();
51+
move |_| {
5552
let nix_profile_bin = home::home_dir()
5653
.context("Unable to get home dir")?
5754
.join(".nix-profile")
5855
.join("bin");
59-
let github_path = std::env::var("GITHUB_PATH")?;
60-
let mut github_path = fs_err::File::options().append(true).open(github_path)?;
61-
github_path.write_all(nix_profile_bin.as_os_str().as_encoded_bytes())?;
62-
github_path.write_all(b"\n")?;
63-
log::info!("Added {} to PATH", nix_profile_bin.display());
56+
57+
match backend {
58+
FlowBackend::Github => {
59+
let github_path = std::env::var("GITHUB_PATH")?;
60+
let mut github_path =
61+
fs_err::File::options().append(true).open(github_path)?;
62+
github_path
63+
.write_all(nix_profile_bin.as_os_str().as_encoded_bytes())?;
64+
github_path.write_all(b"\n")?;
65+
log::info!("Added {} to PATH (Github)", nix_profile_bin.display());
66+
}
67+
FlowBackend::Ado => {
68+
// ADO uses logging commands to update PATH
69+
println!("##vso[task.prependpath]{}", nix_profile_bin.display());
70+
log::info!("Added {} to PATH (ADO)", nix_profile_bin.display());
71+
}
72+
FlowBackend::Local => {
73+
log::warn!("Cannot automatically add to PATH in local backend");
74+
log::warn!(
75+
"Please add {} to your PATH manually",
76+
nix_profile_bin.display()
77+
);
78+
}
79+
}
80+
6481
Ok(())
6582
}
6683
});

flowey/flowey_lib_common/src/nix_deps_provider.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ new_flow_node!(struct Node);
3232
impl FlowNode for Node {
3333
type Request = Request;
3434

35-
fn imports(_ctx: &mut ImportCtx<'_>) {}
35+
fn imports(ctx: &mut ImportCtx<'_>) {
36+
ctx.import::<crate::install_nix::Node>();
37+
}
3638

3739
fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
3840
let mut repo_path = None;
@@ -42,6 +44,8 @@ impl FlowNode for Node {
4244
let mut openhcl_kernel_requests = Vec::new();
4345
let mut uefi_mu_msvm_requests = Vec::new();
4446

47+
let nix_installed = ctx.reqv(crate::install_nix::Request::EnsureInstalled);
48+
4549
// Parse all requests and group by type
4650
for req in requests {
4751
match req {
@@ -69,6 +73,7 @@ impl FlowNode for Node {
6973
}
7074

7175
ctx.emit_rust_step("resolve nix dependency paths", |ctx| {
76+
nix_installed.claim(ctx);
7277
let repo_path = repo_path.claim(ctx);
7378
let openvmm_deps_requests = openvmm_deps_requests.claim(ctx);
7479
let protoc_requests = protoc_requests.claim(ctx);

flowey/flowey_lib_hvlite/src/build_openhcl_initrd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl FlowNode for Node {
117117

118118
ctx.emit_rust_step("building openhcl initrd", |ctx| {
119119
pydeps.clone().claim(ctx);
120+
let platform = ctx.platform();
120121
let interactive_dep = interactive_dep.claim(ctx);
121122
let rootfs_config = rootfs_config.claim(ctx);
122123
let extra_env = extra_env.claim(ctx);
@@ -132,7 +133,7 @@ impl FlowNode for Node {
132133
let openvmm_repo_path = rt.read(openvmm_repo_path);
133134
let kernel_package_root = rt.read(kernel_package_root);
134135

135-
let sh = xshell::Shell::new()?;
136+
let sh = FloweyShell::new(platform)?;
136137

137138
let initrd_path = sh.current_dir().join("openhcl.cpio.gz");
138139

openhcl_kernel.nix

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ in stdenv.mkDerivation {
4040

4141
installPhase = ''
4242
runHook preInstall
43-
mkdir $out
44-
cp vmlinux* $out
45-
mkdir -p $out/modules/build/native/bin/${arch}
46-
cp kernel_build_metadata.json $out/modules/build/native/bin/
47-
cp -r modules $out/modules/build/native/bin/${arch}
43+
mkdir -p $out/build/native/bin/${arch}
44+
cp vmlinux* $out/build/native/bin/${arch}/
45+
cp kernel_build_metadata.json $out/build/native/bin/
46+
cp -r modules $out/build/native/bin/${arch}/
4847
runHook postInstall
4948
'';
5049
}

shell.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ in pkgs.mkShell.override { } {
5050

5151
NIX_OPENVMM_DEPS = openvmm_deps;
5252
NIX_PROTOC_PATH = protoc;
53-
NIX_OPENHCL_KERNEL = "${openhcl_kernel}/vmlinux";
54-
NIX_OPENHCL_KERNEL_MODULES = "${openhcl_kernel}/modules";
53+
NIX_OPENHCL_KERNEL = openhcl_kernel;
5554
NIX_UEFI_MU_MSVM = "${uefi_mu_msvm}/MSVM.fd";
5655
RUST_BACKTRACE = 1;
5756
# will probably need more than one of these for local source + dependencies.

0 commit comments

Comments
 (0)