forked from letsql/letsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
52 lines (49 loc) · 1.42 KB
/
shell.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
let
flake = builtins.getFlake (toString ./.);
inherit (flake.lib.${builtins.currentSystem}) pkgs mkToolsPackages poetryOverrides;
inherit (flake.inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryEnv overrides;
python = pkgs.python310;
editableApp = mkPoetryEnv {
projectDir = ./.;
inherit python;
preferWheels = true;
groups = [ "dev" "test" "docs" ];
editablePackageSources = {
letsql = ./python;
};
overrides = overrides.withDefaults poetryOverrides;
};
toolsPackages = mkToolsPackages editableApp;
shellHook = ''
set -eu
repo_dir=$(git rev-parse --show-toplevel)
if [ "$(basename "$repo_dir")" != "letsql" ]; then
echo "not in letsql, exiting"
exit 1
fi
case $(uname) in
Darwin) suffix=dylib ;;
*) suffix=so ;;
esac
source=$repo_dir/target/release/maturin/libletsql.$suffix
target=$repo_dir/python/letsql/_internal.abi3.so
if [ ! -e "$source" ]; then
${toolsPackages}/bin/maturin build --release
fi
if [ ! -L "$target" -o "$(realpath "$source")" != "$(realpath "$target")" ]; then
rm -f "$target"
ln -s "$source" "$target"
fi
'';
in pkgs.mkShell {
packages = [
editableApp
toolsPackages
pkgs.poetry
pkgs.pkg-config
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
inherit shellHook;
}