Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS nix fixes #2321

Merged
merged 2 commits into from
Nov 11, 2024
Merged
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
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
devShells = forAllSystems (system:
let
pkgs = pkgsFor.${system};
extras = if pkgs.stdenv.isDarwin then [ "psycopg-c" ] else [ "psycopg-binary" ];
in
rec {
evap = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) python3;
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
inherit extras;
};
evap-dev = evap.override { poetry-groups = [ "dev" ]; };
default = evap-dev;
Expand Down
2 changes: 1 addition & 1 deletion nix/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
fi
set -x
cp deployment/localsettings.template.py evap/localsettings.py
sed -i -e "s/\$SECRET_KEY/$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)/" evap/localsettings.py
sed -i -e "s/\$SECRET_KEY/$(head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9 | head -c 32)/" evap/localsettings.py
git submodule update --init
./manage.py migrate --noinput
./manage.py collectstatic --noinput
Expand Down
15 changes: 13 additions & 2 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, python3, poetry2nix, pyproject, poetrylock, poetry-groups ? [ ], extraPackages ? [ ], extraPythonPackages ? (ps: [ ]), ... }:
{ pkgs, lib ? pkgs.lib, python3, poetry2nix, pyproject, poetrylock, extras ? [ ], poetry-groups ? [ ], extraPackages ? [ ], extraPythonPackages ? (ps: [ ]), ... }:

let
# When running a nix shell, XDG_DATA_DIRS will be populated so that bash_completion can (lazily) find this completion script
Expand All @@ -17,11 +17,22 @@ let
poetry-env = poetry2nix.mkPoetryEnv {
python = python3;
# We pass these instead of `projectDir` to avoid adding the dependency on other files.
inherit pyproject poetrylock;
inherit pyproject poetrylock extras;
preferWheels = true;
overrides = poetry2nix.overrides.withDefaults (final: prev: {
# https://github.com/nix-community/poetry2nix/issues/1499
django-stubs-ext = prev.django-stubs-ext.override { preferWheel = false; };

psycopg = prev.psycopg.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ]
++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.openssl ];
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ pkgs.postgresql ];
});

psycopg-c = prev.psycopg-c.overridePythonAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ pkgs.postgresql ];
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ final.setuptools ];
});
});
groups = poetry-groups;
checkGroups = [ ]; # would otherwise always install dev-dependencies
Expand Down
19 changes: 16 additions & 3 deletions poetry.lock

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

8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ django-fsm = "~2.8.2"
Django = "~5.1.0"
mozilla-django-oidc = "~4.0.1"
openpyxl = "~3.1.5"
psycopg = { version = "~3.2.3", extras = ["binary"] }
psycopg = "~3.2.3"
psycopg-c = { version = "~3.2.3", optional = true }
psycopg-binary = { version = "~3.2.3", optional = true }
redis = "~5.2.0"
typing-extensions = "~4.12.2"
xlwt = "~1.3.0"
Expand All @@ -34,6 +36,10 @@ tblib = "~3.0.0"
xlrd = "~2.0.1"
typeguard = "~4.4.0"

[tool.poetry.extras]
psycopg-c = ["psycopg-c"]
psycopg-binary = ["psycopg-binary"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down
Loading