From 381f080565d3c860418b48edec713953c0950904 Mon Sep 17 00:00:00 2001 From: trivernis Date: Mon, 27 Mar 2023 21:25:23 +0200 Subject: [PATCH] Add common scripts and eval command --- Cargo.lock | 320 ++++++++++++----------- configs/crystal/common/pacman.nu | 4 + configs/crystal/distro.toml | 1 + configs/crystal/install-bootloader/up.nu | 2 +- configs/crystal/install-desktop/up.nu | 6 + src/distro/distro_config.rs | 4 + src/task/base_task.rs | 10 +- src/task/commands/eval.rs | 61 +++++ src/task/commands/mod.rs | 2 + src/task/commands/run.rs | 8 +- src/task/custom_task.rs | 22 +- src/task/exec_builder.rs | 18 +- src/task/mod.rs | 18 +- src/task/task_executor.rs | 2 +- 14 files changed, 302 insertions(+), 176 deletions(-) create mode 100644 configs/crystal/common/pacman.nu create mode 100644 src/task/commands/eval.rs diff --git a/Cargo.lock b/Cargo.lock index d323158..3074972 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "alphanumeric-sort" -version = "1.4.4" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e9c9abb82613923ec78d7a461595d52491ba7240f3c64c0bbe0e6d98e0fce0" +checksum = "81149050d254e2b758c80dcf55949e5c45482e0c9cb3670b1c4b48eb51791f8e" [[package]] name = "android_system_properties" @@ -245,9 +245,9 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-unit" -version = "4.0.18" +version = "4.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3348673602e04848647fffaa8e9a861e7b5d5cae6570727b41bde0f722514484" +checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" dependencies = [ "serde", "utf8-width", @@ -299,7 +299,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f83bc2e401ed041b7057345ebc488c005efa0341d5541ce7004d30458d0090b" dependencies = [ "serde", - "toml 0.7.2", + "toml 0.7.3", ] [[package]] @@ -337,9 +337,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -396,9 +396,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" dependencies = [ "bitflags", "clap_derive", @@ -411,22 +411,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -528,9 +527,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" dependencies = [ "libc", ] @@ -662,19 +661,19 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.26" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +checksum = "dd4056f63fce3b82d852c3da92b08ea59959890813a7f4ce9c0ff85b10cf301b" dependencies = [ "quote", - "syn", + "syn 2.0.10", ] [[package]] name = "cxx" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -684,9 +683,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -694,24 +693,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.10", ] [[package]] name = "cxxbridge-flags" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] @@ -763,9 +762,9 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dtparse" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8293d8a873beeaf3daaf818f3f218b30aafcdb8cd7ed6d4b860e09868af790ab" +checksum = "dbd3b6a23c50eb90a80bdb748042620328617e76276b99dc5c97906e47f807c3" dependencies = [ "chrono", "lazy_static", @@ -781,9 +780,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "embed-nu" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce3400809a30d6079a787b45029ba89b195b9a8a8a159a336c470a458be92173" +checksum = "31098e298f6064f3fe898005ed7ba09170f277ab26971501b1947e0aec365035" dependencies = [ "miette", "nu-command", @@ -1085,13 +1084,13 @@ dependencies = [ [[package]] name = "ghost" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e0cd8a998937e25c6ba7cc276b96ec5cc3f4dc4ab5de9ede4fb152bdd5c5eb" +checksum = "e77ac7b51b8e6313251737fcef4b1c01a2ea102bde68415b62c0ee9268fec357" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] @@ -1267,16 +1266,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi 0.3.9", + "windows 0.46.0", ] [[package]] @@ -1322,9 +1321,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -1374,9 +1373,9 @@ dependencies = [ [[package]] name = "inventory" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498ae1c9c329c7972b917506239b557a60386839192f1cf0ca034f345b65db99" +checksum = "7741301a6d6a9b28ce77c0fb77a4eb116b6bc8f3bef09923f7743d059c4157d3" dependencies = [ "ctor", "ghost", @@ -1384,10 +1383,11 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ + "hermit-abi 0.3.1", "libc", "windows-sys 0.45.0", ] @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -1676,12 +1676,12 @@ dependencies = [ [[package]] name = "miette" -version = "5.5.0" +version = "5.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd9b301defa984bbdbe112b4763e093ed191750a0d914a78c1106b2d0fe703" +checksum = "07749fb52853e739208049fb513287c6f448de9103dfa78b05ae01f2fc5809bb" dependencies = [ - "atty", "backtrace", + "is-terminal", "miette-derive", "once_cell", "owo-colors", @@ -1696,20 +1696,20 @@ dependencies = [ [[package]] name = "miette-derive" -version = "5.5.0" +version = "5.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c2401ab7ac5282ca5c8b518a87635b1a93762b0b90b9990c509888eeccba29" +checksum = "2a07ad93a80d1b92bb44cb42d7c49b49c9aab1778befefad49cceb5e4c5bf460" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -2003,7 +2003,7 @@ dependencies = [ "users 0.11.0", "uuid 1.3.0", "wax", - "windows", + "windows 0.44.0", "winreg", ] @@ -2250,9 +2250,9 @@ dependencies = [ [[package]] name = "omnipath" -version = "0.1.1" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7461858c5ac9bde3fcdeedc17f58ed0469ec74f2d737b6369fc31c0b0ef576c" +checksum = "68432e1692e9b974a51efd452485db50f92827fe0931d16721ad867633a571b6" [[package]] name = "once_cell" @@ -2262,18 +2262,19 @@ checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "open" -version = "3.4.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ecf2487e799604735754d2c5896106785987b441b5aee58f242e4d4963179a" +checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8" dependencies = [ "pathdiff", + "windows-sys 0.42.0", ] [[package]] name = "openssl" -version = "0.10.45" +version = "0.10.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -2292,7 +2293,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2303,9 +2304,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" dependencies = [ "autocfg", "cc", @@ -2316,9 +2317,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "overload" @@ -2531,7 +2532,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -2548,9 +2549,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" dependencies = [ "unicode-ident", ] @@ -2622,9 +2623,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -2776,9 +2777,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", @@ -2796,15 +2797,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "reqwest" -version = "0.11.14" +version = "0.11.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" dependencies = [ "base64 0.21.0", "bytes", @@ -2868,9 +2869,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "6.6.0" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb133b9a38b5543fad3807fb2028ea47c5f2b566f4f5e28a11902f1a358348b6" +checksum = "1b68543d5527e158213414a92832d2aab11a84d2571a5eb021ebe22c43aab066" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -2886,7 +2887,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn", + "syn 1.0.109", "walkdir", ] @@ -2902,9 +2903,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.29.0" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b1b21b8760b0ef8ae5b43d40913ff711a2053cb7ff892a34facff7a6365375a" +checksum = "26bd36b60561ee1fb5ec2817f198b6fd09fa571c897a5e86d1487cfc2b096dfc" dependencies = [ "arrayvec 0.7.2", "num-traits", @@ -2912,9 +2913,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" [[package]] name = "rustc-hash" @@ -2924,9 +2925,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ "bitflags", "errno", @@ -2960,7 +2961,7 @@ checksum = "b8053b9cfa97e5b9d7725a1674e06b53cd05de7ec01b230f8a5136794b12dafb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3024,22 +3025,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.155" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] @@ -3055,9 +3056,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" dependencies = [ "itoa", "ryu", @@ -3200,7 +3201,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3250,35 +3251,35 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] name = "supports-color" -version = "1.3.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +checksum = "4950e7174bffabe99455511c39707310e7e9b440364a2fcb1cc21521be57b354" dependencies = [ - "atty", + "is-terminal", "is_ci", ] [[package]] name = "supports-hyperlinks" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" +checksum = "4b4806e0b03b9906e76b018a5d821ebf198c8e9dc0829ed3328eeeb5094aed60" dependencies = [ - "atty", + "is-terminal", ] [[package]] name = "supports-unicode" -version = "1.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" +checksum = "4b6c2cb240ab5dd21ed4906895ee23fe5a48acdbd15a3ce388e7b62a9b66baf7" dependencies = [ - "atty", + "is-terminal", ] [[package]] @@ -3292,6 +3293,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sys-locale" version = "0.2.4" @@ -3356,7 +3368,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3414,22 +3426,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] @@ -3536,7 +3548,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3574,9 +3586,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6" +checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" dependencies = [ "serde", "serde_spanned", @@ -3595,9 +3607,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.5" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7082a95d48029677a28f181e5f6422d0c8339ad8396a39d3f33d62a90c1f6c30" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "serde", @@ -3625,7 +3637,7 @@ dependencies = [ "sys-mount", "thiserror", "tokio", - "toml 0.7.2", + "toml 0.7.3", "tracing", "tracing-subscriber", "valico", @@ -3657,7 +3669,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3736,9 +3748,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "typetag" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69bf9bd14fed1815295233a0eee76a963283b53ebcbd674d463f697d3bfcae0c" +checksum = "edc3ebbaab23e6cc369cb48246769d031f5bd85f1b28141f32982e3c0c7b33cf" dependencies = [ "erased-serde", "inventory", @@ -3749,13 +3761,13 @@ dependencies = [ [[package]] name = "typetag-impl" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf9f5f225956dc2254c6c27500deac9390a066b2e8a1a571300627a7c4400a33" +checksum = "bb01b60fcc3f5e17babb1a9956263f3ccd2cadc3e52908400231441683283c1d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.10", ] [[package]] @@ -3775,9 +3787,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -3967,12 +3979,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi 0.3.9", "winapi-util", ] @@ -4025,7 +4036,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -4059,7 +4070,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4150,6 +4161,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -4176,9 +4196,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -4191,51 +4211,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee7b2c67f962bf5042bfd8b6a916178df33a26eec343ae064cb8e069f638fa6f" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" dependencies = [ "memchr", ] diff --git a/configs/crystal/common/pacman.nu b/configs/crystal/common/pacman.nu new file mode 100644 index 0000000..d0db633 --- /dev/null +++ b/configs/crystal/common/pacman.nu @@ -0,0 +1,4 @@ +def install [...packages: string] { + debug $"running pacman install for packages ($packages)" + eval $"run pacman -S --noconfirm ($packages | str collect ' ')" +} \ No newline at end of file diff --git a/configs/crystal/distro.toml b/configs/crystal/distro.toml index 52f8132..dd1ac09 100644 --- a/configs/crystal/distro.toml +++ b/configs/crystal/distro.toml @@ -4,6 +4,7 @@ website = "https://getcryst.al" [config] schema = "config.schema.json" +include_scripts = ["common/pacman.nu"] [tasks] diff --git a/configs/crystal/install-bootloader/up.nu b/configs/crystal/install-bootloader/up.nu index 0457b3e..87b248b 100644 --- a/configs/crystal/install-bootloader/up.nu +++ b/configs/crystal/install-bootloader/up.nu @@ -1,7 +1,7 @@ let RUN_IN_CHROOT = true; def install_grub_pkgs [] { - (run pacman -S --noconfirm + (install grub efibootmgr crystal-grub-theme diff --git a/configs/crystal/install-desktop/up.nu b/configs/crystal/install-desktop/up.nu index a922b6d..985f373 100644 --- a/configs/crystal/install-desktop/up.nu +++ b/configs/crystal/install-desktop/up.nu @@ -1,6 +1,12 @@ let RUN_IN_CHROOT = true; + +def install_base [] { + install networkmanager +} + # Applies all system changes of `install-desktop` def main [cfg] { echo "Executing up task `install-desktop` with config" $cfg + install_base todo "Implement install desktops" } diff --git a/src/distro/distro_config.rs b/src/distro/distro_config.rs index 4927190..e1f2fe8 100644 --- a/src/distro/distro_config.rs +++ b/src/distro/distro_config.rs @@ -34,6 +34,10 @@ pub struct DistroMetadata { pub struct OSConfigMetadata { /// The path of the config schema file pub schema: Option, + + /// Script files to include in each task script + /// to provide common functionality + pub include_scripts: Vec, } /// The configuration of a single task diff --git a/src/task/base_task.rs b/src/task/base_task.rs index 018e666..c1d7318 100644 --- a/src/task/base_task.rs +++ b/src/task/base_task.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use crate::distro::OSConfig; +use crate::distro::{distro_config::DistroConfig, OSConfig}; use super::{exec_builder::ExecBuilder, TaskTrait}; use embed_nu::IntoValue; @@ -76,7 +76,7 @@ impl BaseTask { impl TaskTrait for BaseTask { #[tracing::instrument(level = "trace", skip_all)] - fn up(&self, config: &OSConfig) -> Result> { + fn up(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { let key_data = self.key_data(); let script = PathBuf::from(key_data.task_name).join("up.nu"); @@ -85,13 +85,13 @@ impl TaskTrait for BaseTask { } else { Option::<()>::None.into_value() }; - let exec = ExecBuilder::create(script, config.to_owned(), task_config)?; + let exec = ExecBuilder::create(script, config.to_owned(), task_config, distro_cfg)?; Ok(Some(exec)) } #[tracing::instrument(level = "trace", skip_all)] - fn down(&self, config: &OSConfig) -> Result> { + fn down(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { let key_data = self.key_data(); let script = PathBuf::from(key_data.task_name).join("down.nu"); let task_config = if let Some(key) = key_data.config_key { @@ -99,7 +99,7 @@ impl TaskTrait for BaseTask { } else { Option::<()>::None.into_value() }; - let exec = ExecBuilder::create(script, config.to_owned(), task_config)?; + let exec = ExecBuilder::create(script, config.to_owned(), task_config, distro_cfg)?; Ok(Some(exec)) } diff --git a/src/task/commands/eval.rs b/src/task/commands/eval.rs new file mode 100644 index 0000000..5f9916e --- /dev/null +++ b/src/task/commands/eval.rs @@ -0,0 +1,61 @@ +use embed_nu::{ + nu_engine::eval_block_with_early_return, + nu_parser, + nu_protocol::{engine::StateWorkingSet, Signature, SyntaxShape}, + CallExt, +}; + +#[derive(Clone)] +pub struct EvalCommand; + +impl embed_nu::nu_protocol::engine::Command for EvalCommand { + fn name(&self) -> &str { + "eval" + } + + fn signature(&self) -> embed_nu::nu_protocol::Signature { + Signature::new("eval") + .required("script", SyntaxShape::String, "the script to eval") + .category(embed_nu::nu_protocol::Category::Custom("Tourmalin".into())) + } + + fn usage(&self) -> &str { + "eval " + } + + fn run( + &self, + engine_state: &embed_nu::nu_protocol::engine::EngineState, + stack: &mut embed_nu::nu_protocol::engine::Stack, + call: &embed_nu::nu_protocol::ast::Call, + input: embed_nu::PipelineData, + ) -> Result { + let code: String = call.req(engine_state, stack, 0)?; + tracing::debug!("Evaluating expression {code}"); + + let mut working_set = StateWorkingSet::new(engine_state); + + let (block, err) = nu_parser::parse(&mut working_set, None, &code.into_bytes(), false, &[]); + + if let Some(err) = err { + return Err(embed_nu::nu_protocol::ShellError::GenericError( + String::from("ParseError"), + err.to_string(), + Some(err.span()), + None, + vec![], + )); + } + + let result = eval_block_with_early_return( + engine_state, + stack, + &block, + input, + call.redirect_stdout, + call.redirect_stdout, + ); + + result + } +} diff --git a/src/task/commands/mod.rs b/src/task/commands/mod.rs index 797b693..bd4bbf8 100644 --- a/src/task/commands/mod.rs +++ b/src/task/commands/mod.rs @@ -1,5 +1,6 @@ mod debug; mod error; +mod eval; mod info; mod run; mod todo; @@ -7,6 +8,7 @@ mod warn; mod with_cwd; pub use debug::*; pub use error::*; +pub use eval::*; pub use info::*; pub use run::*; pub use todo::*; diff --git a/src/task/commands/run.rs b/src/task/commands/run.rs index 63e2731..86c688c 100644 --- a/src/task/commands/run.rs +++ b/src/task/commands/run.rs @@ -46,7 +46,13 @@ impl embed_nu::nu_protocol::engine::Command for RunCommand { .and_then(|v| v.as_string().ok()) .unwrap_or_else(|| std::env::var("PWD").unwrap_or_else(|_| "/".into())); - tracing::debug!("Running {executable} {}", args.join(" ")); + tracing::debug!( + "Running {executable} {}", + args.iter() + .map(|a| format!("'{a}'")) + .collect::>() + .join(" ") + ); let mut cmd = Command::new(&executable) .current_dir(pwd) diff --git a/src/task/custom_task.rs b/src/task/custom_task.rs index aca36db..72da8ee 100644 --- a/src/task/custom_task.rs +++ b/src/task/custom_task.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use embed_nu::IntoValue; -use crate::distro::OSConfig; +use crate::distro::{distro_config::DistroConfig, OSConfig}; use super::{exec_builder::ExecBuilder, TaskTrait}; use miette::Result; @@ -36,7 +36,7 @@ impl CustomTask { impl TaskTrait for CustomTask { #[tracing::instrument(level = "trace", skip_all)] - fn up(&self, config: &OSConfig) -> Result> { + fn up(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { let task_config = if let Some(key) = self.config_key.as_ref() { config.get_nu_value(key)? } else { @@ -46,14 +46,18 @@ impl TaskTrait for CustomTask { if self.skip_on_false && self.config_key.is_some() && config_is_falsy(&task_config) { Ok(None) } else { - let exec = - ExecBuilder::create(self.up_script.to_owned(), config.to_owned(), task_config)?; + let exec = ExecBuilder::create( + self.up_script.to_owned(), + config.to_owned(), + task_config, + distro_cfg, + )?; Ok(Some(exec)) } } #[tracing::instrument(level = "trace", skip_all)] - fn down(&self, config: &OSConfig) -> Result> { + fn down(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { let task_config = if let Some(key) = self.config_key.as_ref() { config.get_nu_value(key)? } else { @@ -63,8 +67,12 @@ impl TaskTrait for CustomTask { if self.skip_on_false && self.config_key.is_some() && config_is_falsy(&task_config) { Ok(None) } else { - let exec = - ExecBuilder::create(self.down_script.to_owned(), config.to_owned(), task_config)?; + let exec = ExecBuilder::create( + self.down_script.to_owned(), + config.to_owned(), + task_config, + distro_cfg, + )?; Ok(Some(exec)) } } diff --git a/src/task/exec_builder.rs b/src/task/exec_builder.rs index 43557e9..0fac537 100644 --- a/src/task/exec_builder.rs +++ b/src/task/exec_builder.rs @@ -3,11 +3,16 @@ use std::path::{Path, PathBuf}; use embed_nu::{Argument, CommandGroupConfig, ValueIntoExpression}; use std::fs; -use crate::{distro::OSConfig, error::ScriptError, utils::CFG_PATH}; +use crate::{ + distro::{distro_config::DistroConfig, OSConfig}, + error::ScriptError, + utils::CFG_PATH, +}; use miette::{Context, IntoDiagnostic, Result}; use super::commands::{ - DebugCommand, ErrorCommand, InfoCommand, RunCommand, TodoCommand, WarnCommand, WithCwdCommand, + DebugCommand, ErrorCommand, EvalCommand, InfoCommand, RunCommand, TodoCommand, WarnCommand, + WithCwdCommand, }; #[derive(Clone)] @@ -21,8 +26,15 @@ impl ExecBuilder { script: PathBuf, os_config: OSConfig, task_config: embed_nu::Value, + distro_config: &DistroConfig, ) -> Result { let script_contents = Self::get_script_contents(&script)?; + let mut common_scripts = String::new(); + + for script in &distro_config.config.include_scripts { + common_scripts.push_str("\n"); + common_scripts.push_str(&Self::get_script_contents(&script)?); + } let mut ctx = embed_nu::Context::builder() .with_command_groups(CommandGroupConfig::default().all_groups(true))? @@ -33,6 +45,7 @@ impl ExecBuilder { .add_command(DebugCommand)? .add_command(WithCwdCommand)? .add_command(TodoCommand)? + .add_command(EvalCommand)? .add_env_var("PWD", std::env::var("PWD").unwrap_or(String::from("/"))) .add_env_var( "PATH", @@ -40,6 +53,7 @@ impl ExecBuilder { ) .add_parent_env_vars() .add_var("TRM_CONFIG", os_config)? + .add_script(common_scripts)? .add_script(script_contents)? .build()?; if !ctx.has_fn("main") { diff --git a/src/task/mod.rs b/src/task/mod.rs index 517420c..f17da47 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -1,6 +1,6 @@ use std::cmp::Ordering; -use crate::distro::OSConfig; +use crate::distro::{distro_config::DistroConfig, OSConfig}; use self::{base_task::BaseTask, custom_task::CustomTask, exec_builder::ExecBuilder}; pub mod base_task; @@ -12,8 +12,8 @@ pub mod task_executor; use miette::Result; pub trait TaskTrait { - fn up(&self, config: &OSConfig) -> Result>; - fn down(&self, config: &OSConfig) -> Result>; + fn up(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result>; + fn down(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result>; /// Used to decide the execution order /// smaller values mean the task get's executed earlier fn order(&self) -> usize; @@ -52,18 +52,18 @@ impl Task { impl TaskTrait for Task { #[inline] - fn up(&self, config: &OSConfig) -> Result> { + fn up(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { match self { - Task::Base(b) => b.up(config), - Task::Custom(c) => c.up(config), + Task::Base(b) => b.up(config, distro_cfg), + Task::Custom(c) => c.up(config, distro_cfg), } } #[inline] - fn down(&self, config: &OSConfig) -> Result> { + fn down(&self, config: &OSConfig, distro_cfg: &DistroConfig) -> Result> { match self { - Task::Base(b) => b.down(config), - Task::Custom(c) => c.down(config), + Task::Base(b) => b.down(config, distro_cfg), + Task::Custom(c) => c.down(config, distro_cfg), } } diff --git a/src/task/task_executor.rs b/src/task/task_executor.rs index b6ab060..315ea89 100644 --- a/src/task/task_executor.rs +++ b/src/task/task_executor.rs @@ -66,7 +66,7 @@ impl TaskExecutor { let mut chroot = None; for task in &self.tasks { - if let Some(up_task) = task.up(&self.os_config)? { + if let Some(up_task) = task.up(&self.os_config, &self.distro_config)? { if up_task.requires_chroot() { if chroot.is_none() { chroot = Some(Chroot::create(&*ROOT_MNT).await?);