From ef86d7e82ae2aedb5b266d713c5cda7345ac90cc Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Wed, 21 Jan 2026 23:46:58 +0100 Subject: [PATCH 1/4] Indicating the Rust version to use when building with Nix properly in the overlay Before it was only used in the devshell; now it is also used when compiling the binary targets. --- default.nix | 5 +---- nix/overlay.nix | 16 +++++++++++++++- rust-toolchain.toml | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index ca28c9e..79a7e76 100644 --- a/default.nix +++ b/default.nix @@ -22,9 +22,6 @@ let ] ); - # We choose a minimal Rust channel to keep the Nix closure size smaller - rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - defaultEnv = pkgs.buildEnv { name = "opsqueue-env-default"; paths = [ @@ -39,7 +36,7 @@ let pkgs.ruff # For compiling the Rust parts - rust + pkgs.rustToolchain pkgs.sqlx-cli # Manage nix pins diff --git a/nix/overlay.nix b/nix/overlay.nix index 3f8c455..7e3fd0d 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -2,9 +2,23 @@ final: prev: let pythonOverlay = import ./python-overlay.nix; + + # We want to use the same Rust version in Nix + # as we use when _not_ using Nix. + # + # When using opsqueue as part of your own Nix derivations, + # be sure to use an overlay to set `rustPlatform` + # to the desired Rust version + # if you want to use a different version from the default. + rustToolchain = final.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml; + rustPlatform = prev.makeRustPlatform { + rustc = rustToolchain; + cargo = rustToolchain; + }; in { - opsqueue = final.callPackage ../opsqueue/opsqueue.nix { }; + rustToolchain = rustToolchain; + opsqueue = final.callPackage ../opsqueue/opsqueue.nix { rustPlatform = final.rustPlatform; }; # The explicit choice is made not to override `python312`, as this will cause a rebuild of many # packages when nixpkgs uses python 3.12 as default python environment. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 693a919..d292b17 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.92.0" +channel = "1.85.0" components = ["clippy", "rustfmt", "rust-analyzer", "rust-src"] profile = "minimal" From 30419922d8852f7a4a8b184ec14e7e5215270a62 Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Thu, 22 Jan 2026 00:20:51 +0100 Subject: [PATCH 2/4] Build main opsqueue binary in Nix using Crane, caching deps - Make usage of `crane` an implementation detail; - When building with Nix, people get to customize what `rustToolchain` is used, by either setting that in the overlay or directly overriding it when using `callPackage`. - Compile opsqueue_python also with Crane (+ Maturin). - Document how the Nix Crane<->Maturin setup works - Bump Rust version in rust-toolchain.toml from 1.85 to 1.92 This is now also the version used when building with Nix! - Boyscout rule: Fix warning about unused Cargo.toml lib.include key - Boyscout rule: Disable integration test timeouts, to test speed of the Nix-based integration suite run on CI --- .pre-commit-config.yaml | 6 - biome.json | 17 --- justfile | 6 +- .../examples/tracing/tracing_consumer.py | 2 +- .../examples/tracing/tracing_producer.py | 4 +- libs/opsqueue_python/opsqueue_python.nix | 110 +++++++++++------- libs/opsqueue_python/pyproject.toml | 12 +- libs/opsqueue_python/src/common.rs | 5 +- libs/opsqueue_python/src/consumer.rs | 2 +- nix/nixpkgs-pinned.nix | 3 +- nix/overlay.nix | 9 +- nix/sources.json | 30 ++++- opsqueue/Cargo.toml | 2 +- opsqueue/opsqueue.nix | 91 ++++++--------- opsqueue/src/consumer/server/mod.rs | 2 +- rust-toolchain.toml | 2 +- 16 files changed, 158 insertions(+), 145 deletions(-) delete mode 100644 biome.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c136ce..672f66c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,12 +25,6 @@ repos: language: system types: [python] require_serial: true - - id: biome - name: Biome formatting - entry: biome format --write --files-ignore-unknown=true --no-errors-on-unmatched - language: system - types: [json] - require_serial: true - id: rustfmt name: rustfmt entry: cargo fmt -- diff --git a/biome.json b/biome.json deleted file mode 100644 index 8c938a8..0000000 --- a/biome.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "formatter": { - "enabled": true, - "formatWithErrors": true, - "indentStyle": "space", - "lineWidth": 100 - }, - "vcs": { - "enabled": true, - "clientKind": "git", - "useIgnoreFile": true - }, - "files": { - "ignore": ["nix/**"], - "maxSize": 20971520 - } -} diff --git a/justfile b/justfile index bf16498..47d5c5b 100644 --- a/justfile +++ b/justfile @@ -47,11 +47,11 @@ test-integration *TEST_ARGS: build-bin build-python cd libs/opsqueue_python source "./.setup_local_venv.sh" - timeout 30 pytest --color=yes {{TEST_ARGS}} + pytest --color=yes {{TEST_ARGS}} # Python integration test suite, using artefacts built through Nix. Args are forwarded to pytest [group('nix')] -nix-test-integration *TEST_ARGS: +nix-test-integration *TEST_ARGS: nix-build #!/usr/bin/env bash set -euxo pipefail nix_build_python_library_dir=$(just nix-build-python) @@ -61,7 +61,7 @@ nix-test-integration *TEST_ARGS: export OPSQUEUE_VIA_NIX=true export RUST_LOG="opsqueue=debug" - timeout 30 pytest --color=yes {{TEST_ARGS}} + pytest --color=yes {{TEST_ARGS}} # Run all linters, fast and slow [group('lint')] diff --git a/libs/opsqueue_python/examples/tracing/tracing_consumer.py b/libs/opsqueue_python/examples/tracing/tracing_consumer.py index 96e16e7..a319117 100644 --- a/libs/opsqueue_python/examples/tracing/tracing_consumer.py +++ b/libs/opsqueue_python/examples/tracing/tracing_consumer.py @@ -8,7 +8,7 @@ # ConsoleSpanExporter, ) from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter -from opentelemetry.sdk.resources import SERVICE_NAME, Resource +from opentelemetry.sdk.resources import SERVICE_NAME, Resource # type: ignore[attr-defined] logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO) diff --git a/libs/opsqueue_python/examples/tracing/tracing_producer.py b/libs/opsqueue_python/examples/tracing/tracing_producer.py index 2d9a1ed..24f0f13 100644 --- a/libs/opsqueue_python/examples/tracing/tracing_producer.py +++ b/libs/opsqueue_python/examples/tracing/tracing_producer.py @@ -13,7 +13,7 @@ # ConsoleSpanExporter, ) from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter -from opentelemetry.sdk.resources import SERVICE_NAME, Resource +from opentelemetry.sdk.resources import SERVICE_NAME, Resource # type: ignore[attr-defined] from opsqueue.producer import ProducerClient @@ -75,7 +75,7 @@ def added_baggage( yield finally: for attached_token in attached_context_tokens: - opentelemetry.context.detach(attached_token) + opentelemetry.context.detach(attached_token) # type: ignore[arg-type] if __name__ == "__main__": diff --git a/libs/opsqueue_python/opsqueue_python.nix b/libs/opsqueue_python/opsqueue_python.nix index d392480..41fcb28 100644 --- a/libs/opsqueue_python/opsqueue_python.nix +++ b/libs/opsqueue_python/opsqueue_python.nix @@ -1,62 +1,92 @@ { + # Builtin + pkgs, lib, + + # Rust version. (Override this with an overlay if you like) + rustToolchain, + + # Native build dependencies: + python, + maturin, buildPythonPackage, - rustPlatform, perl, git, - # Python packages: + + # Python package dependencies: cbor2, opentelemetry-api, opentelemetry-exporter-otlp, opentelemetry-sdk, }: let - root = ../../.; - util = import (root + /nix/util.nix) { inherit lib; }; -in -buildPythonPackage rec { - pname = "opsqueue"; - version = "0.1.0"; - pyproject = true; + sources = import ../../nix/sources.nix; + crane = import sources.crane { pkgs = pkgs; }; + craneLib = crane.overrideToolchain (pkgs: rustToolchain); + extraFileFilter = path: _type: builtins.match ".*(db|sql|py|md)$" path != null; + fileFilter = path: type: (extraFileFilter path type) || (craneLib.filterCargoSources path type); - src = util.fileFilter { - name = "opsqueue_python"; - src = root; + src = lib.cleanSourceWith { + src = ../../.; + name = "opsqueue"; + filter = fileFilter; + }; - # We're copying slightly too much to the Nix store here, - # but using the more granular file filter was very error-prone. - # This is one thing that could be improved a little in the future. - srcGlobalWhitelist = [ - ".py" - ".pyi" - "py.typed" - ".rs" - ".toml" - ".lock" - ".db" - ".md" - ]; + crateName = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; }; + pname = crateName.pname; + version = crateName.version; + commonArgs = { + inherit src version pname; + strictDeps = true; + nativeBuildInputs = [ python ]; + cargoExtraArgs = "--package opsqueue_python"; }; + cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { pname = pname; }); - cargoDeps = rustPlatform.importCargoLock { lockFile = ../../Cargo.lock; }; + wheelTail = "py3-abi3-linux_x86_64"; + wheelName = "opsqueue-${version}-${wheelTail}.whl"; - env = { - DATABASE_URL = "sqlite://./opsqueue/opsqueue_example_database_schema.db"; - }; + crateWheel = + (craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; })).overrideAttrs + (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ maturin ]; - pythonImportsCheck = [ pname ]; + # We intentionally _override_ rather than extend the buildPhase + # as Maturin itself calls `cargo build`, no need to call it twice. + buildPhase = '' + cargo --version + maturin build --release --offline --target-dir ./target --manifest-path "./libs/opsqueue_python/Cargo.toml" + ''; - maturinBuildFlags = [ - "--manifest-path" - "./libs/opsqueue_python/Cargo.toml" - ]; + # We build a single wheel + # but by convention its name is based on the precise combination of + # Python version + OS version + architecture + ... + # + # The Nix hash already covers us for uniqueness and compatibility. + # So this 'trick' copies it to a predictably named file. + # + # Just like `buildPhase`, we override rather than extend + # because we are only interested in the wheel output of Maturin as a whole. + # (which is an archive inside of it containing the `.so` cargo built) + installPhase = '' + mkdir -p $out + for wheel in ./target/wheels/*.whl ; do + cp "$wheel" $out/${wheelName} + done + ''; - nativeBuildInputs = with rustPlatform; [ - perl - git - cargoSetupHook - maturinBuildHook - ]; + # There are no Rust unit tests in the Python FFI library currently, + # so we can skip rebuilding opsqueue_python for tests. + doCheck = false; + }); +in +buildPythonPackage { + pname = pname; + format = "wheel"; + version = crateName.version; + src = "${crateWheel}/${wheelName}"; + doCheck = false; + pythonImportsCheck = [ "opsqueue" ]; propagatedBuildInputs = [ cbor2 diff --git a/libs/opsqueue_python/pyproject.toml b/libs/opsqueue_python/pyproject.toml index 097f0ee..21be1d1 100644 --- a/libs/opsqueue_python/pyproject.toml +++ b/libs/opsqueue_python/pyproject.toml @@ -52,15 +52,15 @@ test = [ "pytest==8.3.3", "pytest-random-order==1.1.1", "pytest-parallel==0.1.1", - "pytest-timeout==2.4.0", + # "pytest-timeout==2.4.0", "py==1.11.0", # Needs to be manually specified because of this issue: https://github.com/kevlened/pytest-parallel/issues/118 ] [tool.pytest.ini_options] # We ensure tests never rely on global state, # by running them in a random order, and in parallel: -addopts = "--random-order --workers=auto" -# Individual tests should be very fast. They should never take multiple seconds -# If after 20sec (accomodating for a toaster-like PC) there is no progress, -# assume a deadlock -timeout=20 +addopts = "--random-order --workers=4" +# # Individual tests should be very fast. They should never take multiple seconds +# # If after 20sec (accomodating for a toaster-like PC) there is no progress, +# # assume a deadlock +# timeout=20 diff --git a/libs/opsqueue_python/src/common.rs b/libs/opsqueue_python/src/common.rs index 91d13a4..ba5e8aa 100644 --- a/libs/opsqueue_python/src/common.rs +++ b/libs/opsqueue_python/src/common.rs @@ -428,11 +428,8 @@ pub async fn check_signals_in_background() -> FatalPythonException { if let Err(err) = py.check_signals() { // A signal was triggered Some(err) - } else if let Some(err) = PyErr::take(py) { - // A non-signal Python exception was thrown - return Some(err); } else { - return None; + PyErr::take(py) } }); if let Some(res) = res { diff --git a/libs/opsqueue_python/src/consumer.rs b/libs/opsqueue_python/src/consumer.rs index 1870ba2..613ac5c 100644 --- a/libs/opsqueue_python/src/consumer.rs +++ b/libs/opsqueue_python/src/consumer.rs @@ -418,7 +418,7 @@ impl ConsumerClient { } done_count = done_count.saturating_add(1); - if done_count % 50 == 0 { + if done_count.is_multiple_of(50) { tracing::info!("Processed {} chunks", done_count); } } diff --git a/nix/nixpkgs-pinned.nix b/nix/nixpkgs-pinned.nix index 8378efa..6e3d386 100644 --- a/nix/nixpkgs-pinned.nix +++ b/nix/nixpkgs-pinned.nix @@ -10,7 +10,8 @@ let used_overlays = [ (import sources.rust-overlay) (import ./overlay.nix) - ] ++ overlays; + ] + ++ overlays; nixpkgsArgs = args // { overlays = used_overlays; diff --git a/nix/overlay.nix b/nix/overlay.nix index 7e3fd0d..a8bfa9b 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,6 +1,7 @@ # Overlay for Nixpkgs which holds all opsqueue related packages. final: prev: let + sources = import ./sources.nix; pythonOverlay = import ./python-overlay.nix; # We want to use the same Rust version in Nix @@ -15,10 +16,14 @@ let rustc = rustToolchain; cargo = rustToolchain; }; + + crane = import sources.crane { pkgs = final; }; + craneLib = crane.overrideToolchain (pkgs: rustToolchain); in { - rustToolchain = rustToolchain; - opsqueue = final.callPackage ../opsqueue/opsqueue.nix { rustPlatform = final.rustPlatform; }; + # inherit naersk; + inherit rustToolchain; + opsqueue = final.callPackage ../opsqueue/opsqueue.nix { }; # The explicit choice is made not to override `python312`, as this will cause a rebuild of many # packages when nixpkgs uses python 3.12 as default python environment. diff --git a/nix/sources.json b/nix/sources.json index 3614497..a8d1a28 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,14 +1,38 @@ { + "crane": { + "branch": "master", + "description": "A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.", + "homepage": "https://crane.dev", + "owner": "ipetkov", + "repo": "crane", + "rev": "0bda7e7d005ccb5522a76d11ccfbf562b71953ca", + "sha256": "1ndhiw867qiwr3kswm2mb81y3xcfdwz92xvs00r6jd4blxsv7z09", + "type": "tarball", + "url": "https://github.com/ipetkov/crane/archive/0bda7e7d005ccb5522a76d11ccfbf562b71953ca.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "naersk": { + "branch": "master", + "description": "Build Rust projects in Nix - no configuration, no code generation, no IFD, sandbox friendly.", + "homepage": "", + "owner": "nix-community", + "repo": "naersk", + "rev": "8d97452673640eb7fabe428e8b6a425bc355008b", + "sha256": "0sgs8dh8yw62dzpd0mm6byf2q4vwqab3r0i62qy52las85f4p1qw", + "type": "tarball", + "url": "https://github.com/nix-community/naersk/archive/8d97452673640eb7fabe428e8b6a425bc355008b.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "nixpkgs": { "branch": "nixpkgs-unstable", "description": "Nix Packages collection", "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d19cf9dfc633816a437204555afeb9e722386b76", - "sha256": "1wirhlw7cqaypgakyfz9ikv7nxdq3il0fk38cdrdmps2zn1l4ccp", + "rev": "ed142ab1b3a092c4d149245d0c4126a5d7ea00b0", + "sha256": "1h7v295lpjfxpxkag2csam7whx918sdypixdi8i85vlb707gg0vm", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/d19cf9dfc633816a437204555afeb9e722386b76.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/ed142ab1b3a092c4d149245d0c4126a5d7ea00b0.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "rust-overlay": { diff --git a/opsqueue/Cargo.toml b/opsqueue/Cargo.toml index 14b0112..272214d 100644 --- a/opsqueue/Cargo.toml +++ b/opsqueue/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" description = "lightweight batch processing queue for heavy loads" repository = "https://github.com/channable/opsqueue" license = "MIT" +include=["opsqueue_example_database_schema.db"] [lib] name="opsqueue" path="src/lib.rs" -include=["opsqueue_example_database_schema.db"] [[bin]] name="opsqueue" diff --git a/opsqueue/opsqueue.nix b/opsqueue/opsqueue.nix index 267907a..df3e280 100644 --- a/opsqueue/opsqueue.nix +++ b/opsqueue/opsqueue.nix @@ -1,6 +1,7 @@ { + pkgs, lib, - rustPlatform, + rustToolchain, # Building options buildType ? "release", # Testing options @@ -9,64 +10,42 @@ useNextest ? false, # Disabled for now. Re-enable as part of https://github.com/channable/opsqueue/issues/81 perl, git, + python312, }: let - root = ../.; - util = import (root + /nix/util.nix) { inherit lib; }; -in -rustPlatform.buildRustPackage { - name = "opsqueue"; - inherit - buildType - checkType - doCheck - useNextest - ; - - src = util.fileFilter { + sources = import ../nix/sources.nix; + crane = import sources.crane { pkgs = pkgs; }; + craneLib = crane.overrideToolchain (pkgs: rustToolchain); + extraFileFilter = path: _type: builtins.match ".*(db|sql)$" path != null; + fileFilter = path: type: (extraFileFilter path type) || (craneLib.filterCargoSources path type); + + # src = craneLib.cleanCargoSource ../.; + src = lib.cleanSourceWith { + src = ../.; name = "opsqueue"; - src = ./.; - - srcWhitelist = [ - "Cargo.toml" - ".cargo(/.*)?" - "build\.rs" - "opsqueue_example_database_schema\.db" - "app(/.*)?" - "migrations(/.*)?" - "src(/.*)?" - ]; - - srcGlobalWhitelist = [ - ".lock" - ".toml" - ".rs" - ".db" - ".sql" - ]; - }; - - postUnpack = '' - cp "${../Cargo.lock}" "/build/opsqueue/Cargo.lock" - chmod +w /build/opsqueue/Cargo.lock - ''; - - env = { - DATABASE_URL = "sqlite:///build/opsqueue/opsqueue_example_database_schema.db"; + filter = fileFilter; }; - nativeBuildInputs = [ - perl - git - ]; - - cargoLock = { - lockFile = ../Cargo.lock; + crateName = craneLib.crateNameFromCargoToml { cargoToml = ../opsqueue/Cargo.toml; }; + pname = crateName.pname; + version = crateName.version; + commonArgs = { + inherit src version pname; + strictDeps = true; + nativeBuildInputs = [ python312 ]; }; - - # This limits the build to only build the opsqueue executable - cargoBuildFlags = [ - "--package" - "opsqueue" - ]; -} + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in +craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts; + + # Needed for the SQLx macros: + env = { + DATABASE_URL = "sqlite:///build/opsqueue/opsqueue/opsqueue_example_database_schema.db"; + }; + + cargoExtraArgs = "--package opsqueue"; + } +) diff --git a/opsqueue/src/consumer/server/mod.rs b/opsqueue/src/consumer/server/mod.rs index c869f5d..412391e 100644 --- a/opsqueue/src/consumer/server/mod.rs +++ b/opsqueue/src/consumer/server/mod.rs @@ -200,7 +200,7 @@ impl Completer { } // Log some indication of progress every so often: self.count = self.count.saturating_add(1); - if self.count % 1000 == 0 { + if self.count.is_multiple_of(1000) { tracing::info!("Processed {} chunks", self.count); } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d292b17..693a919 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.85.0" +channel = "1.92.0" components = ["clippy", "rustfmt", "rust-analyzer", "rust-src"] profile = "minimal" From 06f91e3fb57d1a3c61d256606b132d258a3bbec3 Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Fri, 30 Jan 2026 12:13:54 +0100 Subject: [PATCH 3/4] Allow overriding which Python version is used when building the Opsqueue Python library --- default.nix | 2 +- justfile | 4 ++-- nix/overlay.nix | 14 ++------------ nix/sources.json | 12 ------------ opsqueue/opsqueue.nix | 4 ++-- 5 files changed, 7 insertions(+), 29 deletions(-) diff --git a/default.nix b/default.nix index 79a7e76..e84fd2a 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ let pkgs = import ./nix/nixpkgs-pinned.nix { }; - pythonEnv = pkgs.pythonChannable.withPackages ( + pythonEnv = pkgs.python.withPackages ( p: with p; [ click mypy diff --git a/justfile b/justfile index 47d5c5b..351cb7d 100644 --- a/justfile +++ b/justfile @@ -89,7 +89,7 @@ mypy: # Build Nix-derivations of binary and all libraries (release profile) [group('nix')] -nix-build: (_nix-build "opsqueue" "pythonChannable.pkgs.opsqueue_python") +nix-build: (_nix-build "opsqueue" "python.pkgs.opsqueue_python") # Build Nix-derivation of binary (release profile) [group('nix')] @@ -97,7 +97,7 @@ nix-build-bin: (_nix-build "opsqueue") # Build Nix-derivation of Python client library (release profile) [group('nix')] -nix-build-python: (_nix-build "pythonChannable.pkgs.opsqueue_python") +nix-build-python: (_nix-build "python.pkgs.opsqueue_python") _nix-build +TARGETS: nix build --file nix/nixpkgs-pinned.nix --print-out-paths --print-build-logs --no-link --option sandbox true {{TARGETS}} diff --git a/nix/overlay.nix b/nix/overlay.nix index a8bfa9b..0308f9a 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -8,28 +8,18 @@ let # as we use when _not_ using Nix. # # When using opsqueue as part of your own Nix derivations, - # be sure to use an overlay to set `rustPlatform` + # be sure to use an overlay to set `rustToolchain` # to the desired Rust version # if you want to use a different version from the default. rustToolchain = final.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml; - rustPlatform = prev.makeRustPlatform { - rustc = rustToolchain; - cargo = rustToolchain; - }; crane = import sources.crane { pkgs = final; }; craneLib = crane.overrideToolchain (pkgs: rustToolchain); in { - # inherit naersk; inherit rustToolchain; opsqueue = final.callPackage ../opsqueue/opsqueue.nix { }; - # The explicit choice is made not to override `python312`, as this will cause a rebuild of many - # packages when nixpkgs uses python 3.12 as default python environment. - # These packages should not be affected, e.g. cachix. This is because of a transitive - # dependency on the Python packages that we override. - # In our case cachix > ghc > shpinx > Python libraries. - pythonChannable = prev.python312.override { packageOverrides = pythonOverlay; }; + python = prev.python312.override { packageOverrides = pythonOverlay; }; } diff --git a/nix/sources.json b/nix/sources.json index a8d1a28..1e66034 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -11,18 +11,6 @@ "url": "https://github.com/ipetkov/crane/archive/0bda7e7d005ccb5522a76d11ccfbf562b71953ca.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, - "naersk": { - "branch": "master", - "description": "Build Rust projects in Nix - no configuration, no code generation, no IFD, sandbox friendly.", - "homepage": "", - "owner": "nix-community", - "repo": "naersk", - "rev": "8d97452673640eb7fabe428e8b6a425bc355008b", - "sha256": "0sgs8dh8yw62dzpd0mm6byf2q4vwqab3r0i62qy52las85f4p1qw", - "type": "tarball", - "url": "https://github.com/nix-community/naersk/archive/8d97452673640eb7fabe428e8b6a425bc355008b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, "nixpkgs": { "branch": "nixpkgs-unstable", "description": "Nix Packages collection", diff --git a/opsqueue/opsqueue.nix b/opsqueue/opsqueue.nix index df3e280..d0237b0 100644 --- a/opsqueue/opsqueue.nix +++ b/opsqueue/opsqueue.nix @@ -10,7 +10,7 @@ useNextest ? false, # Disabled for now. Re-enable as part of https://github.com/channable/opsqueue/issues/81 perl, git, - python312, + python, }: let sources = import ../nix/sources.nix; @@ -32,7 +32,7 @@ let commonArgs = { inherit src version pname; strictDeps = true; - nativeBuildInputs = [ python312 ]; + nativeBuildInputs = [ python ]; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; in From d8e2a9dba2cb22b0fe11cf3bcb1c32175b247edf Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Fri, 30 Jan 2026 16:48:59 +0100 Subject: [PATCH 4/4] Try to convince Cachix to also cache opsqueue build deps --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 4403c47..3950eea 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -62,7 +62,7 @@ blocks: jobs: - name: "Build Opsqueue binary (in release mode) & run unit tests" commands: - - "just nix-build-bin | cachix push channable" + - "cachix watch-exec channable -- just nix-build-bin" # Once a day, we update the devenv cache. # Except when fresh, this takes < 1 second # but it cannot live in the prologue @@ -70,7 +70,7 @@ blocks: - cache store nix-store-$(date -u -Idate) /nix - name: "Build Python library (in release mode)" commands: - - "just nix-build-python | cachix push channable" + - "cachix watch-exec channable -- just nix-build-python" - name: "Integration" dependencies: - "Build"