Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Initial decoupling of devour-flake interface #223

Merged
merged 4 commits into from
Aug 16, 2024
Merged

refactor: Initial decoupling of devour-flake interface #223

merged 4 commits into from
Aug 16, 2024

Conversation

srid
Copy link
Member

@srid srid commented Aug 16, 2024

Turns out that https://github.com/srid/devour-flake is just a specific example of a more general idea wherein we define a cross-language function: the function body defined in Nix (as derivation), with flake inputs being "arguments" to it, and the outPath of that derivation as the "return" of the function.

In devour-flake, the input arguments are "flake" (flake to be built) and "systems". We can represent this in Rust as:

pub struct DevourFlakeInput {
    /// The flake devour-flake will build
    pub flake: FlakeUrl,
    /// The systems it will build for. An empty list means all allowed systems.
    pub systems: FlakeUrl,
}

Likewise, the return of the function is a file containing all built paths, which in Rust is:

pub struct DevourFlakeOutput(pub HashSet<StorePath>);

This PR prepares the ground of creating this more generation mechanism, where the entirety of nixci's devour_flake.rs can be generalized so that it can be used for any such function (for example, #51). The result is also simpler to reason about code.

@srid srid marked this pull request as ready for review August 16, 2024 22:35
@srid srid merged commit 9d6c64d into main Aug 16, 2024
14 checks passed
@srid srid deleted the ci/ref branch August 16, 2024 22:35
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.

1 participant