mirror of
https://github.com/typst/typst
synced 2025-05-13 12:36:23 +08:00
Add Nix flake (#158)
This commit is contained in:
parent
52905cf77f
commit
b843ca17d8
4
.gitignore
vendored
4
.gitignore
vendored
@ -18,3 +18,7 @@ bench/target
|
|||||||
# Node
|
# Node
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
|
# Nix
|
||||||
|
/result
|
||||||
|
.direnv/
|
||||||
|
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1679262748,
|
||||||
|
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
76
flake.nix
Normal file
76
flake.nix
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
inherit (builtins)
|
||||||
|
substring
|
||||||
|
;
|
||||||
|
inherit (nixpkgs.lib)
|
||||||
|
genAttrs
|
||||||
|
optionals
|
||||||
|
;
|
||||||
|
|
||||||
|
eachSystem = f: genAttrs
|
||||||
|
[
|
||||||
|
"aarch64-darwin"
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
|
"x86_64-linux"
|
||||||
|
]
|
||||||
|
(system: f nixpkgs.legacyPackages.${system});
|
||||||
|
|
||||||
|
rev = fallback:
|
||||||
|
if self ? rev then
|
||||||
|
substring 0 8 self.rev
|
||||||
|
else
|
||||||
|
fallback;
|
||||||
|
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);
|
||||||
|
|
||||||
|
packages = eachSystem (pkgs: {
|
||||||
|
default = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "typst";
|
||||||
|
version = rev "00000000";
|
||||||
|
|
||||||
|
src = self;
|
||||||
|
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = ./Cargo.lock;
|
||||||
|
allowBuiltinFetchGit = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = optionals pkgs.stdenv.isDarwin [
|
||||||
|
pkgs.darwin.apple_sdk.frameworks.CoreServices
|
||||||
|
];
|
||||||
|
|
||||||
|
cargoBuildFlags = [ "-p" "typst-cli" ];
|
||||||
|
cargoTestFlags = [ "-p" "typst-cli" ];
|
||||||
|
|
||||||
|
TYPST_VERSION = rev "(unknown version)";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user