mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 08:41:42 -05:00
Provide flake template for building an app
Provide a basic flake template for building a Python application.
This commit is contained in:
parent
f0dde911f6
commit
9c90be6a1d
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
|
## Using the flake
|
||||||
|
|
||||||
For the experimental flakes functionality we provide poetry2nix as a flake providing an overlay
|
For the experimental flakes functionality we provide _poetry2nix_ as a flake providing an overlay
|
||||||
to use with [nixpkgs](https://nixos.org/nixpkgs/manual).
|
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
|
```sh
|
||||||
|
nix flake --template github:nix-community/poetry2nix
|
||||||
```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.
|
|
||||||
});
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
12
flake.nix
12
flake.nix
|
@ -5,8 +5,18 @@
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
{
|
rec {
|
||||||
overlay = import ./overlay.nix;
|
overlay = import ./overlay.nix;
|
||||||
|
|
||||||
|
templates = {
|
||||||
|
app = {
|
||||||
|
path = ./templates/app;
|
||||||
|
description = "An example of a NixOS container";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultTemplate = templates.app;
|
||||||
|
|
||||||
} // (flake-utils.lib.eachDefaultSystem (system:
|
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
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