Skip to content

Commit 77ef3d8

Browse files
authored
Use poetry2nix to configure Nix Flake (#99)
It means no special configuration is needed for dependencies that are not packaged in nixpkgs, and installation becomes faster because wheels are used which require less dependencies to be installed.
1 parent 45e9edd commit 77ef3d8

2 files changed

Lines changed: 100 additions & 84 deletions

File tree

flake.lock

Lines changed: 77 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 23 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,45 @@
11
{
2-
inputs = {
3-
pyproject-nix.url = "github:nix-community/pyproject.nix";
4-
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
2+
description = "CLI for remote controlling LG webOS TVs";
53

4+
inputs = {
65
flake-utils.url = "github:numtide/flake-utils";
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
poetry2nix = {
8+
url = "github:nix-community/poetry2nix";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
inputs.flake-utils.follows = "flake-utils";
11+
};
712
};
813

914
outputs =
1015
{
16+
self,
1117
nixpkgs,
12-
pyproject-nix,
1318
flake-utils,
14-
...
19+
poetry2nix,
1520
}:
1621
flake-utils.lib.eachDefaultSystem (
1722
system:
1823
let
19-
inherit (nixpkgs) lib;
20-
project = pyproject-nix.lib.project.loadPoetryPyproject { projectRoot = ./.; };
21-
22-
overlay = _: prev: {
23-
python3 = prev.python3.override {
24-
packageOverrides = _: p: {
25-
cfgs = p.buildPythonPackage rec {
26-
version = "0.13.0";
27-
pname = "cfgs";
28-
format = "pyproject";
29-
nativeBuildInputs = with p.pythonPackages; [ poetry-core ];
30-
src = p.fetchPypi {
31-
inherit version pname;
32-
hash = "sha256-zvR+Z/BRJ4Pug+JMwvOeWyO11MoMMrvXIb1k9IY2Zn4=";
33-
};
34-
};
35-
pzp = p.buildPythonPackage rec {
36-
version = "0.0.25";
37-
pname = "pzp";
38-
format = "pyproject";
39-
nativeBuildInputs = with p.pythonPackages; [
40-
poetry-core
41-
setuptools
42-
];
43-
src = p.fetchPypi {
44-
inherit version pname;
45-
hash = "sha256-29OhVEM9By+SQ6Cb+SF/f3157FBDttCxDHHV8kpcx2Y=";
46-
};
47-
};
48-
typer = p.buildPythonPackage rec {
49-
version = "0.15.1";
50-
pname = "typer";
51-
format = "pyproject";
52-
nativeBuildInputs = with p.pythonPackages; [
53-
poetry-core
54-
pdm-backend
55-
];
56-
propagatedBuildInputs = with p.pythonPackages; [
57-
click
58-
shellingham
59-
rich
60-
typing-extensions
61-
];
62-
src = p.fetchPypi {
63-
inherit version pname;
64-
hash = "sha256-oFiMCn+mihl4oGmBhld3j4ar5v9epqv0cvlAoIv+Two=";
65-
};
66-
};
67-
68-
};
24+
alga =
25+
{ poetry2nix, lib }:
26+
poetry2nix.mkPoetryApplication {
27+
projectDir = self;
28+
preferWheels = true;
6929
};
70-
};
71-
7230
pkgs = import nixpkgs {
7331
inherit system;
74-
overlays = [ overlay ];
32+
overlays = [
33+
poetry2nix.overlays.default
34+
(final: _: {
35+
alga = final.callPackage alga { };
36+
})
37+
];
7538
};
76-
python = pkgs.python3;
7739
in
7840
{
79-
devShells.default =
80-
let
81-
arg = project.renderers.withPackages { inherit python; };
82-
pythonEnv = python.withPackages arg;
83-
in
84-
pkgs.mkShell { packages = [ pythonEnv ]; };
85-
86-
packages.default =
87-
let
88-
attrs = project.renderers.buildPythonPackage { inherit python; };
89-
in
90-
python.pkgs.buildPythonPackage attrs;
41+
packages.default = pkgs.alga;
42+
legacyPackages = pkgs;
9143
}
9244
);
9345
}

0 commit comments

Comments
 (0)