Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ dist/
__pycache__/
.tox
test-results/

# Nix
result
46 changes: 46 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
description = "django-labs-accounts for Penn Labs";

inputs = {
pyproject-nix = {
url = "github:pyproject-nix/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.loadPoetryPyproject {
# 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 x86_64-linux
pkgs = nixpkgs.legacyPackages.x86_64-linux;

# 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.python312.override {
packageOverrides = self: prev: {
django = prev.django_5;
};
};
in
{
# Create a development shell containing dependencies from `pyproject.toml`
devShells.x86_64-linux.default =
let
# Returns a function that can be passed to `python.withPackages`
arg = project.renderers.withPackages { inherit python; extraPackages = (ps: [ ps.pytest ]); };

# Returns a wrapped environment (virtualenv like) with all our packages
pythonEnv = python.withPackages arg;

in
# Create a devShell like normal.
pkgs.mkShell { packages = [ pythonEnv pkgs.poetry ]; };

# Build our package using `buildPythonPackage
packages.x86_64-linux.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;
};
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.11"
Django = "^5.0.2"
requests-oauthlib = "^1.3.1"
requests-oauthlib = "^2.0.0"
requests = "^2.0.0"
djangorestframework = "^3.14.0"
six = "^1.16.0"
Expand Down