|
| 1 | +{ |
| 2 | + description = "Flake for svenvc/neojson"; |
| 3 | + |
| 4 | + inputs = rec { |
| 5 | + flake-utils.url = "github:numtide/flake-utils/v1.0.0"; |
| 6 | + nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; |
| 7 | + pharo-vm-12 = { |
| 8 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 9 | + url = "github:rydnr/nix-flakes/pharo-vm-12.0.1519.2?dir=pharo-vm"; |
| 10 | + }; |
| 11 | + }; |
| 12 | + outputs = inputs: |
| 13 | + with inputs; |
| 14 | + flake-utils.lib.eachDefaultSystem (system: |
| 15 | + let |
| 16 | + org = "svenvc"; |
| 17 | + repo = "neojson"; |
| 18 | + pname = "${repo}"; |
| 19 | + tag = "v18"; |
| 20 | + baseline = "NeoJSON"; |
| 21 | + pkgs = import nixpkgs { inherit system; }; |
| 22 | + description = "An elegant and efficient Smalltalk framework to read and write JSON converting to or from Smalltalk objects"; |
| 23 | + license = pkgs.lib.licenses.mit; |
| 24 | + homepage = "https://github.com/svenvc/neojson"; |
| 25 | + maintainers = with pkgs.lib.maintainers; [ ]; |
| 26 | + nixpkgsVersion = builtins.readFile "${nixpkgs}/.version"; |
| 27 | + nixpkgsRelease = |
| 28 | + builtins.replaceStrings [ "\n" ] [ "" ] "nixpkgs-${nixpkgsVersion}"; |
| 29 | + shared = import ./shared.nix; |
| 30 | + svenvc-neojson-for = { bootstrap-image-name, bootstrap-image-sha256, bootstrap-image-url, pharo-vm }: |
| 31 | + let |
| 32 | + bootstrap-image = pkgs.fetchurl { |
| 33 | + url = bootstrap-image-url; |
| 34 | + sha256 = bootstrap-image-sha256; |
| 35 | + }; |
| 36 | + src = ./../repository; |
| 37 | + in pkgs.stdenv.mkDerivation (finalAttrs: { |
| 38 | + version = tag; |
| 39 | + inherit pname src; |
| 40 | + |
| 41 | + strictDeps = true; |
| 42 | + |
| 43 | + buildInputs = with pkgs; [ |
| 44 | + ]; |
| 45 | + |
| 46 | + nativeBuildInputs = with pkgs; [ |
| 47 | + pharo-vm |
| 48 | + pkgs.unzip |
| 49 | + ]; |
| 50 | + |
| 51 | + unpackPhase = '' |
| 52 | + unzip -o ${bootstrap-image} -d image |
| 53 | + # cp -r ${src} src |
| 54 | + ''; |
| 55 | + |
| 56 | + configurePhase = '' |
| 57 | + runHook preConfigure |
| 58 | +
|
| 59 | + # load baseline |
| 60 | + ${pharo-vm}/bin/pharo image/${bootstrap-image-name} eval --save "EpMonitor current disable. NonInteractiveTranscript stdout install. [ Metacello new repository: 'filetree://${src}'; baseline: '${baseline}'; onConflictUseLoaded; load ] ensure: [ EpMonitor current enable ]" |
| 61 | +
|
| 62 | + runHook postConfigure |
| 63 | + ''; |
| 64 | + |
| 65 | + buildPhase = '' |
| 66 | + runHook preBuild |
| 67 | +
|
| 68 | + # assemble |
| 69 | + ${pharo-vm}/bin/pharo image/${bootstrap-image-name} save "${pname}" |
| 70 | +
|
| 71 | + mkdir dist |
| 72 | + mv image/${pname}.* dist/ |
| 73 | +
|
| 74 | + runHook postBuild |
| 75 | + ''; |
| 76 | + |
| 77 | + installPhase = '' |
| 78 | + runHook preInstall |
| 79 | +
|
| 80 | + mkdir -p $out |
| 81 | + cp -r ${pharo-vm}/bin $out |
| 82 | + cp -r ${pharo-vm}/lib $out |
| 83 | + cp -r dist/* $out/ |
| 84 | + cp image/*.sources $out/ |
| 85 | + mkdir $out/share |
| 86 | + pushd ${src} |
| 87 | + ${pkgs.zip}/bin/zip -r $out/share/src.zip . |
| 88 | + popd |
| 89 | +
|
| 90 | + runHook postInstall |
| 91 | + ''; |
| 92 | + |
| 93 | + meta = { |
| 94 | + longDescription = '' |
| 95 | + NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects. |
| 96 | + ''; |
| 97 | + inherit description homepage license maintainers; |
| 98 | + mainProgram = "pharo"; |
| 99 | + platforms = pkgs.lib.platforms.linux; |
| 100 | + }; |
| 101 | + }); |
| 102 | + in rec { |
| 103 | + defaultPackage = packages.default; |
| 104 | + devShells = rec { |
| 105 | + default = svenvc-neojson-12; |
| 106 | + svenvc-neojson-12 = shared.devShell-for { |
| 107 | + package = packages.svenvc-neojson-12; |
| 108 | + inherit org pkgs repo tag; |
| 109 | + nixpkgs-release = nixpkgsRelease; |
| 110 | + }; |
| 111 | + }; |
| 112 | + packages = rec { |
| 113 | + default = svenvc-neojson-12; |
| 114 | + svenvc-neojson-12 = svenvc-neojson-for rec { |
| 115 | + bootstrap-image-url = pharo-vm-12.resources.${system}.bootstrap-image-url; |
| 116 | + bootstrap-image-sha256 = pharo-vm-12.resources.${system}.bootstrap-image-sha256; |
| 117 | + bootstrap-image-name = pharo-vm-12.resources.${system}.bootstrap-image-name; |
| 118 | + pharo-vm = pharo-vm-12.packages.${system}.pharo-vm; |
| 119 | + }; |
| 120 | + }; |
| 121 | + }); |
| 122 | +} |
0 commit comments