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

Expose nixdeploy as nix function in flake for automatic builds

Open mkg20001 opened this issue 4 years ago • 2 comments

Basically being able to do something like this

outputs = { nixdeploy, nixpkgs }: 
  {
    defaultPackage = nixdeploy.format.lxc { configuration = ./configuration.nix; nixpkgs = nixpkgs; };
  }

mkg20001 avatar Apr 13 '21 18:04 mkg20001

I just want to +1 this concept. I'm not sure if it's already possible, but I'd love to be able to do something like this where I can just nix build .# and my outputs are VM images.

mayl avatar Nov 04 '21 17:11 mayl

So I'm somewhat out of my depth, but I added a nixosGenerate function to my fork which I'm testing here. It works basically like you suggest

outputs = { system, nixpkgs, nixosGenerate }: {
  lxcImage = nixosGenerate{ 
    inherit system pkgs;
    modules = [ ./configuration.nix ];
    format = "lxc";
  };
}

I can run commands like nix build .#lxcImage and result is populated with the image.

This seems to work for several of the formats I've tried, but again I feel a little out of my depth. I opened #119 for comment.

mayl avatar Nov 05 '21 01:11 mayl