Skip to content

Commit

Permalink
Merge pull request #63 from Mic92/fix-macos
Browse files Browse the repository at this point in the history
Fix macos
  • Loading branch information
Mic92 committed Jun 25, 2024
2 parents cfff239 + ac5d392 commit 02c50df
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:
self-test:
strategy:
matrix:
# macos has weird SIGBUS errors in github that I cannot reproduce on aarch64-darwin...
#os: [ ubuntu-latest, macos-latest ]
os: [ ubuntu-latest ]
os: [ ubuntu-latest, macos-latest ]
nom: [ "", "--no-nom"]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -35,8 +33,7 @@ jobs:
tests:
strategy:
matrix:
#os: [ ubuntu-latest, macos-latest ]
os: [ ubuntu-latest ]
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -48,5 +45,8 @@ jobs:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- name: Install nix-eval-jobs for remote test
run: nix profile install --inputs-from . nixpkgs#nix-eval-jobs
- run: command -v nix-eval-jobs && nix-eval-jobs --help
- name: Run tests
run: nix develop -c pytest ./tests
3 changes: 3 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
queue_rules:
- name: default
merge_conditions:
- check-success=self-test (macos-latest)
- check-success=self-test (macos-latest, --no-nom)
- check-success=self-test (ubuntu-latest)
- check-success=self-test (ubuntu-latest, --no-nom)
- check-success=tests (macos-latest)
- check-success=tests (ubuntu-latest)
defaults:
actions:
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Evaluate and build in parallel";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
flake-parts.url = "github:hercules-ci/flake-parts";

treefmt-nix.url = "github:numtide/treefmt-nix";
Expand Down
31 changes: 10 additions & 21 deletions nix_fast_build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,9 @@ def upload_sources(opts: Options) -> str:
)


def nix_shell(packages: list[str]) -> list[str]:
return nix_command(
[
"shell",
"--extra-experimental-features",
"nix-command",
"--extra-experimental-features",
"flakes",
*packages,
"-c",
]
)
def nix_shell(fallback_package: str, wanted_command: str) -> list[str]:
bash_cmd = 'pkg=$1; shift; cmd=("$@"); if command -v "${cmd[0]}" >/dev/null; then exec "${cmd[@]}"; else exec nix --experimental-features "nix-command flakes" shell "$pkg" -c "${cmd[@]}"; fi'
return ["bash", "-c", bash_cmd, "bash", fallback_package, wanted_command]


@asynccontextmanager
Expand Down Expand Up @@ -438,7 +429,6 @@ async def remote_temp_dir(opts: Options) -> AsyncIterator[Path]:
@asynccontextmanager
async def nix_eval_jobs(tmp_dir: Path, opts: Options) -> AsyncIterator[Process]:
args = [
"nix-eval-jobs",
"--gc-roots-dir",
str(tmp_dir / "gcroots"),
"--force-recurse",
Expand All @@ -453,7 +443,9 @@ async def nix_eval_jobs(tmp_dir: Path, opts: Options) -> AsyncIterator[Process]:
if opts.skip_cached:
args.append("--check-cache-status")
if opts.remote:
args = nix_shell(["nixpkgs#nix-eval-jobs"]) + args
args = nix_shell("nixpkgs#nix-eval-jobs", "nix-eval-jobs") + args
else:
args = ["nix-eval-jobs", *args]
args = maybe_remote(args, opts)
logger.info("run %s", shlex.join(args))
proc = await asyncio.create_subprocess_exec(
Expand All @@ -468,7 +460,7 @@ async def nix_eval_jobs(tmp_dir: Path, opts: Options) -> AsyncIterator[Process]:

@asynccontextmanager
async def nix_output_monitor(pipe: Pipe, opts: Options) -> AsyncIterator[Process]:
cmd = maybe_remote([*nix_shell(["nixpkgs#nix-output-monitor"]), "nom"], opts)
cmd = maybe_remote([*nix_shell("nixpkgs#nix-output-monitor", "nom")], opts)
proc = await asyncio.create_subprocess_exec(*cmd, stdin=pipe.read_file)
try:
yield proc
Expand All @@ -491,8 +483,7 @@ async def run_cachix_daemon(
sock_path = tmp_dir / "cachix.sock"
cmd = maybe_remote(
[
*nix_shell(["nixpkgs#cachix"]),
"cachix",
*nix_shell("nixpkgs#cachix", "cachix"),
"daemon",
"run",
"--socket",
Expand Down Expand Up @@ -520,8 +511,7 @@ async def run_cachix_daemon_stop(
return 0
cmd = maybe_remote(
[
*nix_shell(["nixpkgs#cachix"]),
"cachix",
*nix_shell("nixpkgs#cachix", "cachix"),
"daemon",
"stop",
"--socket",
Expand Down Expand Up @@ -590,8 +580,7 @@ async def upload_cachix(
return 0
cmd = maybe_remote(
[
*nix_shell(["nixpkgs#cachix"]),
"cachix",
*nix_shell("nixpkgs#cachix", "cachix"),
"daemon",
"push",
"--socket",
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pythonpath = [ "." ]
[tool.ruff]
target-version = "py311"
line-length = 88
select = ["ALL"]
ignore = [
lint.select = ["ALL"]
lint.ignore = [
# pydocstyle
"D",
# todo comments
Expand Down Expand Up @@ -100,6 +100,8 @@ ignore = [
# Starting a process with a partial executable path
"S607",

# Too many branches
"PLR0912",
# Too many statements
"PLR0915",
# Too many arguments in function definition
Expand Down

0 comments on commit 02c50df

Please sign in to comment.