From 3cec49ce0de08b912a7d4d36b0c9e528fca7b5e1 Mon Sep 17 00:00:00 2001 From: "kody.low" Date: Sun, 7 Apr 2024 08:21:09 -0700 Subject: [PATCH] fix: flake --- .config/semgrep.yaml | 16 ++++++++++++++++ flake.nix | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .config/semgrep.yaml diff --git a/.config/semgrep.yaml b/.config/semgrep.yaml new file mode 100644 index 00000000..cb181dfe --- /dev/null +++ b/.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 diff --git a/flake.nix b/flake.nix index 56b026aa..d8156326 100644 --- a/flake.nix +++ b/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; [ ]; }; }); }