dream2nix/examples/packages
Paul Haerle 6a169a73bd
Python DevShells (for pip) (#951)
* fetchPipMetadata: set meta.mainProgram

* fetchPipMetadata: deduplicate test fixtures

* fetchPipMetadata: add is_direct to lock file

* devShell: proof of concept

* python-local-development: add editables example

* devshell: simplify editables interface

* buildPythonPackage: remove editable option again

* devshell: use findRoot for editables

* devshell: add support for .whl sources

* devshell: avoid polluting the shells environment

* devshell: make editable.nix flatter

because there's only 1 attr left now

* devshell: fix pyEnv by filtering editables

from the environment.

* devshell: skip existing editables

* devshell: remove patched pyEnv, rewrite sys.path

* devshell: add special case for root package

* python-local-development: improve editable example

* python-local-development: filter source

* devshell: reset site_dir on each load

* pip: don't ignoreCollisions in pyEnv

* pip: default to no sitecustomize.py...

and teach the devshell how to load it

* pip: rewrite editable in python

* editable: use shutil.copytree

* editable: refactor into functions

* editables: add suport for console_scripts

* improve pip editables interface

- change editables interface to use bool or path
- expose public.shellHook for composition
- use shellHook by default in public.devShell
- extend example to include a script

* improve edtiable support:

- remove dependency on root package build
- always set root package as editable by default
- compute dit-info dir by calling a packages build backend or extracting directly from the wheel
- only pass required sources to editables shell hook
- add build inputs of all editables to teh dev shell
- move editables state to .dream2nix/python to remove likelyhood of collision with other ecosystems state
- delete editables state if editables configuration changed

* refine python editable support:

- never copy dependency sources
- force user to specify a local path

---------

Co-authored-by: DavHau <hsngrmpf+github@gmail.com>
2024-05-17 01:00:09 +02:00
..
basics cleanup core options 2024-03-12 09:41:59 +00:00
languages Python DevShells (for pip) (#951) 2024-05-17 01:00:09 +02:00
README.md docs: fix template attr in examples readme 2024-03-12 07:33:46 +00:00

package examples

This directory contains examples for modules defining packages. All modules can be used as templates to create new packages.

Each package module is defined by a directory containing a default.nix.

How to use

All examples are self contained via their own flake.nix.

To use multiple packages in a repository, keep only each packages' default.nix and put them under a top-level flake.nix instead, as shown in the repo examples in /examples.

Usage example

For example, in order to initialize a php-package from packages/languages/php-packaging/:

# create new single package repo for php
$ mkdir my-dream2nix-package
$ cd my-dream2nix-package
$ nix flake init -t github:nix-community/dream2nix#templates.php-packaging
wrote: /tmp/my-dream2nix-package/flake.nix
wrote: /tmp/my-dream2nix-package/default.nix

# git add (in case git is used)
git add .

# interact with the package
$ nix flake show
[...]
$ nix build
[...]