Skip to content

flowey: implement nix shell command wrapper#2825

Merged
justus-camp-microsoft merged 2 commits intomicrosoft:mainfrom
justus-camp-microsoft:nix_shell_command_wrapper
Feb 26, 2026
Merged

flowey: implement nix shell command wrapper#2825
justus-camp-microsoft merged 2 commits intomicrosoft:mainfrom
justus-camp-microsoft:nix_shell_command_wrapper

Conversation

@justus-camp-microsoft
Copy link
Contributor

@justus-camp-microsoft justus-camp-microsoft commented Feb 23, 2026

This PR enables wrapping commands per-job in flowey in order to wrap call commands in nix-shell --pure --run <cmd> in some future jobs. Example usage would be (in a pipeline definition):

job = job.set_command_wrapper(CommandWrapperKind::NixShell {
       path: Some("path/to/shell.nix".into()),
   });

Copilot AI review requested due to automatic review settings February 23, 2026 20:11
@justus-camp-microsoft justus-camp-microsoft requested a review from a team as a code owner February 23, 2026 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a command wrapper system for flowey that enables wrapping shell commands in nix-shell --pure --run <cmd>. The implementation introduces FloweyShell and FloweyCmd as thin wrappers around xshell that support transparent command transformation while preserving all command builder methods (args, env vars, stdin, flags).

Changes:

  • Adds new shell abstraction layer (flowey_core/src/shell.rs) with FloweyShell, FloweyCmd, and CommandWrapperKind
  • Updates pipeline infrastructure to support per-job command wrappers with serialization through pipeline.json
  • Modifies shell_cmd! macro to return FloweyCmd instead of xshell::Cmd
  • Demonstrates usage in build_igvm.rs pipeline by wrapping commands with nix-shell

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
flowey/flowey_core/src/shell.rs New shell abstraction module with FloweyShell/FloweyCmd wrappers and CommandWrapperKind enum; includes comprehensive test suite (16 tests)
flowey/flowey_core/src/pipeline.rs Adds command_wrapper field to JobData and set_command_wrapper() method to PipelineJob
flowey/flowey_core/src/node.rs Updates RustRuntimeServices to use FloweyShell instead of xshell::Shell; updates shell_cmd! macro to wrap commands
flowey/flowey_core/src/lib.rs Exports new shell module
flowey/flowey/src/lib.rs Re-exports shell module from flowey_core
flowey/flowey_cli/src/pipeline_resolver/generic.rs Adds command_wrapper to ResolvedPipelineJob structure
flowey/flowey_cli/src/pipeline_resolver/direct_run.rs Applies command wrapper to runtime services when executing jobs locally
flowey/flowey_cli/src/pipeline_resolver/ado_yaml.rs Stores command wrapper in pipeline static DB for ADO backend
flowey/flowey_cli/src/pipeline_resolver/github_yaml/mod.rs Stores command wrapper in pipeline static DB for GitHub backend
flowey/flowey_cli/src/cli/exec_snippet.rs Retrieves and applies command wrapper from pipeline static DB when executing snippets; adds job_command_wrappers field to FloweyPipelineStaticDb
flowey/flowey_cli/src/pipeline_resolver/viz.rs Ignores command_wrapper field in visualization destructuring patterns
flowey/flowey_hvlite/src/pipelines/build_igvm.rs Example usage: wraps build-igvm job commands with NixShell referencing shell.nix

Comment on lines +294 to +300
/// Wrap commands with `nix-shell --pure --run "..."`.
NixShell {
/// Optional path to a `shell.nix` file. If `None`, nix-shell
/// uses its default discovery (looking for `shell.nix` /
/// `default.nix` in the current directory).
path: Option<std::path::PathBuf>,
},
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NixShell wrapper uses --pure flag which clears the environment before running the command. This means that environment variables set via FloweyCmd.env() will not be visible to the command running inside nix-shell, which could be surprising to users. Consider documenting this limitation in the doc comment, or providing guidance on how to pass environment variables into nix-shell (e.g., via shell.nix configuration or --keep flag).

Copilot uses AI. Check for mistakes.
damanm24
damanm24 previously approved these changes Feb 24, 2026
Comment on lines +164 to +165
pub fn ignore_status(mut self) -> Self {
self.ignore_status = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need ignore_status and set_ignore_status? This came up because I was trying to review the usage of pub for all these methods to make sure they are actually required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me shadowing the builder methods on xshell::Cmd. I think we have some usages of this one specifically in the regen pipeline, but those don't use the FloweyShell so this is technically unused at the moment. I think it's unlikely for people to intuitively find underlying xshell methods that are missing from FloweyCmd to try to add them so imo it might be better to just go ahead and implement them all right off the bat (which is what I've done).

@github-actions
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@justus-camp-microsoft justus-camp-microsoft merged commit 5e39667 into microsoft:main Feb 26, 2026
60 checks passed
@justus-camp-microsoft justus-camp-microsoft deleted the nix_shell_command_wrapper branch February 26, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants