From 2151e02838d6bb92350a7f1480716af6a0fc2bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Bur=C4=8Dul?= <39484255+markoburcul@users.noreply.github.com> Date: Mon, 4 Nov 2024 08:46:22 +0100 Subject: [PATCH] nix-flake: Add shell definition (#954) Initialized flake file and added development shell definition. Exporting of default compiler flags is moved to makefile. Referenced issue: https://github.com/codex-storage/nim-codex/issues/940 Signed-off-by: markoburcul --- Makefile | 3 +++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Makefile b/Makefile index 5e6054c1..3340fd10 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ DOCKER_IMAGE_NIM_PARAMS ?= -d:chronicles_colors:none -d:insecure LINK_PCRE := 0 +CXXFLAGS ?= -std=c++17 -mssse3 +export CXXFLAGS + # we don't want an error here, so we can handle things later, in the ".DEFAULT" target -include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..2ea7b7ee --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1729449015, + "narHash": "sha256-Gf04dXB0n4q0A9G5nTGH3zuMGr6jtJppqdeljxua1fo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "89172919243df199fe237ba0f776c3e3e3d72367", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.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 00000000..8778ca4a --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Codex build flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + }; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" "aarch64-linux" + "x86_64-darwin" "aarch64-darwin" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); + pkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in rec { + devShells = forAllSystems (system: let + pkgs = pkgsFor.${system}; + inherit (pkgs) lib stdenv mkShell; + in { + default = mkShell.override { stdenv = pkgs.gcc11Stdenv; } { + buildInputs = with pkgs; [ + # General + git pkg-config openssl lsb-release + # Build + rustc cargo nimble gcc11 cmake nim-unwrapped-1 + # Libraries + gmp llvmPackages.openmp + # Tests + nodejs_18 + ]; + }; + }); + }; +} \ No newline at end of file