From 3618ec6a0ad2cd68599694eb11b1f400e68c4f20 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 09:33:14 +0200 Subject: [PATCH 1/7] sile: nixfmt; move to pkgs/by-name --- .../si/sile/package.nix} | 134 ++++++++++-------- pkgs/top-level/all-packages.nix | 4 - 2 files changed, 77 insertions(+), 61 deletions(-) rename pkgs/{tools/typesetting/sile/default.nix => by-name/si/sile/package.nix} (62%) diff --git a/pkgs/tools/typesetting/sile/default.nix b/pkgs/by-name/si/sile/package.nix similarity index 62% rename from pkgs/tools/typesetting/sile/default.nix rename to pkgs/by-name/si/sile/package.nix index 49dbc74422e7a..a3c4f0bc11438 100644 --- a/pkgs/tools/typesetting/sile/default.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -1,47 +1,54 @@ -{ lib -, stdenv -, darwin -, fetchurl -, makeWrapper -, pkg-config -, poppler_utils -, gitMinimal -, harfbuzz -, icu -, fontconfig -, lua -, libiconv -, makeFontsConf -, gentium -, runCommand -, sile +{ + lib, + stdenv, + darwin, + fetchurl, + makeWrapper, + pkg-config, + poppler_utils, + gitMinimal, + harfbuzz, + icu, + fontconfig, + lua, + libiconv, + makeFontsConf, + gentium, + runCommand, + sile, }: let - luaEnv = lua.withPackages(ps: with ps; [ - cassowary - cldr - cosmo - fluent - linenoise - loadkit - lpeg - lua-zlib - lua_cliargs - luaepnf - luaexpat - luafilesystem - luarepl - luasec - luasocket - luautf8 - penlight - vstruct - ] ++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [ - bit32 - ] ++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [ - compat53 - ]); + luaEnv = lua.withPackages ( + ps: + with ps; + [ + cassowary + cldr + cosmo + fluent + linenoise + loadkit + lpeg + lua-zlib + lua_cliargs + luaepnf + luaexpat + luafilesystem + luarepl + luasec + luasocket + luautf8 + penlight + vstruct + ] + ++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [ + bit32 + ] + ++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [ + compat53 + ] + ); in stdenv.mkDerivation (finalAttrs: { @@ -69,9 +76,7 @@ stdenv.mkDerivation (finalAttrs: { icu fontconfig libiconv - ] - ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.AppKit - ; + ] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.AppKit; passthru = { # So it will be easier to inspect this environment, in comparison to others inherit luaEnv; @@ -79,20 +84,27 @@ stdenv.mkDerivation (finalAttrs: { tests.test = lib.optionalAttrs (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) ( runCommand "sile-test" { - nativeBuildInputs = [ poppler_utils sile ]; + nativeBuildInputs = [ + poppler_utils + sile + ]; inherit (finalAttrs) FONTCONFIG_FILE; - } '' - output=$(mktemp -t selfcheck-XXXXXX.pdf) - echo "foo" | sile -o $output - - pdfinfo $output | grep "SILE v${finalAttrs.version}" > $out - ''); + } + '' + output=$(mktemp -t selfcheck-XXXXXX.pdf) + echo "foo" | sile -o $output - + pdfinfo $output | grep "SILE v${finalAttrs.version}" > $out + '' + ); }; - postPatch = '' - patchShebangs build-aux/*.sh - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' - sed -i -e 's|@import AppKit;|#import |' src/macfonts.m - ''; + postPatch = + '' + patchShebangs build-aux/*.sh + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + sed -i -e 's|@import AppKit;|#import |' src/macfonts.m + ''; NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework AppKit"; @@ -118,7 +130,12 @@ stdenv.mkDerivation (finalAttrs: { done ''; - outputs = [ "out" "doc" "man" "dev" ]; + outputs = [ + "out" + "doc" + "man" + "dev" + ]; meta = with lib; { description = "Typesetting system"; @@ -135,7 +152,10 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://sile-typesetter.org"; changelog = "https://github.com/sile-typesetter/sile/raw/v${finalAttrs.version}/CHANGELOG.md"; platforms = platforms.unix; - maintainers = with maintainers; [ doronbehar alerque ]; + maintainers = with maintainers; [ + doronbehar + alerque + ]; license = licenses.mit; mainProgram = "sile"; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3756a72b7c3f1..f7d5c8e90cf65 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12107,10 +12107,6 @@ with pkgs; silc_server = callPackage ../servers/silc-server { }; - sile = callPackage ../tools/typesetting/sile { - lua = lua5_3; - }; - silenthound = callPackage ../tools/security/silenthound { }; silice = callPackage ../development/compilers/silice { }; From 0a5b0c8cd928ebe29f99f27927b94f6030f4e727 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 10:22:12 +0200 Subject: [PATCH 2/7] sile: don't use with lib; in meta --- pkgs/by-name/si/sile/package.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index a3c4f0bc11438..1ac53835d37e2 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -137,7 +137,7 @@ stdenv.mkDerivation (finalAttrs: { "dev" ]; - meta = with lib; { + meta = { description = "Typesetting system"; longDescription = '' SILE is a typesetting system; its job is to produce beautiful @@ -151,12 +151,12 @@ stdenv.mkDerivation (finalAttrs: { ''; homepage = "https://sile-typesetter.org"; changelog = "https://github.com/sile-typesetter/sile/raw/v${finalAttrs.version}/CHANGELOG.md"; - platforms = platforms.unix; - maintainers = with maintainers; [ + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ doronbehar alerque ]; - license = licenses.mit; + license = lib.licenses.mit; mainProgram = "sile"; }; }) From fca1f18de9448d0861879ac454b5382bc32d221f Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 09:34:01 +0200 Subject: [PATCH 3/7] sile: use finalAttrs.finalPackage when needed --- pkgs/by-name/si/sile/package.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index 1ac53835d37e2..c032f9381a0b7 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -15,7 +15,6 @@ makeFontsConf, gentium, runCommand, - sile, }: let @@ -86,7 +85,7 @@ stdenv.mkDerivation (finalAttrs: { { nativeBuildInputs = [ poppler_utils - sile + finalAttrs.finalPackage ]; inherit (finalAttrs) FONTCONFIG_FILE; } From 9f1a0fde5c45c5017c36832bc4577c88a86e0caf Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 09:35:26 +0200 Subject: [PATCH 4/7] sile: allow easier override of luaEnv --- pkgs/by-name/si/sile/package.nix | 67 +++++++++++++++----------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index c032f9381a0b7..392f8b5cd5421 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -17,39 +17,6 @@ runCommand, }: -let - luaEnv = lua.withPackages ( - ps: - with ps; - [ - cassowary - cldr - cosmo - fluent - linenoise - loadkit - lpeg - lua-zlib - lua_cliargs - luaepnf - luaexpat - luafilesystem - luarepl - luasec - luasocket - luautf8 - penlight - vstruct - ] - ++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [ - bit32 - ] - ++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [ - compat53 - ] - ); -in - stdenv.mkDerivation (finalAttrs: { pname = "sile"; version = "0.14.17"; @@ -70,15 +37,43 @@ stdenv.mkDerivation (finalAttrs: { makeWrapper ]; buildInputs = [ - luaEnv + finalAttrs.finalPackage.passthru.luaEnv harfbuzz icu fontconfig libiconv ] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.AppKit; passthru = { - # So it will be easier to inspect this environment, in comparison to others - inherit luaEnv; + luaEnv = lua.withPackages ( + ps: + with ps; + [ + cassowary + cldr + cosmo + fluent + linenoise + loadkit + lpeg + lua-zlib + lua_cliargs + luaepnf + luaexpat + luafilesystem + luarepl + luasec + luasocket + luautf8 + penlight + vstruct + ] + ++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [ + bit32 + ] + ++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [ + compat53 + ] + ); # Copied from Makefile.am tests.test = lib.optionalAttrs (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) ( runCommand "sile-test" From e37658c6f144b627231cce1be5b12918bb728a01 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 09:37:49 +0200 Subject: [PATCH 5/7] sile: reorder callPackage arguments like in expression --- pkgs/by-name/si/sile/package.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index 392f8b5cd5421..a3c951466b10b 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -1,20 +1,27 @@ { lib, stdenv, - darwin, fetchurl, - makeWrapper, - pkg-config, - poppler_utils, + + # nativeBuildInputs gitMinimal, + pkg-config, + makeWrapper, + + # buildInputs + lua, harfbuzz, icu, fontconfig, - lua, libiconv, + darwin, + # FONTCONFIG_FILE makeFontsConf, gentium, + + # passthru.tests runCommand, + poppler_utils, }: stdenv.mkDerivation (finalAttrs: { From 6b90fbc91f0aec54d30d5e6756392223eb8afbc5 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 10:14:06 +0200 Subject: [PATCH 6/7] sile: use lib.optionals for Darwin specific inputs --- pkgs/by-name/si/sile/package.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index a3c951466b10b..634338cab3826 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -43,13 +43,17 @@ stdenv.mkDerivation (finalAttrs: { pkg-config makeWrapper ]; - buildInputs = [ - finalAttrs.finalPackage.passthru.luaEnv - harfbuzz - icu - fontconfig - libiconv - ] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.AppKit; + buildInputs = + [ + finalAttrs.finalPackage.passthru.luaEnv + harfbuzz + icu + fontconfig + libiconv + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + darwin.apple_sdk.frameworks.AppKit + ]; passthru = { luaEnv = lua.withPackages ( ps: From 5a37bac414ff58ca4d36ed9fc4642035d4597b7d Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 4 Nov 2024 10:23:25 +0200 Subject: [PATCH 7/7] sile: 0.14.17 -> 0.15.5 Diff: https://github.com/sile-typesetter/sile/compare/None...v0.15.5 Changelog: https://github.com/sile-typesetter/sile/raw/v0.15.5/CHANGELOG.md Cleanup many unnecessary hooks. --- pkgs/by-name/si/sile/package.nix | 128 ++++++++++++++++++------------- 1 file changed, 74 insertions(+), 54 deletions(-) diff --git a/pkgs/by-name/si/sile/package.nix b/pkgs/by-name/si/sile/package.nix index 634338cab3826..54a2317adf8d6 100644 --- a/pkgs/by-name/si/sile/package.nix +++ b/pkgs/by-name/si/sile/package.nix @@ -1,12 +1,14 @@ { lib, stdenv, - fetchurl, + fetchzip, # nativeBuildInputs - gitMinimal, pkg-config, - makeWrapper, + jq, + cargo, + rustc, + rustPlatform, # buildInputs lua, @@ -14,6 +16,8 @@ icu, fontconfig, libiconv, + stylua, + typos, darwin, # FONTCONFIG_FILE makeFontsConf, @@ -26,23 +30,27 @@ stdenv.mkDerivation (finalAttrs: { pname = "sile"; - version = "0.14.17"; + version = "0.15.5"; - src = fetchurl { - url = "https://github.com/sile-typesetter/sile/releases/download/v${finalAttrs.version}/sile-${finalAttrs.version}.tar.xz"; - sha256 = "sha256-f4m+3s7au1FoJQrZ3YDAntKJyOiMPQ11bS0dku4GXgQ="; + src = fetchzip { + url = "https://github.com/sile-typesetter/sile/releases/download/v${finalAttrs.version}/sile-${finalAttrs.version}.zip"; + sha256 = "sha256-zP+MGCXGEg19U6tMrHIdgAAfKQT21vFtmoEROXgxUB0="; }; - configureFlags = [ - "--with-system-luarocks" - "--with-manual" - ]; + cargoDeps = rustPlatform.fetchCargoTarball { + inherit (finalAttrs) src; + dontConfigure = true; + hash = "sha256-hmgDG29C5JfQX2acMr8c3lmswa1u5XHauRWFd4QGmOo="; + }; nativeBuildInputs = [ - gitMinimal pkg-config - makeWrapper + jq + cargo + rustc + rustPlatform.cargoSetupHook ]; + buildInputs = [ finalAttrs.finalPackage.passthru.luaEnv @@ -50,10 +58,55 @@ stdenv.mkDerivation (finalAttrs: { icu fontconfig libiconv + stylua + typos ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.AppKit ]; + + configureFlags = + [ + # Nix will supply all the Lua dependencies, so stop the build system from + # bundling vendored copies of them. + "--with-system-lua-sources" + "--with-system-luarocks" + # The automake check target uses pdfinfo to confirm the output of a test + # run, and uses autotools to discover it. This flake build eschews that + # test because it is run from the source directory but the binary is + # already built with system paths, so it can't be checked under Nix until + # after install. After install the Makefile isn't available of course, so + # we have our own copy of it with a hard coded path to `pdfinfo`. By + # specifying some binary here we skip the configure time test for + # `pdfinfo`, by using `false` we make sure that if it is expected during + # build time we would fail to build since we only provide it at test time. + "PDFINFO=false" + ] + ++ lib.optionals (!lua.pkgs.isLuaJIT) [ + "--without-luajit" + ]; + + outputs = [ + "out" + "doc" + "man" + "dev" + ]; + + # TODO: At some point, upstream should support installing the pre-built + # manual automatically + postInstall = '' + install -Dm0644 documentation/sile.pdf $out/share/doc/sile/manual.pdf + ''; + + FONTCONFIG_FILE = makeFontsConf { + fontDirectories = [ + gentium + ]; + }; + + enableParallelBuilding = true; + passthru = { luaEnv = lua.withPackages ( ps: @@ -61,7 +114,6 @@ stdenv.mkDerivation (finalAttrs: { [ cassowary cldr - cosmo fluent linenoise loadkit @@ -77,6 +129,12 @@ stdenv.mkDerivation (finalAttrs: { luautf8 penlight vstruct + # lua packages needed for testing + busted + luacheck + # packages needed for building api docs + ldoc + # NOTE: Add lua packages here, to change the luaEnv also read by `flake.nix` ] ++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [ bit32 @@ -85,9 +143,10 @@ stdenv.mkDerivation (finalAttrs: { compat53 ] ); + # Copied from Makefile.am tests.test = lib.optionalAttrs (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) ( - runCommand "sile-test" + runCommand "${finalAttrs.pname}-test" { nativeBuildInputs = [ poppler_utils @@ -103,45 +162,6 @@ stdenv.mkDerivation (finalAttrs: { ); }; - postPatch = - '' - patchShebangs build-aux/*.sh - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - sed -i -e 's|@import AppKit;|#import |' src/macfonts.m - ''; - - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework AppKit"; - - FONTCONFIG_FILE = makeFontsConf { - fontDirectories = [ - gentium - ]; - }; - - enableParallelBuilding = true; - - preBuild = lib.optionalString stdenv.cc.isClang '' - substituteInPlace libtexpdf/dpxutil.c \ - --replace "ASSERT(ht && ht->table && iter);" "ASSERT(ht && iter);" - ''; - - # remove forbidden references to $TMPDIR - preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - for f in "$out"/bin/*; do - if isELF "$f"; then - patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$f" - fi - done - ''; - - outputs = [ - "out" - "doc" - "man" - "dev" - ]; - meta = { description = "Typesetting system"; longDescription = ''