From 0fd5d789f88a7edb6143702f721b6cc1152b9383 Mon Sep 17 00:00:00 2001 From: DrackThor Date: Sat, 14 Dec 2024 11:14:57 +0100 Subject: [PATCH] feat: added nix direnv (#22) --- .envrc | 1 + .gitignore | 3 +++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) 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 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 0394b1f..4f0c2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,6 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +# nix +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5bb1fbb --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1733808091, + "narHash": "sha256-KWwINTQelKOoQgrXftxoqxmKFZb9pLVfnRvK270nkVk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a0f3e10d94359665dba45b71b4227b0aeb851f8e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "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 0000000..226b7f8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "A Nix-flake-based Node.js development environment"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; # latest stable version at this time + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; + }); + in + { + overlays.default = final: prev: rec { + nodejs = prev.nodejs; + }; + + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ + node2nix + nodejs + pre-commit + ]; + + shellHook = '' + npm ci + export PATH=$PATH:$PWD/bin + ''; + TEST="Hello Cloud Native Austria Contributor! :D"; + }; + }); + }; +}