forked from fediversity/fediversity
		
	allow adding extra Python packages
This commit is contained in:
		
							parent
							
								
									4db91bd0b7
								
							
						
					
					
						commit
						cba66d1b8b
					
				
					 4 changed files with 62 additions and 23 deletions
				
			
		|  | @ -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
									
								
							
							
						
						
									
										11
									
								
								panel/nix/overlay.nix
									
										
									
									
									
										Normal 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; }; | ||||
| } | ||||
|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										32
									
								
								panel/nix/python-packages/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								panel/nix/python-packages/default.nix
									
										
									
									
									
										Normal 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 | ||||
		Loading…
	
	Add table
		
		Reference in a new issue