···182182 # Menu configuration
183183 #
184184185185+ # Search using a "marker file"
186186+ search --set=root --file /EFI/nixos-installer-image
187187+185188 insmod gfxterm
186189 insmod png
187190 set gfxpayload=keep
191191+ set gfxmode=${concatStringsSep "," [
192192+ # GRUB will use the first valid mode listed here.
193193+ # `auto` will sometimes choose the smallest valid mode it detects.
194194+ # So instead we'll list a lot of possibly valid modes :/
195195+ #"3840x2160"
196196+ #"2560x1440"
197197+ "1920x1080"
198198+ "1366x768"
199199+ "1280x720"
200200+ "1024x768"
201201+ "800x600"
202202+ "auto"
203203+ ]}
188204189205 # Fonts can be loaded?
190206 # (This font is assumed to always be provided as a fallback by NixOS)
191191- if loadfont /EFI/boot/unicode.pf2; then
207207+ if loadfont (\$root)/EFI/boot/unicode.pf2; then
192208 set with_fonts=true
193209 fi
194210 if [ "\$textmode" != "true" -a "\$with_fonts" == "true" ]; then
···212228 ${ # When there is a theme configured, use it, otherwise use the background image.
213229 if config.isoImage.grubTheme != null then ''
214230 # Sets theme.
215215- set theme=/EFI/boot/grub-theme/theme.txt
231231+ set theme=(\$root)/EFI/boot/grub-theme/theme.txt
216232 # Load theme fonts
217217- $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n")
233233+ $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (\$root)/EFI/boot/grub-theme/%P\n")
218234 '' else ''
219219- if background_image /EFI/boot/efi-background.png; then
235235+ if background_image (\$root)/EFI/boot/efi-background.png; then
220236 # Black background means transparent background when there
221237 # is a background image set... This seems undocumented :(
222238 set color_normal=black/black
···238254 strictDeps = true;
239255 } ''
240256 mkdir -p $out/EFI/boot/
257257+258258+ # Add a marker so GRUB can find the filesystem.
259259+ touch $out/EFI/nixos-installer-image
241260242261 # ALWAYS required modules.
243262 MODULES="fat iso9660 part_gpt part_msdos \
···294313 ${grubMenuCfg}
295314296315 hiddenentry 'Text mode' --hotkey 't' {
297297- loadfont /EFI/boot/unicode.pf2
316316+ loadfont (\$root)/EFI/boot/unicode.pf2
298317 set textmode=true
299318 terminal_output gfxterm console
300319 }
301320 hiddenentry 'GUI mode' --hotkey 'g' {
302302- $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n")
321321+ $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (\$root)/EFI/boot/grub-theme/%P\n")
303322 set textmode=false
304323 terminal_output gfxterm
305324 }
···370389 ${lib.optionalString (refindBinary != null) ''
371390 # GRUB apparently cannot do "chainloader" operations on "CD".
372391 if [ "\$root" != "cd0" ]; then
392392+ # Force root to be the FAT partition
393393+ # Otherwise it breaks rEFInd's boot
394394+ search --set=root --no-floppy --fs-uuid 1234-5678
373395 menuentry 'rEFInd' --class refind {
374374- # \$root defaults to the drive the EFI is found on.
375396 chainloader (\$root)/EFI/boot/${refindBinary}
376397 }
377398 fi
···403424 mkdir ./boot
404425 cp -p "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}" \
405426 "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}" ./boot/
406406- touch --date=@0 ./EFI ./boot
427427+428428+ # Rewrite dates for everything in the FS
429429+ find . -exec touch --date=2000-01-01 {} +
407430408431 usage_size=$(du -sb --apparent-size . | tr -cd '[:digit:]')
409432 # Make the image 110% as big as the files need to make up for FAT overhead
-21
pkgs/applications/editors/sublime/3/common.nix
···2233{ fetchurl, lib, stdenv, xorg, glib, glibcLocales, gtk3, cairo, pango, libredirect, makeWrapper, wrapGAppsHook
44, pkexecPath ? "/run/wrappers/bin/pkexec"
55-, writeScript, common-updater-scripts, curl, gnugrep
65, openssl, bzip2, bash, unzip, zip
76}:
87···125124 size=$(basename $directory)
126125 mkdir -p "$out/share/icons/hicolor/$size/apps"
127126 ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
128128- done
129129- '';
130130-131131- passthru.updateScript = writeScript "${pname}-update-script" ''
132132- #!${stdenv.shell}
133133- set -o errexit
134134- PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep ]}
135135-136136- latestVersion=$(curl -s ${versionUrl})
137137-138138- if [[ "${buildVersion}" = "$latestVersion" ]]; then
139139- echo "The new version same as the old version."
140140- exit 0
141141- fi
142142-143143- for platform in ${lib.concatStringsSep " " meta.platforms}; do
144144- # The script will not perform an update when the version attribute is up to date from previous platform run
145145- # We need to clear it before each run
146146- update-source-version ${packageAttribute}.${primaryBinary} 0 0000000000000000000000000000000000000000000000000000000000000000 --file=${versionFile} --version-key=buildVersion --system=$platform
147147- update-source-version ${packageAttribute}.${primaryBinary} $latestVersion --file=${versionFile} --version-key=buildVersion --system=$platform
148127 done
149128 '';
150129
+148
pkgs/applications/editors/sublime/4/common.nix
···11+{ buildVersion, aarch64sha256, x64sha256, dev ? false }:
22+33+{ fetchurl, stdenv, lib, xorg, glib, libglvnd, glibcLocales, gtk3, cairo, pango, makeWrapper, wrapGAppsHook
44+, writeShellScript, common-updater-scripts, curl
55+, openssl, bzip2, bash, unzip, zip
66+}:
77+88+let
99+ pname = "sublimetext4";
1010+ packageAttribute = "sublime4${lib.optionalString dev "-dev"}";
1111+ binaries = [ "sublime_text" "plugin_host-3.3" "plugin_host-3.8" "crash_reporter" ];
1212+ primaryBinary = "sublime_text";
1313+ primaryBinaryAliases = [ "subl" "sublime" "sublime4" ];
1414+ downloadUrl = "https://download.sublimetext.com/sublime_text_build_${buildVersion}_${arch}.tar.xz";
1515+ versionUrl = "https://download.sublimetext.com/latest/${if dev then "dev" else "stable"}";
1616+ versionFile = builtins.toString ./packages.nix;
1717+ archSha256 = {
1818+ "aarch64-linux" = aarch64sha256;
1919+ "x86_64-linux" = x64sha256;
2020+ }.${stdenv.hostPlatform.system};
2121+ arch = {
2222+ "aarch64-linux" = "arm64";
2323+ "x86_64-linux" = "x64";
2424+ }.${stdenv.hostPlatform.system};
2525+2626+ libPath = lib.makeLibraryPath [ xorg.libX11 xorg.libXtst glib libglvnd openssl gtk3 cairo pango ];
2727+in let
2828+ binaryPackage = stdenv.mkDerivation {
2929+ pname = "${pname}-bin";
3030+ version = buildVersion;
3131+3232+ src = fetchurl {
3333+ url = downloadUrl;
3434+ sha256 = archSha256;
3535+ };
3636+3737+ dontStrip = true;
3838+ dontPatchELF = true;
3939+ buildInputs = [ glib gtk3 ]; # for GSETTINGS_SCHEMAS_PATH
4040+ nativeBuildInputs = [ zip unzip makeWrapper wrapGAppsHook ];
4141+4242+ # make exec.py in Default.sublime-package use own bash with an LD_PRELOAD instead of "/bin/bash"
4343+ patchPhase = ''
4444+ runHook prePatch
4545+4646+ # TODO: Should not be necessary even in 3
4747+ mkdir Default.sublime-package-fix
4848+ ( cd Default.sublime-package-fix
4949+ unzip -q ../Packages/Default.sublime-package
5050+ substituteInPlace "exec.py" --replace \
5151+ "[\"/bin/bash\"" \
5252+ "[\"$out/sublime_bash\""
5353+ zip -q ../Packages/Default.sublime-package **/*
5454+ )
5555+ rm -r Default.sublime-package-fix
5656+5757+ runHook postPatch
5858+ '';
5959+6060+ buildPhase = ''
6161+ runHook preBuild
6262+6363+ for binary in ${ builtins.concatStringsSep " " binaries }; do
6464+ patchelf \
6565+ --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
6666+ --set-rpath ${libPath}:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \
6767+ $binary
6868+ done
6969+7070+ # Rewrite pkexec argument. Note that we cannot delete bytes in binary.
7171+ sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' ${primaryBinary}
7272+7373+ runHook postBuild
7474+ '';
7575+7676+ installPhase = ''
7777+ runHook preInstall
7878+7979+ mkdir -p $out
8080+ cp -r * $out/
8181+8282+ # We can't just call /usr/bin/env bash because a relocation error occurs
8383+ # when trying to run a build from within Sublime Text
8484+ ln -s ${bash}/bin/bash $out/sublime_bash
8585+8686+ runHook postInstall
8787+ '';
8888+8989+ dontWrapGApps = true; # non-standard location, need to wrap the executables manually
9090+9191+ postFixup = ''
9292+ sed -i 's#/usr/bin/pkexec#pkexec\x00\x00\x00\x00\x00\x00\x00\x00\x00#g' "$out/${primaryBinary}"
9393+9494+ wrapProgram $out/${primaryBinary} \
9595+ --set LOCALE_ARCHIVE "${glibcLocales.out}/lib/locale/locale-archive" \
9696+ "''${gappsWrapperArgs[@]}"
9797+ '';
9898+ };
9999+in stdenv.mkDerivation (rec {
100100+ inherit pname;
101101+ version = buildVersion;
102102+103103+ phases = [ "installPhase" ];
104104+105105+ ${primaryBinary} = binaryPackage;
106106+107107+ nativeBuildInputs = [ makeWrapper ];
108108+109109+ installPhase = ''
110110+ mkdir -p "$out/bin"
111111+ makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
112112+ '' + builtins.concatStringsSep "" (map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases) + ''
113113+ mkdir -p "$out/share/applications"
114114+ substitute "''$${primaryBinary}/${primaryBinary}.desktop" "$out/share/applications/${primaryBinary}.desktop" --replace "/opt/${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
115115+ for directory in ''$${primaryBinary}/Icon/*; do
116116+ size=$(basename $directory)
117117+ mkdir -p "$out/share/icons/hicolor/$size/apps"
118118+ ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
119119+ done
120120+ '';
121121+122122+ passthru.updateScript = writeShellScript "${pname}-update-script" ''
123123+ set -o errexit
124124+ PATH=${lib.makeBinPath [ common-updater-scripts curl ]}
125125+126126+ latestVersion=$(curl -s ${versionUrl})
127127+128128+ if [[ "${buildVersion}" = "$latestVersion" ]]; then
129129+ echo "The new version same as the old version."
130130+ exit 0
131131+ fi
132132+133133+ for platform in ${lib.concatStringsSep " " meta.platforms}; do
134134+ # The script will not perform an update when the version attribute is up to date from previous platform run
135135+ # We need to clear it before each run
136136+ update-source-version ${packageAttribute}.${primaryBinary} 0 0000000000000000000000000000000000000000000000000000000000000000 --file=${versionFile} --version-key=buildVersion --system=$platform
137137+ update-source-version ${packageAttribute}.${primaryBinary} $latestVersion --file=${versionFile} --version-key=buildVersion --system=$platform
138138+ done
139139+ '';
140140+141141+ meta = with lib; {
142142+ description = "Sophisticated text editor for code, markup and prose";
143143+ homepage = "https://www.sublimetext.com/";
144144+ maintainers = with maintainers; [ jtojnar wmertens demin-dmitriy zimbatm ];
145145+ license = licenses.unfree;
146146+ platforms = [ "aarch64-linux" "x86_64-linux" ];
147147+ };
148148+})