-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
54 lines (52 loc) · 2.16 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
description = "A typed transformer demo";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication mkPoetryEnv defaultPoetryOverrides;
myOverrides = [
(final: prev:
{
equinox = prev.equinox.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ final.hatchling ];
});
})
(defaultPoetryOverrides.overrideOverlay (final: prev: {
# `rich` has some dependencies that are problematic at build time
# (they bring in the all-but-abandoned `future` which is incompatible with python 3.12)
# but overriding the override like this removes the `commonmark` dependency
# specified in `defaultPoetryOverrides`
rich = prev.rich.overridePythonAttrs (old: { });
}))
];
poetryAttrs = (extras: {
projectDir = ./.;
preferWheels = true;
python = pkgs.python312;
overrides = myOverrides;
extras = extras;
});
in
rec {
formatter = pkgs.nixpkgs-fmt;
# Just a dummy env because a default package is required
packages.default = pkgs.python312;
devShells.default = (mkPoetryEnv (poetryAttrs [ "dev" "vscode" ])).env.overrideAttrs (final: prev: {
# pip required for VSCode interactive window
# We maybe should specify `ruff` in the pyproject.toml but then `poetry2nix` downloads the whole rust
# toolchain to build it from source
nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [ pkgs.poetry pkgs.ruff ];
shellHook = (prev.shellHook or "") + ''
export PATH=node_modules/.bin/:$PATH
'';
});
}
);
}