Fix Nix flake (#1450)

Typst now requires Rust 1.70 which is not available in nixpkgs yet, so we switch to fenix instead
This commit is contained in:
figsoda 2023-06-12 07:49:39 -04:00 committed by GitHub
parent a883ceed8d
commit 638a534273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 39 deletions

45
flake.lock generated
View File

@ -1,12 +1,33 @@
{ {
"nodes": { "nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1686291735,
"narHash": "sha256-mpq2m6TN3ImqqUqA4u93NvkZu5vH//3spqjmPRbRlvA=",
"owner": "nix-community",
"repo": "fenix",
"rev": "6e6a94c4d0cac4821b6452fbae46609b89a8ddcf",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1679262748, "lastModified": 1686226982,
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=", "narHash": "sha256-nLuiPoeiVfqqzeq9rmXxpybh77VS37dsY/k8N2LoxVg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6", "rev": "a64b73e07d4aa65cfcbda29ecf78eaf9e72e44bd",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -18,8 +39,26 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1686239338,
"narHash": "sha256-c6Mm7UnDf3j3akY3YB3rELFA76QRbB8ttSBsh00LWi0=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "9c03aa1ac2e67051db83a85baf3cfee902e4dd84",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -1,9 +1,13 @@
{ {
inputs = { inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
}; };
outputs = { self, nixpkgs }: outputs = { self, fenix, nixpkgs }:
let let
inherit (nixpkgs.lib) inherit (nixpkgs.lib)
genAttrs genAttrs
@ -24,7 +28,15 @@
rev = fallback: rev = fallback:
self.shortRev or fallback; self.shortRev or fallback;
packageFor = pkgs: pkgs.rustPlatform.buildRustPackage rec { 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"; pname = "typst";
inherit ((importTOML ./Cargo.toml).workspace.package) version; inherit ((importTOML ./Cargo.toml).workspace.package) version;
@ -57,20 +69,24 @@
{ {
devShells = eachSystem (pkgs: { devShells = eachSystem (pkgs: {
default = pkgs.mkShell { default = pkgs.mkShell {
packages = with pkgs; [ packages =
cargo let
clippy fenix' = fenix.packages.${pkgs.stdenv.hostPlatform.system};
rust-analyzer in
rustc [
rustfmt (fenix'.default.withComponents [
"cargo"
"clippy"
"rustc"
"rustfmt"
])
fenix'.rust-analyzer
]; ];
buildInputs = optionals pkgs.stdenv.isDarwin [ buildInputs = optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreServices pkgs.darwin.apple_sdk.frameworks.CoreServices
pkgs.libiconv pkgs.libiconv
]; ];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
}; };
}); });