nixos-generators
nixos-generators copied to clipboard
Add `--files` flag for copying files
Closes #60?
Allows copying of files into build artifacts that support it.
I am not sure that this is the best implementation, but it is fairly straightforward and worked for the couple of formats I tested out with a NixOS flake. Sometimes it is necessary to use --option sandbox false to copy files, but that's to be expected.
There's many different ways build artifacts get made, so documenting each type seems difficult. I am open to suggestions on how we could improve this.
Example command:
nixos-generate \
-f iso \
--flake './#mysystem' \
--files '[{ "source": "'$(realpath ./README.md)'", "target": "/README.md" }]' \
--option sandbox false
hmm, I'm not a big fan of this interface, seems rather clunky and since it only supports some images I think a more general approach would be nicer. maybe something like --arg readme ./README.md. People then could add { readme, } to their arguments and add it to the contents. problem is, not all formats have something like: isoImage.contents = files;, But that should be added in nixpkgs for the different formats then IMHO
I am not sure if this is possible nor do I know if this is a good idea, but we could make a new option in the nixos-generate.nix for each of the formats to use that specifies whether they accept files to be copied. That way the CLI could either list out all formats that support copying files or throw if files are given to a format that doesn't accept them.