about summary refs log tree commit diff
path: root/pkgs/development/julia-modules/util.nix
blob: 0c01fcbe82863079a604ec39e974535ef25d53e0 (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
{ git
, runCommand
}:

{
  # Add packages to a Python environment. Works if you pass something like either
  # a) python3
  # b) python3.withPackages (ps: [...])
  # See https://github.com/NixOS/nixpkgs/pull/97467#issuecomment-689315186
  addPackagesToPython = python: packages:
    if python ? "env" then python.override (old: {
      extraLibs = old.extraLibs ++ packages;
    })
    else python.withPackages (ps: packages);

  # Convert an ordinary source checkout into a repo with a single commit
  repoifySimple = name: path:
    runCommand ''${name}-repoified'' {buildInputs = [git];} ''
      mkdir -p $out
      cp -r ${path}/. $out
      cd $out
      chmod -R u+w .
      rm -rf .git
      git init
      git add . -f
      git config user.email "julia2nix@localhost"
      git config user.name "julia2nix"
      git commit -m "Dummy commit"
    '';

  # Convert an dependency source info into a repo with a single commit
  repoifyInfo = uuid: info:
    runCommand ''julia-${info.name}-${info.version}'' {buildInputs = [git];} ''
      mkdir -p $out
      cp -r ${info.src}/. $out
      cd $out
      chmod -R u+w .
      rm -rf .git
      git init
      git add . -f
      git config user.email "julia2nix@localhost"
      git config user.name "julia2nix"
      git commit -m "Dummy commit"
    '';
}