-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
58 lines (47 loc) · 1.56 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
53
54
55
56
57
58
{
pkgs ? import <nixpkgs> { },
}:
let
title = "Meni 3D Library";
dependencies = with pkgs; [
poetry
python311Full
# Install via nix packages that have C bindings
python311Packages.pyside6
python311Packages.vtk
];
shellHook = ''
# Activate pip venv
[[ -e venv ]] && . venv/bin/activate
'';
shellHookDescription = [
# Add shell hook description here, as an array of strings
"Activate python environment at venv"
];
commands = {
"scode" = "Sandboxed version of Visual Studio Code";
};
title_color = "$(tput setaf 4)";
item_color = "$(tput setaf 8)";
command_color = "$(tput setaf 2)";
reset = "$(tput sgr0)";
mark = "${item_color} ● ${reset}";
in
pkgs.mkShell {
nativeBuildInputs = dependencies;
shellHook =
shellHook
+ ''
cat <<EOF| boxes -d ansi-rounded -p t1h4b0
${title_color + title + reset}
${
reset
+ (if builtins.lessThan 0 (builtins.length dependencies) then "Packages installed:\n" + (builtins.foldl' (x: y: x + mark + y.name + "\n") "" dependencies) + "\n" else "")
+ (if builtins.lessThan 0 (builtins.length shellHookDescription) then "On start:\n" + (builtins.foldl' (x: y: x + mark + y + "\n") "" shellHookDescription) + "\n" else "")
+ (if builtins.lessThan 0 (builtins.length (builtins.attrNames commands)) then "Commands:\n" else "")
+ (builtins.foldl' (x: y: x + mark + command_color + y + reset + ": " + commands.${y} + "\n") "" (builtins.attrNames commands))
}
EOF
'';
PROJECT_ROOT = builtins.toString ./.;
}