nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 67 lines 2.4 kB view raw
1{ 2 godot3-mono, 3 nuget-to-json, 4 5}: 6 7godot3-mono.overrideAttrs ( 8 self: base: { 9 pname = "godot3-mono-make-deps"; 10 11 nativeBuildInputs = base.nativeBuildInputs ++ [ 12 nuget-to-json 13 ]; 14 15 nugetDeps = null; 16 nugetSource = null; 17 nugetConfig = null; 18 19 keepNugetConfig = true; 20 21 outputs = [ "out" ]; 22 buildPhase = " "; 23 installPhase = ''echo "No output intended. Run make-deps.sh instead." > $out''; 24 25 # This script is used to update the accompanying deps.json file, a JSON file listing the 26 # nuget packages that the godot-mono code depends on, along with their sha256 hashes. This 27 # file is referenced by the godot-mono derivation and needs to be updated every time the 28 # godot version is updated. The way it works is: 29 # 30 # 1) Creates and navigates to a temporary directory and then explicitly runs the unpack, 31 # patch, and configure phases from the godot-mono derivation. 32 # 2) Instead of building at this point, a nuget restore is performed, downloading all the 33 # nuget dependencies of godot-mono into a local folder. 34 # 3) Once these have been downloaded, the nuget-to-json tool is used to generate a JSON 35 # array listing the locally obtained nuget packages, along with their sha256 hashes. 36 # 4) This JSON array is saved as deps.json in the PWD. 37 # 38 # This process is impure, because it entails downloading files with unknown hashes, so it 39 # is run manually by the maintainer within a nix-shell environment. Running the accompanying 40 # make-deps.sh instead simplifies this. 41 makeDeps = '' 42 set -e 43 outdir="$(pwd)" 44 wrkdir="$(mktemp -d)" 45 trap 'rm -rf -- "$wrkdir"' EXIT 46 pushd "$wrkdir" > /dev/null 47 unpackPhase 48 cd source 49 patchPhase 50 configurePhase 51 52 # Without RestorePackagesPath set, it restores packages to a temp directory. Specifying 53 # a path ensures we have a place to run nuget-to-json. 54 nugetRestore() { dotnet msbuild -t:Restore -p:RestorePackagesPath=nugetPackages $1; } 55 56 nugetRestore modules/mono/glue/GodotSharp/GodotSharp.sln 57 nugetRestore modules/mono/editor/GodotTools/GodotTools.sln 58 59 nuget-to-json nugetPackages > "$outdir"/deps.json 60 popd > /dev/null 61 ''; 62 63 meta = base.meta // { 64 description = "Derivation with no output that exists to provide an environment for make-deps.sh"; 65 }; 66 } 67)