From 46d936b80c9bc17fa662820d03f7c9cdfabcabdc Mon Sep 17 00:00:00 2001 From: Ben-PH Date: Fri, 18 Jul 2025 14:25:43 +0200 Subject: [PATCH] chore(ci): initial flake.nix file with dev shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- README.md | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index e40c1ea12..fa6e65487 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ git clone https://github.com/vacp2p/nim-libp2p cd nim-libp2p nimble install -dy ``` +You can use `nix develop` to start a shell with Nim and Nimble. ### Testing Run unit tests: ```sh diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..8ffd05286 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1752620740, + "narHash": "sha256-f3pO+9lg66mV7IMmmIqG4PL3223TYMlnlw+pnpelbss=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "32a4e87942101f1c9f9865e04dc3ddb175f5f32e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..ae3a1acba --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "nim-libp2p dev shell flake"; + + nixConfig = { + extra-substituters = [ "https://nix-cache.status.im/" ]; + extra-trusted-public-keys = [ "nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY=" ]; + }; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + }; + + outputs = { self, nixpkgs }: + let + stableSystems = [ + "x86_64-linux" "aarch64-linux" "armv7a-linux" + "x86_64-darwin" "aarch64-darwin" + "x86_64-windows" + ]; + forEach = nixpkgs.lib.genAttrs; + forAllSystems = forEach stableSystems; + pkgsFor = forEach stableSystems ( + system: import nixpkgs { inherit system; } + ); + in rec { + devShells = forAllSystems (system: { + default = pkgsFor.${system}.mkShell { + nativeBuildInputs = with pkgsFor.${system}; [ + nim-2_2 nimble openssl.dev + ]; + }; + }); + }; +}