Skip to content

Commit

Permalink
style(nix): Reformat Nix-lang sources with nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Nov 3, 2024
1 parent a12be30 commit 6c1a82f
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 204 deletions.
212 changes: 120 additions & 92 deletions build-aux/pkg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,72 @@
# the `version`, `src` and `libtexpdf-src` attributes that are given by the
# `flake.nix`. In Nixpkgs, we don't need `libtexpdf-src` because we use
# `fetchFromGitHub` with fetchSubmodules = true;`.
{ lib
, stdenv
, version, src, libtexpdf-src
, autoreconfHook
, gitMinimal
, pkg-config
, jq
, cargo
, rustc
, rustPlatform
, makeWrapper
, poppler_utils
, harfbuzz
, icu
, fontconfig
, lua
, libiconv
, darwin
, makeFontsConf
, gentium
, runCommand
, stylua
, typos
{
lib,
stdenv,
version,
src,
libtexpdf-src,
autoreconfHook,
gitMinimal,
pkg-config,
jq,
cargo,
rustc,
rustPlatform,
makeWrapper,
poppler_utils,
harfbuzz,
icu,
fontconfig,
lua,
libiconv,
darwin,
makeFontsConf,
gentium,
runCommand,
stylua,
typos,
}:

let
luaEnv = lua.withPackages(ps: with ps; [
cassowary
cldr
fluent
linenoise
loadkit
lpeg
lua-zlib
lua_cliargs
luaepnf
luaexpat
luafilesystem
luarepl
luasec
luasocket
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
] ++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [
compat53
]);
in stdenv.mkDerivation (finalAttrs: {
luaEnv = lua.withPackages (
ps:
with ps;
[
cassowary
cldr
fluent
linenoise
loadkit
lpeg
lua-zlib
lua_cliargs
luaepnf
luaexpat
luafilesystem
luarepl
luasec
luasocket
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
]
++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [
compat53
]
);
in
stdenv.mkDerivation (finalAttrs: {
pname = "sile";
inherit version src;

Expand Down Expand Up @@ -92,37 +102,41 @@ in stdenv.mkDerivation (finalAttrs: {
lockFile = ../Cargo.lock;
};

buildInputs = [
luaEnv
harfbuzz
icu
fontconfig
libiconv
stylua
typos
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit
];
buildInputs =
[
luaEnv
harfbuzz
icu
fontconfig
libiconv
stylua
typos
]
++ lib.optionals stdenv.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"
#"--with-manual" In Nixpkgs we add this flag, here its not important enough
] ++ lib.optionals (!lua.pkgs.isLuaJIT) [
"--without-luajit"
];
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"
#"--with-manual" In Nixpkgs we add this flag, here its not important enough
]
++ lib.optionals (!lua.pkgs.isLuaJIT) [
"--without-luajit"
];

postPatch = ''
patchShebangs build-aux/*.sh build-aux/git-version-gen
Expand All @@ -149,17 +163,28 @@ in stdenv.mkDerivation (finalAttrs: {
inherit luaEnv;
# Copied from Makefile.am
tests.test = lib.optionalAttrs (!(stdenv.isDarwin && stdenv.isAarch64)) (
runCommand "${finalAttrs.pname}-test" {
nativeBuildInputs = [ poppler_utils finalAttrs.finalPackage ];
runCommand "${finalAttrs.pname}-test"
{
nativeBuildInputs = [
poppler_utils
finalAttrs.finalPackage
];
inherit (finalAttrs) FONTCONFIG_FILE;
} ''
output=$(mktemp -t selfcheck-XXXXXX.pdf)
echo "<sile>foo</sile>" | sile -o $output -
pdfinfo $output | grep "SILE v${finalAttrs.version}" > $out
'');
}
''
output=$(mktemp -t selfcheck-XXXXXX.pdf)
echo "<sile>foo</sile>" | sile -o $output -
pdfinfo $output | grep "SILE v${finalAttrs.version}" > $out
''
);
};

outputs = [ "out" "doc" "man" "dev" ];
outputs = [
"out"
"doc"
"man"
"dev"
];

meta = {
description = "A typesetting system";
Expand All @@ -177,7 +202,10 @@ in stdenv.mkDerivation (finalAttrs: {
# In nixpkgs we use a version specific URL for CHANGELOG.md
changelog = "https://github.com/sile-typesetter/sile/raw/master/CHANGELOG.md";
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ doronbehar alerque ];
maintainers = with lib.maintainers; [
doronbehar
alerque
];
license = lib.licenses.mit;
};
})
23 changes: 14 additions & 9 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# https://wiki.nixos.org/wiki/Flakes#Using_flakes_with_stable_Nix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}
).defaultNix
Loading

0 comments on commit 6c1a82f

Please sign in to comment.