-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
44 lines (43 loc) · 1.48 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
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
config = {
allowUnfree = true;
cudaSupport = true;
};
};
lib = pkgs.lib;
# Make scripts from the Python project available
attrs = builtins.fromTOML (builtins.readFile ./src/gwas/pyproject.toml);
write = name: value:
let
match = lib.splitString ":" value;
package = builtins.elemAt match 0;
function = builtins.elemAt match 1;
in
pkgs.writers.makeScriptWriter { interpreter = "${pkgs.coreutils}/bin/env python"; } "/bin/${name}" ''
import sys
from ${package} import ${function}
if __name__ == "__main__":
sys.exit(${function}())
'';
scripts = lib.mapAttrsToList write attrs.project.scripts;
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
packages = [ pkgs.clang pkgs.clang-tools pkgs.gcc pkgs.gdb pkgs.micromamba pkgs.ruff ] ++ scripts;
shellHook = ''
export PYTHONBREAKPOINT=ipdb.set_trace
export PYTHONDONTWRITEBYTECODE=1
export PYTHONUNBUFFERED=1
export PYTHONPATH="$(git rev-parse --show-toplevel)/src/gwas/src"
eval "$(micromamba shell hook --shell=posix)"
micromamba activate gwas-protocol
'';
};
};
}