projects/guix·blob java-team · refs

89 lines · 2.9 KiB

1Upstream-Status: Not applicable.
2See-also: https://github.com/typst/typst/pull/6190
3diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs
4index ee3ae7e31..3ab497fca 100644
5--- a/crates/typst-cli/src/args.rs
6+++ b/crates/typst-cli/src/args.rs
7@@ -454,6 +454,9 @@ pub struct PackageArgs {
8 #[clap(long = "package-path", env = "TYPST_PACKAGE_PATH", value_name = "DIR")]
9 pub package_path: Option<PathBuf>,
10
11+ #[clap(env = "GUIX_TYPST_PACKAGE_PATH", value_delimiter = ENV_PATH_SEP)]
12+ pub guix_typst_package_path: Option<Vec<PathBuf>>,
13+
14 /// Custom path to package cache, defaults to system-dependent location.
15 #[clap(
16 long = "package-cache-path",
17diff --git a/crates/typst-cli/src/packages.rs b/crates/typst-cli/src/packages.rs
18index 86d739ec9..9be2ac716 100644
19--- a/crates/typst-cli/src/packages.rs
20+++ b/crates/typst-cli/src/packages.rs
21@@ -13,6 +13,12 @@ pub fn system(args: &PackageArgs) -> SystemPackages {
22 .clone()
23 .map(FsPackages::new)
24 .or_else(FsPackages::system_cache),
25+ args.guix_typst_package_path
26+ .clone()
27+ .unwrap_or_default()
28+ .iter()
29+ .map(FsPackages::new)
30+ .collect(),
31 UniversePackages::new(crate::download::downloader()),
32 )
33 }
34diff --git a/crates/typst-kit/src/packages.rs b/crates/typst-kit/src/packages.rs
35index c0027b9c5..668e80551 100644
36--- a/crates/typst-kit/src/packages.rs
37+++ b/crates/typst-kit/src/packages.rs
38@@ -35,6 +35,7 @@ use {
39 pub struct SystemPackages {
40 data: Option<FsPackages>,
41 cache: Option<FsPackages>,
42+ guix: Vec<FsPackages>,
43 universe: UniversePackages,
44 }
45
46@@ -53,6 +54,7 @@ impl SystemPackages {
47 Self::from_parts(
48 FsPackages::system_data(),
49 FsPackages::system_cache(),
50+ Vec::<FsPackages>::new(),
51 UniversePackages::new(downloader),
52 )
53 }
54@@ -61,9 +63,10 @@ impl SystemPackages {
55 pub fn from_parts(
56 data: Option<FsPackages>,
57 cache: Option<FsPackages>,
58+ guix: Vec<FsPackages>,
59 universe: UniversePackages,
60 ) -> Self {
61- Self { data, cache, universe }
62+ Self { data, cache, guix, universe }
63 }
64
65 /// Returns a handle to the data package directory.
66@@ -76,6 +79,10 @@ impl SystemPackages {
67 self.cache.as_ref()
68 }
69
70+ pub fn guix(&self) -> &Vec<FsPackages> {
71+ self.guix.as_ref()
72+ }
73+
74 /// Returns a handle to the Typst universe registry.
75 pub fn universe(&self) -> &UniversePackages {
76 &self.universe
77@@ -99,6 +106,12 @@ impl SystemPackages {
78 return Ok(root);
79 }
80
81+ for candidate in self.guix.iter() {
82+ if let Some(root) = candidate.obtain(spec) {
83+ return Ok(root);
84+ }
85+ }
86+
87 if let Some(cache) = &self.cache {
88 if let Some(root) = cache.obtain(spec) {
89 return Ok(root);