difftreelog
nocargo testing
4 files changed
flake.lockdiffbeforeafterboth49 "type": "github"49 "type": "github"50 }50 }51 },51 },52 "flake-utils": {53 "inputs": {54 "systems": "systems"55 },56 "locked": {57 "lastModified": 1701680307,58 "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",59 "owner": "numtide",60 "repo": "flake-utils",61 "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",62 "type": "github"63 },64 "original": {65 "owner": "numtide",66 "repo": "flake-utils",67 "type": "github"68 }69 },52 "fleet-tf": {70 "fleet-tf": {53 "inputs": {71 "inputs": {54 "flake-parts": [72 "flake-parts": [124 "type": "github"142 "type": "github"125 }143 }126 },144 },145 "nix-filter": {146 "locked": {147 "lastModified": 1687178632,148 "narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=",149 "owner": "numtide",150 "repo": "nix-filter",151 "rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174",152 "type": "github"153 },154 "original": {155 "owner": "numtide",156 "repo": "nix-filter",157 "type": "github"158 }159 },127 "nixpkgs": {160 "nixpkgs": {128 "locked": {161 "locked": {129 "lastModified": 1781820577,162 "lastModified": 1781820577,171 "type": "github"204 "type": "github"172 }205 }173 },206 },207 "nocargo": {208 "inputs": {209 "flake-utils": "flake-utils",210 "nix-filter": "nix-filter",211 "nixpkgs": [212 "nixpkgs"213 ],214 "registry-crates-io": [215 "registry-crates-io"216 ]217 },218 "locked": {219 "lastModified": 1778181426,220 "owner": "deltaex",221 "repo": "nocargo",222 "rev": "10b5ad93582992ed19bf2bd92840e544601cced4",223 "type": "gitlab"224 },225 "original": {226 "owner": "deltaex",227 "repo": "nocargo",228 "type": "gitlab"229 }230 },231 "registry-crates-io": {232 "flake": false,233 "locked": {234 "lastModified": 1783425179,235 "narHash": "sha256-g9gZx0E3isjuTXGwmkY7pVmYAkYDn0UucxO5c+GOpvw=",236 "owner": "rust-lang",237 "repo": "crates.io-index",238 "rev": "c4f52e3ab01b43153b474dda067993b982457908",239 "type": "github"240 },241 "original": {242 "owner": "rust-lang",243 "repo": "crates.io-index",244 "type": "github"245 }246 },174 "root": {247 "root": {175 "inputs": {248 "inputs": {176 "crane": "crane",249 "crane": "crane",177 "flake-parts": "flake-parts",250 "flake-parts": "flake-parts",178 "fleet-tf": "fleet-tf",251 "fleet-tf": "fleet-tf",179 "nix": "nix",252 "nix": "nix",180 "nixpkgs": "nixpkgs",253 "nixpkgs": "nixpkgs",254 "nocargo": "nocargo",255 "registry-crates-io": "registry-crates-io",181 "rust-overlay": "rust-overlay",256 "rust-overlay": "rust-overlay",182 "shelly": "shelly",257 "shelly": "shelly",183 "treefmt-nix": "treefmt-nix"258 "treefmt-nix": "treefmt-nix"216 "type": "github"291 "type": "github"217 }292 }218 },293 },294 "systems": {295 "locked": {296 "lastModified": 1681028828,297 "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",298 "owner": "nix-systems",299 "repo": "default",300 "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",301 "type": "github"302 },303 "original": {304 "owner": "nix-systems",305 "repo": "default",306 "type": "github"307 }308 },219 "treefmt-nix": {309 "treefmt-nix": {220 "inputs": {310 "inputs": {221 "nixpkgs": [311 "nixpkgs": [flake.nixdiffbeforeafterboth--- a/flake.nix
+++ b/flake.nix
@@ -12,6 +12,15 @@
inputs.nixpkgs-lib.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
+ nocargo = {
+ url = "gitlab:deltaex/nocargo";
+ inputs.nixpkgs.follows = "nixpkgs";
+ inputs.registry-crates-io.follows = "registry-crates-io";
+ };
+ registry-crates-io = {
+ url = "github:rust-lang/crates.io-index";
+ flake = false;
+ };
shelly.url = "github:CertainLach/shelly";
fleet-tf = {
url = "github:CertainLach/fleet-tf";
@@ -136,6 +145,7 @@
let
packages = pkgs.callPackages ./pkgs {
inherit craneLib inputs;
+ rustToolchain = rust;
};
in
packages // { default = packages.fleet; }
pkgs/default.nixdiffbeforeafterboth--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -2,12 +2,16 @@
callPackage,
craneLib,
inputs,
+ rustToolchain ? null,
}:
let
remowt-agents-bundle = callPackage ./remowt-agents-bundle.nix { inherit craneLib; };
in
{
fleet = callPackage ./fleet.nix { inherit craneLib inputs remowt-agents-bundle; };
+ fleet-nocargo = callPackage ./fleet-nocargo.nix {
+ inherit inputs remowt-agents-bundle rustToolchain;
+ };
fleet-install-secrets = callPackage ./fleet-install-secrets.nix { inherit craneLib; };
fleet-generator-helper = callPackage ./fleet-generator-helper.nix { inherit craneLib; };
fleet-usbd = callPackage ./fleet-usbd.nix { inherit craneLib inputs; };
pkgs/fleet-nocargo.nixdiffbeforeafterboth--- /dev/null
+++ b/pkgs/fleet-nocargo.nix
@@ -0,0 +1,164 @@
+{
+ lib,
+ pkgs,
+ stdenv,
+ callPackage,
+ fetchurl,
+ pkg-config,
+ rustPlatform,
+ rustc,
+ rofi,
+ installShellFiles,
+ inputs,
+ remowt-agents-bundle,
+ rustToolchain ? null,
+}:
+let
+ system = stdenv.hostPlatform.system;
+ nocargoSrc = inputs.nocargo;
+ nocargoLib = import (nocargoSrc + "/lib") {
+ inherit lib;
+ inherit (inputs.nocargo.inputs) nix-filter;
+ };
+ toml2json = callPackage (nocargoSrc + "/toml2json") { };
+ buildRustCrateUnwrapped = callPackage (nocargoSrc + "/build-rust-crate") {
+ nocargo-lib = nocargoLib;
+ inherit toml2json;
+ };
+ # nocargo passes profile.panic to every crate, breaking build script and
+ # proc-macro linkage; cargo applies it only to final artifacts:
+ # https://doc.rust-lang.org/cargo/reference/profiles.html#panic
+ buildRustCrate =
+ args:
+ let
+ profile = args.profile or { };
+ crate = buildRustCrateUnwrapped (
+ args
+ // {
+ profile = removeAttrs profile [ "panic" ];
+ buildFlags = [ "--cfg=tokio_unstable" ] ++ args.buildFlags or [ ];
+ # Every crate dev output propagates its transitive dev closure, and
+ # the bintools hook emits -L for each one; on large dependency
+ # closures the resulting NIX_LDFLAGS overflows the execve limit
+ # ("Argument list too long"). Those entries only contain .rmeta;
+ # rustc gets real paths via --extern and -Ldependency.
+ postHook = ''
+ _newLdflags=
+ for _flag in $NIX_LDFLAGS; do
+ if [[ "$_flag" == -L/nix/store/*-rust_*/lib ]]; then continue; fi
+ _newLdflags+="''${_newLdflags:+ }$_flag"
+ done
+ export NIX_LDFLAGS="$_newLdflags"
+ unset _newLdflags _flag
+ '';
+ }
+ );
+ in
+ if profile.panic or "unwind" == "unwind" then
+ crate
+ else
+ crate
+ // {
+ bin = crate.bin.overrideAttrs (old: {
+ buildFlags = old.buildFlags ++ [ "-Cpanic=${profile.panic}" ];
+ });
+ };
+
+ extraProcMacroCrates = [
+ "bifrostlink-macros"
+ "curve25519-dalek-derive"
+ "derive_more-impl"
+ "iroh-metrics-derive"
+ "jni-macros"
+ "jni-sys-macros"
+ "n0-error-macros"
+ "proc-macro-error-attr2"
+ "prost-derive"
+ "spez"
+ "test-log-macros"
+ ];
+ cratesIoOverride =
+ import (nocargoSrc + "/crates-io-override") { inherit lib pkgs; }
+ // lib.genAttrs extraProcMacroCrates (_: _: { procMacro = true; })
+ // {
+ derive_more = { version, ... }: { procMacro = lib.versionOlder version "1.0.0"; };
+ test-log = { version, ... }: { procMacro = lib.versionOlder version "0.2.12"; };
+ # scratch bakes env!("OUT_DIR") into its lib as a shared writable
+ # directory, and cxx-build then creates files there from dependent
+ # builds; a store path is immutable, so rebake it to a path that
+ # exists in every build sandbox.
+ scratch = _: {
+ postConfigure = ''
+ export OUT_DIR="$NIX_BUILD_TOP/rust-scratch-out-dir"
+ mkdir -p "$OUT_DIR"
+ '';
+ };
+ };
+ cratesIoIndex = nocargoLib.pkg-info.mkIndex fetchurl inputs.registry-crates-io cratesIoOverride;
+
+ mkRustPackageOrWorkspace = callPackage nocargoLib.support.mkRustPackageOrWorkspace {
+ defaultRegistries = {
+ "https://github.com/rust-lang/crates.io-index" = cratesIoIndex;
+ };
+ inherit buildRustCrate;
+ };
+
+ ws = mkRustPackageOrWorkspace {
+ src = lib.cleanSourceWith {
+ src = ../.;
+ filter =
+ path: type:
+ (if type == "directory" then baseNameOf path != "target" else true)
+ && (
+ type == "directory"
+ || lib.any (suffix: lib.hasSuffix suffix path) [
+ ".rs"
+ ".toml"
+ ".cc"
+ ".hh"
+ ]
+ || baseNameOf path == "Cargo.lock"
+ );
+ };
+ rustc = if rustToolchain != null then rustToolchain else rustc;
+ buildCrateOverrides = {
+ nix-eval = _: {
+ nativeBuildInputs = [
+ pkg-config
+ rustPlatform.bindgenHook
+ ];
+ propagatedBuildInputs = [
+ inputs.nix.packages.${system}.nix-expr-c
+ inputs.nix.packages.${system}.nix-flake-c
+ inputs.nix.packages.${system}.nix-fetchers-c
+ ];
+ };
+ fleet-base = _: {
+ REMOWT_AGENTS_DIR = "${remowt-agents-bundle}";
+ };
+ remowt-ui-prompt = _: {
+ ROFI = "${rofi}/bin/rofi";
+ };
+ };
+ };
+
+ fleet = ws.release.fleet.bin;
+in
+stdenv.mkDerivation {
+ pname = "fleet-nocargo";
+ inherit (fleet) version;
+
+ nativeBuildInputs = [ installShellFiles ];
+
+ buildCommand = ''
+ mkdir -p $out/bin
+ ln -s ${fleet}/bin/* $out/bin/
+
+ for shell in bash fish zsh; do
+ installShellCompletion --cmd fleet \
+ --$shell <($out/bin/fleet complete --shell $shell)
+ done
+ '';
+
+ passthru.workspace = ws;
+}