Update nix flake and use nixfmt (#6827)
This commit is contained in:
parent
f278e43e0f
commit
2d5fa4f0ff
45
flake.lock
45
flake.lock
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727060013,
|
"lastModified": 1755993354,
|
||||||
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
|
"narHash": "sha256-FCRRAzSaL/+umLIm3RU3O/+fJ2ssaPHseI2SSFL8yZU=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
|
"rev": "25bd41b24426c7734278c2ff02e53258851db914",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -23,11 +23,11 @@
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727245890,
|
"lastModified": 1755585599,
|
||||||
"narHash": "sha256-B4gUhZxqdn24PqL7z7ZuvLOS84HVskhKRByWdgA4/RI=",
|
"narHash": "sha256-tl/0cnsqB/Yt7DbaGMel2RLa7QG5elA8lkaOXli6VdY=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "de3acda8b67b92abeeb35ac236924afd959874ad",
|
"rev": "6ed03ef4c8ec36d193c18e06b9ecddde78fb7e42",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -41,11 +41,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726153070,
|
"lastModified": 1754487366,
|
||||||
"narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
|
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
|
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -56,11 +56,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726937504,
|
"lastModified": 1756125398,
|
||||||
"narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
|
"narHash": "sha256-XexyKZpf46cMiO5Vbj+dWSAXOnr285GHsMch8FBoHbc=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9357f4f23713673f310988025d9dc261c20e70c6",
|
"rev": "3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -72,14 +72,17 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725233747,
|
"lastModified": 1753579242,
|
||||||
"narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=",
|
"narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=",
|
||||||
"type": "tarball",
|
"owner": "nix-community",
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e",
|
||||||
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"owner": "nix-community",
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|
@ -95,11 +98,11 @@
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727104575,
|
"lastModified": 1755504847,
|
||||||
"narHash": "sha256-lB/ZS0SnHyE8Z3G8DIL/QJPg6w6x5ZhgVO2pBqnz89g=",
|
"narHash": "sha256-VX0B9hwhJypCGqncVVLC+SmeMVd/GAYbJZ0MiiUn2Pk=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "3d0343251fe084b335b55c17a52bb4a3527b1bd0",
|
"rev": "a905e3b21b144d77e1b304e49f3264f6f8d4db75",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
261
flake.nix
261
flake.nix
|
|
@ -15,130 +15,153 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ flake-parts, crane, nixpkgs, fenix, rust-manifest, self, ... }: flake-parts.lib.mkFlake { inherit inputs; } {
|
outputs =
|
||||||
systems = import inputs.systems;
|
inputs@{
|
||||||
|
flake-parts,
|
||||||
|
crane,
|
||||||
|
nixpkgs,
|
||||||
|
fenix,
|
||||||
|
rust-manifest,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = import inputs.systems;
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
inputs.flake-parts.flakeModules.easyOverlay
|
inputs.flake-parts.flakeModules.easyOverlay
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem = { self', pkgs, lib, system, ... }:
|
perSystem =
|
||||||
let
|
{
|
||||||
cargoToml = lib.importTOML ./Cargo.toml;
|
self',
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cargoToml = lib.importTOML ./Cargo.toml;
|
||||||
|
|
||||||
pname = "typst";
|
pname = "typst";
|
||||||
version = cargoToml.workspace.package.version;
|
version = cargoToml.workspace.package.version;
|
||||||
|
|
||||||
rust-toolchain = (fenix.packages.${system}.fromManifestFile rust-manifest).defaultToolchain;
|
rust-toolchain = (fenix.packages.${system}.fromManifestFile rust-manifest).defaultToolchain;
|
||||||
|
|
||||||
# Crane-based Nix flake configuration.
|
# Crane-based Nix flake configuration.
|
||||||
# Based on https://github.com/ipetkov/crane/blob/master/examples/trunk-workspace/flake.nix
|
# Based on https://github.com/ipetkov/crane/blob/master/examples/trunk-workspace/flake.nix
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
|
||||||
|
|
||||||
# Typst files to include in the derivation.
|
# Typst files to include in the derivation.
|
||||||
# Here we include Rust files, docs and tests.
|
# Here we include Rust files, docs and tests.
|
||||||
src = lib.fileset.toSource {
|
src = lib.fileset.toSource {
|
||||||
root = ./.;
|
root = ./.;
|
||||||
fileset = lib.fileset.unions [
|
fileset = lib.fileset.unions [
|
||||||
./Cargo.toml
|
./Cargo.toml
|
||||||
./Cargo.lock
|
./Cargo.lock
|
||||||
./rustfmt.toml
|
./rustfmt.toml
|
||||||
./crates
|
./crates
|
||||||
./docs
|
./docs
|
||||||
./tests
|
./tests
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Typst derivation's args, used within crane's derivation generation
|
||||||
|
# functions.
|
||||||
|
commonCraneArgs = {
|
||||||
|
inherit src pname version;
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.openssl
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.openssl.dev
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Derivation with just the dependencies, so we don't have to keep
|
||||||
|
# re-building them.
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly commonCraneArgs;
|
||||||
|
|
||||||
|
typst = craneLib.buildPackage (
|
||||||
|
commonCraneArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
|
||||||
|
nativeBuildInputs = commonCraneArgs.nativeBuildInputs ++ [
|
||||||
|
pkgs.installShellFiles
|
||||||
|
];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
installManPage crates/typst-cli/artifacts/*.1
|
||||||
|
installShellCompletion \
|
||||||
|
crates/typst-cli/artifacts/typst.{bash,fish} \
|
||||||
|
--zsh crates/typst-cli/artifacts/_typst
|
||||||
|
'';
|
||||||
|
|
||||||
|
GEN_ARTIFACTS = "artifacts";
|
||||||
|
TYPST_VERSION =
|
||||||
|
let
|
||||||
|
rev = self.shortRev or "dirty";
|
||||||
|
version = cargoToml.workspace.package.version;
|
||||||
|
in
|
||||||
|
"${version} (${rev})";
|
||||||
|
|
||||||
|
meta.mainProgram = "typst";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
formatter = pkgs.nixfmt-tree;
|
||||||
|
|
||||||
|
packages = {
|
||||||
|
default = typst;
|
||||||
|
typst-dev = self'.packages.default;
|
||||||
|
};
|
||||||
|
|
||||||
|
overlayAttrs = builtins.removeAttrs self'.packages [ "default" ];
|
||||||
|
|
||||||
|
apps.default = {
|
||||||
|
type = "app";
|
||||||
|
program = lib.getExe typst;
|
||||||
|
};
|
||||||
|
|
||||||
|
checks = {
|
||||||
|
typst-fmt = craneLib.cargoFmt commonCraneArgs;
|
||||||
|
typst-clippy = craneLib.cargoClippy (
|
||||||
|
commonCraneArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoClippyExtraArgs = "--workspace -- --deny warnings";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
typst-test = craneLib.cargoTest (
|
||||||
|
commonCraneArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoTestExtraArgs = "--workspace";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = craneLib.devShell {
|
||||||
|
checks = self'.checks;
|
||||||
|
inputsFrom = [ typst ];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rust-analyzer
|
||||||
|
];
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
# A script for quickly running tests.
|
||||||
|
# See https://github.com/typst/typst/blob/main/tests/README.md#making-an-alias
|
||||||
|
(pkgs.writeShellScriptBin "testit" ''
|
||||||
|
cargo test --workspace --test tests -- "$@"
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
# Typst derivation's args, used within crane's derivation generation
|
|
||||||
# functions.
|
|
||||||
commonCraneArgs = {
|
|
||||||
inherit src pname version;
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.openssl
|
|
||||||
] ++ (lib.optionals pkgs.stdenv.isDarwin [
|
|
||||||
pkgs.darwin.apple_sdk.frameworks.CoreServices
|
|
||||||
pkgs.libiconv
|
|
||||||
]);
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.openssl.dev
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Derivation with just the dependencies, so we don't have to keep
|
|
||||||
# re-building them.
|
|
||||||
cargoArtifacts = craneLib.buildDepsOnly commonCraneArgs;
|
|
||||||
|
|
||||||
typst = craneLib.buildPackage (commonCraneArgs // {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
|
|
||||||
nativeBuildInputs = commonCraneArgs.nativeBuildInputs ++ [
|
|
||||||
pkgs.installShellFiles
|
|
||||||
];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
installManPage crates/typst-cli/artifacts/*.1
|
|
||||||
installShellCompletion \
|
|
||||||
crates/typst-cli/artifacts/typst.{bash,fish} \
|
|
||||||
--zsh crates/typst-cli/artifacts/_typst
|
|
||||||
'';
|
|
||||||
|
|
||||||
GEN_ARTIFACTS = "artifacts";
|
|
||||||
TYPST_VERSION =
|
|
||||||
let
|
|
||||||
rev = self.shortRev or "dirty";
|
|
||||||
version = cargoToml.workspace.package.version;
|
|
||||||
in
|
|
||||||
"${version} (${rev})";
|
|
||||||
|
|
||||||
meta.mainProgram = "typst";
|
|
||||||
});
|
|
||||||
in
|
|
||||||
{
|
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
|
||||||
|
|
||||||
packages = {
|
|
||||||
default = typst;
|
|
||||||
typst-dev = self'.packages.default;
|
|
||||||
};
|
|
||||||
|
|
||||||
overlayAttrs = builtins.removeAttrs self'.packages [ "default" ];
|
|
||||||
|
|
||||||
apps.default = {
|
|
||||||
type = "app";
|
|
||||||
program = lib.getExe typst;
|
|
||||||
};
|
|
||||||
|
|
||||||
checks = {
|
|
||||||
typst-fmt = craneLib.cargoFmt commonCraneArgs;
|
|
||||||
typst-clippy = craneLib.cargoClippy (commonCraneArgs // {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
cargoClippyExtraArgs = "--workspace -- --deny warnings";
|
|
||||||
});
|
|
||||||
typst-test = craneLib.cargoTest (commonCraneArgs // {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
cargoTestExtraArgs = "--workspace";
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.default = craneLib.devShell {
|
|
||||||
checks = self'.checks;
|
|
||||||
inputsFrom = [ typst ];
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
rust-analyzer
|
|
||||||
];
|
|
||||||
|
|
||||||
packages = [
|
|
||||||
# A script for quickly running tests.
|
|
||||||
# See https://github.com/typst/typst/blob/main/tests/README.md#making-an-alias
|
|
||||||
(pkgs.writeShellScriptBin "testit" ''
|
|
||||||
cargo test --workspace --test tests -- "$@"
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue