From 1ea8bf828630c344ac8fc243e01f61c0beb223f4 Mon Sep 17 00:00:00 2001 From: Alex Nordlund Date: Mon, 28 Aug 2023 21:41:47 +0200 Subject: [PATCH] Add Nix flake --- .envrc | 1 + .gitignore | 3 ++- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..2f8e1d3f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake --impure diff --git a/.gitignore b/.gitignore index 65b58fc8..90cdc83b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ node_modules .settings bin examples/**/*.lock -*.hprof \ No newline at end of file +*.hprof +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..85bed954 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1693231525, + "narHash": "sha256-Zmh8m0HHcgGBDth6jdJPmc4UAAP0L4jQmqIztywF1Iw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c540061ac8d72d6e6d99345bd2d590c82b2f58c1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.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..893f535d --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "A Nix-flake-based development environment"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-23.05"; + + outputs = { self, nixpkgs }: + let + javaVersion = 11; + nodeVersion = 18; + overlays = [ + (final: prev: rec { + jdk = prev."jdk${toString javaVersion}"; + nodejs = prev."nodejs-${toString nodeVersion}_x"; + pnpm = prev.nodePackages.pnpm; + }) + ]; + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit overlays system; }; + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + NIX_LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath [ + pkgs.stdenv.cc.cc.lib + ]; + NIX_LD = nixpkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; + packages = with pkgs; [ jdk nodejs pnpm stdenv ]; + }; + }); + }; +}