Files
Emily fdb820602b treewide: drop simple x86_64-darwin mentions
To reproduce:

    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: nix-x86_64-darwin
          language: nix
          rule:
            any:
              - pattern: "\"x86_64-darwin\""
                kind: list_expression > string_expression
              - pattern:
                  context: "{ \"x86_64-darwin\" = $EXPR; }"
                  selector: binding
              - pattern:
                  context: "{ x86_64-darwin = $EXPR; }"
                  selector: binding
          fix:
            template: ""
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-first-x86_64-darwin
          language: json
          rule:
            kind: object > pair:nth-child(1)
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandEnd: { regex: "," }
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-x86_64-darwin
          language: json
          rule:
            kind: object > pair
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandStart: { regex: "," }
        ' pkgs
    $ git restore pkgs/by-name/om/omnix/package.nix
    $ git diff --name-only -z \
        | nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
            -c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
    $ treefmt
2026-07-15 03:58:16 +01:00

128 lines
3.2 KiB
Nix

{
lib,
stdenv,
fetchzip,
fetchurl,
autoPatchelfHook,
copyDesktopItems,
makeWrapper,
makeDesktopItem,
cups,
qt6,
undmg,
xkeyboard-config,
writeScript,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "010editor";
version = "16.0.4";
src = finalAttrs.passthru.srcs.${stdenv.hostPlatform.system};
sourceRoot = ".";
strictDeps = true;
dontBuild = true;
dontConfigure = true;
nativeBuildInputs =
lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
copyDesktopItems
makeWrapper
qt6.wrapQtAppsHook
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ undmg ];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
cups
qt6.qtbase
qt6.qtwayland
xkeyboard-config
];
installPhase =
let
darwinInstall = ''
mkdir -p $out/Applications
cp -R *.app $out/Applications
'';
linuxInstall = ''
mkdir -p $out/opt && cp -ar source/* $out/opt
# Wrap binary: clean env, fix XKB lookup
makeWrapper $out/opt/010editor $out/bin/010editor \
--unset QT_PLUGIN_PATH \
--set XKB_CONFIG_ROOT ${xkeyboard-config}/share/X11/xkb
# Install icon
install -D $out/opt/010_icon_128x128.png $out/share/icons/hicolor/128x128/apps/010.png
'';
in
''
runHook preInstall
${if stdenv.hostPlatform.isDarwin then darwinInstall else linuxInstall}
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = "010editor";
exec = "010editor %f";
icon = "010";
desktopName = "010 Editor";
genericName = "Text and hex editor";
categories = [ "Development" ];
mimeTypes = [
"text/html"
"text/plain"
"text/x-c++hdr"
"text/x-c++src"
"text/xml"
];
})
];
passthru.srcs = {
x86_64-linux = fetchzip {
url = "https://download.sweetscape.com/010EditorLinux64Installer${finalAttrs.version}.tar.gz";
hash = "sha256-M1D2Bmi45sYiB0Ci+0X0AxyIeR+On60xt4jP1Jsy5tA=";
};
aarch64-darwin = fetchurl {
url = "https://download.sweetscape.com/010EditorMacARM64Installer${finalAttrs.version}.dmg";
hash = "sha256-+yU5JdPNS2BfiZLsBLyyC+ieVNqbIWba3teBlTIDWtk=";
};
};
passthru = {
updateScript = writeScript "update-010editor" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl pcre2 common-updater-scripts
set -eu -o pipefail
# Expect the text in format of "Version: major.minor.patchlevel
newVersion="$(curl -s https://sweetscape.com/download/010editor/ | pcre2grep -o1 'Version: ([0-9]+\.[0-9]+\.[0-9]+)' | sort -u)"
for platform in ${toString finalAttrs.meta.platforms}; do
update-source-version _010editor "$newVersion" --source-key=passthru.srcs.$platform --ignore-same-version
done
'';
};
meta = {
description = "Text and hex editor";
homepage = "https://www.sweetscape.com/010editor/";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ eljamm ];
platforms = [
"aarch64-darwin"
"x86_64-linux"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
mainProgram = "010editor";
};
})