-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flake.nix with development environment & CI
This makes it easy to onboard new contributors, as flake.nix provides the fully configured development environment, package definition, and continuous integration: - development environment: nix develop - package build: nix build - package install: nix profile install - testing: nix flake check
- Loading branch information
Showing
5 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: "Nix: build and check" | ||
on: | ||
pull_request: | ||
push: | ||
paths-ignore: | ||
- '**.md' | ||
jobs: | ||
nix: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v25 | ||
with: | ||
nix_path: nixpkgs=channel:nixpkgs-unstable | ||
install_url: https://releases.nixos.org/nix/nix-2.18.1/install | ||
extra_nix_config: | | ||
experimental-features = nix-command flakes | ||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||
- uses: DeterminateSystems/magic-nix-cache-action@v2 | ||
- run: nix flake check --print-build-logs --show-trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ | |
/tests/00*00-latex-*.fmt | ||
/tests/*-plain-*.fmt | ||
/tests/xenia/paper.pdf | ||
|
||
.direnv | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
description = "Tectonic, a modernized TeX/LaTeX engine"; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
inherit (nixpkgs) lib; | ||
supportedSystems = [ | ||
"aarch64-linux" | ||
"aarch64-darwin" | ||
"i686-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
foreachSystem = f: lib.genAttrs supportedSystems (system: f { | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
/** final packages set (of a given system) provided in this flake */ | ||
final = self.packages.${system}; | ||
}); | ||
addCargoFeatures = x: lib.unique (x ++ [ | ||
/** currently nix flake does not work well with git submodules, so we | ||
ensure that the nixpkgs provided harfbuzz is used instead. */ | ||
"external-harfbuzz" | ||
]); | ||
in | ||
{ | ||
packages = foreachSystem ({ pkgs, final }: { | ||
|
||
/** package definition from nixpkgs, with local overrides */ | ||
tectonic-unwrapped = pkgs.tectonic-unwrapped.overrideAttrs ( | ||
{ meta, cargoBuildFeatures, cargoCheckFeatures, ... }: { | ||
name = "tectonic"; | ||
src = ./.; | ||
cargoDeps = pkgs.rustPlatform.importCargoLock { | ||
lockFile = ./Cargo.lock; | ||
}; | ||
cargoBuildFeatures = addCargoFeatures cargoBuildFeatures; | ||
cargoCheckFeatures = addCargoFeatures cargoCheckFeatures; | ||
|
||
/* | ||
For `flake.nix` contributors: put additional overrides here. | ||
If the changes are also applicable to the `tectonic` package | ||
in nixpkgs, consider first improving the definition there, | ||
and then update the `flake.lock` here. | ||
*/ | ||
|
||
meta = { | ||
# to correctly generate meta.position for back trace: | ||
inherit (meta) description; | ||
|
||
# maintainers for the local overrides: | ||
maintainers = with lib.maintainers; [ bryango ]; | ||
}; | ||
} | ||
); | ||
|
||
/** a version of biber that works with the current tectonic bundle */ | ||
inherit (pkgs) biber-for-tectonic; | ||
|
||
/** tectonic wrapped with the correct version of biber; this provides | ||
a partial fix for issue #893. */ | ||
tectonic = pkgs.tectonic.override { | ||
inherit (final) | ||
tectonic-unwrapped | ||
biber-for-tectonic; | ||
}; | ||
|
||
/** the default package to build & install */ | ||
default = final.tectonic; | ||
}); | ||
|
||
devShells = foreachSystem ({ pkgs, final }: { | ||
default = final.tectonic-unwrapped.overrideAttrs (prev: { | ||
# for developments, e.g. symbol lookup in std library | ||
env.RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; | ||
}); | ||
}); | ||
|
||
checks = foreachSystem ({ pkgs, final }: | ||
let | ||
tectonic-unwrapped = | ||
final.tectonic-unwrapped.overrideAttrs (prevAttrs: { | ||
preCheck = prevAttrs.preCheck or "" + '' | ||
export RUST_BACKTRACE=1 | ||
''; | ||
}); | ||
in | ||
{ | ||
inherit tectonic-unwrapped; | ||
tectonic = final.tectonic.override { | ||
inherit tectonic-unwrapped; | ||
}; | ||
}); | ||
}; | ||
} |