typed is now in rust!

This commit is contained in:
Schrottkatze 2026-08-25 17:27:34 +02:00
commit 393a0a3ea5
7 changed files with 555 additions and 94 deletions

319
Cargo.lock generated
View file

@ -140,9 +140,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.9.0"
version = "2.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
[[package]]
name = "bumpalo"
@ -238,6 +238,15 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "convert_case"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
@ -260,6 +269,24 @@ dependencies = [
"winapi",
]
[[package]]
name = "crossterm"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
dependencies = [
"bitflags 2.13.1",
"crossterm_winapi",
"derive_more",
"document-features",
"mio 1.0.2",
"parking_lot",
"rustix",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
@ -269,6 +296,37 @@ dependencies = [
"winapi",
]
[[package]]
name = "derive_more"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn",
]
[[package]]
name = "document-features"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
dependencies = [
"litrs",
]
[[package]]
name = "dyn-clone"
version = "1.0.19"
@ -290,6 +348,16 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "flip-bool"
version = "0.1.0"
@ -309,6 +377,15 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "fsevent-sys"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
dependencies = [
"libc",
]
[[package]]
name = "futures-channel"
version = "0.3.30"
@ -561,14 +638,34 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "inotify"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "153be1941a183ec9ccd095ddbe17a8b8d435ef6c76e9e02451b933c3999af2c8"
dependencies = [
"bitflags 2.13.1",
"inotify-sys",
"libc",
]
[[package]]
name = "inotify-sys"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d"
dependencies = [
"libc",
]
[[package]]
name = "inquire"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a"
dependencies = [
"bitflags 2.9.0",
"crossterm",
"bitflags 2.13.1",
"crossterm 0.25.0",
"dyn-clone",
"fuzzy-matcher",
"fxhash",
@ -612,10 +709,42 @@ dependencies = [
]
[[package]]
name = "libc"
version = "0.2.153"
name = "kqueue"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
checksum = "8d763e5b24120b4ddf50de6c92308156765aabfbbccebf401da7cff2d70a41ea"
dependencies = [
"kqueue-sys",
"libc",
]
[[package]]
name = "kqueue-sys"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087"
dependencies = [
"bitflags 2.13.1",
"libc",
]
[[package]]
name = "libc"
version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "litrs"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
[[package]]
name = "lock_api"
@ -674,6 +803,7 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [
"hermit-abi",
"libc",
"log",
"wasi",
"windows-sys 0.52.0",
]
@ -697,6 +827,33 @@ dependencies = [
"serde_json",
]
[[package]]
name = "notify"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
dependencies = [
"bitflags 2.13.1",
"fsevent-sys",
"inotify",
"kqueue",
"libc",
"log",
"mio 1.0.2",
"notify-types",
"walkdir",
"windows-sys 0.60.2",
]
[[package]]
name = "notify-types"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a"
dependencies = [
"bitflags 2.13.1",
]
[[package]]
name = "num-traits"
version = "0.2.18"
@ -973,6 +1130,28 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
dependencies = [
"bitflags 2.13.1",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "rustls"
version = "0.23.12"
@ -1020,12 +1199,27 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]
name = "serde"
version = "1.0.228"
@ -1105,6 +1299,7 @@ checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
dependencies = [
"libc",
"mio 0.8.11",
"mio 1.0.2",
"signal-hook",
]
@ -1360,6 +1555,15 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typed"
version = "0.1.0"
dependencies = [
"clap",
"crossterm 0.29.0",
"notify",
]
[[package]]
name = "unicode-bidi"
version = "0.3.15"
@ -1416,6 +1620,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "want"
version = "0.3.1"
@ -1532,6 +1746,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -1547,6 +1770,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-registry"
version = "0.2.0"
@ -1595,6 +1824,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [
"windows-targets 0.53.5",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
@ -1619,13 +1857,30 @@ dependencies = [
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
"windows_i686_gnullvm",
"windows_i686_gnullvm 0.52.6",
"windows_i686_msvc 0.52.6",
"windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link",
"windows_aarch64_gnullvm 0.53.1",
"windows_aarch64_msvc 0.53.1",
"windows_i686_gnu 0.53.1",
"windows_i686_gnullvm 0.53.1",
"windows_i686_msvc 0.53.1",
"windows_x86_64_gnu 0.53.1",
"windows_x86_64_gnullvm 0.53.1",
"windows_x86_64_msvc 0.53.1",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
@ -1638,6 +1893,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
@ -1650,6 +1911,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_aarch64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
@ -1662,12 +1929,24 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
@ -1680,6 +1959,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_i686_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
@ -1692,6 +1977,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
@ -1704,6 +1995,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
@ -1716,6 +2013,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "windows_x86_64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
[[package]]
name = "zerocopy"
version = "0.7.32"

View file

@ -1,5 +1,7 @@
[workspace]
resolver = "2"
members = [ "programs/bar-pinger", "programs/bar-ws-monitor", "programs/flip-bool",
"programs/jrnl"
, "programs/traveldings"]
members = ["programs/*"]
[workspace.dependencies]
clap.version = "4"
clap.features = [ "derive", "env" ]

129
flake.lock generated
View file

@ -83,21 +83,6 @@
"type": "github"
}
},
"crane_2": {
"locked": {
"lastModified": 1727060013,
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
"owner": "ipetkov",
"repo": "crane",
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
@ -121,18 +106,15 @@
},
"fenix_2": {
"inputs": {
"nixpkgs": [
"typst-within",
"nixpkgs"
],
"nixpkgs": "nixpkgs_5",
"rust-analyzer-src": "rust-analyzer-src_2"
},
"locked": {
"lastModified": 1727245890,
"narHash": "sha256-B4gUhZxqdn24PqL7z7ZuvLOS84HVskhKRByWdgA4/RI=",
"lastModified": 1786348189,
"narHash": "sha256-tnTpFky6/GeXVMBO+hLJK2jWS4J8TYloL+rqRME9gAk=",
"owner": "nix-community",
"repo": "fenix",
"rev": "de3acda8b67b92abeeb35ac236924afd959874ad",
"rev": "a0b1aef63d7e9c5568958e0d90f6fe48f0f4a7a2",
"type": "github"
},
"original": {
@ -210,21 +192,21 @@
"type": "github"
}
},
"flake-parts_3": {
"flake-utils": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_2"
"systems": "systems_2"
},
"locked": {
"lastModified": 1726153070,
"narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
@ -350,18 +332,6 @@
"type": "github"
}
},
"nixpkgs-lib_2": {
"locked": {
"lastModified": 1725233747,
"narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
}
},
"nixpkgs-nixcord": {
"locked": {
"lastModified": 1780453794,
@ -454,11 +424,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1726937504,
"narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
"lastModified": 1786106723,
"narHash": "sha256-zDSUbpoeo/9ZmD2+wXnzxoo1+uhL8vxc0b8yuYMKYq0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9357f4f23713673f310988025d9dc261c20e70c6",
"rev": "f13ff45afd1bb73e640eaa08a7066dbed07e3238",
"type": "github"
},
"original": {
@ -504,7 +474,7 @@
"nixpkgs-stable": "nixpkgs-stable",
"nixpkgs-unstable-small": "nixpkgs-unstable-small",
"stylix": "stylix",
"typst-within": "typst-within"
"typst-lsp": "typst-lsp"
}
},
"rust-analyzer-src": {
@ -527,11 +497,11 @@
"rust-analyzer-src_2": {
"flake": false,
"locked": {
"lastModified": 1727104575,
"narHash": "sha256-lB/ZS0SnHyE8Z3G8DIL/QJPg6w6x5ZhgVO2pBqnz89g=",
"lastModified": 1786285255,
"narHash": "sha256-zJukKxGKLxcO7E6+P49Qe6XaSbbyGG44kFvQYLWaD3M=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "3d0343251fe084b335b55c17a52bb4a3527b1bd0",
"rev": "57411b3a0fb0181ed5965f6541d5ed39a9d79d4c",
"type": "github"
},
"original": {
@ -541,18 +511,6 @@
"type": "github"
}
},
"rust-manifest": {
"flake": false,
"locked": {
"narHash": "sha256-Yqu2/i9170R7pQhvOCR1f5SyFr7PcFbO6xcMr9KWruQ=",
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.83.0.toml"
},
"original": {
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.83.0.toml"
}
},
"stylix": {
"inputs": {
"base16": "base16",
@ -678,28 +636,47 @@
"type": "github"
}
},
"typst-within": {
"inputs": {
"crane": "crane_2",
"fenix": "fenix_2",
"flake-parts": "flake-parts_3",
"nixpkgs": "nixpkgs_5",
"rust-manifest": "rust-manifest",
"systems": "systems_2"
},
"typst": {
"flake": false,
"locked": {
"lastModified": 1739736913,
"narHash": "sha256-qVaWE+q1Npq8XbvrZ/c6ElU+F1u1YNf2a18X4RzVLoc=",
"owner": "schrottkatze",
"lastModified": 1784276123,
"narHash": "sha256-5C3ussV1YBDB97S4nIlzLBTRiJSc7aDqDJ0b+9vybac=",
"owner": "typst",
"repo": "typst",
"rev": "5aa9b90a7b3e7f5ed964bf6727e445bdfc5211cd",
"rev": "9dfd3a08500b7896045f907433cf7b4b02434fad",
"type": "github"
},
"original": {
"owner": "schrottkatze",
"owner": "typst",
"ref": "v0.15.1",
"repo": "typst",
"type": "github"
}
},
"typst-lsp": {
"inputs": {
"fenix": "fenix_2",
"flake-utils": "flake-utils",
"nixpkgs": [
"typst-lsp",
"fenix",
"nixpkgs"
],
"typst": "typst"
},
"locked": {
"lastModified": 1787651800,
"narHash": "sha256-MYwnArQ6ga6h3CiR6pVgoEI5GuHL9iM2ok7u0gHuw54=",
"ref": "refs/heads/master",
"rev": "a2e0c8eeb9c322faf1d1f3e1d61f43f133a716fa",
"revCount": 464,
"type": "git",
"url": "https://codeberg.org/schrottkatze/typst-lsp.git"
},
"original": {
"type": "git",
"url": "https://codeberg.org/schrottkatze/typst-lsp.git"
}
}
},
"root": "root",

View file

@ -6,9 +6,10 @@
nixpkgs-stable.url = "nixpkgs/nixos-25.11";
nixpkgs-unstable-small.url = "nixpkgs/nixos-unstable-small";
stylix.url = "github:nix-community/stylix";
typst-within.url = "github:schrottkatze/typst";
crane.url = "github:ipetkov/crane";
nixcord.url = "github:kaylorben/nixcord";
typst-lsp.url = "git+https://codeberg.org/schrottkatze/typst-lsp.git";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@ -25,12 +26,12 @@
nixpkgs,
nixpkgs-stable,
nixpkgs-unstable-small,
typst-within,
home-manager,
nixos-hardware,
stylix,
fenix,
crane,
typst-lsp,
...
}@inputs:
let
@ -49,6 +50,7 @@
pname = "s10e-bs";
version = "0.0.1";
src = crane-lib.cleanCargoSource (crane-lib.path ./.);
buildInputs = [ pkgs.inotify-tools ];
};
};
in
@ -81,7 +83,7 @@
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
inherit inputs pkgs-unstable-small pkgs-stable;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord
@ -117,7 +119,7 @@
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
inherit inputs pkgs-unstable-small pkgs-stable;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord

