From 13b4b7531af7ab5b5d9fa28d191184e73b3ec535 Mon Sep 17 00:00:00 2001 From: Scott Moore Date: Tue, 11 Jul 2023 22:29:08 +1000 Subject: [PATCH] Add development environment using Nix flakes --- .envrc | 1 + .gitignore | 3 ++ flake.lock | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++++++++++++++ 4 files changed, 128 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 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 89593d6d..464cb30a 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,6 @@ dist/ .next .DS_Store /.vscode + +# Direnv +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..e31d4356 --- /dev/null +++ b/flake.lock @@ -0,0 +1,80 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1688466019, + "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nix-packages": { + "locked": { + "lastModified": 1689047559, + "narHash": "sha256-s3xILs1+Hh4z8zudSnbOz5xM7ltzpg4WZ952ea7OlZ0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a187ec43efbeec0f3be6f9d13a6836fcbb914a9d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nix-systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1688049487, + "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nix-packages": "nix-packages", + "nix-systems": "nix-systems" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..01e6b52f --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nix-packages.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nix-systems.url = "github:nix-systems/default"; + }; + outputs = inputs @ { + flake-parts, + nix-packages, + nix-systems, + ... + }: let + packagesModule = { + perSystem = {system, ...}: { + _module.args.packages = import nix-packages { + inherit system; + }; + }; + }; + + systemsModule = { + systems = import nix-systems; + }; + in + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + packagesModule + systemsModule + ]; + + perSystem = {packages, ...}: { + devShells.default = packages.mkShell { + nativeBuildInputs = with packages; [ + # Nix + alejandra + nil + + # Node + nodejs + ]; + }; + }; + }; +}