Add templates to create starting point examples
Nix Flakes provide a template mechanism: https://peppe.rs/posts/novice_nix:_flake_templates/
we could define templates for basic examples to serve as starting points
nix flake new -t nxc#basic <folder_name>
nix flake new -t nxc#basic_nur <folder_name>
in the nxc root flake:
{
description = "nixos-compose";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
app = pkgs.poetry2nix.mkPoetryApplication {
projectDir = ./.;
propagatedBuildInputs = [ pkgs.openssh ];
};
packageName = "nixos-compose";
in {
templates = {
basic = {
path = ./examples/basic;
description = "basic nxc example";
};
basic_nur = {
path = ./examples/basic_nur;
description = "basic nxc example with a NUR";
};
};
packages.${packageName} = app;
defaultPackage = self.packages.${system}.${packageName};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ poetry ];
inputsFrom = builtins.attrValues self.packages.${system};
};
});
}
this template set looks like it could be easily be generated with Nix code and the path to the examples
folder