df-web/flake.nix
2022-11-21 01:37:22 +10:00

73 lines
2.5 KiB
Nix

# 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:
(python.withPackages (ps: with ps; [
pytest
fastapi
uvicorn
sqlalchemy
psycopg2
])));
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
pkgs.postgresql
];
shellHook =
''
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
'';
};
}
) [ "python310" ]
);
}
);
}