diff --git a/package/linux-devshell/default.nix b/package/linux-devshell/default.nix index 37f6d31..53185ca 100644 --- a/package/linux-devshell/default.nix +++ b/package/linux-devshell/default.nix @@ -30,7 +30,7 @@ let name = "linux-devshell"; executable = true; text = '' - #!${shell} + #!/bin/sh ${lib.concatMapStringsSep "\n" (option: "set -o ${option}") bashOptions} ${logHelpers} diff --git a/test/package/linux-devshell/run-test.sh b/test/package/linux-devshell/run-test.sh new file mode 100755 index 0000000..7c3893e --- /dev/null +++ b/test/package/linux-devshell/run-test.sh @@ -0,0 +1,47 @@ +#!/bin/dash +set -eu + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +echo "Building standalone script..." +nix build "${REPO_ROOT}#linux-devshell-standalone" --no-link +STANDALONE_SCRIPT="$(nix build "${REPO_ROOT}#linux-devshell-standalone" --print-out-paths)" + +echo "Standalone script built at: ${STANDALONE_SCRIPT}" + +echo "Creating test repo..." +TEST_REPO="$(mktemp -d)" +trap 'rm -rf "$TEST_REPO"' EXIT + +mkdir -p "${TEST_REPO}/script" +cp "$STANDALONE_SCRIPT" "${TEST_REPO}/script/linux-devshell" +chmod +x "${TEST_REPO}/script/linux-devshell" + +cat > "${TEST_REPO}/flake.nix" <<'FLAKE' +{ + description = "Test flake for linux-devshell"; + + outputs = { self, nixpkgs }: { + devShells.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { + shellHook = '' + echo "=== Inside dev shell ===" + echo "This is a test dev shell" + exit 0 + ''; + }; + }; +} +FLAKE + +echo "Test repo created at: ${TEST_REPO}" +echo "" +echo "Running linux-devshell in Arch Linux container..." + +docker run --rm -it \ + -v "${TEST_REPO}:/test-repo:ro" \ + -w /test-repo \ + archlinux:latest \ + /test-repo/script/linux-devshell || { + echo "Test completed (exit code: $?)" + }