From 97d56b031448f01f41c98920f667c1114507abb7 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 7 Jun 2024 07:23:35 +0000 Subject: [PATCH] flake: add a `pkgs.python` template --- flake.nix | 19 +++++++++++++------ templates/pkgs/python/default.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 templates/pkgs/python/default.nix diff --git a/flake.nix b/flake.nix index cad4eeaf..08f9ab3a 100644 --- a/flake.nix +++ b/flake.nix @@ -635,6 +635,19 @@ path = ./templates/env/python-data; description = "python environment for data processing"; }; + + pkgs.make = { + # initialize with: + # - `nix flake init -t '/home/colin/dev/nixos/#pkgs.make'` + path = ./templates/pkgs/make; + description = "default Makefile-based derivation"; + }; + pkgs.python = { + # initialize with: + # - `nix flake init -t '/home/colin/dev/nixos/#pkgs.python'` + path = ./templates/pkgs/python; + description = "python package"; + }; pkgs.rust-inline = { # initialize with: # - `nix flake init -t '/home/colin/dev/nixos/#pkgs.rust-inline'` @@ -647,12 +660,6 @@ path = ./templates/pkgs/rust; description = "rust package fit to ship in nixpkgs"; }; - pkgs.make = { - # initialize with: - # - `nix flake init -t '/home/colin/dev/nixos/#pkgs.make'` - path = ./templates/pkgs/make; - description = "default Makefile-based derivation"; - }; }; }; } diff --git a/templates/pkgs/python/default.nix b/templates/pkgs/python/default.nix new file mode 100644 index 00000000..8e02c3d2 --- /dev/null +++ b/templates/pkgs/python/default.nix @@ -0,0 +1,28 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +}: buildPythonPackage { + pname = "mypackage"; + version = "0.1-unstable-2024-06-04"; + format = "pyproject"; # or setuptools + + src = fetchFromGitHub { + owner = "owner"; + repo = "repo"; + rev = "${version}"; + }; + + propagatedBuildInputs = [ + # other python modules this depends on, if this package is supposed to be importable + ]; + + pythonImportsCheck = [ + "mymodule" + ]; + + meta = with lib; { + homepage = "https://example.com"; + description = "python template project"; + maintainers = with maintainers; [ colinsane ]; + }; +}