Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 105 lines 2.7 kB view raw
1{ 2 uiua_versionType ? "stable", 3 4 lib, 5 stdenv, 6 rustPlatform, 7 fetchFromGitHub, 8 pkg-config, 9 versionCheckHook, 10 11 libffi, 12 audioSupport ? true, 13 alsa-lib, 14 webcamSupport ? false, 15 libGL, 16 libxkbcommon, 17 wayland, 18 xorg, 19 windowSupport ? false, 20 21 runCommand, 22}: 23 24let 25 versionInfo = 26 { 27 "stable" = import ./stable.nix; 28 "unstable" = import ./unstable.nix; 29 } 30 .${uiua_versionType}; 31in 32 33rustPlatform.buildRustPackage (finalAttrs: { 34 pname = "uiua"; 35 inherit (versionInfo) version cargoHash; 36 37 src = fetchFromGitHub { 38 owner = "uiua-lang"; 39 repo = "uiua"; 40 inherit (versionInfo) tag hash; 41 }; 42 43 nativeBuildInputs = 44 lib.optionals (webcamSupport || stdenv.hostPlatform.isDarwin) [ rustPlatform.bindgenHook ] 45 ++ lib.optionals audioSupport [ pkg-config ]; 46 47 buildInputs = [ 48 libffi 49 ] # we force dynamic linking our own libffi below 50 ++ lib.optionals (audioSupport && stdenv.hostPlatform.isLinux) [ alsa-lib ]; 51 52 buildFeatures = [ 53 "libffi/system" 54 ] # force libffi to be linked dynamically instead of rebuilding it 55 ++ lib.optional audioSupport "audio" 56 ++ lib.optional webcamSupport "webcam" 57 ++ lib.optional windowSupport "window"; 58 59 postFixup = 60 let 61 runtimeDependencies = lib.optionals windowSupport [ 62 libGL 63 libxkbcommon 64 wayland 65 xorg.libX11 66 xorg.libXcursor 67 xorg.libXi 68 xorg.libXrandr 69 ]; 70 in 71 lib.optionalString (runtimeDependencies != [ ] && stdenv.hostPlatform.isLinux) '' 72 patchelf --add-rpath ${lib.makeLibraryPath runtimeDependencies} $out/bin/uiua 73 ''; 74 75 nativeInstallCheckInputs = [ versionCheckHook ]; 76 versionCheckProgramArg = "--version"; 77 doInstallCheck = true; 78 79 passthru.updateScript = versionInfo.updateScript; 80 passthru.tests.run = 81 runCommand "uiua-test-run" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } 82 '' 83 uiua init 84 diff -U3 --color=auto <(uiua run main.ua) <(echo '"Hello, World!"') 85 touch $out 86 ''; 87 88 meta = { 89 changelog = "https://github.com/uiua-lang/uiua/blob/${finalAttrs.src.rev}/changelog.md"; 90 description = "Stack-oriented array programming language with a focus on simplicity, beauty, and tacit code"; 91 longDescription = '' 92 Uiua combines the stack-oriented and array-oriented paradigms in a single 93 language. Combining these already terse paradigms results in code with a very 94 high information density and little syntactic noise. 95 ''; 96 homepage = "https://www.uiua.org/"; 97 license = lib.licenses.mit; 98 mainProgram = "uiua"; 99 maintainers = with lib.maintainers; [ 100 cafkafk 101 tomasajt 102 defelo 103 ]; 104 }; 105})