git.delta.rocks / fleet / refs/commits / 3ff14079c557

difftreelog

nocargo testing

zwxmoxttYaroslav Bolyukin2026-07-07parent: #3470788.patch.diff

4 files changed

modifiedflake.lockdiffbeforeafterboth
--- a/flake.lock
+++ b/flake.lock
@@ -49,6 +49,24 @@
         "type": "github"
       }
     },
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1701680307,
+        "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
     "fleet-tf": {
       "inputs": {
         "flake-parts": [
@@ -124,6 +142,21 @@
         "type": "github"
       }
     },
+    "nix-filter": {
+      "locked": {
+        "lastModified": 1687178632,
+        "narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=",
+        "owner": "numtide",
+        "repo": "nix-filter",
+        "rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "nix-filter",
+        "type": "github"
+      }
+    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1781820577,
@@ -171,6 +204,46 @@
         "type": "github"
       }
     },
+    "nocargo": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nix-filter": "nix-filter",
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "registry-crates-io": [
+          "registry-crates-io"
+        ]
+      },
+      "locked": {
+        "lastModified": 1778181426,
+        "owner": "deltaex",
+        "repo": "nocargo",
+        "rev": "10b5ad93582992ed19bf2bd92840e544601cced4",
+        "type": "gitlab"
+      },
+      "original": {
+        "owner": "deltaex",
+        "repo": "nocargo",
+        "type": "gitlab"
+      }
+    },
+    "registry-crates-io": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1783425179,
+        "narHash": "sha256-g9gZx0E3isjuTXGwmkY7pVmYAkYDn0UucxO5c+GOpvw=",
+        "owner": "rust-lang",
+        "repo": "crates.io-index",
+        "rev": "c4f52e3ab01b43153b474dda067993b982457908",
+        "type": "github"
+      },
+      "original": {
+        "owner": "rust-lang",
+        "repo": "crates.io-index",
+        "type": "github"
+      }
+    },
     "root": {
       "inputs": {
         "crane": "crane",
@@ -178,6 +251,8 @@
         "fleet-tf": "fleet-tf",
         "nix": "nix",
         "nixpkgs": "nixpkgs",
+        "nocargo": "nocargo",
+        "registry-crates-io": "registry-crates-io",
         "rust-overlay": "rust-overlay",
         "shelly": "shelly",
         "treefmt-nix": "treefmt-nix"
@@ -216,6 +291,21 @@
         "type": "github"
       }
     },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
     "treefmt-nix": {
       "inputs": {
         "nixpkgs": [
modifiedflake.nixdiffbeforeafterboth
before · flake.nix
1{2  description = "NixOS cluster configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/release-26.05";6    rust-overlay = {7      url = "github:oxalica/rust-overlay";8      inputs.nixpkgs.follows = "nixpkgs";9    };10    flake-parts = {11      url = "github:hercules-ci/flake-parts";12      inputs.nixpkgs-lib.follows = "nixpkgs";13    };14    crane.url = "github:ipetkov/crane";15    shelly.url = "github:CertainLach/shelly";16    fleet-tf = {17      url = "github:CertainLach/fleet-tf";18      inputs.nixpkgs.follows = "nixpkgs";19      inputs.shelly.follows = "shelly";20      inputs.flake-parts.follows = "flake-parts";21    };22    treefmt-nix = {23      url = "github:numtide/treefmt-nix";24      inputs.nixpkgs.follows = "nixpkgs";25    };26    # DeterminateSystem's nix fork is controversial, but I don't mind it,27    # and it has lazy-trees support which is useful for fleet.28    nix = {29      url = "github:deltarocks/nix/fleet";30      inputs.nixpkgs.follows = "nixpkgs";31      inputs.flake-parts.follows = "flake-parts";32    };33  };34  outputs =35    inputs:36    inputs.flake-parts.lib.mkFlake37      {38        inherit inputs;39      }40      {41        imports = [ inputs.shelly.flakeModule ];42        flake = rec {43          lib =44            (import ./lib {45              inherit (inputs.nixpkgs) lib;46            })47            // {48              fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";49            };50          flakeModules.default = import ./lib/flakePart.nix {51            inherit (inputs) crane;52          };53          flakeModule = flakeModules.default;5455          flakeModules.fleet-tf = ./modules/extras/tf.nix;5657          # Used to test nix-eval bindings58          testData = {59            testObj = {60              v = "Hello";61            };62            testString = "hello";63            testPrimop = op: "PREFIX_" + (op "body" "_SUFFIX");64          };6566          # To be used with https://github.com/NixOS/nix/pull/889267          # schemas =68          #   let69          #     inherit (inputs.nixpkgs.lib) mapAttrs;70          #   in71          #   {72          #     fleetConfigurations = {73          #       version = 1;74          #       doc = ''75          #         The `fleetConfigurations` flake output defines fleet cluster configurations.76          #       '';77          #       inventory = output: {78          #         children = mapAttrs (configName: cluster: {79          #           what = "fleet cluster configuration";80          #81          #           children = mapAttrs (hostName: host: {82          #             what = "host [${host.system}]";83          #           }) cluster.config.hosts;84          #           # It is possible to implement this inventory right now, but I want to85          #           # get rid of `fleet.nix` file in the future.86          #           # children.secrets = { };87          #         }) output;88          #       };89          #     };90          #   };91        };92        # Supported and tested list of deployment targets.93        systems = [94          "x86_64-linux"95          "aarch64-linux"96          "armv7l-linux"97          "armv6l-linux"98        ];99        perSystem =100          {101            config,102            system,103            pkgs,104            self,105            inputs',106            ...107          }:108          let109            inherit (lib.attrsets) mapAttrs';110            inherit (lib.lists) elem;111            # Can also be built for darwin, through it is not usual to deploy nixos systems from macos machines.112            # I have no hardware for such testing, thus only adding machines I actually have and use.113            #114            # It is not possible to deploy any host from armv6/armv7 hardware, and I don't think it even makes sense.115            deployerSystems = [116              "aarch64-linux"117              "x86_64-linux"118            ];119            deployerSystem = elem system deployerSystems;120            lib = pkgs.lib;121            rust = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {122              enableLibsecret = false;123            };124            craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;125            treefmt = (inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build;126          in127          {128            _module.args.pkgs = import inputs.nixpkgs {129              inherit system;130              overlays = [131                inputs.rust-overlay.overlays.default132              ];133            };134            # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.135            packages = lib.mkIf deployerSystem (136              let137                packages = pkgs.callPackages ./pkgs {138                  inherit craneLib inputs;139                };140              in141              packages // { default = packages.fleet; }142            );143            # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.144            # checks there build packages for default nixpkgs rustPlatform packages.145            checks =146              let147                nixpkgsCraneLib = inputs.crane.mkLib pkgs;148                packages = pkgs.callPackages ./pkgs {149                  craneLib = nixpkgsCraneLib;150                  inherit inputs;151                };152                prefixAttrs =153                  prefix: attrs:154                  mapAttrs' (name: value: {155                    name = "${prefix}${name}";156                    value = value.overrideAttrs (prev: {157                      pname = "${prefix}${prev.pname}";158                    });159                  }) attrs;160              in161              # fleet-install-secrets is installed to remote systems, thus needs to work162              # with rust in nixpkgs.163              (prefixAttrs "nixpkgs-" {164                inherit (packages) fleet-install-secrets;165              })166              // {167                formatting = treefmt.check self;168              };169            # TODO: It should be possible to move lib.mkIf to default attribute, instead of disabling the whole170            # devShells block, yet nix flake check fails here, due to no default shell found. It is nix or flake-parts bug?171            shelly.shells.default = lib.mkIf deployerSystem {172              factory = craneLib.devShell;173              packages = with pkgs; [174                rust175176                pkg-config177                openssl178                udev179                rustPlatform.bindgenHook180                inputs'.nix.packages.nix-expr-c181                inputs'.nix.packages.nix-flake-c182                inputs'.nix.packages.nix-fetchers-c183                inputs'.nix.packages.nix-store-c184                inputs'.nix.packages.nix185186                (rage.overrideAttrs { cargoFeatures = [ "plugin" ]; })187              ];188              environment.PROTOC = "${pkgs.protobuf}/bin/protoc";189            };190            formatter = treefmt.wrapper;191          };192      };193}
after · flake.nix
1{2  description = "NixOS cluster configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/release-26.05";6    rust-overlay = {7      url = "github:oxalica/rust-overlay";8      inputs.nixpkgs.follows = "nixpkgs";9    };10    flake-parts = {11      url = "github:hercules-ci/flake-parts";12      inputs.nixpkgs-lib.follows = "nixpkgs";13    };14    crane.url = "github:ipetkov/crane";15    nocargo = {16      url = "gitlab:deltaex/nocargo";17      inputs.nixpkgs.follows = "nixpkgs";18      inputs.registry-crates-io.follows = "registry-crates-io";19    };20    registry-crates-io = {21      url = "github:rust-lang/crates.io-index";22      flake = false;23    };24    shelly.url = "github:CertainLach/shelly";25    fleet-tf = {26      url = "github:CertainLach/fleet-tf";27      inputs.nixpkgs.follows = "nixpkgs";28      inputs.shelly.follows = "shelly";29      inputs.flake-parts.follows = "flake-parts";30    };31    treefmt-nix = {32      url = "github:numtide/treefmt-nix";33      inputs.nixpkgs.follows = "nixpkgs";34    };35    # DeterminateSystem's nix fork is controversial, but I don't mind it,36    # and it has lazy-trees support which is useful for fleet.37    nix = {38      url = "github:deltarocks/nix/fleet";39      inputs.nixpkgs.follows = "nixpkgs";40      inputs.flake-parts.follows = "flake-parts";41    };42  };43  outputs =44    inputs:45    inputs.flake-parts.lib.mkFlake46      {47        inherit inputs;48      }49      {50        imports = [ inputs.shelly.flakeModule ];51        flake = rec {52          lib =53            (import ./lib {54              inherit (inputs.nixpkgs) lib;55            })56            // {57              fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";58            };59          flakeModules.default = import ./lib/flakePart.nix {60            inherit (inputs) crane;61          };62          flakeModule = flakeModules.default;6364          flakeModules.fleet-tf = ./modules/extras/tf.nix;6566          # Used to test nix-eval bindings67          testData = {68            testObj = {69              v = "Hello";70            };71            testString = "hello";72            testPrimop = op: "PREFIX_" + (op "body" "_SUFFIX");73          };7475          # To be used with https://github.com/NixOS/nix/pull/889276          # schemas =77          #   let78          #     inherit (inputs.nixpkgs.lib) mapAttrs;79          #   in80          #   {81          #     fleetConfigurations = {82          #       version = 1;83          #       doc = ''84          #         The `fleetConfigurations` flake output defines fleet cluster configurations.85          #       '';86          #       inventory = output: {87          #         children = mapAttrs (configName: cluster: {88          #           what = "fleet cluster configuration";89          #90          #           children = mapAttrs (hostName: host: {91          #             what = "host [${host.system}]";92          #           }) cluster.config.hosts;93          #           # It is possible to implement this inventory right now, but I want to94          #           # get rid of `fleet.nix` file in the future.95          #           # children.secrets = { };96          #         }) output;97          #       };98          #     };99          #   };100        };101        # Supported and tested list of deployment targets.102        systems = [103          "x86_64-linux"104          "aarch64-linux"105          "armv7l-linux"106          "armv6l-linux"107        ];108        perSystem =109          {110            config,111            system,112            pkgs,113            self,114            inputs',115            ...116          }:117          let118            inherit (lib.attrsets) mapAttrs';119            inherit (lib.lists) elem;120            # Can also be built for darwin, through it is not usual to deploy nixos systems from macos machines.121            # I have no hardware for such testing, thus only adding machines I actually have and use.122            #123            # It is not possible to deploy any host from armv6/armv7 hardware, and I don't think it even makes sense.124            deployerSystems = [125              "aarch64-linux"126              "x86_64-linux"127            ];128            deployerSystem = elem system deployerSystems;129            lib = pkgs.lib;130            rust = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {131              enableLibsecret = false;132            };133            craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;134            treefmt = (inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build;135          in136          {137            _module.args.pkgs = import inputs.nixpkgs {138              inherit system;139              overlays = [140                inputs.rust-overlay.overlays.default141              ];142            };143            # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.144            packages = lib.mkIf deployerSystem (145              let146                packages = pkgs.callPackages ./pkgs {147                  inherit craneLib inputs;148                  rustToolchain = rust;149                };150              in151              packages // { default = packages.fleet; }152            );153            # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.154            # checks there build packages for default nixpkgs rustPlatform packages.155            checks =156              let157                nixpkgsCraneLib = inputs.crane.mkLib pkgs;158                packages = pkgs.callPackages ./pkgs {159                  craneLib = nixpkgsCraneLib;160                  inherit inputs;161                };162                prefixAttrs =163                  prefix: attrs:164                  mapAttrs' (name: value: {165                    name = "${prefix}${name}";166                    value = value.overrideAttrs (prev: {167                      pname = "${prefix}${prev.pname}";168                    });169                  }) attrs;170              in171              # fleet-install-secrets is installed to remote systems, thus needs to work172              # with rust in nixpkgs.173              (prefixAttrs "nixpkgs-" {174                inherit (packages) fleet-install-secrets;175              })176              // {177                formatting = treefmt.check self;178              };179            # TODO: It should be possible to move lib.mkIf to default attribute, instead of disabling the whole180            # devShells block, yet nix flake check fails here, due to no default shell found. It is nix or flake-parts bug?181            shelly.shells.default = lib.mkIf deployerSystem {182              factory = craneLib.devShell;183              packages = with pkgs; [184                rust185186                pkg-config187                openssl188                udev189                rustPlatform.bindgenHook190                inputs'.nix.packages.nix-expr-c191                inputs'.nix.packages.nix-flake-c192                inputs'.nix.packages.nix-fetchers-c193                inputs'.nix.packages.nix-store-c194                inputs'.nix.packages.nix195196                (rage.overrideAttrs { cargoFeatures = [ "plugin" ]; })197              ];198              environment.PROTOC = "${pkgs.protobuf}/bin/protoc";199            };200            formatter = treefmt.wrapper;201          };202      };203}
modifiedpkgs/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; };
addedpkgs/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;
+}