-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
65 lines (55 loc) · 2.48 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
description = "API for Ethan";
inputs.nixpkgs.url = "github:nixos/nixpkgs/master";
inputs.nur.url = "github:nix-community/nur";
inputs.nur.inputs.nixpkgs.follows = "nixpkgs";
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
outputs =
{ nixpkgs, pyproject-nix, ... }:
let
# Loads pyproject.toml into a high-level project representation
# Do you notice how this is not tied to any `system` attribute or package sets?
# That is because `project` refers to a pure data representation.
project = pyproject-nix.lib.project.loadPyproject {
# Read & unmarshal pyproject.toml relative to this project root.
# projectRoot is also used to set `src` for renderers such as buildPythonPackage.
projectRoot = ./.;
};
# This example is only using aarch64-darwin
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
# We are using the default nixpkgs Python3 interpreter & package set.
#
# This means that you are purposefully ignoring:
# - Version bounds
# - Dependency sources (meaning local path dependencies won't resolve to the local path)
#
# To use packages from local sources see "Overriding Python packages" in the nixpkgs manual:
# https://nixos.org/manual/nixpkgs/stable/#reference
#
# Or use an overlay generator such as uv2nix:
# https://github.com/pyproject-nix/uv2nix
python = pkgs.python3;
in
{
# Create a development shell containing dependencies from `pyproject.toml`
devShells.aarch64-darwin.default =
let
# Returns a function that can be passed to `python.withPackages`
arg = project.renderers.withPackages { inherit python; };
# Returns a wrapped environment (virtualenv like) with all our packages
pythonEnv = python.withPackages arg;
in
# Create a devShell like normal.
pkgs.mkShell { packages = [ pythonEnv ]; };
# Build our package using `buildPythonPackage
packages.aarch64-darwin.default =
let
# Returns an attribute set that can be passed to `buildPythonPackage`.
attrs = project.renderers.buildPythonPackage { inherit python; };
in
# Pass attributes to buildPythonPackage.
# Here is a good spot to add on any missing or custom attributes.
python.pkgs.buildPythonPackage (attrs // { env.CUSTOM_ENVVAR = "hello"; });
};
}