1{
2 gitMinimal,
3 runCommand,
4}:
5
6{
7 # Add packages to a Python environment. Works if you pass something like either
8 # a) python3
9 # b) python3.withPackages (ps: [...])
10 # See https://github.com/NixOS/nixpkgs/pull/97467#issuecomment-689315186
11 addPackagesToPython =
12 python: packages:
13 if python ? "env" then
14 python.override (old: {
15 extraLibs = old.extraLibs ++ packages;
16 })
17 else
18 python.withPackages (ps: packages);
19
20 # Convert an ordinary source checkout into a repo with a single commit
21 repoifySimple =
22 name: path:
23 runCommand ''${name}-repoified'' { buildInputs = [ gitMinimal ]; } ''
24 mkdir -p $out
25 cp -r ${path}/. $out
26 cd $out
27 chmod -R u+w .
28 rm -rf .git
29 git init
30 git add . -f
31 git config user.email "julia2nix@localhost"
32 git config user.name "julia2nix"
33 git commit -m "Dummy commit"
34 '';
35
36 # Convert an dependency source info into a repo with a single commit
37 repoifyInfo =
38 uuid: info:
39 runCommand ''julia-${info.name}-${info.version}'' { buildInputs = [ gitMinimal ]; } ''
40 mkdir -p $out
41 cp -r ${info.src}/. $out
42 cd $out
43 chmod -R u+w .
44 rm -rf .git
45 git init
46 git add . -f
47 git config user.email "julia2nix@localhost"
48 git config user.name "julia2nix"
49 git commit -m "Dummy commit"
50 '';
51}