From fdc3397567635053b92784e0e7630351224e648f Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Wed, 5 Mar 2025 14:56:47 +0530 Subject: [PATCH 1/3] chore: Enable Nix sandbox tests where applicable; Enable clippy The clippy issue was on nightly. As of https://github.com/juspay/omnix/pull/427 we are no longer on nightly --- crates/nix_rs/crate.nix | 8 +++++--- crates/nix_rs/src/command.rs | 2 +- crates/omnix-ci/crate.nix | 8 +++++--- crates/omnix-ci/src/step/custom.rs | 1 - crates/omnix-cli/crate.nix | 26 +++++++++++++++++++++++--- crates/omnix-common/crate.nix | 8 +++++++- crates/omnix-health/src/check/shell.rs | 4 ++-- crates/omnix-health/src/json.rs | 2 +- om.yaml | 18 ++++++++---------- 9 files changed, 52 insertions(+), 25 deletions(-) diff --git a/crates/nix_rs/crate.nix b/crates/nix_rs/crate.nix index 28a3ab9c..ffc380a7 100644 --- a/crates/nix_rs/crate.nix +++ b/crates/nix_rs/crate.nix @@ -1,9 +1,11 @@ +{ pkgs, ... }: { - autoWire = [ ]; + # Autowiring `crate` so that the tests are run in nix sandbox when `om ci` is used + autoWire = [ "crate" ]; crane = { args = { - nativeBuildInputs = [ - # nix # Tests need nix cli + nativeBuildInputs = with pkgs; [ + nix # Tests need nix cli ]; }; }; diff --git a/crates/nix_rs/src/command.rs b/crates/nix_rs/src/command.rs index 291560a2..27aa9432 100644 --- a/crates/nix_rs/src/command.rs +++ b/crates/nix_rs/src/command.rs @@ -79,7 +79,7 @@ impl NixCmd { pub fn command(&self) -> Command { let mut cmd = Command::new("nix"); cmd.kill_on_drop(true); - cmd.args(self.args.into_iter()); + cmd.args(&self.args); cmd } diff --git a/crates/omnix-ci/crate.nix b/crates/omnix-ci/crate.nix index ffa289d7..be67f3f5 100644 --- a/crates/omnix-ci/crate.nix +++ b/crates/omnix-ci/crate.nix @@ -12,6 +12,7 @@ ] ++ [ libiconv pkg-config + nix ]; buildInputs = lib.optionals pkgs.stdenv.isDarwin ( @@ -22,9 +23,10 @@ ) ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.openssl ]; - # Disable tests due to sandboxing issues; we run them on CI - # instead. - doCheck = false; + cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ + # requires networking + "--skip=config::core::tests::test_config_loading" + ]); }; }; } diff --git a/crates/omnix-ci/src/step/custom.rs b/crates/omnix-ci/src/step/custom.rs index 99f2381f..83d75d14 100644 --- a/crates/omnix-ci/src/step/custom.rs +++ b/crates/omnix-ci/src/step/custom.rs @@ -76,7 +76,6 @@ impl CustomStep { override_inputs: subflake.override_inputs.clone(), current_dir: Some(path.clone()), no_write_lock_file: false, - ..Default::default() }; match self { diff --git a/crates/omnix-cli/crate.nix b/crates/omnix-cli/crate.nix index 36ec3674..41bdc77d 100644 --- a/crates/omnix-cli/crate.nix +++ b/crates/omnix-cli/crate.nix @@ -21,6 +21,7 @@ in # > error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin` (if (stdenv.isDarwin && stdenv.isAarch64) then pkgsStatic.libiconv else pkgs.libiconv) pkgs.pkg-config + pkgs.nix ]; buildInputs = lib.optionals pkgs.stdenv.isDarwin ( @@ -32,9 +33,28 @@ in pkgsStatic.openssl ]; - # Disable tests due to sandboxing issues; we run them on CI - # instead. - doCheck = false; + cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ + # requires networking + "--skip=command::ci::build_flake_output" + "--skip=command::ci::test_haskell_multi_nix" + "--skip=command::ci::test_haskell_multi_nix_all_dependencies" + "--skip=command::ci::test_services_flake" + "--skip=command::show::om_show_nixos_configurations" + "--skip=command::show::om_show_remote" + + # required health checks, like "Flakes Enabled" and "Max Jobs" fails in sandbox + "--skip=command::health::om_health" + + # error: creating directory '/nix/var/nix/profiles': Permission denied + # TODO: elaborate on the error + "--skip=command::init::om_init" + + # FIXME: This should pass in the sandbox + # > ❄\u{fe0f} nix -j auto eval --json --override-input flake ../.. --override-input flake-schemas /nix/store/0npxvlidr0w1b99lrvcmd2wd46y2kibh-flake-schemas --override-input systems /nix/store/g1pv78p6lk92hjzr7syrcihvj4rx1fnz-source --no-write-lock-file \'/nix/store/qm8q4kylp1jy68k34c2bskpamxgyc9ix-source#contents.excludingOutputPaths\' --quiet --quiet\u{fe0f} + # > error: experimental Nix feature \'nix-command\' is disabled; use \'--extra-experimental-features nix-command\' to override + # > Error: Unable to fetch flake + "--skip=command::show::om_show_local" + ]); meta = { description = "Command-line interface for Omnix"; mainProgram = "om"; diff --git a/crates/omnix-common/crate.nix b/crates/omnix-common/crate.nix index 4d29b8f9..f4dc1f65 100644 --- a/crates/omnix-common/crate.nix +++ b/crates/omnix-common/crate.nix @@ -1,3 +1,9 @@ +{ lib, ... }: { - autoWire = [ ]; + # Autowiring `crate` so that the tests are run in nix sandbox when `om ci` is used + autoWire = [ "crate" ]; + crane.args.cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ + # requires networking + "--skip=config::test_get_omconfig_from_remote_flake_with_attr" + ]); } diff --git a/crates/omnix-health/src/check/shell.rs b/crates/omnix-health/src/check/shell.rs index 3f4719ac..fbed53ec 100644 --- a/crates/omnix-health/src/check/shell.rs +++ b/crates/omnix-health/src/check/shell.rs @@ -172,9 +172,9 @@ impl Shell { OS::MacOS { .. } => "Library/Application Support/nushell", _ => ".config/nushell", }; - vec!["env.nu", "config.nu", "login.nu"] + ["env.nu", "config.nu", "login.nu"] .iter() - .map(|f| format!("{}/{}", base, f).into()) + .map(|f| format!("{}/{}", base, f)) .collect() } } diff --git a/crates/omnix-health/src/json.rs b/crates/omnix-health/src/json.rs index f69e7bbf..45e26993 100644 --- a/crates/omnix-health/src/json.rs +++ b/crates/omnix-health/src/json.rs @@ -51,7 +51,7 @@ impl HealthEnvInfo { .context("Unable to gather nix info")?; Ok(Self { - nix_installer: nix_info.nix_env.installer.clone().into(), + nix_installer: nix_info.nix_env.installer.clone(), system: nix_info.nix_config.system.value.clone(), os: nix_info.nix_env.os.clone(), total_memory: nix_info.nix_env.total_memory, diff --git a/om.yaml b/om.yaml index e99a1aa2..b3dbf269 100644 --- a/om.yaml +++ b/om.yaml @@ -25,16 +25,14 @@ ci: systems: - x86_64-linux - aarch64-darwin - # Disabled until upstream bug is fixed, - # https://github.com/rust-lang/rust-clippy/issues/14045 - # cargo-clippy: - # type: devshell - # command: - # - just - # - clippy - # systems: - # - x86_64-linux - # - aarch64-darwin + cargo-clippy: + type: devshell + command: + - just + - clippy + systems: + - x86_64-linux + - aarch64-darwin cargo-doc: type: devshell command: From 87bd8dd734c85c61053b4ddb42b3c5f5578e8d37 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Wed, 5 Mar 2025 19:19:31 +0530 Subject: [PATCH 2/3] fix mac build --- crates/nix_rs/crate.nix | 8 +++++++- crates/omnix-common/crate.nix | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/nix_rs/crate.nix b/crates/nix_rs/crate.nix index ffc380a7..a09433a9 100644 --- a/crates/nix_rs/crate.nix +++ b/crates/nix_rs/crate.nix @@ -1,9 +1,15 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { # Autowiring `crate` so that the tests are run in nix sandbox when `om ci` is used autoWire = [ "crate" ]; crane = { args = { + buildInputs = lib.optionals pkgs.stdenv.isDarwin ( + with pkgs.apple_sdk_frameworks; [ + IOKit + SystemConfiguration + ] + ); nativeBuildInputs = with pkgs; [ nix # Tests need nix cli ]; diff --git a/crates/omnix-common/crate.nix b/crates/omnix-common/crate.nix index f4dc1f65..927ecdf3 100644 --- a/crates/omnix-common/crate.nix +++ b/crates/omnix-common/crate.nix @@ -1,9 +1,17 @@ -{ lib, ... }: +{ pkgs, lib, ... }: { # Autowiring `crate` so that the tests are run in nix sandbox when `om ci` is used autoWire = [ "crate" ]; - crane.args.cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ - # requires networking - "--skip=config::test_get_omconfig_from_remote_flake_with_attr" - ]); + crane.args = { + buildInputs = lib.optionals pkgs.stdenv.isDarwin ( + with pkgs.apple_sdk_frameworks; [ + IOKit + SystemConfiguration + ] + ); + cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ + # requires networking + "--skip=config::test_get_omconfig_from_remote_flake_with_attr" + ]); + }; } From d009c5365a91bc382a26ebb14c85371e14d36cc7 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Wed, 5 Mar 2025 19:30:32 +0530 Subject: [PATCH 3/3] revert clippy changes --- crates/nix_rs/src/command.rs | 2 +- crates/omnix-ci/src/step/custom.rs | 1 + crates/omnix-health/src/check/shell.rs | 4 ++-- crates/omnix-health/src/json.rs | 2 +- om.yaml | 18 ++++++++++-------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/nix_rs/src/command.rs b/crates/nix_rs/src/command.rs index 27aa9432..291560a2 100644 --- a/crates/nix_rs/src/command.rs +++ b/crates/nix_rs/src/command.rs @@ -79,7 +79,7 @@ impl NixCmd { pub fn command(&self) -> Command { let mut cmd = Command::new("nix"); cmd.kill_on_drop(true); - cmd.args(&self.args); + cmd.args(self.args.into_iter()); cmd } diff --git a/crates/omnix-ci/src/step/custom.rs b/crates/omnix-ci/src/step/custom.rs index 83d75d14..99f2381f 100644 --- a/crates/omnix-ci/src/step/custom.rs +++ b/crates/omnix-ci/src/step/custom.rs @@ -76,6 +76,7 @@ impl CustomStep { override_inputs: subflake.override_inputs.clone(), current_dir: Some(path.clone()), no_write_lock_file: false, + ..Default::default() }; match self { diff --git a/crates/omnix-health/src/check/shell.rs b/crates/omnix-health/src/check/shell.rs index fbed53ec..3f4719ac 100644 --- a/crates/omnix-health/src/check/shell.rs +++ b/crates/omnix-health/src/check/shell.rs @@ -172,9 +172,9 @@ impl Shell { OS::MacOS { .. } => "Library/Application Support/nushell", _ => ".config/nushell", }; - ["env.nu", "config.nu", "login.nu"] + vec!["env.nu", "config.nu", "login.nu"] .iter() - .map(|f| format!("{}/{}", base, f)) + .map(|f| format!("{}/{}", base, f).into()) .collect() } } diff --git a/crates/omnix-health/src/json.rs b/crates/omnix-health/src/json.rs index 45e26993..f69e7bbf 100644 --- a/crates/omnix-health/src/json.rs +++ b/crates/omnix-health/src/json.rs @@ -51,7 +51,7 @@ impl HealthEnvInfo { .context("Unable to gather nix info")?; Ok(Self { - nix_installer: nix_info.nix_env.installer.clone(), + nix_installer: nix_info.nix_env.installer.clone().into(), system: nix_info.nix_config.system.value.clone(), os: nix_info.nix_env.os.clone(), total_memory: nix_info.nix_env.total_memory, diff --git a/om.yaml b/om.yaml index b3dbf269..e99a1aa2 100644 --- a/om.yaml +++ b/om.yaml @@ -25,14 +25,16 @@ ci: systems: - x86_64-linux - aarch64-darwin - cargo-clippy: - type: devshell - command: - - just - - clippy - systems: - - x86_64-linux - - aarch64-darwin + # Disabled until upstream bug is fixed, + # https://github.com/rust-lang/rust-clippy/issues/14045 + # cargo-clippy: + # type: devshell + # command: + # - just + # - clippy + # systems: + # - x86_64-linux + # - aarch64-darwin cargo-doc: type: devshell command: