2022-11-20 00:29:07 -08:00
|
|
|
# The core functionality is provided here using flakes. Legacy support for
|
|
|
|
# `nix-shell` is provided by a wrapper in `shell.nix`.
|
|
|
|
|
|
|
|
# TODO Hacking around the Qt problems
|
|
|
|
# TODO PyPI package not in nixpkgs
|
|
|
|
{
|
|
|
|
description = "Python development environment";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs .url = "github:nixos/nixpkgs/nixos-22.05";
|
|
|
|
flake-utils .url = "github:numtide/flake-utils";
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils, ... }:
|
|
|
|
# Option 1: try to support each default system
|
|
|
|
flake-utils.lib.eachDefaultSystem # NB Some packages in nixpkgs are not supported on some systems
|
|
|
|
# Option 2: try to support selected systems
|
|
|
|
# flake-utils.lib.eachSystem ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin"]
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
# Any overlays you need can go here
|
|
|
|
overlays = [ ];
|
|
|
|
};
|
|
|
|
# ----- A Python interpreter with the packages that interest us -------
|
|
|
|
python-with-all-my-packages = (python:
|
2022-11-20 07:37:22 -08:00
|
|
|
(python.withPackages (ps: with ps; [
|
|
|
|
pytest
|
|
|
|
fastapi
|
|
|
|
uvicorn
|
|
|
|
sqlalchemy
|
|
|
|
psycopg2
|
2022-11-20 00:29:07 -08:00
|
|
|
])));
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
|
|
|
|
#devShell = self.devShells.${ system }.python310; # does not need `rec`
|
|
|
|
devShell = devShells.python310;
|
|
|
|
devShells =
|
|
|
|
builtins.listToAttrs (
|
|
|
|
builtins.map
|
|
|
|
(
|
|
|
|
pythonVersion: {
|
|
|
|
name = pythonVersion;
|
|
|
|
value = pkgs.mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
(python-with-all-my-packages pkgs.${ pythonVersion })
|
|
|
|
];
|
|
|
|
packages = [
|
|
|
|
pkgs.python3Packages.python-lsp-server
|
2022-11-20 07:37:22 -08:00
|
|
|
pkgs.postgresql
|
2022-11-20 00:29:07 -08:00
|
|
|
];
|
|
|
|
shellHook =
|
|
|
|
''
|
2022-11-20 07:37:22 -08:00
|
|
|
export PGDATA=$PWD/postgres_data
|
|
|
|
export PGHOST=$PWD/postgres
|
|
|
|
export LOG_PATH=$PWD/postgres/LOG
|
|
|
|
export PGDATABASE=dustforce
|
|
|
|
export DATABASE_URL="postgresql:///postgres?host=$PGHOST"
|
|
|
|
./start.sh
|
2022-11-20 00:29:07 -08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
2022-11-20 07:37:22 -08:00
|
|
|
) [ "python310" ]
|
2022-11-20 00:29:07 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|