my nixos/home-manager configuration
1
fork

Configure Feed

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

vendor in fixed discord krisp and graalvm21-ce pkgs

+820 -51
-34
flake.lock
··· 149 149 "type": "github" 150 150 } 151 151 }, 152 - "nixpkgs-discord": { 153 - "locked": { 154 - "lastModified": 1764874544, 155 - "narHash": "sha256-ucrTutn3jEIFu6kK6hZGHxxubg2qVuQZhBszEcbiUHc=", 156 - "owner": "sehnryr", 157 - "repo": "nixpkgs", 158 - "rev": "0d113150dad20423c915e969644871f2a2b732e4", 159 - "type": "github" 160 - }, 161 - "original": { 162 - "owner": "sehnryr", 163 - "ref": "discord-fhs-krisp-fix", 164 - "repo": "nixpkgs", 165 - "type": "github" 166 - } 167 - }, 168 - "nixpkgs-graalvm-ce-21": { 169 - "locked": { 170 - "lastModified": 1709246466, 171 - "narHash": "sha256-jN8Y5Zv2tNUKIGuSqhm8yIMn2x6jhMQvNwKYduvKxjU=", 172 - "owner": "nixos", 173 - "repo": "nixpkgs", 174 - "rev": "ed4db9c6c75079ff3570a9e3eb6806c8f692dc26", 175 - "type": "github" 176 - }, 177 - "original": { 178 - "owner": "nixos", 179 - "repo": "nixpkgs", 180 - "rev": "ed4db9c6c75079ff3570a9e3eb6806c8f692dc26", 181 - "type": "github" 182 - } 183 - }, 184 152 "nixpkgs-unstable": { 185 153 "locked": { 186 154 "lastModified": 1764667669, ··· 246 214 "home-manager": "home-manager", 247 215 "nixos-hardware": "nixos-hardware", 248 216 "nixpkgs": "nixpkgs", 249 - "nixpkgs-discord": "nixpkgs-discord", 250 - "nixpkgs-graalvm-ce-21": "nixpkgs-graalvm-ce-21", 251 217 "nixpkgs-unstable": "nixpkgs-unstable", 252 218 "nur": "nur", 253 219 "opnix": "opnix",
+2 -17
flake.nix
··· 2 2 inputs = { 3 3 nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11"; 4 4 nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable"; 5 - nixpkgs-graalvm-ce-21.url = "github:nixos/nixpkgs?rev=ed4db9c6c75079ff3570a9e3eb6806c8f692dc26"; 6 - nixpkgs-discord.url = "github:sehnryr/nixpkgs?ref=discord-fhs-krisp-fix"; 7 5 8 6 nixos-hardware.url = "github:nixos/nixos-hardware?ref=master"; 9 7 ··· 54 52 allowUnfree = true; 55 53 }; 56 54 overlays = [ 55 + nur.overlays.default 57 56 (final: prev: { 58 57 unstable = import inputs.nixpkgs-unstable { 59 58 inherit system; 60 59 inherit config; 61 60 }; 62 - graalvm21-ce = 63 - (import inputs.nixpkgs-graalvm-ce-21 { 64 - inherit system; 65 - inherit config; 66 - }).graalvm-ce.overrideAttrs 67 - (old: { 68 - name = "graalvm-ce"; 69 - version = "21.0.2"; 70 - }); 71 - discord = 72 - (import inputs.nixpkgs-discord { 73 - inherit system; 74 - inherit config; 75 - }).discord; 76 61 }) 77 - nur.overlays.default 62 + (final: pref: import ./pkgs { pkgs = final; }) 78 63 ]; 79 64 80 65 pkgs = import nixpkgs {
+5
pkgs/default.nix
··· 1 + { pkgs }: 2 + { 3 + discord = (pkgs.callPackage ./discord { }).discord; 4 + graalvm21-ce = pkgs.callPackage ./graalvm-ce { }; 5 + }
+126
pkgs/discord/darwin.nix
··· 1 + { 2 + pname, 3 + version, 4 + src, 5 + meta, 6 + stdenv, 7 + binaryName, 8 + desktopName, 9 + self, 10 + lib, 11 + undmg, 12 + makeWrapper, 13 + writeScript, 14 + python3, 15 + runCommand, 16 + branch, 17 + withOpenASAR ? false, 18 + openasar, 19 + withVencord ? false, 20 + vencord, 21 + withEquicord ? false, 22 + equicord, 23 + withMoonlight ? false, 24 + moonlight, 25 + commandLineArgs ? "", 26 + }: 27 + 28 + let 29 + discordMods = [ 30 + withVencord 31 + withEquicord 32 + withMoonlight 33 + ]; 34 + enabledDiscordModsCount = builtins.length (lib.filter (x: x) discordMods); 35 + 36 + disableBreakingUpdates = 37 + runCommand "disable-breaking-updates.py" 38 + { 39 + pythonInterpreter = "${python3.interpreter}"; 40 + configDirName = lib.toLower binaryName; 41 + meta.mainProgram = "disable-breaking-updates.py"; 42 + } 43 + '' 44 + mkdir -p $out/bin 45 + cp ${./disable-breaking-updates.py} $out/bin/disable-breaking-updates.py 46 + substituteAllInPlace $out/bin/disable-breaking-updates.py 47 + chmod +x $out/bin/disable-breaking-updates.py 48 + ''; 49 + in 50 + assert lib.assertMsg ( 51 + enabledDiscordModsCount <= 1 52 + ) "discord: Only one of Vencord, Equicord or Moonlight can be enabled at the same time"; 53 + stdenv.mkDerivation { 54 + inherit 55 + pname 56 + version 57 + src 58 + meta 59 + ; 60 + 61 + nativeBuildInputs = [ 62 + undmg 63 + makeWrapper 64 + ]; 65 + 66 + sourceRoot = "."; 67 + 68 + installPhase = '' 69 + runHook preInstall 70 + 71 + mkdir -p $out/Applications 72 + cp -r "${desktopName}.app" $out/Applications 73 + 74 + # wrap executable to $out/bin 75 + mkdir -p $out/bin 76 + makeWrapper "$out/Applications/${desktopName}.app/Contents/MacOS/${binaryName}" "$out/bin/${binaryName}" \ 77 + --run ${lib.getExe disableBreakingUpdates} \ 78 + --add-flags ${lib.escapeShellArg commandLineArgs} 79 + 80 + runHook postInstall 81 + ''; 82 + 83 + postInstall = 84 + lib.strings.optionalString withOpenASAR '' 85 + cp -f ${openasar} $out/Applications/${desktopName}.app/Contents/Resources/app.asar 86 + '' 87 + + lib.strings.optionalString withVencord '' 88 + mv $out/Applications/${desktopName}.app/Contents/Resources/app.asar $out/Applications/${desktopName}.app/Contents/Resources/_app.asar 89 + mkdir $out/Applications/${desktopName}.app/Contents/Resources/app.asar 90 + echo '{"name":"discord","main":"index.js"}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json 91 + echo 'require("${vencord}/patcher.js")' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/index.js 92 + '' 93 + + lib.strings.optionalString withEquicord '' 94 + mv $out/Applications/${desktopName}.app/Contents/Resources/app.asar $out/Applications/${desktopName}.app/Contents/Resources/_app.asar 95 + mkdir $out/Applications/${desktopName}.app/Contents/Resources/app.asar 96 + echo '{"name":"discord","main":"index.js"}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json 97 + echo 'require("${equicord}/desktop/patcher.js")' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/index.js 98 + '' 99 + + lib.strings.optionalString withMoonlight '' 100 + mv $out/Applications/${desktopName}.app/Contents/Resources/app.asar $out/Applications/${desktopName}.app/Contents/Resources/_app.asar 101 + mkdir $out/Applications/${desktopName}.app/Contents/Resources/app.asar 102 + echo '{"name":"discord","main":"injector.js","private": true}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json 103 + echo 'require("${moonlight}/injector.js").inject(require("path").join(__dirname, "../_app.asar"));' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/injector.js 104 + ''; 105 + 106 + passthru = { 107 + # make it possible to run disableBreakingUpdates standalone 108 + inherit disableBreakingUpdates; 109 + updateScript = ./update.py; 110 + 111 + tests = { 112 + withVencord = self.override { 113 + withVencord = true; 114 + }; 115 + withEquicord = self.override { 116 + withEquicord = true; 117 + }; 118 + withMoonlight = self.override { 119 + withMoonlight = true; 120 + }; 121 + withOpenASAR = self.override { 122 + withOpenASAR = true; 123 + }; 124 + }; 125 + }; 126 + }
+116
pkgs/discord/default.nix
··· 1 + { 2 + callPackage, 3 + fetchurl, 4 + lib, 5 + stdenv, 6 + discord, 7 + discord-ptb, 8 + discord-canary, 9 + discord-development, 10 + }: 11 + let 12 + variants = rec { 13 + x86_64-linux = { 14 + discord = rec { 15 + branch = "stable"; 16 + binaryName = desktopName; 17 + desktopName = "Discord"; 18 + self = discord; 19 + }; 20 + discord-ptb = { 21 + branch = "ptb"; 22 + binaryName = "DiscordPTB"; 23 + desktopName = "Discord PTB"; 24 + self = discord-ptb; 25 + }; 26 + discord-canary = { 27 + branch = "canary"; 28 + binaryName = "DiscordCanary"; 29 + desktopName = "Discord Canary"; 30 + self = discord-canary; 31 + }; 32 + discord-development = { 33 + branch = "development"; 34 + binaryName = "DiscordDevelopment"; 35 + desktopName = "Discord Development"; 36 + self = discord-development; 37 + }; 38 + }; 39 + x86_64-darwin = { 40 + discord = rec { 41 + branch = "stable"; 42 + binaryName = desktopName; 43 + desktopName = "Discord"; 44 + self = discord; 45 + }; 46 + discord-ptb = rec { 47 + branch = "ptb"; 48 + binaryName = desktopName; 49 + desktopName = "Discord PTB"; 50 + self = discord-ptb; 51 + }; 52 + discord-canary = rec { 53 + branch = "canary"; 54 + binaryName = desktopName; 55 + desktopName = "Discord Canary"; 56 + self = discord-canary; 57 + }; 58 + discord-development = rec { 59 + branch = "development"; 60 + binaryName = desktopName; 61 + desktopName = "Discord Development"; 62 + self = discord-development; 63 + }; 64 + }; 65 + 66 + aarch64-darwin = x86_64-darwin; 67 + default = x86_64-linux; # Used for unsupported platforms, so we can return *something* there. 68 + }; 69 + 70 + meta = { 71 + description = "All-in-one cross-platform voice and text chat for gamers"; 72 + downloadPage = "https://discordapp.com/download"; 73 + homepage = "https://discordapp.com/"; 74 + license = lib.licenses.unfree; 75 + mainProgram = "discord"; 76 + maintainers = with lib.maintainers; [ 77 + artturin 78 + FlameFlag 79 + infinidoge 80 + jopejoe1 81 + Scrumplex 82 + ]; 83 + platforms = [ 84 + "x86_64-linux" 85 + "x86_64-darwin" 86 + "aarch64-darwin" 87 + ]; 88 + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 89 + }; 90 + package = if stdenv.hostPlatform.isLinux then ./linux.nix else ./darwin.nix; 91 + 92 + sources = lib.importJSON ./sources.json; 93 + in 94 + lib.genAttrs [ "discord" "discord-ptb" "discord-canary" "discord-development" ] ( 95 + pname: 96 + let 97 + args = (variants.${stdenv.hostPlatform.system} or variants.default).${pname}; 98 + platformName = if stdenv.hostPlatform.isDarwin then "osx" else "linux"; 99 + source = sources."${platformName}-${args.branch}"; 100 + in 101 + callPackage package ( 102 + args 103 + // { 104 + inherit pname; 105 + inherit (source) version; 106 + 107 + src = fetchurl { 108 + inherit (source) url hash; 109 + }; 110 + 111 + meta = meta // { 112 + mainProgram = args.binaryName; 113 + }; 114 + } 115 + ) 116 + )
+56
pkgs/discord/disable-breaking-updates.py
··· 1 + #!@pythonInterpreter@ 2 + # slightly tweaked from the script created by @lionirdeadman 3 + # https://github.com/flathub/com.discordapp.Discord/blob/master/disable-breaking-updates.py 4 + """ 5 + Disable breaking updates which will prompt users to download a deb or tar file 6 + and lock them out of Discord making the program unusable. 7 + 8 + This will dramatically improve the experience : 9 + 10 + 1) The maintainer doesn't need to be worried at all times of an update which will break Discord. 11 + 2) People will not be locked out of the program while the maintainer runs to update it. 12 + 13 + """ 14 + 15 + import json 16 + import os 17 + import sys 18 + from pathlib import Path 19 + 20 + config_home = { 21 + "darwin": os.path.join(os.path.expanduser("~"), "Library", "Application Support"), 22 + "linux": os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.path.expanduser("~"), ".config") 23 + }.get(sys.platform, None) 24 + 25 + if config_home is None: 26 + print("[Nix] Unsupported operating system.") 27 + sys.exit(1) 28 + 29 + config_dir_name = "@configDirName@".replace(" ", "") if sys.platform == "darwin" else "@configDirName@" 30 + 31 + settings_path = Path(f"{config_home}/{config_dir_name}/settings.json") 32 + settings_path_temp = Path(f"{config_home}/{config_dir_name}/settings.json.tmp") 33 + 34 + if os.path.exists(settings_path): 35 + with settings_path.open(encoding="utf-8") as settings_file: 36 + try: 37 + settings = json.load(settings_file) 38 + except json.JSONDecodeError: 39 + print("[Nix] settings.json is malformed, letting Discord fix itself") 40 + sys.exit(0) 41 + else: 42 + settings = {} 43 + 44 + if settings.get("SKIP_HOST_UPDATE"): 45 + print("[Nix] Disabling updates already done") 46 + else: 47 + skip_host_update = {"SKIP_HOST_UPDATE": True} 48 + settings.update(skip_host_update) 49 + 50 + os.makedirs(os.path.dirname(settings_path), exist_ok=True) 51 + 52 + with settings_path_temp.open("w", encoding="utf-8") as settings_file_temp: 53 + json.dump(settings, settings_file_temp, indent=2) 54 + 55 + settings_path_temp.rename(settings_path) 56 + print("[Nix] Disabled updates")
+326
pkgs/discord/linux.nix
··· 1 + { 2 + pname, 3 + version, 4 + src, 5 + meta, 6 + binaryName, 7 + desktopName, 8 + self, 9 + buildFHSEnv, 10 + makeDesktopItem, 11 + lib, 12 + stdenv, 13 + alsa-lib, 14 + at-spi2-atk, 15 + at-spi2-core, 16 + atk, 17 + cairo, 18 + cups, 19 + dbus, 20 + expat, 21 + fontconfig, 22 + freetype, 23 + gdk-pixbuf, 24 + glib, 25 + gtk3, 26 + libcxx, 27 + glibc, 28 + libdrm, 29 + libglvnd, 30 + libnotify, 31 + libpulseaudio, 32 + libuuid, 33 + libva, 34 + libX11, 35 + libXScrnSaver, 36 + libXcomposite, 37 + libXcursor, 38 + libXdamage, 39 + libXext, 40 + libXfixes, 41 + libXi, 42 + libXrandr, 43 + libXrender, 44 + libXtst, 45 + libxcb, 46 + libxshmfence, 47 + libgbm, 48 + nspr, 49 + nss, 50 + pango, 51 + systemdLibs, 52 + libappindicator-gtk3, 53 + libdbusmenu, 54 + writeScript, 55 + pipewire, 56 + libxkbcommon, 57 + mesa, 58 + python3, 59 + runCommand, 60 + libunity, 61 + speechd-minimal, 62 + wayland, 63 + branch, 64 + withOpenASAR ? false, 65 + openasar, 66 + withVencord ? false, 67 + vencord, 68 + withEquicord ? false, 69 + equicord, 70 + withMoonlight ? false, 71 + moonlight, 72 + withTTS ? true, 73 + enableAutoscroll ? false, 74 + # Disabling this would normally break Discord. 75 + # The intended use-case for this is when SKIP_HOST_UPDATE is enabled via other means, 76 + # for example if a settings.json is linked declaratively (e.g., with home-manager). 77 + disableUpdates ? true, 78 + # Make disabling the Chromium sandbox opt-in; recent Electron no longer needs this. 79 + disableChromiumSandbox ? false, 80 + commandLineArgs ? "", 81 + }: 82 + 83 + let 84 + discordMods = [ 85 + withVencord 86 + withEquicord 87 + withMoonlight 88 + ]; 89 + enabledDiscordModsCount = builtins.length (lib.filter (x: x) discordMods); 90 + 91 + disableBreakingUpdates = 92 + runCommand "disable-breaking-updates.py" 93 + { 94 + pythonInterpreter = "${python3.interpreter}"; 95 + configDirName = lib.toLower binaryName; 96 + meta.mainProgram = "disable-breaking-updates.py"; 97 + } 98 + '' 99 + mkdir -p $out/bin 100 + cp ${./disable-breaking-updates.py} $out/bin/disable-breaking-updates.py 101 + substituteAllInPlace $out/bin/disable-breaking-updates.py 102 + chmod +x $out/bin/disable-breaking-updates.py 103 + ''; 104 + 105 + discordDir = stdenv.mkDerivation { 106 + name = "${pname}-${version}-dir"; 107 + inherit src; 108 + 109 + dontPatchELF = true; 110 + dontStrip = true; 111 + dontPatchShebangs = true; 112 + 113 + dontBuild = true; 114 + dontConfigure = true; 115 + 116 + installPhase = '' 117 + runHook preInstall 118 + 119 + mkdir -p $out/opt/${binaryName} 120 + cp -a ./. $out/opt/${binaryName} 121 + cd $out/opt/${binaryName} 122 + 123 + ${lib.optionalString withOpenASAR '' 124 + cp -f ${openasar} resources/app.asar 125 + ''} 126 + ${lib.optionalString withVencord '' 127 + mv resources/app.asar resources/_app.asar 128 + mkdir resources/app.asar 129 + echo '{"name":"discord","main":"index.js"}' > resources/app.asar/package.json 130 + echo 'require("${vencord}/patcher.js")' > resources/app.asar/index.js 131 + ''} 132 + ${lib.optionalString withEquicord '' 133 + mv resources/app.asar resources/_app.asar 134 + mkdir resources/app.asar 135 + echo '{"name":"discord","main":"index.js"}' > resources/app.asar/package.json 136 + echo 'require("${equicord}/desktop/patcher.js")' > resources/app.asar/index.js 137 + ''} 138 + ${lib.optionalString withMoonlight '' 139 + mv resources/app.asar resources/_app.asar 140 + mkdir resources/app 141 + echo '{"name":"discord","main":"injector.js","private": true}' > resources/app/package.json 142 + echo 'require("${moonlight}/injector.js").inject(require("path").join(__dirname, "../_app.asar"));' > resources/app/injector.js 143 + ''} 144 + 145 + runHook postInstall 146 + ''; 147 + }; 148 + 149 + fhsEnv = buildFHSEnv { 150 + name = "${pname}-fhs"; 151 + 152 + targetPkgs = 153 + pkgs: 154 + [ 155 + libcxx 156 + glibc 157 + systemdLibs 158 + libpulseaudio 159 + libdrm 160 + libgbm 161 + stdenv.cc.cc.lib 162 + alsa-lib 163 + atk 164 + at-spi2-atk 165 + at-spi2-core 166 + cairo 167 + cups 168 + dbus 169 + expat 170 + fontconfig 171 + freetype 172 + gdk-pixbuf 173 + glib 174 + gtk3 175 + libglvnd 176 + libnotify 177 + libX11 178 + libXcomposite 179 + libXcursor 180 + libXdamage 181 + libXext 182 + libXfixes 183 + libXi 184 + libXrandr 185 + libXrender 186 + libXtst 187 + libXScrnSaver 188 + libxcb 189 + libxshmfence 190 + libuuid 191 + libva 192 + nspr 193 + nss 194 + pango 195 + pipewire 196 + libxkbcommon 197 + mesa 198 + libappindicator-gtk3 199 + libdbusmenu 200 + libunity 201 + wayland 202 + ] 203 + ++ lib.optionals withTTS [ speechd-minimal ]; 204 + 205 + multiPkgs = pkgs: [ 206 + alsa-lib 207 + libpulseaudio 208 + ]; 209 + 210 + runScript = writeScript "${pname}-wrapper" '' 211 + #!${stdenv.shell} 212 + set -euo pipefail 213 + 214 + ${lib.optionalString disableUpdates '' 215 + ${lib.getExe disableBreakingUpdates} 216 + ''} 217 + 218 + if [[ -n "''${XDG_DATA_DIRS:-}" ]]; then 219 + export XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}/:''${XDG_DATA_DIRS}" 220 + else 221 + export XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}/" 222 + fi 223 + 224 + extraArgs=() 225 + if [[ -n "''${NIXOS_OZONE_WL:-}" && -n "''${WAYLAND_DISPLAY:-}" ]]; then 226 + extraArgs+=(--ozone-platform=wayland --enable-features=WaylandWindowDecorations --enable-wayland-ime=true) 227 + fi 228 + 229 + ${lib.optionalString enableAutoscroll '' 230 + extraArgs+=(--enable-blink-features=MiddleClickAutoscroll) 231 + ''} 232 + 233 + ${lib.optionalString disableChromiumSandbox '' 234 + extraArgs+=(--no-sandbox --disable-gpu-sandbox) 235 + ''} 236 + 237 + ${lib.optionalString withTTS '' 238 + if [[ "''${NIXOS_SPEECH:-default}" != "False" ]]; then 239 + export NIXOS_SPEECH=True 240 + extraArgs+=(--enable-speech-dispatcher) 241 + else 242 + unset NIXOS_SPEECH 243 + fi 244 + ''} 245 + 246 + cmd=( 247 + ${discordDir}/opt/${binaryName}/${binaryName} 248 + ) 249 + cmd+=("''${extraArgs[@]}") 250 + ${lib.optionalString (commandLineArgs != "") '' 251 + cmd+=(${lib.escapeShellArg commandLineArgs}) 252 + ''} 253 + 254 + exec "''${cmd[@]}" "$@" 255 + ''; 256 + }; 257 + 258 + desktopItem = makeDesktopItem { 259 + name = pname; 260 + exec = binaryName; 261 + icon = pname; 262 + inherit desktopName; 263 + genericName = meta.description; 264 + categories = [ 265 + "Network" 266 + "InstantMessaging" 267 + ]; 268 + mimeTypes = [ "x-scheme-handler/discord" ]; 269 + startupWMClass = "discord"; 270 + }; 271 + in 272 + assert lib.assertMsg ( 273 + enabledDiscordModsCount <= 1 274 + ) "discord: Only one of Vencord, Equicord or Moonlight can be enabled at the same time"; 275 + stdenv.mkDerivation { 276 + inherit 277 + pname 278 + version 279 + meta 280 + ; 281 + 282 + dontUnpack = true; 283 + dontBuild = true; 284 + dontConfigure = true; 285 + 286 + installPhase = '' 287 + runHook preInstall 288 + 289 + mkdir -p $out/bin 290 + mkdir -p $out/share/applications 291 + mkdir -p $out/share/pixmaps 292 + mkdir -p $out/share/icons/hicolor/256x256/apps 293 + 294 + ln -s ${fhsEnv}/bin/${pname}-fhs $out/bin/${binaryName} 295 + # Without || true the install would fail on case-insensitive filesystems 296 + ln -s ${fhsEnv}/bin/${pname}-fhs $out/bin/${lib.strings.toLower binaryName} || true 297 + 298 + ln -s ${discordDir}/opt/${binaryName}/discord.png $out/share/pixmaps/${pname}.png 299 + ln -s ${discordDir}/opt/${binaryName}/discord.png $out/share/icons/hicolor/256x256/apps/${pname}.png 300 + 301 + ln -s ${desktopItem}/share/applications/${pname}.desktop $out/share/applications/ 302 + 303 + runHook postInstall 304 + ''; 305 + 306 + passthru = { 307 + # make it possible to run disableBreakingUpdates standalone 308 + inherit disableBreakingUpdates; 309 + updateScript = ./update.py; 310 + 311 + tests = { 312 + withVencord = self.override { 313 + withVencord = true; 314 + }; 315 + withEquicord = self.override { 316 + withEquicord = true; 317 + }; 318 + withMoonlight = self.override { 319 + withMoonlight = true; 320 + }; 321 + withOpenASAR = self.override { 322 + withOpenASAR = true; 323 + }; 324 + }; 325 + }; 326 + }
+42
pkgs/discord/sources.json
··· 1 + { 2 + "linux-canary": { 3 + "hash": "sha256-hhrjKkXnhHm8gntPMGjst1eLu8xqube73lnbW5TEINY=", 4 + "url": "https://canary.dl2.discordapp.net/apps/linux/0.0.819/discord-canary-0.0.819.tar.gz", 5 + "version": "0.0.819" 6 + }, 7 + "linux-development": { 8 + "hash": "sha256-1zlRLOxWUA7QNAMi2SRWCdnx1dbmkwWQSCl7Pyexoac=", 9 + "url": "https://development.dl2.discordapp.net/apps/linux/0.0.93/discord-development-0.0.93.tar.gz", 10 + "version": "0.0.93" 11 + }, 12 + "linux-ptb": { 13 + "hash": "sha256-uz3QNIDzmB/4aLNRNgB1wzpNJlc8ous8aUvcqGaHE7c=", 14 + "url": "https://ptb.dl2.discordapp.net/apps/linux/0.0.168/discord-ptb-0.0.168.tar.gz", 15 + "version": "0.0.168" 16 + }, 17 + "linux-stable": { 18 + "hash": "sha256-PN1E8GjVopEPGW9ISb0y1Lo7nnj30CXylW0nTR1Pc6U=", 19 + "url": "https://stable.dl2.discordapp.net/apps/linux/0.0.117/discord-0.0.117.tar.gz", 20 + "version": "0.0.117" 21 + }, 22 + "osx-canary": { 23 + "hash": "sha256-bBimaZYUjkd7MwiqJiNjgQpiBOEUAVhTFOoQ/cnR+K0=", 24 + "url": "https://canary.dl2.discordapp.net/apps/osx/0.0.923/DiscordCanary.dmg", 25 + "version": "0.0.923" 26 + }, 27 + "osx-development": { 28 + "hash": "sha256-x4i/bbaR4XjzyZGkVerUl8oxxhm01A+2tpN+UEtKwwc=", 29 + "url": "https://development.dl2.discordapp.net/apps/osx/0.0.105/DiscordDevelopment.dmg", 30 + "version": "0.0.105" 31 + }, 32 + "osx-ptb": { 33 + "hash": "sha256-Yk9q4GageNb/Tt+R1SGwWnJBRrjG4QIO6qYLjhak460=", 34 + "url": "https://ptb.dl2.discordapp.net/apps/osx/0.0.200/DiscordPTB.dmg", 35 + "version": "0.0.200" 36 + }, 37 + "osx-stable": { 38 + "hash": "sha256-k4S9UyO2GLmT/nnR1BUcUVjhFvxjGeQv2tbuZzEh8Ro=", 39 + "url": "https://stable.dl2.discordapp.net/apps/osx/0.0.369/Discord.dmg", 40 + "version": "0.0.369" 41 + } 42 + }
+110
pkgs/discord/update.py
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i python3 -p python3 3 + 4 + from enum import StrEnum 5 + from typing import List, Tuple 6 + from subprocess import PIPE, Popen 7 + import json 8 + import urllib.request 9 + import re 10 + import os.path 11 + 12 + SRC_NAME = "source" 13 + 14 + VERSION_REGEX = re.compile(r"\/([\d.]+)\/") 15 + 16 + 17 + class Platform(StrEnum): 18 + LINUX = "linux" 19 + MACOS = "osx" 20 + 21 + def format_type(self): 22 + if self.value == Platform.LINUX.value: 23 + return "tar.gz" 24 + elif self.value == Platform.MACOS.value: 25 + return "dmg" 26 + raise RuntimeError("Invalid platform") 27 + 28 + 29 + class Branch(StrEnum): 30 + STABLE = "stable" 31 + PTB = "ptb" 32 + CANARY = "canary" 33 + DEVELOPMENT = "development" 34 + 35 + 36 + Variant = Tuple[Platform, Branch] 37 + 38 + 39 + def serialize_variant(variant: Variant) -> str: 40 + platform, branch = variant 41 + return f"{platform}-{branch}" 42 + 43 + 44 + def url_for_variant(variant: Variant) -> str: 45 + platform, branch = variant 46 + 47 + return f"https://discord.com/api/download/{branch.value}?platform={platform.value}&format={platform.format_type()}" 48 + 49 + 50 + def fetch_redirect_url(url: str) -> str: 51 + headers = {"user-agent": "Nixpkgs-Discord-Update-Script/0.0.0"} 52 + # note that urllib follows redirects by default. So we can extract the final url from the response object 53 + req = urllib.request.Request(url, headers=headers) 54 + with urllib.request.urlopen(req) as response: 55 + return response.url 56 + 57 + 58 + def version_from_url(url: str) -> str: 59 + matches = VERSION_REGEX.search(url) 60 + assert matches, f"Url {url} must contain version number" 61 + version = matches.group(1) 62 + assert version 63 + return version 64 + 65 + 66 + def prefetch(url: str) -> str: 67 + with Popen(["nix-prefetch-url", "--name", "source", url], stdout=PIPE) as p: 68 + assert p.stdout 69 + b32_hash = p.stdout.read().decode("utf-8").strip() 70 + with Popen( 71 + ["nix-hash", "--to-sri", "--type", "sha256", b32_hash], stdout=PIPE 72 + ) as p: 73 + assert p.stdout 74 + sri_hash = p.stdout.read().decode("utf-8").strip() 75 + return sri_hash 76 + 77 + 78 + def main(): 79 + variants: List[Variant] = [ 80 + (Platform.LINUX, Branch.STABLE), 81 + (Platform.LINUX, Branch.PTB), 82 + (Platform.LINUX, Branch.CANARY), 83 + (Platform.LINUX, Branch.DEVELOPMENT), 84 + (Platform.MACOS, Branch.STABLE), 85 + (Platform.MACOS, Branch.PTB), 86 + (Platform.MACOS, Branch.CANARY), 87 + (Platform.MACOS, Branch.DEVELOPMENT), 88 + ] 89 + 90 + sources = {} 91 + 92 + for v in variants: 93 + url = url_for_variant(v) 94 + url = fetch_redirect_url(url) 95 + version = version_from_url(url) 96 + sri_hash = prefetch(url) 97 + 98 + sources[serialize_variant(v)] = { 99 + "url": url, 100 + "version": version, 101 + "hash": sri_hash, 102 + } 103 + 104 + with open(os.path.join(os.path.dirname(__file__), "sources.json"), "w") as f: 105 + json.dump(sources, f, indent=2, sort_keys=True) 106 + f.write("\n") 107 + 108 + 109 + if __name__ == "__main__": 110 + main()
+15
pkgs/graalvm-ce/default.nix
··· 1 + { 2 + stdenv, 3 + fetchurl, 4 + graalvmPackages, 5 + }: 6 + 7 + let 8 + version = (import ./hashes.nix).version; 9 + hashes = (import ./hashes.nix).hashes; 10 + in 11 + graalvmPackages.buildGraalvm { 12 + inherit version; 13 + src = fetchurl hashes.${stdenv.system}; 14 + meta.platforms = builtins.attrNames hashes; 15 + }
+22
pkgs/graalvm-ce/hashes.nix
··· 1 + # Generated by update.sh script 2 + { 3 + "version" = "21.0.2"; 4 + "hashes" = { 5 + "aarch64-linux" = { 6 + sha256 = "0yndazvc4kyr9widfn8ql5vd57m4m5inqz2wcpsarw38rs8ycjx3"; 7 + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-aarch64_bin.tar.gz"; 8 + }; 9 + "x86_64-linux" = { 10 + sha256 = "0j5ffszcaqv3fq159hyb611jm8w1q4n1cywmbd7vi69smad0cj5h"; 11 + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz"; 12 + }; 13 + "x86_64-darwin" = { 14 + sha256 = "1qfrn1068idnkzd6mdpw1x17sqrj59rz9avphj8225sxlhzsk2ks"; 15 + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_macos-x64_bin.tar.gz"; 16 + }; 17 + "aarch64-darwin" = { 18 + sha256 = "1dssa3nhix7bqygdkkfp0b9myjg5f91dlgm8mf6r7qf7mj9klpji"; 19 + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_macos-aarch64_bin.tar.gz"; 20 + }; 21 + }; 22 + }