From 970d836d772f06d73b0a8d364b703134d8cd3f72 Mon Sep 17 00:00:00 2001 From: Wout De Puysseleir Date: Wed, 17 Jan 2024 12:08:46 -0800 Subject: [PATCH] Add flake file --- .envrc | 1 + .gitignore | 6 ++++++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 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 97044e0..8806018 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,9 @@ node_modules/ # Build files priv/static/ + +# Direnv +.direnv +.nix-hex +.nix-mix +.erlang-history diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..088534e --- /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": 1705316053, + "narHash": "sha256-J2Ey5mPFT8gdfL2XC0JTZvKaBw/b2pnyudEXFvl+dQM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c3e128f3c0ecc1fb04aef9f72b3dcc2f6cecf370", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "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 0000000..1d8004d --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = + "A flake for building development environment of Phoenix project."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in with pkgs; { + devShells.default = mkShell { + buildInputs = + [ erlangR26 beam.packages.erlangR26.elixir_1_16 nodejs-18_x ] + ++ lib.optionals stdenv.isLinux [ + # For ExUnit Notifier on Linux. + libnotify + + # For file_system on Linux. + inotify-tools + ] ++ lib.optionals stdenv.isDarwin ([ + # For ExUnit Notifier on macOS. + terminal-notifier + + # For file_system on macOS. + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.CoreServices + ]); + + shellHook = '' + # allows mix to work on the local directory + mkdir -p .nix-mix + mkdir -p .nix-hex + export MIX_HOME=$PWD/.nix-mix + export HEX_HOME=$PWD/.nix-hex + export ERL_LIBS=$HEX_HOME/lib/erlang/lib + + # concats PATH + export PATH=$MIX_HOME/bin:$PATH + export PATH=$MIX_HOME/escripts:$PATH + export PATH=$HEX_HOME/bin:$PATH + + # enables history for IEx + export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.erlang-history\"'" + ''; + }; + }); +} +