2023-03-27 17:26:08 +03:00
{
inputs = {
nixpkgs . url = " g i t h u b : n i x o s / n i x p k g s / n i x o s - u n s t a b l e " ;
} ;
outputs = { self , nixpkgs }:
let
inherit ( nixpkgs . lib )
genAttrs
2023-04-06 21:14:01 +03:00
importTOML
2023-03-27 17:26:08 +03:00
optionals
2023-05-22 12:10:48 +03:00
cleanSource
2023-03-27 17:26:08 +03:00
;
eachSystem = f : genAttrs
[
" a a r c h 6 4 - d a r w i n "
" a a r c h 6 4 - l i n u x "
" x 8 6 _ 6 4 - d a r w i n "
" x 8 6 _ 6 4 - l i n u x "
]
( system : f nixpkgs . legacyPackages . ${ system } ) ;
rev = fallback :
2023-05-22 12:10:48 +03:00
self . shortRev or fallback ;
2023-03-27 23:42:05 +03:00
2023-05-22 12:10:48 +03:00
packageFor = pkgs : pkgs . rustPlatform . buildRustPackage rec {
2023-03-27 23:42:05 +03:00
pname = " t y p s t " ;
2023-05-22 12:10:48 +03:00
inherit ( ( importTOML ./Cargo.toml ) . workspace . package ) version ;
2023-03-27 23:42:05 +03:00
2023-05-22 12:10:48 +03:00
src = cleanSource ./. ;
2023-03-27 23:42:05 +03:00
cargoLock = {
lockFile = ./Cargo.lock ;
allowBuiltinFetchGit = true ;
} ;
2023-04-06 21:14:01 +03:00
nativeBuildInputs = [
pkgs . installShellFiles
] ;
2023-03-27 23:42:05 +03:00
buildInputs = optionals pkgs . stdenv . isDarwin [
pkgs . darwin . apple_sdk . frameworks . CoreServices
] ;
2023-04-06 21:14:01 +03:00
postInstall = ''
installManPage cli/artifacts /* . 1
installShellCompletion \
cli/artifacts/typst. { bash , fish } \
- - zsh cli/artifacts/_typst
'' ;
GEN_ARTIFACTS = " a r t i f a c t s " ;
2023-05-22 12:10:48 +03:00
TYPST_VERSION = " ${ version } ( ${ rev " u n k n o w n h a s h " } ) " ;
2023-03-27 23:42:05 +03:00
} ;
2023-03-27 17:26:08 +03:00
in
{
devShells = eachSystem ( pkgs : {
default = pkgs . mkShell {
packages = with pkgs ; [
cargo
clippy
rust-analyzer
rustc
rustfmt
] ;
buildInputs = optionals pkgs . stdenv . isDarwin [
pkgs . darwin . apple_sdk . frameworks . CoreServices
pkgs . libiconv
] ;
RUST_SRC_PATH = pkgs . rustPlatform . rustLibSrc ;
} ;
} ) ;
formatter = eachSystem ( pkgs : pkgs . nixpkgs-fmt ) ;
2023-03-27 23:42:05 +03:00
overlays . default = _ : prev : {
typst-dev = packageFor prev ;
} ;
2023-03-27 17:26:08 +03:00
2023-03-27 23:42:05 +03:00
packages = eachSystem ( pkgs : {
default = packageFor pkgs ;
2023-03-27 17:26:08 +03:00
} ) ;
} ;
}