A minimal example that parses a Nix derivation, instantiates it, builds it and mounts a Nix store with the output. See the corresponding post on my blog for the details.
Clone the repo and add the SNIX_BUILD_SANDBOX_SHELL to .cargo/config.toml:
[env]
SNIX_BUILD_SANDBOX_SHELL = "<path/to/a/static/sh>"And then use Cargo inside its devshell:
nix develop
cargo run -- <workdir/for/oci_builder> <mount/dir/for/store>`And you should see output like the following:
The out path of our derivation is: /nix/store/8xyaxfx92n684ijx4iqnc5ang05d139n-my-message
The derivation path is: /nix/store/zyyyxas4l14pagim19iwl478i455rr8q-my-message.drv
The derivation is: Derivation { arguments: ["-c", "echo 'Hello world' > $out"], builder: "/bin/sh", environment: {"builder": "/bin/sh", "name": "my-message", "out": "/nix/store/8xyaxfx92n684ijx4iqnc5ang05d139n-my-message", "system": "x86_64-linux"}, input_derivations: {}, input_sources: {}, outputs: {"out": Output { path: Some(StorePath { digest: [54, 141, 208, 10, 120, 86, 21, 102, 113, 36, 93, 70, 130, 140, 21, 169, 187, 174, 124, 71], name: "my-message" }), ca_hash: None }}, system: "x86_64-linux" }
Mounting the store to /home/pascal/tmp/mount/, CTRL-C to umount
If you have feedback or run into any problems, feel free to open an issue.