diff --git a/README.md b/README.md index ce7b2a4..d5c1f5d 100644 --- a/README.md +++ b/README.md @@ -298,28 +298,12 @@ in pkgs.poetry2nix.mkPoetryApplication { ## Using the flake -For the experimental flakes functionality we provide poetry2nix as a flake providing an overlay -to use with [nixpkgs](https://nixos.org/nixpkgs/manual). +For the experimental flakes functionality we provide _poetry2nix_ as a flake providing an overlay +to use with [nixpkgs](https://nixos.org/nixpkgs/manual). Additionally, the flake provides +a flake template to quickly start using _poetry2nix_ in a project: -#### Example - -```nix -{ - description = "Your flake using poetry2nix"; - - inputs.nixpkgs.url = "github:NixOS/nixpkgs"; - inputs.utils.url = "github:numtide/flake-utils"; - inputs.poetry2nix-src.url = "github:nix-community/poetry2nix"; - - outputs = {nixpkgs, utils, poetry2nix-src, self}: utils.lib.eachDefaultSystem (system: let - - pkgs = import nixpkgs { inherit system; overlays = [ poetry2nix-src.overlay ]; }; - - in - { - # use pkgs.poetry2nix here. - }); - } +```sh +nix flake --template github:nix-community/poetry2nix ``` ## Contributing diff --git a/flake.nix b/flake.nix index 669def1..d2d1726 100644 --- a/flake.nix +++ b/flake.nix @@ -5,8 +5,18 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs"; outputs = { self, nixpkgs, flake-utils }: - { + rec { overlay = import ./overlay.nix; + + templates = { + app = { + path = ./templates/app; + description = "An example of a NixOS container"; + }; + }; + + defaultTemplate = templates.app; + } // (flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { diff --git a/templates/app/flake.nix b/templates/app/flake.nix new file mode 100644 index 0000000..e87172d --- /dev/null +++ b/templates/app/flake.nix @@ -0,0 +1,34 @@ +{ + description = "Application packaged using poetry2nix"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + inputs.poetry2nix.url = "github:nix-community/poetry2nix"; + + outputs = { self, nixpkgs, flake-utils, poetry2nix }: + { + # Nixpkgs overlay providing the application + overlay = nixpkgs.lib.composeManyExtensions [ + poetry2nix.overlay + (final: prev: { + # The application + myapp = prev.poetry2nix.mkPoetryApplication { + projectDir = ./.; + }; + }) + ]; + } // (flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }; + in + rec { + apps = { + myapp = pkgs.myapp; + }; + + defaultApp = apps.myapp; + })); +}