diff options
| author | figsoda <figsoda@pm.me> | 2023-06-12 07:49:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 13:49:39 +0200 |
| commit | 638a534273b712fd8a3fe37632ae88a2fe75aa72 (patch) | |
| tree | a0d20fdc59e4ecdee7e6a7714e616a1c2f21e29f /flake.nix | |
| parent | a883ceed8d74cd63c5717d916fdc76a56d2bf1c3 (diff) | |
Fix Nix flake (#1450)
Typst now requires Rust 1.70 which is not available in nixpkgs yet, so we switch to fenix instead
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 82 |
1 files changed, 49 insertions, 33 deletions
@@ -1,9 +1,13 @@ { inputs = { + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs }: + outputs = { self, fenix, nixpkgs }: let inherit (nixpkgs.lib) genAttrs @@ -24,53 +28,65 @@ rev = fallback: self.shortRev or fallback; - packageFor = pkgs: pkgs.rustPlatform.buildRustPackage rec { - pname = "typst"; - inherit ((importTOML ./Cargo.toml).workspace.package) version; + packageFor = pkgs: + let + rust = fenix.packages.${pkgs.stdenv.hostPlatform.system}.minimal.toolchain; + rustPlatform = pkgs.makeRustPlatform { + cargo = rust; + rustc = rust; + }; + in + rustPlatform.buildRustPackage rec { + pname = "typst"; + inherit ((importTOML ./Cargo.toml).workspace.package) version; - src = cleanSource ./.; + src = cleanSource ./.; - cargoLock = { - lockFile = ./Cargo.lock; - allowBuiltinFetchGit = true; - }; + cargoLock = { + lockFile = ./Cargo.lock; + allowBuiltinFetchGit = true; + }; - nativeBuildInputs = [ - pkgs.installShellFiles - ]; + nativeBuildInputs = [ + pkgs.installShellFiles + ]; - buildInputs = optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.CoreServices - ]; + buildInputs = optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.CoreServices + ]; - postInstall = '' - installManPage cli/artifacts/*.1 - installShellCompletion \ - cli/artifacts/typst.{bash,fish} \ - --zsh cli/artifacts/_typst - ''; + postInstall = '' + installManPage cli/artifacts/*.1 + installShellCompletion \ + cli/artifacts/typst.{bash,fish} \ + --zsh cli/artifacts/_typst + ''; - GEN_ARTIFACTS = "artifacts"; - TYPST_VERSION = "${version} (${rev "unknown hash"})"; - }; + GEN_ARTIFACTS = "artifacts"; + TYPST_VERSION = "${version} (${rev "unknown hash"})"; + }; in { devShells = eachSystem (pkgs: { default = pkgs.mkShell { - packages = with pkgs; [ - cargo - clippy - rust-analyzer - rustc - rustfmt - ]; + packages = + let + fenix' = fenix.packages.${pkgs.stdenv.hostPlatform.system}; + in + [ + (fenix'.default.withComponents [ + "cargo" + "clippy" + "rustc" + "rustfmt" + ]) + fenix'.rust-analyzer + ]; buildInputs = optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.CoreServices pkgs.libiconv ]; - - RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; }; }); |
