Skip to content

Commit

Permalink
Switch to uv2nix (#2345)
Browse files Browse the repository at this point in the history
I also added a CI job to build the nix setup on Mac, so we can catch missing wheels early on.
  • Loading branch information
niklasmohrin authored Dec 2, 2024
1 parent b368835 commit 01d979f
Show file tree
Hide file tree
Showing 8 changed files with 1,014 additions and 1,484 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,14 @@ jobs:
path: evap/static/css
- name: Run tests
run: xvfb-run --auto-servernum npx jest

macos-nix-build:
runs-on: macos-14
name: Build nix environment on MacOS
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/setup_evap
with:
start-db: true
164 changes: 61 additions & 103 deletions flake.lock

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

58 changes: 32 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
url = "github:nix-community/poetry2nix";

pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
uv2nix = {
url = "github:adisbladis/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};

Expand All @@ -23,18 +35,28 @@
devShells = forAllSystems (system:
let
pkgs = pkgsFor.${system};
extras = if pkgs.stdenv.isDarwin then [ "psycopg-c" ] else [ "psycopg-binary" ];
dependency-groups = 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;
inherit (inputs) pyproject-nix uv2nix pyproject-build-systems;
inherit dependency-groups;
workspaceRoot = ./.;
};
evap-dev = evap.override { poetry-groups = [ "dev" ]; };
evap-dev = evap.override (prev: { dependency-groups = (prev.dependency-groups or [ ]) ++ [ "dev" ]; });
default = evap-dev;

impure = pkgs.mkShell {
packages = with pkgs; [
(self.packages.${system}.python3)
uv
postgresql
];
shellHook = ''
unset PYTHONPATH
'';
};
});

packages = forAllSystems (system:
Expand All @@ -48,29 +70,13 @@
{
inherit pkgs only-databases;
inherit (inputs) services-flake;
inherit (self.devShells.${system}.evap.passthru) poetry-env;
inherit (self.devShells.${system}.evap.passthru) venv;
})
];
};
in
rec {
python3 = pkgs.python310.override {
self = python3;
packageOverrides = lib.composeManyExtensions [
(_finalPackages: prevPackages: lib.mapAttrs
(_name: package:
if lib.isDerivation package && lib.hasAttr "overridePythonAttrs" package
then package.overridePythonAttrs (_: { doCheck = false; })
else package)
prevPackages)
(finalPackages: prevPackages: {
jeepney = prevPackages.jeepney.overridePythonAttrs (prev: {
buildInputs = prev.buildInputs or [ ] ++ [ finalPackages.outcome finalPackages.trio ];
});
})
];
};
poetry = (pkgs.poetry.override { inherit python3; }).overridePythonAttrs { doCheck = false; };
python3 = pkgs.python310;

services = make-process-compose true;
services-full = make-process-compose false;
Expand Down
9 changes: 3 additions & 6 deletions nix/services.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{ pkgs, lib ? pkgs.lib, services-flake, only-databases, poetry-env }: {
{ pkgs, lib ? pkgs.lib, services-flake, only-databases, venv }: {
imports = [
services-flake.processComposeModules.default
];

httpServer = {
enable = true;
uds = "process-compose.socket";
};
cli.options.unix-socket = "process-compose.socket";

services = {
redis."r1" = {
Expand Down Expand Up @@ -58,7 +55,7 @@
settings.processes."init-django" = {
command = pkgs.writeShellApplication {
name = "init-django";
runtimeInputs = with pkgs; [ poetry-env git gnused gettext coreutils ];
runtimeInputs = with pkgs; [ venv git gnused gettext coreutils ];
text = ''
set -e
if [[ -f evap/localsettings.py ]]; then
Expand Down
Loading

0 comments on commit 01d979f

Please sign in to comment.