This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / pkgs / moebius / package.nix
5.0 kB 150 lines
1{ 2 lib, 3 stdenv, 4 buildNpmPackage, 5 fetchFromGitHub, 6 makeWrapper, 7 makeDesktopItem, 8 copyDesktopItems, 9 electron_43, 10 nix-update-script, 11}: 12 13let 14 electron = electron_43; 15in 16buildNpmPackage (finalAttrs: { 17 pname = "moebius"; 18 # Upstream's last tagged release (1.0.29) only ships x86_64 binaries; build the 19 # newer master commit from source so it runs natively on every platform. 20 version = "1.0.29-unstable-2023-12-18"; 21 22 src = fetchFromGitHub { 23 owner = "blocktronics"; 24 repo = "moebius"; 25 rev = "1f624d62654d614177635ab18a288253c3b917eb"; 26 hash = "sha256-Uu6vEhbXXiVbUTgC/WeF+SVCf0oLzg4OnGFZIx7SJ6I="; 27 }; 28 29 npmDepsHash = "sha256-hLZF0FvyAgJVURmU6M4UYFauZz5SLvH2+6W2qDogoXU="; 30 31 passthru.updateScript = nix-update-script { 32 extraArgs = [ 33 "--flake" 34 "--version=branch" 35 ]; 36 }; 37 38 # discord-rpc pulls the optional native `register-scheme` git dependency, which 39 # is only used outside Electron (inside Electron it falls back to 40 # app.setAsDefaultProtocolClient), so drop it and build a pure-JS closure. 41 forceGitDeps = true; 42 npmFlags = [ 43 "--omit=dev" 44 "--omit=optional" 45 ]; 46 47 # We ship the app on nixpkgs' Electron; don't download a private one or run the 48 # electron-builder packaging step. 49 env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 50 dontNpmBuild = true; 51 52 nativeBuildInputs = [ 53 makeWrapper 54 ] 55 ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ]; 56 57 desktopItems = lib.optionals stdenv.hostPlatform.isLinux [ 58 (makeDesktopItem { 59 name = "moebius"; 60 desktopName = "Moebius"; 61 comment = finalAttrs.meta.description; 62 exec = "moebius %U"; 63 icon = "moebius"; 64 startupWMClass = "Moebius"; 65 categories = [ "Graphics" ]; 66 mimeTypes = [ "text/x-ansi" ]; 67 }) 68 ]; 69 70 installPhase = '' 71 runHook preInstall 72 73 app=$out/libexec/moebius 74 res=$app/resources 75 mkdir -p "$app" "$out/bin" 76 cp -r app node_modules package.json "$app/" 77 78 # Sample art and control-character sheets the app loads at runtime. 79 mkdir -p "$res" 80 cp -r build/ans "$res/ans" 81 cp -r build/png "$res/png" 82 83 # The app switches resource paths on app.isPackaged; we run an unpacked tree, 84 # so pin both branches to the store copy above. 85 find "$app/app" -name '*.js' | while read -r f; do 86 substituteInPlace "$f" \ 87 --replace-quiet 'remote.app.isPackaged' 'true' \ 88 --replace-quiet 'process.resourcesPath' "\"$res\"" 89 done 90 91 # @electron/remote 2.1.0 calls the internal features.isViewApiEnabled(), 92 # removed in modern Electron; guard it (the fix shipped upstream in 2.1.2). 93 substituteInPlace "$app/node_modules/@electron/remote/dist/src/common/module-names.js" \ 94 --replace-fail 'if (!features || features.isViewApiEnabled()) {' \ 95 'if (!features || !features.isViewApiEnabled || features.isViewApiEnabled()) {' 96 97 makeWrapper ${lib.getExe electron} $out/bin/moebius \ 98 --add-flags "$app" \ 99 ${lib.optionalString stdenv.hostPlatform.isLinux '' 100 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" 101 ''} 102 '' 103 + lib.optionalString stdenv.hostPlatform.isLinux '' 104 for size in 16 32 128 512 1024; do 105 install -Dm644 build/icons/icon_''${size}x''${size}.png \ 106 $out/share/icons/hicolor/''${size}x''${size}/apps/moebius.png 107 done 108 '' 109 + lib.optionalString stdenv.hostPlatform.isDarwin '' 110 appdir="$out/Applications/Moebius.app/Contents" 111 mkdir -p "$appdir/MacOS" "$appdir/Resources" 112 cp build/icon.icns "$appdir/Resources/moebius.icns" 113 makeWrapper $out/bin/moebius "$appdir/MacOS/Moebius" 114 cat > "$appdir/Info.plist" <<EOF 115 <?xml version="1.0" encoding="UTF-8"?> 116 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 117 <plist version="1.0"> 118 <dict> 119 <key>CFBundleName</key><string>Moebius</string> 120 <key>CFBundleDisplayName</key><string>Moebius</string> 121 <key>CFBundleExecutable</key><string>Moebius</string> 122 <key>CFBundleIdentifier</key><string>org.andyherbert.moebius</string> 123 <key>CFBundleIconFile</key><string>moebius.icns</string> 124 <key>CFBundleShortVersionString</key><string>${finalAttrs.version}</string> 125 <key>CFBundlePackageType</key><string>APPL</string> 126 <key>LSMinimumSystemVersion</key><string>10.13</string> 127 <key>NSHighResolutionCapable</key><true/> 128 </dict> 129 </plist> 130 EOF 131 '' 132 + '' 133 runHook postInstall 134 ''; 135 136 meta = { 137 description = "Modern ANSI and ASCII art editor with a Photoshop-style half-block brush"; 138 homepage = "https://blocktronics.github.io/moebius/"; 139 downloadPage = "https://github.com/blocktronics/moebius/releases"; 140 license = lib.licenses.asl20; 141 maintainers = [ ]; 142 platforms = [ 143 "x86_64-linux" 144 "aarch64-linux" 145 "x86_64-darwin" 146 "aarch64-darwin" 147 ]; 148 mainProgram = "moebius"; 149 }; 150})