-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshell.nix
More file actions
39 lines (33 loc) · 859 Bytes
/
shell.nix
File metadata and controls
39 lines (33 loc) · 859 Bytes
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
let
nixpkgs = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/tarball/nixos-25.05";
sha256 = "062g9k0dn0x6a7pcc4w17gkv7sd8gnbbsbr8cmihqdpsrs355gmp";
};
pkgs = import nixpkgs { config = {allowUnfree=true;}; overlays = []; };
in
let
shell_packages = with pkgs; [
git
jujutsu
pre-commit
poetry
];
in
pkgs.mkShell {
buildInputs = shell_packages;
shellHook = ''
has_venv_dir=false
has_pyproject=false
[ -d ".venv" ] && has_venv_dir=true
[ -f "pyproject.toml" ] && has_pyproject=true
if ! $has_venv_dir && $has_pyproject; then
echo "Creating a virtual environment..."
poetry config virtualenvs.in-project true --local
poetry install --with dev
fi
if $has_venv_dir; then
echo "Activating the virtual environment..."
source .venv/bin/activate
fi
'';
}