1
0
Fork 0

allow adding extra Python packages

This commit is contained in:
Valentin Gagarin 2025-03-04 11:10:43 +01:00
parent 4db91bd0b7
commit cba66d1b8b
4 changed files with 62 additions and 23 deletions

View file

@ -4,15 +4,11 @@
pkgs ? import sources.nixpkgs {
inherit system;
config = { };
overlays = [ ];
overlays = [ (import ./nix/overlay.nix) ];
},
}:
let
package =
let
callPackage = pkgs.lib.callPackageWith (pkgs // pkgs.python3.pkgs);
in
callPackage ./nix/package.nix { };
package = pkgs.callPackage ./nix/package.nix { };
pkgs' = pkgs.extend (_final: _prev: { panel = package; });

11
panel/nix/overlay.nix Normal file
View file

@ -0,0 +1,11 @@
/**
Nixpkgs overlay adding extra packages needed for the application
*/
_: prev:
let
extraPython3Packages = prev.callPackage ./python-packages { };
in
{
python3 = prev.lib.attrsets.recursiveUpdate prev.python3 { pkgs = extraPython3Packages; };
}

View file

@ -1,13 +1,7 @@
{
lib,
buildPythonPackage,
dj-database-url,
django-compressor,
django-debug-toolbar,
django-libsass,
django_4,
setuptools,
sqlite,
python3,
}:
let
src =
@ -31,7 +25,7 @@ let
include-package-data = true
'';
in
buildPythonPackage {
python3.pkgs.buildPythonPackage {
pname = name;
inherit (pyproject.project) version;
pyproject = true;
@ -42,15 +36,21 @@ buildPythonPackage {
cp ${builtins.toFile "source" pyproject-toml} pyproject.toml
'';
propagatedBuildInputs = [
dj-database-url
django-compressor
django-debug-toolbar
django-libsass
django_4
setuptools
sqlite
];
propagatedBuildInputs =
let
pythonPackages = with python3.pkgs; [
dj-database-url
django-compressor
django-debug-toolbar
django-libsass
django_4
setuptools
];
in
[
sqlite
]
++ pythonPackages;
postInstall = ''
mkdir -p $out/bin

View file

@ -0,0 +1,32 @@
/**
Collection of locally provided Python packages.
Add packages by creating a directory containing a `default.nix` file.
The directory name will be used for the attribute name in package set.
A package crecipe can use Python packages in its argument directly, e.g.
```nix
{ fetchFromGitHub, buildPythonPackage, django_4 }:
{
# ...
}
```
*/
{ pkgs }:
let
callPackage = pkgs.lib.callPackageWith (pkgs // pkgs.python3.pkgs // extraPython3Packages);
extraPython3Packages =
let
dir = toString ./.;
in
with builtins;
listToAttrs (
map (name: {
inherit name;
value = callPackage (dir + "/${name}") { };
}) (attrNames (readDir dir))
);
in
extraPython3Packages