about summary refs log tree commit diff
path: root/pkgs/applications/version-management/nbstripout/default.nix
blob: 854c66a6d5e414b89e7889634edafa2f01f2be4d (plain) (blame)
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
{ lib
, python3
, fetchPypi
, coreutils
, git
, mercurial
}:

python3.pkgs.buildPythonApplication rec {
  version = "0.6.1";
  pname = "nbstripout";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-kGW83RSIs4bk88CB/8HUj0UTovjYv00NmiggjF2v6dM=";
  };

  # for some reason, darwin uses /bin/sh echo native instead of echo binary, so
  # force using the echo binary
  postPatch = ''
    substituteInPlace tests/test-git.t --replace "echo" "${coreutils}/bin/echo"
  '';

  propagatedBuildInputs = with python3.pkgs; [
    ipython
    nbformat
  ];

  nativeCheckInputs = [
    coreutils
    git
    mercurial
  ] ++ (with python3.pkgs; [
    pytest-cram
    pytestCheckHook
  ]);

  preCheck = ''
    export HOME=$(mktemp -d)
    export PATH=$out/bin:$PATH
    git config --global init.defaultBranch main
  '';

  meta = {
    description = "Strip output from Jupyter and IPython notebooks";
    homepage = "https://github.com/kynan/nbstripout";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ jluttine ];
    mainProgram = "nbstripout";
  };
}