From acf75faa29c2e2b539b0ff29b50edafe936fba3a Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 May 2022 20:25:27 -0400 Subject: [PATCH] Working sile for darwin --- nix/darwin/darwin-configuration.nix | 3 +- nix/darwin/flake.lock | 47 ++++++++++- nix/darwin/flake.nix | 6 +- nix/sile/flake.lock | 41 ++++++++++ nix/sile/flake.nix | 15 ++++ nix/sile/package.nix | 117 ++++++++++++++++++++++++++++ 6 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 nix/sile/flake.lock create mode 100644 nix/sile/flake.nix create mode 100644 nix/sile/package.nix diff --git a/nix/darwin/darwin-configuration.nix b/nix/darwin/darwin-configuration.nix index ef5648e..4f8b89b 100644 --- a/nix/darwin/darwin-configuration.nix +++ b/nix/darwin/darwin-configuration.nix @@ -89,8 +89,7 @@ coreutils watch iterm2 - # TODO(jwall): Find a non broken sile package version and add it as an overlay - # sile # this is currently broken on darwin: https://github.com/NixOS/nixpkgs/issues/23018 + inputs.sile # TODO add sonic-pi here if it supports the arch ]; diff --git a/nix/darwin/flake.lock b/nix/darwin/flake.lock index 30d784a..d874488 100644 --- a/nix/darwin/flake.lock +++ b/nix/darwin/flake.lock @@ -132,6 +132,21 @@ "type": "github" } }, + "flake-utils_5": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": "nixpkgs" @@ -226,13 +241,28 @@ "type": "github" } }, + "nixpkgs_5": { + "locked": { + "lastModified": 1651545648, + "narHash": "sha256-7f1JYFHtfTOvois5LdXrKXthjb6rE9i8ZxWDQyzYKAk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "24c33ab7952544ad355d0677c9eea931b23f371c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "root": { "inputs": { "darwin": "darwin", "durnitisp": "durnitisp", "nixpkgs": "nixpkgs_2", "runwhen": "runwhen", - "rust-overlay": "rust-overlay_2" + "rust-overlay": "rust-overlay_2", + "sile": "sile" } }, "runwhen": { @@ -299,6 +329,21 @@ "repo": "rust-overlay", "type": "github" } + }, + "sile": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "narHash": "sha256-5JapwZZF3DBmVXtyK8gzDgaquNMgzS8l5+nR8lMm9uk=", + "path": "./../sile", + "type": "path" + }, + "original": { + "path": "./../sile", + "type": "path" + } } }, "root": "root", diff --git a/nix/darwin/flake.nix b/nix/darwin/flake.nix index 562e988..c7570c8 100644 --- a/nix/darwin/flake.nix +++ b/nix/darwin/flake.nix @@ -11,9 +11,10 @@ url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; + sile.url = "path:./../sile"; }; - outputs = {self, nixpkgs, darwin, runwhen, durnitisp, rust-overlay, ...}: + outputs = {self, nixpkgs, darwin, runwhen, durnitisp, rust-overlay, sile }: let forSystem = (system: let @@ -29,11 +30,12 @@ durnitisp = durnitisp.defaultPackage."${system}"; rust-overlay = rust-overlay.overlay; buildah = pkgs.buildah; + sile = sile.defaultPackage."${system}"; }; }); in { darwinConfigurations."jeremys-mbp" = forSystem "aarch64-darwin"; darwinConfigurations."jeremys-mbpx86" = forSystem "x86_64-darwin"; - }; + }; } diff --git a/nix/sile/flake.lock b/nix/sile/flake.lock new file mode 100644 index 0000000..e406d60 --- /dev/null +++ b/nix/sile/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1651545648, + "narHash": "sha256-7f1JYFHtfTOvois5LdXrKXthjb6rE9i8ZxWDQyzYKAk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "24c33ab7952544ad355d0677c9eea931b23f371c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/sile/flake.nix b/nix/sile/flake.nix new file mode 100644 index 0000000..09b9890 --- /dev/null +++ b/nix/sile/flake.nix @@ -0,0 +1,15 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = {self, nixpkgs, flake-utils}: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + sile = with pkgs; callPackage ./package.nix { }; + in { + defaultPackage = sile; + }); +} diff --git a/nix/sile/package.nix b/nix/sile/package.nix new file mode 100644 index 0000000..70f9b8b --- /dev/null +++ b/nix/sile/package.nix @@ -0,0 +1,117 @@ +{ lib, stdenv +, darwin +, fetchurl +, makeBinaryWrapper +, pkg-config +, poppler_utils +, gitMinimal +, harfbuzz +, icu +, fontconfig +, lua +, libiconv +, makeFontsConf +, gentium +}: + +let + luaEnv = lua.withPackages(ps: with ps; [ + cassowary + cosmo + compat53 + linenoise + lpeg + lua-zlib + lua_cliargs + luaepnf + luaexpat + luafilesystem + luarepl + luasec + luasocket + luautf8 + penlight + stdlib + vstruct + ]); +in + +stdenv.mkDerivation rec { + pname = "sile"; + version = "0.12.5"; + + src = fetchurl { + url = "https://github.com/sile-typesetter/sile/releases/download/v${version}/${pname}-${version}.tar.xz"; + sha256 = "0z9wdiqwarysh3lhxss3w53vq58ml46bdi9ymr853kfl7m4gz5yy"; + }; + + configureFlags = [ + "--with-system-luarocks" + "--with-manual" + ]; + + nativeBuildInputs = [ + gitMinimal + pkg-config + makeBinaryWrapper + ]; + buildInputs = [ + harfbuzz + icu + fontconfig + libiconv + luaEnv + ] + ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.AppKit + ; + checkInputs = [ + poppler_utils + ]; + + preConfigure = '' + patchShebangs build-aux/*.sh + '' + lib.optionalString stdenv.isDarwin '' + sed -i -e 's|@import AppKit;|#import |' src/macfonts.m + ''; + + NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework AppKit"; + + FONTCONFIG_FILE = makeFontsConf { + fontDirectories = [ + gentium + ]; + }; + + #TODO(jwall): Eventually we shouldn't need this anymore + #doCheck = true; + + enableParallelBuilding = true; + + preBuild = lib.optionalString stdenv.cc.isClang '' + substituteInPlace libtexpdf/dpxutil.c \ + --replace "ASSERT(ht && ht->table && iter);" "ASSERT(ht && iter);" + ''; + + # Hack to avoid TMPDIR in RPATHs. + preFixup = ''rm -rf "$(pwd)" && mkdir "$(pwd)" ''; + + outputs = [ "out" "doc" "man" "dev" ]; + + meta = with lib; { + description = "A typesetting system"; + longDescription = '' + SILE is a typesetting system; its job is to produce beautiful + printed documents. Conceptually, SILE is similar to TeX—from + which it borrows some concepts and even syntax and + algorithms—but the similarities end there. Rather than being a + derivative of the TeX family SILE is a new typesetting and + layout engine written from the ground up using modern + technologies and borrowing some ideas from graphical systems + such as InDesign. + ''; + homepage = "https://sile-typesetter.org"; + changelog = "https://github.com/sile-typesetter/sile/raw/v${version}/CHANGELOG.md"; + platforms = platforms.unix; + license = licenses.mit; + }; +}