nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

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

Open seanrmurphy opened this issue 1 year ago • 0 comments

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 avatar Feb 26 '24 14:02 seanrmurphy