Replace ALL of the nu stuff with embed-nu

integration-not-installation
trivernis 2 years ago
parent 8d37f60cd7
commit fd97b535df
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

307
Cargo.lock generated

@ -274,9 +274,9 @@ dependencies = [
[[package]] [[package]]
name = "cargo_toml" name = "cargo_toml"
version = "0.12.3" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd63e5969cd55839b1ff80d8694e7571667befbaee13bbc2fe7aabc7d2cc104c" checksum = "6a621d5d6d6c8d086dbaf1fe659981da41a1b63c6bdbba30b4dbb592c6d3bd49"
dependencies = [ dependencies = [
"serde", "serde",
"toml", "toml",
@ -359,9 +359,9 @@ dependencies = [
[[package]] [[package]]
name = "clang-sys" name = "clang-sys"
version = "1.3.3" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
dependencies = [ dependencies = [
"glob", "glob",
"libc", "libc",
@ -370,9 +370,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.0.7" version = "4.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a1af219c3e254a8b4649d6ddaef886b2015089f35f2ac5e1db31410c0566ab8" checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -385,9 +385,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.0.7" version = "4.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd114ae53ce5a0670f43d2f169c1cd26c69b4896b0c121900cf1e4d06d67316c" checksum = "a4a307492e1a34939f79d3b6b9650bd2b971513cd775436bf2b78defeb5af00b"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -443,13 +443,13 @@ dependencies = [
[[package]] [[package]]
name = "console" name = "console"
version = "0.15.1" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847" checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c"
dependencies = [ dependencies = [
"encode_unicode", "encode_unicode",
"lazy_static",
"libc", "libc",
"once_cell",
"terminal_size 0.1.17", "terminal_size 0.1.17",
"unicode-width", "unicode-width",
"winapi 0.3.9", "winapi 0.3.9",
@ -532,26 +532,24 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.9.10" version = "0.9.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"crossbeam-utils", "crossbeam-utils",
"memoffset", "memoffset",
"once_cell",
"scopeguard", "scopeguard",
] ]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.11" version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"once_cell",
] ]
[[package]] [[package]]
@ -711,6 +709,21 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "embed-nu"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d98e94d6656fddfe81de41bf37772da321b6ff5f5f6701e3a4140fd33ae2a41f"
dependencies = [
"nu-command",
"nu-engine",
"nu-parser",
"nu-protocol",
"paste",
"rusty-value",
"thiserror",
]
[[package]] [[package]]
name = "eml-parser" name = "eml-parser"
version = "0.1.3" version = "0.1.3"
@ -967,15 +980,6 @@ dependencies = [
"slab", "slab",
] ]
[[package]]
name = "fuzzy-matcher"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94"
dependencies = [
"thread_local",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.6" version = "0.14.6"
@ -1082,9 +1086,9 @@ dependencies = [
[[package]] [[package]]
name = "hashlink" name = "hashlink"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452c155cb93fecdfb02a73dd57b5d8e442c2063bd7aac72f1bc5e4263a43086" checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa"
dependencies = [ dependencies = [
"hashbrown", "hashbrown",
] ]
@ -1189,14 +1193,13 @@ dependencies = [
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.48" version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a0714f28b1ee39ccec0770ccb544eb02c9ef2c82bb096230eefcffa6468b0" checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"core-foundation-sys", "core-foundation-sys",
"js-sys", "js-sys",
"once_cell",
"wasm-bindgen", "wasm-bindgen",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1325,20 +1328,11 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89" checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89"
[[package]]
name = "is_executable"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa9acdc6d67b75e626ad644734e8bc6df893d9cd2a834129065d3dd6158ea9c8"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.10.4" version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8bf247779e67a9082a4790b45e71ac7cfd1321331a5c856a74a9faebdab78d0" checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [ dependencies = [
"either", "either",
] ]
@ -1394,9 +1388,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.132" version = "0.2.134"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -1447,9 +1441,9 @@ checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.8" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390" checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"scopeguard", "scopeguard",
@ -1485,9 +1479,9 @@ dependencies = [
[[package]] [[package]]
name = "md-5" name = "md-5"
version = "0.10.4" version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca"
dependencies = [ dependencies = [
"digest", "digest",
] ]
@ -1676,18 +1670,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "nix"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"libc",
"memoffset",
]
[[package]] [[package]]
name = "nodrop" name = "nodrop"
version = "0.1.14" version = "0.1.14"
@ -1751,48 +1733,29 @@ dependencies = [
] ]
[[package]] [[package]]
name = "nu-ansi-term" name = "ntapi"
version = "0.46.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc"
dependencies = [ dependencies = [
"overload",
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]] [[package]]
name = "nu-cli" name = "nu-ansi-term"
version = "0.68.1" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12a77ebff12eb9b09a8ce0e89bd6747ebc48fb8c5df6c0e6605da8a48c613a2f" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [ dependencies = [
"atty", "overload",
"chrono", "winapi 0.3.9",
"crossterm",
"fancy-regex",
"fuzzy-matcher",
"is_executable",
"lazy_static",
"log",
"miette 5.3.0",
"nu-ansi-term",
"nu-color-config",
"nu-engine",
"nu-parser",
"nu-path",
"nu-protocol",
"nu-utils",
"reedline",
"strip-ansi-escapes",
"sysinfo",
"thiserror",
] ]
[[package]] [[package]]
name = "nu-color-config" name = "nu-color-config"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0d08593241080536418ca3db3f2052b7034fc74a58479601b908ab175e9cf6" checksum = "946a55fbce40e56f457fd3355ed530cfbe63bfba000322c11b48adf4e801ec76"
dependencies = [ dependencies = [
"nu-ansi-term", "nu-ansi-term",
"nu-json", "nu-json",
@ -1803,9 +1766,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-command" name = "nu-command"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e63d745d4e763e4391c2a4553d24eb37de6af760b946b6445bf6ee58c9e41f6" checksum = "b7db633817155bc83e3435d1a07b31e31663d33a3e52377f5ed958fe87bc5476"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"alphanumeric-sort", "alphanumeric-sort",
@ -1864,6 +1827,7 @@ dependencies = [
"reqwest", "reqwest",
"roxmltree", "roxmltree",
"rust-embed", "rust-embed",
"same-file",
"serde", "serde",
"serde_ini", "serde_ini",
"serde_urlencoded", "serde_urlencoded",
@ -1887,9 +1851,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-engine" name = "nu-engine"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cca58a5ef28c6e3fd0bacefef1ffc3f0821e78ae8ffcc273792ba24246ee450c" checksum = "1cb577dce34dcae875895e2e23f8453be4c6ce4020d15cb7c3d7e792dd398ac3"
dependencies = [ dependencies = [
"chrono", "chrono",
"nu-glob", "nu-glob",
@ -1902,15 +1866,15 @@ dependencies = [
[[package]] [[package]]
name = "nu-glob" name = "nu-glob"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b02b5186af3a3910ea97743dba82c30cfac6ea855aa2a1d72e459800a05d29e2" checksum = "13a7ff36edc1ce07131b9160b3443e96c1654b577a6b73a94e4309f58f406786"
[[package]] [[package]]
name = "nu-json" name = "nu-json"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50419e7496da8e3a78be2791cab1ce7051dbf4f4ddceec6cb7c241d88a8c7a03" checksum = "0bac5f205183dd45ce3be98ad898d243b3d3a93cb1dd998d960751c790251d69"
dependencies = [ dependencies = [
"fancy-regex", "fancy-regex",
"lazy_static", "lazy_static",
@ -1921,9 +1885,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-parser" name = "nu-parser"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1db9f05336e31d439e63eb906ad0db4e6e87cd9e5548a1eb63a7db41d7965c13" checksum = "3ba0868b4c46b24c1db931546fca4044a306426eaf51e7d8148c12a9f8e5b005"
dependencies = [ dependencies = [
"chrono", "chrono",
"itertools", "itertools",
@ -1938,9 +1902,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-path" name = "nu-path"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f300b72519e7fbd26e2705a77de4f3949225a9e3cbfdb1183e409cf598fb079" checksum = "400058f815595b5a79cc51a0539108571c60d0918c5dc304006650d9d267ec8c"
dependencies = [ dependencies = [
"dirs-next", "dirs-next",
"dunce", "dunce",
@ -1949,9 +1913,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-pretty-hex" name = "nu-pretty-hex"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f14f527357d184dcff2b48fbd0f6c0905f3a9823f9d66baf80b3373dc3e5e41f" checksum = "9fa9667e6ddf13e01a5f192caa8570b19f062dfe1fa70af6f28b2ab56c369d57"
dependencies = [ dependencies = [
"nu-ansi-term", "nu-ansi-term",
"rand", "rand",
@ -1959,9 +1923,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-protocol" name = "nu-protocol"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc0406451ef33ac8ab30e6809928975a8536a93da9ab8b834a4f9580aa08d96" checksum = "2b24c01c3ee5b45b9b3ce743a02dbc8af0e42985f585f0fb4e759d5155699a72"
dependencies = [ dependencies = [
"byte-unit", "byte-unit",
"chrono", "chrono",
@ -1982,18 +1946,16 @@ dependencies = [
[[package]] [[package]]
name = "nu-system" name = "nu-system"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5b35e9a7a17941d7fd0b07eafe9739e3434b092f68083c59c4adde562a93068" checksum = "e6e196605b4808d199f8c56337365ad77f38f1ca7ba08e4fac4f88e603dca549"
dependencies = [ dependencies = [
"atty",
"chrono", "chrono",
"errno", "errno",
"libc", "libc",
"libproc", "libproc",
"mach2", "mach2",
"nix", "ntapi 0.3.7",
"ntapi",
"once_cell", "once_cell",
"procfs", "procfs",
"winapi 0.3.9", "winapi 0.3.9",
@ -2001,9 +1963,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-table" name = "nu-table"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8402e0b84efd00bad80ade17708a0619ee2d1b1527c07fd4913813870fec99a3" checksum = "2d7fd72a13d7df0b2a16aa873420fed8e1f2fd8a8cd3de312e61ae8d10626f5f"
dependencies = [ dependencies = [
"atty", "atty",
"nu-ansi-term", "nu-ansi-term",
@ -2014,9 +1976,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-term-grid" name = "nu-term-grid"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ba82d8ca649a211e1be9588ad543104fe42e6b3920dc8a3ba38913780f3a0b2" checksum = "08e49fe2fefd84382ab749002877535230c28b26ed38bacc19c6e14beffa8cf9"
dependencies = [ dependencies = [
"strip-ansi-escapes", "strip-ansi-escapes",
"unicode-width", "unicode-width",
@ -2024,9 +1986,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-test-support" name = "nu-test-support"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f0828fadfb33e4c5df00c023f82dffcc952eb7f61d0c36bd1ba6c4d2cbf593" checksum = "8d7ccf966c8a056138ea2b59805eae0958134bd35882e6d2b0485a82d62f64d1"
dependencies = [ dependencies = [
"getset", "getset",
"hamcrest2", "hamcrest2",
@ -2041,9 +2003,9 @@ dependencies = [
[[package]] [[package]]
name = "nu-utils" name = "nu-utils"
version = "0.68.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d465fec1c369d59c64a0c60ed7bab29f3ac15183f604ee9308c98e96eee33fc7" checksum = "84eddf8bbcd2017504c7c17a97d5c18cf8f5aa7c2fa20b54bdeed734575d2683"
dependencies = [ dependencies = [
"crossterm_winapi", "crossterm_winapi",
"lscolors", "lscolors",
@ -2180,15 +2142,15 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.14.0" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.41" version = "0.10.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -2218,9 +2180,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.75" version = "0.9.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -2292,6 +2254,12 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "paste"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]] [[package]]
name = "pathdiff" name = "pathdiff"
version = "0.2.1" version = "0.2.1"
@ -2414,9 +2382,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.43" version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -2556,9 +2524,9 @@ dependencies = [
[[package]] [[package]]
name = "reedline" name = "reedline"
version = "0.11.0" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5559b5ab4817b0da0c6fc6814edfae537209e01d955a2f3e7595606e3d039691" checksum = "311b256d0a325a92d685f1401fccf83341afba1a62d56bbfa3c98b87073db195"
dependencies = [ dependencies = [
"chrono", "chrono",
"crossterm", "crossterm",
@ -2611,9 +2579,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.11" version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes",
@ -2627,10 +2595,10 @@ dependencies = [
"hyper-tls", "hyper-tls",
"ipnet", "ipnet",
"js-sys", "js-sys",
"lazy_static",
"log", "log",
"mime", "mime",
"native-tls", "native-tls",
"once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"serde", "serde",
@ -2733,9 +2701,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.35.9" version = "0.35.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c825b8aa8010eb9ee99b75f05e10180b9278d161583034d7574c9d617aeada" checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"errno", "errno",
@ -2751,6 +2719,26 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
[[package]]
name = "rusty-value"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f862c10d8f4556a65ee7c7dbd7cefeda8e6d375c6fe8a2fc8c4731f4a59ea1a"
dependencies = [
"rusty-value-derive",
]
[[package]]
name = "rusty-value-derive"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63139d85db644c06991260d1fcd08e06f8b5829f08b029a5cc85d203988ace12"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.11" version = "1.0.11"
@ -2807,18 +2795,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.144" version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.144" version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2891,7 +2879,7 @@ checksum = "8c0ea0c68418544f725eba5401a5b965a2263254c92458d04aeae74e9d88ff4e"
dependencies = [ dependencies = [
"const_format", "const_format",
"is_debug", "is_debug",
"time 0.3.14", "time 0.3.15",
] ]
[[package]] [[package]]
@ -2956,9 +2944,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.9.0" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]] [[package]]
name = "smawk" name = "smawk"
@ -3040,9 +3028,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.99" version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3066,14 +3054,14 @@ dependencies = [
[[package]] [[package]]
name = "sysinfo" name = "sysinfo"
version = "0.25.3" version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71eb43e528fdc239f08717ec2a378fdb017dddbc3412de15fff527554591a66c" checksum = "7890fff842b8db56f2033ebee8f6efe1921475c3830c115995552914fb967580"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
"ntapi", "ntapi 0.4.0",
"once_cell", "once_cell",
"rayon", "rayon",
"winapi 0.3.9", "winapi 0.3.9",
@ -3160,18 +3148,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.35" version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.35" version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3200,9 +3188,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.14" version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b" checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c"
dependencies = [ dependencies = [
"itoa 1.0.3", "itoa 1.0.3",
"libc", "libc",
@ -3237,9 +3225,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.21.1" version = "1.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes", "bytes",
@ -3247,7 +3235,6 @@ dependencies = [
"memchr", "memchr",
"mio 0.8.4", "mio 0.8.4",
"num_cpus", "num_cpus",
"once_cell",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2",
@ -3308,13 +3295,9 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"dotenv", "dotenv",
"embed-nu",
"lazy_static", "lazy_static",
"miette 5.3.0", "rusty-value",
"nu-cli",
"nu-command",
"nu-engine",
"nu-parser",
"nu-protocol",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
@ -3462,9 +3445,9 @@ checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
[[package]] [[package]]
name = "unicode-linebreak" name = "unicode-linebreak"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba853b89cad55680dd3cf06f2798cb1ad8d483f0e2dfa14138d7e789ecee5c4e" checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137"
dependencies = [ dependencies = [
"hashbrown", "hashbrown",
"regex", "regex",

@ -16,23 +16,19 @@ path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "4.0.7", features = ["derive"] } clap = { version = "4.0.9", features = ["derive"] }
color-eyre = "0.6.2" color-eyre = "0.6.2"
dotenv = "0.15.0" dotenv = "0.15.0"
embed-nu = "0.2.5"
lazy_static = "1.4.0" lazy_static = "1.4.0"
miette = "5.3.0" rusty-value = "0.4.1"
nu-cli = "0.68.1" serde = { version = "1.0.145", features = ["derive"] }
nu-command = "0.68.1"
nu-engine = "0.68.1"
nu-parser = "0.68.1"
nu-protocol = "0.68.1"
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.85" serde_json = "1.0.85"
thiserror = "1.0.35" thiserror = "1.0.37"
tokio = { version = "1.21.1", features = ["rt", "io-std", "io-util", "process", "time", "macros", "tracing", "fs"] } tokio = { version = "1.21.2", features = ["rt", "io-std", "io-util", "process", "time", "macros", "tracing", "fs"] }
tracing = "0.1.36" tracing = "0.1.36"
tracing-subscriber = "0.3.15" tracing-subscriber = "0.3.15"
[build-dependencies] [build-dependencies]
cargo_toml = "0.12.3" cargo_toml = "0.12.4"
serde = { version = "1.0.144", features = ["derive"] } serde = { version = "1.0.145", features = ["derive"] }

@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use embed_nu::RustyValue;
use serde::Deserialize;
use crate::tasks::{ use crate::tasks::{
BootloaderConfig, BootloaderPreset, DesktopConfig, ExtraPackages, Kernel, KernelConfig, BootloaderConfig, BootloaderPreset, DesktopConfig, ExtraPackages, Kernel, KernelConfig,
@ -8,7 +9,7 @@ use crate::tasks::{
UsersConfig, UsersConfig,
}; };
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct Config { pub struct Config {
pub locale: LocaleConfig, pub locale: LocaleConfig,
pub network: NetworkConfig, pub network: NetworkConfig,

@ -1,29 +1,17 @@
use std::{io, path::PathBuf}; use std::{io, path::PathBuf};
use miette::Diagnostic;
use nu_protocol::ShellError;
use thiserror::Error; use thiserror::Error;
pub type AppResult<T> = std::result::Result<T, AppError>; pub type AppResult<T> = std::result::Result<T, AppError>;
#[derive(Error, Diagnostic, Debug)] #[derive(Error, Debug)]
pub enum AppError { pub enum AppError {
#[error("Miette error")]
#[diagnostic()]
Miette(miette::Error),
#[error("Error while evaluating nu script")]
#[diagnostic()]
Nu(#[from] ShellError),
#[error("Could not find the script file")] #[error("Could not find the script file")]
ScriptNotFound(PathBuf), ScriptNotFound(PathBuf),
#[diagnostic()] #[error("Nu error {0}")]
#[error("Could not parse the source file: {0}")] NuError(#[from] embed_nu::Error),
ParseError(#[from] nu_parser::ParseError),
#[diagnostic()]
#[error("Could not find the main mehod in the script file {0}")] #[error("Could not find the main mehod in the script file {0}")]
MissingMain(PathBuf), MissingMain(PathBuf),
@ -35,10 +23,7 @@ pub enum AppError {
#[error("IO Error: {0}")] #[error("IO Error: {0}")]
Io(#[from] io::Error), Io(#[from] io::Error),
}
impl From<miette::Error> for AppError { #[error("JSON deserialization error {0}")]
fn from(e: miette::Error) -> Self { JSON(#[from] serde_json::Error),
Self::Miette(e)
}
} }

@ -2,8 +2,7 @@ use config::Config;
use error::{AppError, AppResult}; use error::{AppError, AppResult};
use scripting::{ use scripting::{
loader::{HookType, ScriptLoader}, loader::{HookType, ScriptLoader},
record::RecordValue, script::{NuScript, Script},
script::{NuScript, Script, ScriptArgs},
}; };
use tasks::*; use tasks::*;
@ -18,7 +17,7 @@ macro_rules! tasks {
($($function:ident => $script:ident),+) => { ($($function:ident => $script:ident),+) => {
$( $(
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub async fn $function(&self, cfg: &<$script as crate::scripting::script::Script>::Args) -> AppResult<()> { pub async fn $function(&self, cfg: <$script as crate::scripting::script::Script>::Args) -> AppResult<()> {
self.execute_task::<$script>(cfg).await self.execute_task::<$script>(cfg).await
} }
)+ )+
@ -59,58 +58,57 @@ impl TaskExecutor {
/// Installs the system from the given system configuration /// Installs the system from the given system configuration
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub async fn install_from_config(&self) -> AppResult<()> { pub async fn install_from_config(&self) -> AppResult<()> {
let config = self let config = self.config.clone().ok_or_else(|| AppError::MissingConfig)?;
.config self.create_partitions(config.partitions).await?;
.as_ref() self.install_base(()).await?;
.ok_or_else(|| AppError::MissingConfig)?; self.install_kernels(config.kernels).await?;
self.create_partitions(&config.partitions).await?; self.install_bootloader(config.bootloader).await?;
self.install_base(&()).await?; self.configure_locale(config.locale).await?;
self.install_kernels(&config.kernels).await?; self.configure_network(config.network).await?;
self.install_bootloader(&config.bootloader).await?;
self.configure_locale(&config.locale).await?;
self.configure_network(&config.network).await?;
if config.enable_zramd { if config.enable_zramd {
self.install_zramd(&()).await?; self.install_zramd(()).await?;
} }
if config.enable_timeshift { if config.enable_timeshift {
self.install_timeshift(&()).await?; self.install_timeshift(()).await?;
} }
if config.enable_flatpak { if config.enable_flatpak {
self.install_flatpak(&()).await?; self.install_flatpak(()).await?;
} }
self.setup_users(&config.users).await?; self.setup_users(config.users).await?;
self.setup_root_user(&config.root_user).await?; self.setup_root_user(config.root_user).await?;
self.install_desktop(&config.desktop).await?; self.install_desktop(config.desktop).await?;
self.install_extra_packages(&config.extra_packages).await?; self.install_extra_packages(config.extra_packages).await?;
if let Some(unakite) = &config.unakite { if let Some(unakite) = config.unakite {
self.configure_unakite(unakite).await?; self.configure_unakite(unakite).await?;
} }
Ok(()) Ok(())
} }
async fn execute_task<S: Script>(&self, args: &S::Args) -> AppResult<()> { async fn execute_task<S: Script>(&self, args: S::Args) -> AppResult<()> {
if let Some(pre_hook) = self.loader.load_hook::<S>(HookType::Pre) { if let Some(pre_hook) = self.loader.load_hook::<S>(HookType::Pre) {
self.execute(pre_hook, args).await?; self.execute(pre_hook, args.clone()).await?;
} }
let script = self.loader.load::<S>()?; let script = self.loader.load::<S>()?;
self.execute(script, args).await?;
if let Some(post_hook) = self.loader.load_hook::<S>(HookType::Post) { if let Some(post_hook) = self.loader.load_hook::<S>(HookType::Post) {
self.execute(script, args.clone()).await?;
self.execute(post_hook, args).await?; self.execute(post_hook, args).await?;
} else {
self.execute(script, args.clone()).await?;
} }
Ok(()) Ok(())
} }
#[inline] #[inline]
async fn execute<S: Script>(&self, mut script: NuScript<S>, args: &S::Args) -> AppResult<()> { async fn execute<S: Script>(&self, mut script: NuScript<S>, args: S::Args) -> AppResult<()> {
if let Some(cfg) = self.config.as_ref() { if let Some(cfg) = self.config.as_ref() {
script.set_global_var("TRM_CONFIG", cfg.get_args()) script.set_global_var("TRM_CONFIG", cfg.to_owned())
} else { } else {
script.set_global_var("TRM_CONFIG", RecordValue::from(Config::empty().get_args())) script.set_global_var("TRM_CONFIG", Config::empty())
} }
.set_global_var("TRM_VERSION", env!("CARGO_PKG_VERSION")) .set_global_var("TRM_VERSION", env!("CARGO_PKG_VERSION"))
.execute(args) .execute(args)

@ -1,6 +1,5 @@
use args::{Args, Command, GenerateScriptsArgs, InstallFromConfigArgs}; use args::{Args, Command, GenerateScriptsArgs, InstallFromConfigArgs};
use clap::Parser; use clap::Parser;
use miette::{Context, IntoDiagnostic};
use tokio::{fs::OpenOptions, io::AsyncReadExt}; use tokio::{fs::OpenOptions, io::AsyncReadExt};
use tourmaline::{config::Config, error::AppResult, generate_script_files, TaskExecutor}; use tourmaline::{config::Config, error::AppResult, generate_script_files, TaskExecutor};
@ -20,20 +19,10 @@ async fn main() {
} }
async fn install_from_config(args: InstallFromConfigArgs) -> AppResult<()> { async fn install_from_config(args: InstallFromConfigArgs) -> AppResult<()> {
let mut file = OpenOptions::new() let mut file = OpenOptions::new().read(true).open(args.path).await?;
.read(true)
.open(args.path)
.await
.into_diagnostic()
.context("Could not read file")?;
let mut cfg_contents = String::new(); let mut cfg_contents = String::new();
file.read_to_string(&mut cfg_contents) file.read_to_string(&mut cfg_contents).await?;
.await let config: Config = serde_json::from_str(&cfg_contents)?;
.into_diagnostic()
.context("Could not read file")?;
let config: Config = serde_json::from_str(&cfg_contents)
.into_diagnostic()
.context("Could not parse config as JSON")?;
TaskExecutor::with_config(config) TaskExecutor::with_config(config)
.install_from_config() .install_from_config()

@ -1,232 +0,0 @@
#![allow(unused)]
use std::{
collections::HashMap,
mem,
path::{Path, PathBuf},
};
use nu_cli::gather_parent_env_vars;
use tokio::fs;
use miette::IntoDiagnostic;
use nu_protocol::{
ast::{Argument, Block, Call, Expr, Expression, Pipeline},
engine::{EngineState, Stack, StateDelta, StateWorkingSet},
DeclId, PipelineData, Signature, Span, Type, Value,
};
use crate::error::{AppError, AppResult};
use super::record::RecordValue;
/// An executor for nu scripts
pub struct NuExecutor {
script_path: PathBuf,
args: Vec<RecordValue>,
global_vars: HashMap<String, RecordValue>,
}
impl NuExecutor {
pub fn new<P: AsRef<Path>>(script_path: P) -> Self {
Self {
script_path: script_path.as_ref().to_owned(),
args: Vec::new(),
global_vars: HashMap::new(),
}
}
pub fn add_arg<A: Into<RecordValue>>(&mut self, arg: A) -> &mut Self {
self.args.push(arg.into());
self
}
pub fn add_args<A: Into<RecordValue>, I: IntoIterator<Item = A>>(
&mut self,
args: I,
) -> &mut Self {
let mut args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
self.args.append(&mut args);
self
}
/// Adds a global variable to the executor which can
/// be accessed from within the script
pub fn add_global_var<S: ToString, V: Into<RecordValue>>(
&mut self,
name: S,
value: V,
) -> &mut Self {
self.global_vars.insert(name.to_string(), value.into());
self
}
/// Adds multiple global variables
pub fn add_global_vars<S: ToString, R: Into<RecordValue>, I: IntoIterator<Item = (S, R)>>(
&mut self,
vars: I,
) -> &mut Self {
self.global_vars
.extend(&mut vars.into_iter().map(|(k, v)| (k.to_string(), v.into())));
self
}
/// Executes the given script file in a clean nu context.
#[tracing::instrument(level = "trace", skip_all)]
pub async fn execute(&mut self) -> AppResult<()> {
let mut engine_state = nu_command::create_default_context();
let mut stack = nu_protocol::engine::Stack::new();
let init_cwd = nu_cli::get_init_cwd();
gather_parent_env_vars(&mut engine_state, &init_cwd);
nu_engine::convert_env_values(&mut engine_state, &stack);
let vars = mem::take(&mut self.global_vars);
let vars = vars
.into_iter()
.map(|(k, v)| (k, v.into_protocol_value()))
.collect::<HashMap<_, _>>();
add_variables_to_state(vars, &mut engine_state, &mut stack);
let (block, main_id) = read_script_file(&self.script_path, &mut engine_state).await?;
// put everything the script defines into scope
nu_engine::eval_block(
&engine_state,
&mut stack,
&block,
empty_pipeline(),
false,
false,
)
.into_diagnostic()?;
let args = mem::take(&mut self.args);
// block in a different thread to be able to execute scripts in parallel
tokio::task::spawn_blocking(move || {
// create a call to the main method wit the given arguments and execute it
let call_block = create_call(main_id, args);
let data = nu_engine::eval_block(
&engine_state,
&mut stack,
&call_block,
empty_pipeline(),
false,
false,
)?;
// the last print is returned as the result pipeline of the script so
// we need to print it manually
data.print(&mut engine_state, &mut stack, false, true);
AppResult::Ok(())
})
.await
.unwrap()?;
Ok(())
}
}
/// Adds variables to the nu engine state
/// Note: Calling this function multiple times will override other variables
#[tracing::instrument(level = "trace", skip(state, stack))]
fn add_variables_to_state(
vars: HashMap<String, Value>,
state: &mut EngineState,
stack: &mut Stack,
) {
let state2 = nu_command::create_default_context();
let mut working_set = StateWorkingSet::new(&state2);
vars.into_iter()
.map(|(name, value)| {
(
working_set.add_variable(
name.as_bytes().to_vec(),
Span::new(0, 0),
nu_protocol::Type::String,
),
value,
)
})
.for_each(|(var_id, value)| stack.add_var(var_id, value));
state.merge_delta(working_set.render());
}
/// Reads the nu script file and
/// returns its root block
#[tracing::instrument(level = "trace", skip(engine_state))]
async fn read_script_file(
path: &Path,
engine_state: &mut EngineState,
) -> AppResult<(Block, DeclId)> {
let script_contents = fs::read(&path).await.into_diagnostic()?;
let string_path = path.to_string_lossy().into_owned();
// parse the source file
let (block, working_set) = parse_nu(engine_state, &script_contents, Some(&string_path))?;
// check if a main method exists in the block
if let Some(decl_id) = working_set.find_decl(b"main", &Type::Block) {
let delta = working_set.render();
engine_state.merge_delta(delta);
Ok((block, decl_id))
} else {
Err(AppError::MissingMain(PathBuf::from(path)))
}
}
/// Parses a nu script
#[tracing::instrument(level = "trace", skip_all)]
fn parse_nu<'a>(
engine_state: &'a mut EngineState,
script: &[u8],
script_path: Option<&str>,
) -> AppResult<(Block, StateWorkingSet<'a>)> {
let mut working_set = StateWorkingSet::new(engine_state);
let (block, err) = nu_parser::parse(&mut working_set, script_path, script, false, &[]);
if let Some(err) = err {
Err(AppError::from(err))
} else {
Ok((block, working_set))
}
}
/// Creates a call nu expression with the given main block declaration ID
/// and arguments in the form of record values
#[tracing::instrument(level = "trace")]
fn create_call(decl_id: DeclId, args: Vec<RecordValue>) -> Block {
let args = args
.into_iter()
.map(|a| Argument::Positional(a.into_expression()))
.collect();
let call = Call {
decl_id,
head: Span::new(0, 0),
arguments: args,
redirect_stdout: true,
redirect_stderr: false,
};
let pipeline = Pipeline {
expressions: vec![Expression {
expr: Expr::Call(Box::new(call)),
span: Span::new(0, 0),
ty: Type::Any,
custom_completion: None,
}],
};
Block {
signature: Box::new(Signature::build("Call to main")),
pipelines: vec![pipeline],
captures: Vec::new(),
redirect_env: false,
span: None,
}
}
fn empty_pipeline() -> PipelineData {
PipelineData::new(Span::new(0, 0))
}

@ -1,5 +1,2 @@
pub mod executor;
pub mod loader; pub mod loader;
pub mod record;
pub mod record_serializer;
pub mod script; pub mod script;

@ -1,190 +0,0 @@
use std::{borrow::Cow, collections::HashMap};
use nu_protocol::{
ast::{Expr, Expression},
Span, Type, Value,
};
#[derive(Clone, Debug)]
pub enum RecordValue {
Int(i64),
Float(f64),
String(String),
Bytes(Vec<u8>),
Boolean(bool),
Null,
Map(Vec<(RecordValue, RecordValue)>),
List(Vec<RecordValue>),
}
impl RecordValue {
/// Creates an expresion for this value
pub fn into_expr(self) -> Expr {
match self {
RecordValue::Int(i) => Expr::Int(i),
RecordValue::Float(f) => Expr::Float(f),
RecordValue::String(s) => Expr::String(s),
RecordValue::Boolean(b) => Expr::Bool(b),
RecordValue::Null => Expr::Nothing,
RecordValue::Map(m) => Expr::Record(
m.into_iter()
.map(|(k, v)| (k.into_expression(), v.into_expression()))
.collect(),
),
RecordValue::List(l) => {
Expr::List(l.into_iter().map(RecordValue::into_expression).collect())
}
RecordValue::Bytes(b) => Expr::Binary(b),
}
}
/// Creates a new wrapped expression for this value
pub fn into_expression(self) -> Expression {
let nu_type = self.get_type();
let expr = self.into_expr();
Expression {
expr,
span: Span::new(0, 0),
ty: nu_type,
custom_completion: None,
}
}
/// Creates a nu protocol value from this value
pub fn into_protocol_value(self) -> Value {
let span = Span::new(0, 0);
match self {
RecordValue::Int(val) => Value::Int { val, span },
RecordValue::Float(val) => Value::Float { val, span },
RecordValue::String(val) => Value::String { val, span },
RecordValue::Bytes(val) => Value::Binary { val, span },
RecordValue::Boolean(val) => Value::Bool { val, span },
RecordValue::Null => Value::Nothing { span },
RecordValue::Map(m) => {
let mut cols = Vec::new();
let mut vals = Vec::new();
for (key, val) in m {
cols.push(key.to_string());
vals.push(val.into_protocol_value());
}
Value::Record { cols, vals, span }
}
RecordValue::List(l) => Value::List {
vals: l
.into_iter()
.map(RecordValue::into_protocol_value)
.collect(),
span,
},
}
}
/// Returns the type of this value
fn get_type(&self) -> Type {
match &self {
RecordValue::Int(_) => Type::Int,
RecordValue::Float(_) => Type::Float,
RecordValue::String(_) => Type::String,
RecordValue::Boolean(_) => Type::Bool,
RecordValue::Null => Type::Nothing,
RecordValue::Map(m) => {
let type_map = m
.iter()
.map(|(k, v)| (k.to_string(), v.get_type()))
.collect();
Type::Record(type_map)
}
RecordValue::List(l) => {
let list_type = if let Some(first) = l.first() {
first.get_type()
} else {
Type::Nothing
};
Type::List(Box::new(list_type))
}
RecordValue::Bytes(_) => Type::Binary,
}
}
}
impl ToString for RecordValue {
fn to_string(&self) -> String {
match self {
RecordValue::Int(i) => i.to_string(),
RecordValue::Float(f) => f.to_string(),
RecordValue::String(s) => s.clone(),
RecordValue::Boolean(b) => b.to_string(),
RecordValue::Null => String::new(),
RecordValue::Map(_) => String::new(),
RecordValue::List(_) => String::new(),
RecordValue::Bytes(_) => String::new(),
}
}
}
impl From<i64> for RecordValue {
fn from(num: i64) -> Self {
Self::Int(num)
}
}
impl From<f64> for RecordValue {
fn from(num: f64) -> Self {
Self::Float(num)
}
}
impl From<String> for RecordValue {
fn from(s: String) -> Self {
Self::String(s)
}
}
impl<'a> From<Cow<'a, str>> for RecordValue {
fn from(s: Cow<'a, str>) -> Self {
Self::String(s.into_owned())
}
}
impl From<&str> for RecordValue {
fn from(s: &str) -> Self {
Self::String(s.into())
}
}
impl From<bool> for RecordValue {
fn from(b: bool) -> Self {
Self::Boolean(b)
}
}
impl<T: Into<RecordValue>> From<Option<T>> for RecordValue {
fn from(opt: Option<T>) -> Self {
match opt {
Some(val) => val.into(),
None => Self::Null,
}
}
}
impl<T1: Into<RecordValue>, T2: Into<RecordValue>> From<HashMap<T1, T2>> for RecordValue {
fn from(map: HashMap<T1, T2>) -> Self {
let map = map.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
Self::Map(map)
}
}
impl<T: Into<RecordValue>> From<Vec<T>> for RecordValue {
fn from(list: Vec<T>) -> Self {
let list = list.into_iter().map(|l| l.into()).collect();
Self::List(list)
}
}
impl From<Vec<u8>> for RecordValue {
fn from(b: Vec<u8>) -> Self {
Self::Bytes(b)
}
}

@ -1,444 +0,0 @@
use std::{collections::HashMap, mem};
use thiserror::Error;
use super::record::RecordValue;
#[derive(Default)]
pub struct RecordSerializer {
list_serializer: Option<RecordListSerializer>,
map_serializer: Option<RecordMapSerializer>,
}
#[derive(Default)]
pub struct RecordListSerializer {
serializer: Option<Box<RecordSerializer>>,
entries: Vec<RecordValue>,
}
#[derive(Default)]
pub struct RecordMapSerializer {
serializer: Option<Box<RecordSerializer>>,
last_key: Option<RecordValue>,
entries: Vec<(RecordValue, RecordValue)>,
}
impl RecordSerializer {
pub fn list_serializer(&mut self, cap: Option<usize>) -> &mut RecordListSerializer {
if self.list_serializer.is_none() {
self.list_serializer = Some(RecordListSerializer::with_capacity_opt(cap));
}
self.list_serializer.as_mut().unwrap()
}
pub fn map_serializer(&mut self, cap: Option<usize>) -> &mut RecordMapSerializer {
if self.map_serializer.is_none() {
self.map_serializer = Some(RecordMapSerializer::with_capacity_opt(cap));
}
self.map_serializer.as_mut().unwrap()
}
}
impl RecordListSerializer {
pub fn with_capacity(capacity: usize) -> Self {
Self {
entries: Vec::with_capacity(capacity),
serializer: None,
}
}
pub fn with_capacity_opt(capacity: Option<usize>) -> Self {
match capacity {
Some(cap) => Self::with_capacity(cap),
None => Self::default(),
}
}
pub fn serializer(&mut self) -> &mut RecordSerializer {
if self.serializer.is_none() {
self.serializer = Some(Box::new(RecordSerializer::default()));
}
self.serializer.as_mut().unwrap()
}
}
impl RecordMapSerializer {
pub fn with_capacity(capacity: usize) -> Self {
Self {
last_key: None,
entries: Vec::with_capacity(capacity),
serializer: None,
}
}
pub fn with_capacity_opt(capacity: Option<usize>) -> Self {
match capacity {
Some(cap) => Self::with_capacity(cap),
None => Self::default(),
}
}
pub fn serializer(&mut self) -> &mut RecordSerializer {
if self.serializer.is_none() {
self.serializer = Some(Box::new(RecordSerializer::default()));
}
self.serializer.as_mut().unwrap()
}
}
#[derive(Error, Debug)]
pub enum RecordSerError {
#[error("{0}")]
Msg(String),
#[error("Encountered map value before map key")]
ValueBeforeKey,
}
impl serde::ser::Error for RecordSerError {
fn custom<T>(msg: T) -> Self
where
T: std::fmt::Display,
{
Self::Msg(msg.to_string())
}
}
impl<'a> serde::ser::Serializer for &'a mut RecordSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
type SerializeSeq = &'a mut RecordListSerializer;
type SerializeTuple = &'a mut RecordListSerializer;
type SerializeTupleStruct = &'a mut RecordListSerializer;
type SerializeTupleVariant = &'a mut RecordListSerializer;
type SerializeMap = &'a mut RecordMapSerializer;
type SerializeStruct = &'a mut RecordMapSerializer;
type SerializeStructVariant = &'a mut RecordMapSerializer;
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error> {
Ok(v.into())
}
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error> {
Ok(v.into())
}
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error> {
Ok((v as i64).into())
}
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error> {
Ok((v as f64).into())
}
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error> {
Ok(v.into())
}
fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error> {
Ok(v.to_string().into())
}
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
Ok(v.into())
}
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
Ok(v.to_vec().into())
}
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
Ok(RecordValue::Null)
}
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
{
value.serialize(self)
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
self.serialize_none()
}
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
self.serialize_unit()
}
fn serialize_unit_variant(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
self.serialize_str(variant)
}
fn serialize_newtype_struct<T: ?Sized>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
{
value.serialize(self)
}
fn serialize_newtype_variant<T: ?Sized>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
{
let mut map = HashMap::new();
map.insert(variant.to_string(), value.serialize(self)?);
Ok(map.into())
}
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
Ok(self.list_serializer(len))
}
fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, Self::Error> {
Ok(self.list_serializer(Some(len)))
}
fn serialize_tuple_struct(
self,
_name: &'static str,
len: usize,
) -> Result<Self::SerializeTupleStruct, Self::Error> {
Ok(self.list_serializer(Some(len)))
}
fn serialize_tuple_variant(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
Ok(self.list_serializer(Some(len)))
}
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
Ok(self.map_serializer(len))
}
fn serialize_struct(
self,
_name: &'static str,
len: usize,
) -> Result<Self::SerializeStruct, Self::Error> {
Ok(self.map_serializer(Some(len)))
}
fn serialize_struct_variant(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
Ok(self.map_serializer(Some(len)))
}
}
impl<'a> serde::ser::SerializeTuple for &'a mut RecordListSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push(val);
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(mem::take(&mut self.entries).into())
}
}
impl<'a> serde::ser::SerializeSeq for &'a mut RecordListSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push(val);
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(mem::take(&mut self.entries).into())
}
}
impl<'a> serde::ser::SerializeTupleStruct for &'a mut RecordListSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push(val);
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(mem::take(&mut self.entries).into())
}
}
impl<'a> serde::ser::SerializeTupleVariant for &'a mut RecordListSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push(val);
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(mem::take(&mut self.entries).into())
}
}
impl<'a> serde::ser::SerializeMap for &'a mut RecordMapSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = key.serialize(self.serializer())?;
self.last_key = Some(val);
Ok(())
}
fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
if let Some(last_key) = self.last_key.take() {
let val = value.serialize(self.serializer())?;
self.entries.push((last_key, val));
Ok(())
} else {
Err(RecordSerError::ValueBeforeKey)
}
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(RecordValue::Map(mem::take(&mut self.entries)))
}
}
impl<'a> serde::ser::SerializeStruct for &'a mut RecordMapSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_field<T: ?Sized>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push((key.into(), val));
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(RecordValue::Map(mem::take(&mut self.entries)))
}
}
impl<'a> serde::ser::SerializeStructVariant for &'a mut RecordMapSerializer {
type Ok = RecordValue;
type Error = RecordSerError;
fn serialize_field<T: ?Sized>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: serde::Serialize,
{
let val = value.serialize(self.serializer())?;
self.entries.push((key.into(), val));
Ok(())
}
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(RecordValue::Map(mem::take(&mut self.entries)))
}
}

@ -1,16 +1,18 @@
use core::fmt; use core::fmt;
use std::{collections::HashMap, marker::PhantomData, path::PathBuf}; use std::{collections::HashMap, marker::PhantomData, path::PathBuf};
use serde::Serialize; use embed_nu::{
rusty_value::RustyValue, Argument, CommandGroupConfig, ContextBuilder, IntoArgument, IntoValue,
RawValue, Value,
};
use tokio::fs;
use crate::error::AppResult; use crate::error::{AppError, AppResult};
use super::{executor::NuExecutor, record::RecordValue, record_serializer::RecordSerializer};
/// A trait implemented for a given nu script type to /// A trait implemented for a given nu script type to
/// associate arguments /// associate arguments
pub trait Script { pub trait Script {
type Args: ScriptArgs + fmt::Debug; type Args: ScriptArgs + fmt::Debug + Clone;
/// Returns the (expected) name of the script file /// Returns the (expected) name of the script file
/// This function is used by the loader to load the associated file /// This function is used by the loader to load the associated file
@ -28,17 +30,18 @@ pub trait Script {
/// Script arguments that can be collected in a Vec to /// Script arguments that can be collected in a Vec to
/// be passed to the script /// be passed to the script
pub trait ScriptArgs { pub trait ScriptArgs: RustyValue {
fn get_args(&self) -> Vec<RecordValue>; fn get_args(self) -> Vec<Argument>;
} }
impl<T: Serialize> ScriptArgs for T { impl<T: RustyValue> ScriptArgs for T {
fn get_args(&self) -> Vec<RecordValue> { fn get_args(self) -> Vec<Argument> {
let mut serializer = RecordSerializer::default(); match self.into_value() {
let val = self.serialize(&mut serializer).unwrap(); Value::List { vals, .. } => vals
match val { .into_iter()
RecordValue::List(entries) => entries, .map(|v| RawValue(v).into_argument())
val => vec![val], .collect(),
val => vec![RawValue(val).into_argument()],
} }
} }
} }
@ -46,7 +49,7 @@ impl<T: Serialize> ScriptArgs for T {
/// A nu script instance that can be executed /// A nu script instance that can be executed
pub struct NuScript<S: Script> { pub struct NuScript<S: Script> {
path: PathBuf, path: PathBuf,
vars: HashMap<String, RecordValue>, vars: HashMap<String, Value>,
__phantom: PhantomData<S>, __phantom: PhantomData<S>,
} }
@ -60,24 +63,30 @@ impl<S: Script> NuScript<S> {
} }
/// Adds a global variable /// Adds a global variable
pub fn set_global_var<S1: ToString, V: Into<RecordValue>>( pub fn set_global_var<S1: ToString, V: IntoValue>(&mut self, key: S1, value: V) -> &mut Self {
&mut self, self.vars.insert(key.to_string(), value.into_value());
key: S1,
value: V,
) -> &mut Self {
self.vars.insert(key.to_string(), value.into());
self self
} }
/// Executes the script with the given args /// Executes the script with the given args
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub async fn execute(&self, args: &S::Args) -> AppResult<()> { pub async fn execute(&self, args: S::Args) -> AppResult<()> {
NuExecutor::new(&self.path) let mut ctx = ContextBuilder::default()
.add_args(args.get_args()) .with_command_groups(CommandGroupConfig::default().all_groups(true))
.add_global_vars(self.vars.clone()) .add_script(self.read_file().await?)?
.execute() .build()?;
.await
if ctx.has_fn("main") {
ctx.call_fn("main", args.get_args())?;
Ok(())
} else {
Err(AppError::MissingMain(self.path.clone()))
}
}
async fn read_file(&self) -> AppResult<String> {
fs::read_to_string(&self.path).await.map_err(AppError::from)
} }
} }

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,7 +8,7 @@ script!(ConfigureLocaleScript {
args = LocaleConfig args = LocaleConfig
}); });
#[derive(Clone, Deserialize, Serialize, Debug)] #[derive(Clone, Deserialize, RustyValue, Debug)]
pub struct LocaleConfig { pub struct LocaleConfig {
pub locale: Vec<String>, pub locale: Vec<String>,
pub keymap: String, pub keymap: String,

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,7 +8,7 @@ script!(ConfigureNetworkScript {
args = NetworkConfig args = NetworkConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct NetworkConfig { pub struct NetworkConfig {
pub hostname: String, pub hostname: String,
pub ipv6_loopback: bool, pub ipv6_loopback: bool,

@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -9,7 +10,7 @@ script!(ConfigureUnakiteScript {
args = UnakiteConfig args = UnakiteConfig
}); });
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, RustyValue, Deserialize)]
pub struct UnakiteConfig { pub struct UnakiteConfig {
pub root: PathBuf, pub root: PathBuf,
pub old_root: PathBuf, pub old_root: PathBuf,

@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -9,27 +10,27 @@ script!(CreatePartitionsScript {
args = PartitionsConfig args = PartitionsConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct PartitionsConfig { pub struct PartitionsConfig {
pub device: PathBuf, pub device: PathBuf,
pub efi_partition: bool, pub efi_partition: bool,
pub partitions: Partitions, pub partitions: Partitions,
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub enum Partitions { pub enum Partitions {
Auto, Auto,
Manual(Vec<Partition>), Manual(Vec<Partition>),
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct Partition { pub struct Partition {
pub mountpoint: PathBuf, pub mountpoint: PathBuf,
pub blockdevice: PathBuf, pub blockdevice: PathBuf,
pub filesystem: Option<FileSystem>, pub filesystem: Option<FileSystem>,
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub enum FileSystem { pub enum FileSystem {
VFAT, VFAT,
BFS, BFS,

@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -9,13 +10,13 @@ script!(InstallBootloaderScript {
args = BootloaderConfig args = BootloaderConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct BootloaderConfig { pub struct BootloaderConfig {
pub preset: BootloaderPreset, pub preset: BootloaderPreset,
pub location: PathBuf, pub location: PathBuf,
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub enum BootloaderPreset { pub enum BootloaderPreset {
GrubEfi, GrubEfi,
Legacy, Legacy,

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,7 +8,7 @@ script!(InstallDesktopScript {
args = DesktopConfig args = DesktopConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub enum DesktopConfig { pub enum DesktopConfig {
Onyx, Onyx,
KdePlasma, KdePlasma,

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,11 +8,11 @@ script!(InstallKernelsScript {
args = KernelConfig args = KernelConfig
}); });
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, RustyValue, Deserialize)]
pub struct KernelConfig { pub struct KernelConfig {
pub default: Kernel, pub default: Kernel,
pub additional: Vec<Kernel>, pub additional: Vec<Kernel>,
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, RustyValue, Deserialize)]
pub struct Kernel(pub String); pub struct Kernel(pub String);

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::rusty_value::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,7 +8,7 @@ script!(SetupRootUserScript {
args = RootUserConfig args = RootUserConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct RootUserConfig { pub struct RootUserConfig {
pub password: String, pub password: String,
} }

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize}; use embed_nu::RustyValue;
use serde::Deserialize;
use crate::script; use crate::script;
@ -7,12 +8,12 @@ script!(SetupUsersScript {
args = UsersConfig args = UsersConfig
}); });
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct UsersConfig { pub struct UsersConfig {
pub users: Vec<User>, pub users: Vec<User>,
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, RustyValue)]
pub struct User { pub struct User {
pub name: String, pub name: String,
pub password: String, pub password: String,

Loading…
Cancel
Save