mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
Merge pull request #289 from FRidh/template
Provide flake template for building an app
This commit is contained in:
commit
35017baff2
3 changed files with 50 additions and 22 deletions
26
README.md
26
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
|
||||
|
|
12
flake.nix
12
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 {
|
||||
|
|
34
templates/app/flake.nix
Normal file
34
templates/app/flake.nix
Normal file
|
@ -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;
|
||||
}));
|
||||
}
|
Loading…
Add table
Reference in a new issue