Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add Nix Flake.
Browse files Browse the repository at this point in the history
This allows Nix users to install typst-lsp just by
specifying the GitHub repository & provides a
development shell.
  • Loading branch information
Triton171 authored and nvarner committed May 10, 2023
1 parent 7106217 commit 3837914
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;

packageFor = pkgs:
pkgs.rustPlatform.buildRustPackage {
pname = "typst-lsp";
version = rev "00000000";

src = self;

cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};

buildInputs = optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreServices
];
};
in {
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
cargo
clippy
rust-analyzer
rustc
rustfmt
nodejs
];

buildInputs = optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreServices
pkgs.libiconv
];

RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});

packages = eachSystem (pkgs: {
default = packageFor pkgs;
});
};
}

0 comments on commit 3837914

Please sign in to comment.