aboutsummaryrefslogtreecommitdiff
path: root/lib/mk-dev-shell.nix
blob: cc7d940f9be91952893001b186666e36361ca763 (plain)
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
flake:
{ pkgs
, tools ? []
, envVars ? {}
, prePrompt ? ""
, shell ? null
}:

let
  shellLib = flake.lib.shell { inherit pkgs; };

in pkgs.mkShell {
  packages = tools;
  shellHook = ''
    ${shellLib.exportEnvVars envVars}

    ${shellLib.ifSomeAttrs envVars shellLib.printEnvVars}
    ${shellLib.ifSomeList tools shellLib.printBins}
    echo
    ${prePrompt}

    ${if (shell != null) then shell else shellLib.startUserShell}
    exit $?
  '';
}