kody.low hai 11 meses
pai
achega
3cec49ce0d
Modificáronse 2 ficheiros con 54 adicións e 3 borrados
  1. 16 0
      .config/semgrep.yaml
  2. 38 3
      flake.nix

+ 16 - 0
.config/semgrep.yaml

@@ -0,0 +1,16 @@
+rules:
+  # - id: use-of-unwrap
+  #   pattern: $X.unwrap()
+  #   message: "Found use of unwrap(). Consider using more robust error handling."
+  #   languages: [rust]
+  #   severity: WARNING
+  # - id: use-of-expect
+  #   pattern: $X.expect(...)
+  #   message: "Found use of expect(). Consider providing clearer error messages or using more robust error handling."
+  #   languages: [rust]
+  #   severity: WARNING
+  - id: direct-panic
+    pattern: panic!(...)
+    message: "Direct use of panic!(). Consider if there's a more graceful way to handle this error case."
+    languages: [rust]
+    severity: ERROR

+ 38 - 3
flake.nix

@@ -1,5 +1,5 @@
 {
-  description = "A very basic flake";
+  description = "Cashu Development Kit";
 
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
@@ -15,11 +15,46 @@
   outputs = { self, nixpkgs, flakebox, flake-utils }:
     flake-utils.lib.eachDefaultSystem (system:
       let
+        pkgs = import nixpkgs { system = system; };
+        lib = pkgs.lib;
         flakeboxLib = flakebox.lib.${system} { };
-      in
-      {
+        rustSrc = flakeboxLib.filterSubPaths {
+          root = builtins.path {
+            name = "cashu-sdk";
+            path = ./.;
+          };
+          paths = [ "crates/cashu" "crates/cashu-sdk" ];
+        };
+
+        targetsStd = flakeboxLib.mkStdTargets { };
+        toolchainsStd = flakeboxLib.mkStdToolchains { };
+
+        toolchainNative = flakeboxLib.mkFenixToolchain {
+          targets = (pkgs.lib.getAttrs [ "default" ] targetsStd);
+        };
+
+        commonArgs = {
+          buildInputs = [ pkgs.openssl ] ++ lib.optionals pkgs.stdenv.isDarwin
+            [ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ];
+          nativeBuildInputs = [ pkgs.pkg-config ];
+        };
+        outputs = (flakeboxLib.craneMultiBuild { toolchains = toolchainsStd; })
+          (craneLib':
+            let
+              craneLib = (craneLib'.overrideArgs {
+                pname = "flexbox-multibuild";
+                src = rustSrc;
+              }).overrideArgs commonArgs;
+            in rec {
+              workspaceDeps = craneLib.buildWorkspaceDepsOnly { };
+              workspaceBuild =
+                craneLib.buildWorkspace { cargoArtifacts = workspaceDeps; };
+            });
+      in {
         devShells = flakeboxLib.mkShells {
+          toolchain = toolchainNative;
           packages = [ ];
+          nativeBuildInputs = with pkgs; [ ];
         };
       });
 }