diff --git a/crates/nix_rs/crate.nix b/crates/nix_rs/crate.nix index 28a3ab9c..a09433a9 100644 --- a/crates/nix_rs/crate.nix +++ b/crates/nix_rs/crate.nix @@ -1,9 +1,17 @@ +{ pkgs, lib, ... }: { - 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 + 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-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-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..927ecdf3 100644 --- a/crates/omnix-common/crate.nix +++ b/crates/omnix-common/crate.nix @@ -1,3 +1,17 @@ +{ pkgs, lib, ... }: { - autoWire = [ ]; + # 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 + ] + ); + cargoTestExtraArgs = "-- " + (lib.concatStringsSep " " [ + # requires networking + "--skip=config::test_get_omconfig_from_remote_flake_with_attr" + ]); + }; }