diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..4f4f1088 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +# this caches nix setup, making day-to-day nix usage much faster. +# see flake.nix for our nix setup +use flake diff --git a/.gitignore b/.gitignore index c395be12..4005c6c6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ yarn.lock .env dist lib + +# used by the nix when nix is used to provide a development environment +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..5e8c3171 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708979614, + "narHash": "sha256-FWLWmYojIg6TeqxSnHkKpHu5SGnFP5um1uUjH+wRV6g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b7ee09cf5614b02d289cd86fcfa6f24d4e078c2a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..b2099bd1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +# this flake installs all tools required for the dev env +{ + description = "nlx SDK dev env"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + + outputs = + { self + , nixpkgs + , flake-utils + }: + flake-utils.lib.eachDefaultSystem (system: + let + assertVersion = version: pkg: ( + assert (pkgs.lib.assertMsg (builtins.toString pkg.version == version) '' + Expecting version of ${pkg.name} to be ${version} but got ${pkg.version}; + ''); + pkg + ); + pkgs = import nixpkgs + { + system = system; + config.allowUnfree = true; + }; + + in + { + formatter = pkgs.nixpkgs-fmt; + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + (assertVersion (nixpkgs.lib.strings.fileContents "${self}/.node-version") nodejs_18) + ]; + }; + }); +}