View file

@ -1,4 +1,9 @@
{ config, pkgs, ... }:
{
config,
pkgs,
inputs,
...
}:
{
imports = [
./binds.nix
@ -15,6 +20,7 @@
pkgs.tinymist
pkgs.typstyle
pkgs.markdown-oxide
inputs.typst-lsp.packages.x86_64-linux.default
];
};
programs.helix = {
@ -96,12 +102,18 @@
command = "psalm";
args = [ "--language-server" ];
};
"tinymist" = {
"typst-lsp" = {
command = "typst-lsp";
config = {
exportPdf = "onType";
formatterMode = "typstyle";
};
};
# "tinymist" = {
# config = {
# exportPdf = "onType";
# outputPath = "$root/$dir/$name";
# };
# };
};
language = [
{
@ -141,7 +153,7 @@
{
name = "typst";
language-servers = [
"tinymist"
"typst-lsp"
"discord-presence-lsp"
];
}

View file

@ -0,0 +1,9 @@
[package]
name = "typed"
version = "0.1.0"
edition = "2024"
[dependencies]
clap.workspace = true
crossterm = "0.29.0"
notify = "8"

156
programs/typed/src/main.rs Normal file
View file

@ -0,0 +1,156 @@
#![feature(lock_value_accessors)]
use std::{
io,
path::Path,
process::{Command, exit},
sync::{
Arc, Condvar, Mutex,
atomic::{AtomicBool, AtomicU32, Ordering},
mpsc::channel,
},
thread::{self},
};
use clap::Parser;
use notify::{Event, RecursiveMode, Watcher};
use crate::cli::Cli;
mod cli {
use clap::Parser;
#[derive(Debug, Parser)]
pub struct Cli {
pub path: String,
#[arg(short, long, env)]
pub editor: Option<String>,
#[arg(short, long, env)]
pub viewer: Option<String>,
#[arg(short, long)]
pub no_edit: bool,
}
}
// TODOs:
// - create empty file if file doesnt exist
// - compile to pdf
// - always ensure pdf exists
// - delete pdf by default on program close
fn main() -> std::io::Result<()> {
let args = Cli::parse();
let pdf_path = format!("{}.pdf", args.path);
let typ_path = format!("{}.typ", args.path);
let mupdf_pid = Arc::new(AtomicU32::new(0));
let editor_pid = Arc::new(AtomicU32::new(0));
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pdf_path_ = pdf_path.clone();
let mupdf_pid_ = Arc::clone(&mupdf_pid);
let viewer = args.viewer.unwrap_or("mupdf-x11".to_string());
let pair_mupdf = pair.clone();
thread::spawn(move || {
let mut mupdf = Command::new(&viewer);
mupdf.arg(&pdf_path_);
loop {
let Ok(mut mupdf) = mupdf.spawn() else {
break;
};
mupdf_pid_.store(mupdf.id(), Ordering::Relaxed);
let wait_res = mupdf.wait();
if let Ok(status) = wait_res
&& status.success()
{
// we exited!
crossterm::terminal::disable_raw_mode().unwrap();
// we can unwrap here, because crashing doesnt matter when we're exiting anyway, it'll just be less clean
pair_mupdf.0.set(true).unwrap();
pair_mupdf.1.notify_all();
break;
}
}
});
let pdf_path_ = pdf_path.clone();
let mupdf_pid_ = Arc::clone(&mupdf_pid);
thread::spawn(move || {
let (tx, rx) = channel::<notify::Result<Event>>();
let mut watcher = notify::recommended_watcher(tx).unwrap();
let _ = watcher.watch(Path::new(&pdf_path_), RecursiveMode::NonRecursive);
loop {
let p = rx.recv();
match p {
Ok(Ok(e)) if e.kind.is_modify() || e.kind.is_create() => {
let mupdf_pid = mupdf_pid_.load(Ordering::Relaxed);
if mupdf_pid != 0 {
let mut kill = Command::new("kill");
let _ = kill.arg("-1").arg(mupdf_pid.to_string()).spawn();
}
}
Ok(Ok(e)) if e.kind.is_remove() => {
let _ = watcher.watch(Path::new(&pdf_path_), RecursiveMode::NonRecursive);
}
_ => {}
}
}
});
// the editor?
let pair_editor = pair.clone();
let editor_pid_ = editor_pid.clone();
if let Some(editor) = args.editor
&& !args.no_edit
{
thread::spawn(move || {
let Ok(mut editor) = Command::new(editor).arg(&typ_path).spawn() else {
pair_editor.0.set(true).unwrap();
pair_editor.1.notify_all();
return;
};
editor_pid_.store(editor.id(), Ordering::Relaxed);
let _ = editor.wait();
// we know the editor exited here!
pair_editor.0.set(true).unwrap();
pair_editor.1.notify_all();
});
}
let (done, cvar) = &*pair;
// result doesnt matter.
// poisoned? we exit
// done? we exit
// we'll complain about the poison tho
let res = done
.lock()
.and_then(|lock| cvar.wait_while(lock, |done| !*done));
let mupdf_pid = mupdf_pid.load(Ordering::Relaxed);
let mupdf_killer = Command::new("kill")
.arg("-9")
.arg(mupdf_pid.to_string())
.spawn();
let editor_pid = editor_pid.load(Ordering::Relaxed);
if editor_pid != 0 {
let editor_killer = Command::new("kill")
.arg("-9")
.arg(editor_pid.to_string())
.spawn();
let _ = editor_killer.unwrap().wait();
}
let _ = mupdf_killer.unwrap().wait();
println!("goodbye :3");
if res.is_err() {
println!("the waiter was poisoned btw :(")
}
Ok(())
}