devshells.nix 1.42 KB
Newer Older
xuxzh1's avatar
update  
xuxzh1 committed
1
2
{ inputs, ... }:

xuxzh1's avatar
init  
xuxzh1 committed
3
4
{
  perSystem =
xuxzh1's avatar
update  
xuxzh1 committed
5
6
7
8
9
10
    {
      config,
      lib,
      system,
      ...
    }:
xuxzh1's avatar
init  
xuxzh1 committed
11
12
    {
      devShells =
xuxzh1's avatar
update  
xuxzh1 committed
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
        let
          pkgs = import inputs.nixpkgs { inherit system; };
          stdenv = pkgs.stdenv;
          scripts = config.packages.python-scripts;
        in
        lib.pipe (config.packages) [
          (lib.concatMapAttrs (
            name: package: {
              ${name} = pkgs.mkShell {
                name = "${name}";
                inputsFrom = [ package ];
                shellHook = ''
                  echo "Entering ${name} devShell"
                '';
              };
              "${name}-extra" =
                if (name == "python-scripts") then
                  null
                else
                  pkgs.mkShell {
                    name = "${name}-extra";
                    inputsFrom = [
                      package
                      scripts
                    ];
                    # Extra packages that *may* be used by some scripts
                    packages = [
                        pkgs.python3Packages.tiktoken
                    ];
                    shellHook = ''
                      echo "Entering ${name} devShell"
                      addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
                    '';
                  };
            }
          ))
          (lib.filterAttrs (name: value: value != null))
        ];
xuxzh1's avatar
init  
xuxzh1 committed
51
52
    };
}