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

feat(qcow): add support for specifying contents in a qcow image via specialArgs #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seanrmurphy
Copy link

@seanrmurphy seanrmurphy commented Feb 26, 2024

I wanted to be able to inject files into a qcow image using the content parameter in the qcow builder; I just passed it in via specialArgs.

Not really sure if this is the best way to do it, but it worked for me.

Here is an example of how it can be called:

    let
      fs = nixpkgs.lib.fileset;
      sourceFiles = fs.unions [
        ./configuration.nix
        ./flake.nix
        ./README.md
      ];
    in ...
       qcow = nixos-generators.nixosGenerate {
         system = "x86_64-linux";
         modules = [ ./configuration.nix ];
         format = "qcow";
         specialArgs = {
           qcow.contents = [
             {
               source = fs.toSource {
                 root = ./.;
                 fileset = sourceFiles;
               };
               target = "/root/nixos-config";
               user = "root";
               group = "root";
               mode = "755";
             }
           ];
         };

@seanrmurphy seanrmurphy changed the title feat(qcow): add support for specifying contents in a qcow image via s… feat(qcow): add support for specifying contents in a qcow image via specialArgs Feb 26, 2024
}: {
}:
let
contents = specialArgs.qcow.contents or [];
Copy link
Member

Choose a reason for hiding this comment

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

@Lassulus why we do we now use specialArgs instead of defining cleaner nixos options?

Choose a reason for hiding this comment

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

I was thinking about this also when making pr for #387 Is there a better way of exposing parameters of the upstream imports?

Copy link
Member

@phaer phaer Oct 30, 2024

Choose a reason for hiding this comment

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

Missed this PR and comment before, but just answered in #387: The "parameters" to upstream imports are often just "module options" - you should be able to just set them in an argument to modules in nixosGenerate.

See #387 (comment) for an example of this.

In this PR though, content is not exposed as an option upstream but just a parameter to the function in make-disk-image.nix. So one would need to lib.mkOption a new one in formats/qcow.nix

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