From 34047cf43fe80b446e09107b2cdef91be64312cf Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 5 Oct 2024 17:46:05 +0400 Subject: [PATCH 1/5] chore: move tasks to devenv-tasks --- Cargo.lock | 19 +++++++++---------- Cargo.toml | 2 +- {tasks => devenv-tasks}/Cargo.toml | 3 +-- {tasks => devenv-tasks}/src/main.rs | 0 package.nix | 9 ++++----- 5 files changed, 15 insertions(+), 18 deletions(-) rename {tasks => devenv-tasks}/Cargo.toml (81%) rename {tasks => devenv-tasks}/src/main.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index f3b7e16a3..bf6719444 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -596,6 +596,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "devenv-tasks" +version = "0.1.0" +dependencies = [ + "clap", + "serde_json", + "tokio", +] + [[package]] name = "diff" version = "0.1.13" @@ -2559,16 +2568,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tasks" -version = "0.1.0" -dependencies = [ - "clap", - "devenv", - "serde_json", - "tokio", -] - [[package]] name = "tempdir" version = "0.3.7" diff --git a/Cargo.toml b/Cargo.toml index a97ade945..49c554edf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["devenv", "devenv-eval-cache", "devenv-run-tests", "tasks", "xtask"] +members = ["devenv", "devenv-eval-cache", "devenv-run-tests", "devenv-tasks", "xtask"] [workspace.package] edition = "2021" diff --git a/tasks/Cargo.toml b/devenv-tasks/Cargo.toml similarity index 81% rename from tasks/Cargo.toml rename to devenv-tasks/Cargo.toml index 5bf36a924..92a903cda 100644 --- a/tasks/Cargo.toml +++ b/devenv-tasks/Cargo.toml @@ -1,11 +1,10 @@ [package] -name = "tasks" +name = "devenv-tasks" version = "0.1.0" edition.workspace = true license.workspace = true [dependencies] clap.workspace = true -devenv.workspace = true serde_json.workspace = true tokio.workspace = true diff --git a/tasks/src/main.rs b/devenv-tasks/src/main.rs similarity index 100% rename from tasks/src/main.rs rename to devenv-tasks/src/main.rs diff --git a/package.nix b/package.nix index 624be841e..8c324062b 100644 --- a/package.nix +++ b/package.nix @@ -13,13 +13,13 @@ pkgs.rustPlatform.buildRustPackage { ".*devenv(/.*)?" ".*devenv-eval-cache(/.*)?" ".*devenv-run-tests(/.*)?" + ".*devenv-tasks(/.*)?" ".*xtask(/.*)?" - ".*tasks(/.*)?" ]; cargoBuildFlags = if build_tasks - then [ "-p tasks" ] + then [ "-p devenv-tasks" ] else [ "-p devenv -p devenv-run-tests" ]; doCheck = !build_tasks; @@ -32,8 +32,7 @@ pkgs.rustPlatform.buildRustPackage { pkgs.makeWrapper pkgs.pkg-config pkgs.installShellFiles - pkgs.sqlx-cli - ]; + ] ++ pkgs.lib.optional (!build_tasks) pkgs.sqlx-cli; buildInputs = [ pkgs.openssl ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration @@ -44,7 +43,7 @@ pkgs.rustPlatform.buildRustPackage { # A local database to use for preparing queries DATABASE_URL = "sqlite:nix-eval-cache.db"; - preBuild = '' + preBuild = pkgs.lib.optionalString (!build_tasks) '' cargo sqlx database setup --source devenv-eval-cache/migrations cargo sqlx prepare --workspace ''; From 727753aceac42d60c5e378a4253c5c60de5b3298 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 5 Oct 2024 18:04:50 +0400 Subject: [PATCH 2/5] chore: move tasks module to tasks crate This should speed up the task bin build, as it won't have to build everything that devenv requires. --- Cargo.lock | 8 ++++++++ Cargo.toml | 10 ++++++++-- devenv-run-tests/Cargo.toml | 2 +- devenv-tasks/Cargo.toml | 7 +++++++ devenv/src/tasks.rs => devenv-tasks/src/lib.rs | 1 + devenv-tasks/src/main.rs | 2 +- devenv/Cargo.toml | 12 +++++++----- devenv/src/lib.rs | 2 +- 8 files changed, 34 insertions(+), 10 deletions(-) rename devenv/src/tasks.rs => devenv-tasks/src/lib.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index bf6719444..960d9a274 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,6 +539,7 @@ dependencies = [ "cli-table", "console", "devenv-eval-cache", + "devenv-tasks", "dotlock", "fs2", "hex", @@ -601,8 +602,15 @@ name = "devenv-tasks" version = "0.1.0" dependencies = [ "clap", + "console", + "miette", + "petgraph", + "serde", "serde_json", + "tempfile", + "thiserror", "tokio", + "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 49c554edf..cd6a10d1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,13 +12,14 @@ repository = "https://github.com/cachix/devenv/" devenv = { path = "devenv" } devenv-eval-cache = { path = "devenv-eval-cache" } devenv-run-tests = { path = "devenv-run-tests" } -tasks = { path = "tasks" } +devenv-tasks = { path = "devenv-tasks" } xtask = { path = "xtask" } ansiterm = "0.12.2" blake3 = "1.5.4" clap = { version = "4.5.1", features = ["derive", "cargo"] } cli-table = "0.4.7" +console = "0.15.8" dotlock = "0.5.0" fs2 = "0.4.3" futures = "0.3.30" @@ -28,6 +29,7 @@ indoc = "2.0.4" lazy_static = "1.5.0" miette = { version = "7.1.0", features = ["fancy"] } nix = { version = "0.28.0", features = ["signal"] } +petgraph = "0.6.5" regex = "1.10.3" reqwest = "0.11.26" schematic = { version = "0.14.3", features = [ @@ -36,13 +38,14 @@ schematic = { version = "0.14.3", features = [ "renderer_template", "renderer_json_schema", ] } -serde = "1.0.197" +serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" serde_repr = "0.1.19" serde_yaml = "0.9.32" sha2 = "0.10.8" sqlx = { version = "0.8.2", features = ["time", "sqlite", "runtime-tokio"] } tempdir = "0.3.7" +tempfile = "3.12.0" thiserror = "1.0.63" tracing = "0.1.40" which = "6.0.0" @@ -51,8 +54,11 @@ xdg = "2.5.2" tokio = { version = "1.39.3", features = [ "process", "fs", + "io-util", "macros", "rt-multi-thread", + "sync", + "time", ] } schemars = "0.8.16" diff --git a/devenv-run-tests/Cargo.toml b/devenv-run-tests/Cargo.toml index 14e68207b..103f58436 100644 --- a/devenv-run-tests/Cargo.toml +++ b/devenv-run-tests/Cargo.toml @@ -8,4 +8,4 @@ license.workspace = true clap.workspace = true devenv.workspace = true tempdir.workspace = true -tokio = "1.39.3" +tokio.workspace = true diff --git a/devenv-tasks/Cargo.toml b/devenv-tasks/Cargo.toml index 92a903cda..7f1a5c798 100644 --- a/devenv-tasks/Cargo.toml +++ b/devenv-tasks/Cargo.toml @@ -6,5 +6,12 @@ license.workspace = true [dependencies] clap.workspace = true +console.workspace = true +miette.workspace = true +petgraph.workspace = true +serde.workspace = true serde_json.workspace = true +tempfile.workspace = true +thiserror.workspace = true tokio.workspace = true +tracing.workspace = true diff --git a/devenv/src/tasks.rs b/devenv-tasks/src/lib.rs similarity index 99% rename from devenv/src/tasks.rs rename to devenv-tasks/src/lib.rs index 844d4123d..69c703a53 100644 --- a/devenv/src/tasks.rs +++ b/devenv-tasks/src/lib.rs @@ -1327,3 +1327,4 @@ fi Ok(temp_file.into_temp_path()) } } + diff --git a/devenv-tasks/src/main.rs b/devenv-tasks/src/main.rs index 4d70776e5..8b1fc9fad 100644 --- a/devenv-tasks/src/main.rs +++ b/devenv-tasks/src/main.rs @@ -1,5 +1,5 @@ use clap::{Parser, Subcommand}; -use devenv::tasks::{Config, TaskConfig, TasksUi}; +use devenv_tasks::{Config, TaskConfig, TasksUi}; use std::env; #[derive(Parser)] diff --git a/devenv/Cargo.toml b/devenv/Cargo.toml index f8344042a..45964c618 100644 --- a/devenv/Cargo.toml +++ b/devenv/Cargo.toml @@ -10,9 +10,12 @@ default-run = "devenv" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +devenv-eval-cache.workspace = true +devenv-tasks.workspace = true + clap.workspace = true cli-table.workspace = true -console = "0.15.8" +console.workspace = true dotlock.workspace = true fs2.workspace = true hex.workspace = true @@ -20,8 +23,7 @@ include_dir.workspace = true indoc.workspace = true miette.workspace = true nix.workspace = true -devenv-eval-cache.workspace = true -petgraph = "0.6.5" +petgraph.workspace = true regex.workspace = true reqwest.workspace = true schemars.workspace = true @@ -32,8 +34,8 @@ serde_yaml.workspace = true sha2.workspace = true sqlx.workspace = true tempdir.workspace = true -tempfile = "3.12.0" -thiserror = "1.0.63" +tempfile.workspace = true +thiserror.workspace = true tokio.workspace = true tracing.workspace = true which.workspace = true diff --git a/devenv/src/lib.rs b/devenv/src/lib.rs index c95ab36ee..5a894696d 100644 --- a/devenv/src/lib.rs +++ b/devenv/src/lib.rs @@ -3,7 +3,7 @@ pub(crate) mod cnix; pub mod config; mod devenv; pub mod log; -pub mod tasks; pub use cli::{default_system, GlobalOptions}; pub use devenv::{Devenv, DevenvOptions}; +pub use devenv_tasks as tasks; From 87caa64d15c49dba851f8747f2c6b66a1324af19 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 5 Oct 2024 18:10:46 +0400 Subject: [PATCH 3/5] tasks: use new bin name for tasks --- src/modules/tasks.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/tasks.nix b/src/modules/tasks.nix index d3265a6d0..6ca5f62b8 100644 --- a/src/modules/tasks.nix +++ b/src/modules/tasks.nix @@ -12,7 +12,7 @@ let pkgs.writeScript name '' #!${pkgs.lib.getBin config.package}/bin/${config.binary} ${command} - ${lib.optionalString (config.exports != []) "${devenv}/bin/tasks export ${lib.concatStringsSep " " config.exports}"} + ${lib.optionalString (config.exports != []) "${devenv}/bin/devenv-tasks export ${lib.concatStringsSep " " config.exports}"} ''; in { @@ -137,13 +137,13 @@ in }; }; enterShell = '' - ${devenv}/bin/tasks run devenv:enterShell + ${devenv}/bin/devenv-tasks run devenv:enterShell if [ -f "$DEVENV_DOTFILE/load-exports" ]; then source "$DEVENV_DOTFILE/load-exports" fi ''; enterTest = '' - ${devenv}/bin/tasks run devenv:enterTest + ${devenv}/bin/devenv-tasks run devenv:enterTest ''; }; } From da127c2a36b934793613f66f5821af2fd8896a18 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 5 Oct 2024 18:30:56 +0400 Subject: [PATCH 4/5] chore: re-arrange test deps --- Cargo.lock | 146 ++-------------------------------------- Cargo.toml | 10 +-- devenv-tasks/Cargo.toml | 3 + devenv/Cargo.toml | 4 -- 4 files changed, 12 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 960d9a274..f247b5629 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,6 @@ dependencies = [ "miette", "nix", "petgraph", - "pretty_assertions", "regex", "reqwest", "schemars", @@ -560,7 +559,6 @@ dependencies = [ "sqlx", "tempdir", "tempfile", - "test-log", "thiserror", "tokio", "tracing", @@ -605,6 +603,7 @@ dependencies = [ "console", "miette", "petgraph", + "pretty_assertions", "serde", "serde_json", "tempfile", @@ -697,27 +696,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1284,15 +1262,6 @@ dependencies = [ "unicode-id", ] -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "md-5" version = "0.10.6" @@ -1413,16 +1382,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -1541,12 +1500,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "owo-colors" version = "4.0.0" @@ -1799,17 +1752,8 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1820,15 +1764,9 @@ checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.2" @@ -2165,15 +2103,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "shlex" version = "1.3.0" @@ -2618,28 +2547,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "test-log" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dffced63c2b5c7be278154d76b479f9f9920ed34e7574201407f0b14e2bbb93" -dependencies = [ - "env_logger", - "test-log-macros", - "tracing-subscriber", -] - -[[package]] -name = "test-log-macros" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - [[package]] name = "textwrap" version = "0.16.1" @@ -2671,16 +2578,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "time" version = "0.3.36" @@ -2826,35 +2723,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", ] [[package]] @@ -2949,12 +2817,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index cd6a10d1c..8d3b48f2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ clap = { version = "4.5.1", features = ["derive", "cargo"] } cli-table = "0.4.7" console = "0.15.8" dotlock = "0.5.0" -fs2 = "0.4.3" futures = "0.3.30" hex = "0.4.3" include_dir = "0.7.3" @@ -30,8 +29,10 @@ lazy_static = "1.5.0" miette = { version = "7.1.0", features = ["fancy"] } nix = { version = "0.28.0", features = ["signal"] } petgraph = "0.6.5" +pretty_assertions = { version = "1.4.0", features = ["unstable"] } regex = "1.10.3" reqwest = "0.11.26" +schemars = "0.8.16" schematic = { version = "0.14.3", features = [ "schema", "yaml", @@ -48,9 +49,6 @@ tempdir = "0.3.7" tempfile = "3.12.0" thiserror = "1.0.63" tracing = "0.1.40" -which = "6.0.0" -whoami = "1.5.1" -xdg = "2.5.2" tokio = { version = "1.39.3", features = [ "process", "fs", @@ -60,7 +58,9 @@ tokio = { version = "1.39.3", features = [ "sync", "time", ] } -schemars = "0.8.16" +which = "6.0.0" +whoami = "1.5.1" +xdg = "2.5.2" # Always build optimized sqlx-macro to speed up query checks [profile.dev.package.sqlx-macros] diff --git a/devenv-tasks/Cargo.toml b/devenv-tasks/Cargo.toml index 7f1a5c798..1afbf238d 100644 --- a/devenv-tasks/Cargo.toml +++ b/devenv-tasks/Cargo.toml @@ -15,3 +15,6 @@ tempfile.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true + +[dev-dependencies] +pretty_assertions.workspace = true diff --git a/devenv/Cargo.toml b/devenv/Cargo.toml index 45964c618..d7b573137 100644 --- a/devenv/Cargo.toml +++ b/devenv/Cargo.toml @@ -41,7 +41,3 @@ tracing.workspace = true which.workspace = true whoami.workspace = true xdg.workspace = true - -[dev-dependencies] -pretty_assertions = { version = "1.4.0", features = ["unstable"] } -test-log = { version = "0.2.16", features = ["trace"] } From f6afdf262b4356338c70df319f88bc3721e01944 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 5 Oct 2024 18:33:25 +0400 Subject: [PATCH 5/5] chore: drop unused dependency --- Cargo.lock | 11 ----------- devenv/Cargo.toml | 1 - 2 files changed, 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f247b5629..2d763fd4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,7 +541,6 @@ dependencies = [ "devenv-eval-cache", "devenv-tasks", "dotlock", - "fs2", "hex", "include_dir", "indoc", @@ -787,16 +786,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" diff --git a/devenv/Cargo.toml b/devenv/Cargo.toml index d7b573137..bd03b42b5 100644 --- a/devenv/Cargo.toml +++ b/devenv/Cargo.toml @@ -17,7 +17,6 @@ clap.workspace = true cli-table.workspace = true console.workspace = true dotlock.workspace = true -fs2.workspace = true hex.workspace = true include_dir.workspace = true indoc.workspace = true