about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-12-09T11·14+0200
committerclbot <clbot@tvl.fyi>2023-12-09T12·58+0000
commitf11c6d610ce002774df714cf2c998989643dccfa (patch)
tree6afb85e6b90bdbf74dbecbd037bc4d8d631081ca
parent0907420600ba0f9270065dd83e81fb8f56dfda71 (diff)
chore(tvix/nix_cli): drop crate r/7133
The only thing this was doing was invoking nix-store --add, which is not
gonna help us populate the tvix-store at all (and we now have
`tvix-store import`).

This is also (rightfully) causing clippy warnings, because of some
fields being unused.

It's more of a skeleton, and rather than shelling out to Nix for some
usecases, we might introduce a "compatible" Nix CLI frontend for a
subset of commands.

Drop this for now, to decrease the noise and confusion.

Change-Id: I2fd399e9320260f08893b685561755af9c7c961c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10226
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
-rw-r--r--tvix/Cargo.lock8
-rw-r--r--tvix/Cargo.nix45
-rw-r--r--tvix/Cargo.toml1
-rw-r--r--tvix/nix_cli/Cargo.toml18
-rw-r--r--tvix/nix_cli/default.nix5
-rw-r--r--tvix/nix_cli/src/bin/nix-store.rs106
-rw-r--r--tvix/nix_cli/src/main.rs3
7 files changed, 0 insertions, 186 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock
index d6f96feaf889..e1838f331760 100644
--- a/tvix/Cargo.lock
+++ b/tvix/Cargo.lock
@@ -1532,14 +1532,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "nix-cli"
-version = "0.1.0"
-dependencies = [
- "clap 4.2.7",
- "tempfile",
-]
-
-[[package]]
 name = "nix-compat"
 version = "0.1.0"
 dependencies = [
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index 6270f89761e0..b6d17d21651c 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -33,16 +33,6 @@ rec {
   # You can override the features with
   # workspaceMembers."${crateName}".build.override { features = [ "default" "feature1" ... ]; }.
   workspaceMembers = {
-    "nix-cli" = rec {
-      packageId = "nix-cli";
-      build = internal.buildRustCrateWithFeatures {
-        packageId = "nix-cli";
-      };
-
-      # Debug support which might change between releases.
-      # File a bug if you depend on any for non-debug work!
-      debug = internal.debugCrate { inherit packageId; };
-    };
     "nix-compat" = rec {
       packageId = "nix-compat";
       build = internal.buildRustCrateWithFeatures {
@@ -4607,41 +4597,6 @@ rec {
         };
         resolvedDefaultFeatures = [ "feature" "fs" "user" ];
       };
-      "nix-cli" = rec {
-        crateName = "nix-cli";
-        version = "0.1.0";
-        edition = "2021";
-        crateBin = [
-          {
-            name = "nix-cli";
-            path = "src/main.rs";
-            requiredFeatures = [ ];
-          }
-          {
-            name = "nix-store";
-            path = "src/bin/nix-store.rs";
-            requiredFeatures = [ ];
-          }
-        ];
-        # We can't filter paths with references in Nix 2.4
-        # See https://github.com/NixOS/nix/issues/5410
-        src =
-          if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
-          then lib.cleanSourceWith { filter = sourceFilter; src = ./nix_cli; }
-          else ./nix_cli;
-        dependencies = [
-          {
-            name = "clap";
-            packageId = "clap 4.2.7";
-          }
-          {
-            name = "tempfile";
-            packageId = "tempfile";
-          }
-        ];
-        features = { };
-        resolvedDefaultFeatures = [ "integration_tests" ];
-      };
       "nix-compat" = rec {
         crateName = "nix-compat";
         version = "0.1.0";
diff --git a/tvix/Cargo.toml b/tvix/Cargo.toml
index 167e0aa2e2c0..0642c3238818 100644
--- a/tvix/Cargo.toml
+++ b/tvix/Cargo.toml
@@ -24,7 +24,6 @@ members = [
   "eval",
   "eval/builtin-macros",
   "glue",
-  "nix_cli",
   "nix-compat",
   "serde",
   "store",
diff --git a/tvix/nix_cli/Cargo.toml b/tvix/nix_cli/Cargo.toml
deleted file mode 100644
index f9de2b97706b..000000000000
--- a/tvix/nix_cli/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-name = "nix-cli"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies.clap]
-version = "4.0"
-
-[dependencies.tempfile]
-version = "3.2.0"
-
-[[bin]]
-name = "nix-store"
-
-[features]
-integration_tests = []
diff --git a/tvix/nix_cli/default.nix b/tvix/nix_cli/default.nix
deleted file mode 100644
index 4c79e46cabfa..000000000000
--- a/tvix/nix_cli/default.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ depot, ... }:
-
-depot.tvix.crates.workspaceMembers.nix-cli.build.override {
-  runTests = true;
-}
diff --git a/tvix/nix_cli/src/bin/nix-store.rs b/tvix/nix_cli/src/bin/nix-store.rs
deleted file mode 100644
index 1cd64e8d1cee..000000000000
--- a/tvix/nix_cli/src/bin/nix-store.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-fn main() {
-    main_args(std::env::args().collect()).unwrap_or_else(|e| e.exit());
-}
-
-pub fn main_args(args: Vec<String>) -> clap::error::Result<NixResult> {
-    let matches = clap::Command::new("nix-store")
-        .subcommand(clap::Command::new("--add").arg(clap::Arg::new("FILE").required(true).index(1)))
-        .try_get_matches_from(args.iter())?;
-    if let Some(add) = matches.subcommand_matches("--add") {
-        let file = add.get_one::<String>("FILE").expect("--add needs a file");
-        let file_contents = std::fs::read_to_string(file)
-            .unwrap_or_else(|_| panic!("file {} does not exist", file));
-        Ok(NixResult::FileAddedToStore {
-            content: file_contents,
-        })
-    } else {
-        panic!("read some arguments that we do not know: {:?}", args)
-    }
-}
-
-#[derive(Debug, Eq, PartialEq)]
-pub enum NixResult {
-    FileAddedToStore { content: String },
-}
-
-#[cfg(test)]
-mod integration_tests {
-    use std::collections::VecDeque;
-    use std::io::Write;
-
-    use super::*;
-
-    #[derive(Debug)]
-    enum NixOutput {
-        #[allow(dead_code)]
-        Err {
-            status: i32,
-            stdout: String,
-            stderr: String,
-        },
-        Ok {
-            stdout: String,
-            stderr: String,
-        },
-    }
-
-    fn run_nix_command(cmd: &str, args: Vec<String>) -> NixOutput {
-        let out = std::process::Command::new(cmd)
-            .args(args)
-            .output()
-            .unwrap_or_else(|_| panic!("could not run {}", cmd));
-        match out.status.code().expect("no status code!") {
-            0 => NixOutput::Ok {
-                stdout: String::from_utf8_lossy(&out.stdout).trim_end().to_string(),
-                stderr: String::from_utf8_lossy(&out.stderr).trim_end().to_string(),
-            },
-            status => NixOutput::Err {
-                status,
-                stdout: String::from_utf8_lossy(&out.stdout).trim_end().to_string(),
-                stderr: String::from_utf8_lossy(&out.stderr).trim_end().to_string(),
-            },
-        }
-    }
-
-    fn nix_nix_store<'a>(args: Vec<String>) -> NixResult {
-        match run_nix_command("nix-store", args) {
-            err @ NixOutput::Err { .. } => panic!("nix-store --add failed: {:#?}", err),
-            NixOutput::Ok { stdout, .. } => NixResult::FileAddedToStore {
-                content: std::fs::read_to_string(&stdout)
-                    .unwrap_or_else(|_| panic!("cannot open {} as store file", stdout)),
-            },
-        }
-    }
-
-    fn tvix_nix_store<'a>(args: Vec<String>) -> NixResult {
-        eprintln!("running tvix with arguments {:?}", args);
-        let mut args = VecDeque::from(args);
-        args.push_front("tvix-store".to_string());
-        super::main_args(Vec::from(args))
-            .unwrap_or_else(|e| panic!("clap command line parsing failed:\n{}", e))
-    }
-
-    #[test]
-    #[cfg_attr(not(feature = "integration_tests"), ignore)]
-    fn test_nix_store_add() {
-        let file_content = "I am a copied file";
-        let mut tempfile = tempfile::NamedTempFile::new().expect("cannot create temp file");
-        tempfile
-            .write_all(file_content.as_bytes())
-            .expect("could not write to tempfile");
-        assert_eq!(
-            tvix_nix_store(vec![
-                "--add".to_string(),
-                tempfile.path().as_os_str().to_string_lossy().into_owned()
-            ]),
-            nix_nix_store(vec![
-                "--add".to_string(),
-                tempfile.path().as_os_str().to_string_lossy().into_owned()
-            ]),
-            "added file contents were not the same"
-        );
-
-        // make sure the tempfile lives till here
-        drop(tempfile)
-    }
-}
diff --git a/tvix/nix_cli/src/main.rs b/tvix/nix_cli/src/main.rs
deleted file mode 100644
index 40086e6f27ee..000000000000
--- a/tvix/nix_cli/src/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
-    println!("Hello, tvix!");
-}