[Linux-only] basically bloxstap for sober

nix fixes

+10 -9
+3
src/api/constants.ts
··· 14 14 15 15 export const DISCORD_APPID = "1005469189907173486"; 16 16 export const SMALL_IMAGE_KEY = "roblox"; 17 + 18 + export const isCompiled = process.argv0.endsWith("bin/tuxstrap") 19 + export const isNixOS = isCompiled && ((process.argv0 === "/run/current-system/sw/bin/tuxstrap") || process.argv0.includes("/nix/store"))
+2 -2
src/api/sober/DesktopEntry.ts
··· 2 2 import { writeFileSync } from "fs"; 3 3 import { homedir } from "os"; 4 4 import { join } from "path"; 5 + import { isCompiled } from "../constants"; 5 6 6 7 type DesktopEntry = { 7 8 name: string; ··· 57 58 58 59 export async function registerXDG(fileName: string) { 59 60 if ( 60 - process.argv0.endsWith("bin/tuxstrap") || 61 - process.argv0 === "/run/current-system/sw/bin/tuxstrap" 61 + isCompiled 62 62 ) { 63 63 for (const mimeType of tuxstrapDesktopEntry.mimeTypes) { 64 64 const r = await $`xdg-mime default ${fileName} ${mimeType}`
+5 -7
src/index.ts
··· 1 1 import { $ } from "bun"; 2 - import { SOBER_APPID, TUXSTRAP_VERSION } from "./api/constants"; 2 + import { isCompiled, isNixOS, SOBER_APPID, TUXSTRAP_VERSION } from "./api/constants"; 3 3 import { 4 4 _libocbwoy3Version, 5 5 libocbwoy3Greet, ··· 51 51 .replaceAll("\\t", "\t") 52 52 ); 53 53 if ( 54 - process.argv0.endsWith("bin/tuxstrap") || 55 - process.argv0 === "/run/current-system/sw/bin/tuxstrap" 54 + isCompiled 56 55 ) { 57 56 console.log( 58 57 `TuxStrap ${TUXSTRAP_VERSION}, libocbwoy3 ${_libocbwoy3Version}, Bun ${ 59 58 Bun.version_with_sha 60 59 }, ${ 61 - process.argv0.includes("/nix/store") 60 + isNixOS 62 61 ? "Nix build" 63 62 : "compiled" 64 63 }` ··· 129 128 libocbwoy3Greet(); 130 129 131 130 if ( 132 - process.argv0.endsWith("bin/tuxstrap") || 133 - process.argv0 === "/run/current-system/sw/bin/tuxstrap" 131 + isCompiled 134 132 ) { 135 133 console.log( 136 134 `Using ${ 137 - process.argv0.includes("/nix/store") ? "Nix" : "built" 135 + isNixOS ? "Nix" : "built" 138 136 } version of TuxStrap!! ${process.argv0}` 139 137 ); 140 138 }