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