From 5c98ca4528841ae0ce2cf0257de88c48e186cb72 Mon Sep 17 00:00:00 2001 From: Fran Date: Thu, 29 Aug 2024 15:33:29 -0300 Subject: [PATCH 1/4] setup: add asdf + nix flake --- sequential/installing/README.md | 41 +++++++++++++++++++++++++++++---- sequential/installing/flake.nix | 36 +++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 sequential/installing/flake.nix diff --git a/sequential/installing/README.md b/sequential/installing/README.md index 1991961..1f51d35 100644 --- a/sequential/installing/README.md +++ b/sequential/installing/README.md @@ -9,10 +9,43 @@ In this exercise we will setup our environment before we start our real coding. We will need some software: -- Check how to install [Erlang](https://www.erlang.org/). -- Install the main build tool [Rebar3](https://github.com/erlang/rebar3). -- Ensure that you have [Make](https://en.wikipedia.org/wiki/Make_(software)) - installed and running. +- Erlang 27. +- Make (probably already installed on your system). +- Rebar. + +We suggest 2 ways to install Erlang: asdf or nix. + +### ASDF + +First, we need to install ASDF: +```sh +git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1 +``` +Then we'll have to add this to your bash or zsh config file: +```sh +. "$HOME/.asdf/asdf.sh" +``` +Or, if you're using fish: +```fish +source ~/.asdf/asdf.fish +``` + +Be sure to check asdf's website, since there are some extra goodies to config +like shell completions. + +```sh +asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git +``` + +And finally, install erlang 27.0.1: +```sh +asdf install erlang 27.0.1 && asdf global erlang 27.0.1 +``` + +The global command is just to tell your environment to always use erlang 27, you +can use `asdf local` instead to have distinct versions base on which folder you're currently in. + + ## Checking environment diff --git a/sequential/installing/flake.nix b/sequential/installing/flake.nix new file mode 100644 index 0000000..3c0bcfa --- /dev/null +++ b/sequential/installing/flake.nix @@ -0,0 +1,36 @@ +{ + description = "Erlings flake"; + + inputs = { + beam-flakes = { + url = "github:shanesveller/nix-beam-flakes"; + inputs.flake-parts.follows = "flake-parts"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = inputs @ { + beam-flakes, + flake-parts, + ... + }: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [beam-flakes.flakeModule]; + + systems = ["aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; + + perSystem = _: { + beamWorkspace = { + enable = true; + devShell = { + languageServers.erlang = true; + }; + versions = { + erlang = "27.0.1"; + }; + }; + }; + }; +} From 6bf84374541ab1bd51593932a516cb00286e8f12 Mon Sep 17 00:00:00 2001 From: Fran Date: Thu, 29 Aug 2024 16:11:33 -0300 Subject: [PATCH 2/4] setup-update: use simple nix-shell instead of flake --- sequential/installing/flake.nix | 36 --------------------------------- sequential/installing/shell.nix | 9 +++++++++ 2 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 sequential/installing/flake.nix create mode 100644 sequential/installing/shell.nix diff --git a/sequential/installing/flake.nix b/sequential/installing/flake.nix deleted file mode 100644 index 3c0bcfa..0000000 --- a/sequential/installing/flake.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - description = "Erlings flake"; - - inputs = { - beam-flakes = { - url = "github:shanesveller/nix-beam-flakes"; - inputs.flake-parts.follows = "flake-parts"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - flake-parts.url = "github:hercules-ci/flake-parts"; - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - }; - - outputs = inputs @ { - beam-flakes, - flake-parts, - ... - }: - flake-parts.lib.mkFlake {inherit inputs;} { - imports = [beam-flakes.flakeModule]; - - systems = ["aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; - - perSystem = _: { - beamWorkspace = { - enable = true; - devShell = { - languageServers.erlang = true; - }; - versions = { - erlang = "27.0.1"; - }; - }; - }; - }; -} diff --git a/sequential/installing/shell.nix b/sequential/installing/shell.nix new file mode 100644 index 0000000..46af1ef --- /dev/null +++ b/sequential/installing/shell.nix @@ -0,0 +1,9 @@ +let + pkgs = import { config = {}; overlays = []; }; +in +pkgs.mkShell { + packages = [ + (pkgs.erlang.override { version = "27.0.1"; }) + pkgs.beamPackages.rebar3 + ]; +} From 04aeabd0859e4f3b04d87b5c5c138dedd0b6f4da Mon Sep 17 00:00:00 2001 From: Fran Date: Thu, 29 Aug 2024 16:35:55 -0300 Subject: [PATCH 3/4] setup-update: specify nix steps --- sequential/installing/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sequential/installing/README.md b/sequential/installing/README.md index 1f51d35..22b9295 100644 --- a/sequential/installing/README.md +++ b/sequential/installing/README.md @@ -13,7 +13,7 @@ real coding. We will need some software: - Make (probably already installed on your system). - Rebar. -We suggest 2 ways to install Erlang: asdf or nix. +We suggest 2 ways to install Erlang + Rebar: asdf or nix. ### ASDF @@ -45,7 +45,17 @@ asdf install erlang 27.0.1 && asdf global erlang 27.0.1 The global command is just to tell your environment to always use erlang 27, you can use `asdf local` instead to have distinct versions base on which folder you're currently in. +### Nix +Clone the repo: +```sh +git clone https://github.com/lambdaclass/erlings.git +``` +cd into this folder and eval the nix shell: +```sh +cd erlings/sequential/install && nix-shell +``` +This will drop you into a bare-bones bash shell with erlang and rebar installed. ## Checking environment From bdb1a3edbe8d2a3af91338cd2a80191bc44ca6fe Mon Sep 17 00:00:00 2001 From: Fran Date: Thu, 29 Aug 2024 16:43:52 -0300 Subject: [PATCH 4/4] setup-update: update rebar output --- sequential/installing/README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sequential/installing/README.md b/sequential/installing/README.md index 22b9295..1e373cd 100644 --- a/sequential/installing/README.md +++ b/sequential/installing/README.md @@ -55,7 +55,8 @@ cd into this folder and eval the nix shell: ```sh cd erlings/sequential/install && nix-shell ``` -This will drop you into a bare-bones bash shell with erlang and rebar installed. +This will drop you into a bare-bones bash shell with erlang and rebar installed, +which you can use for the exercises. ## Checking environment @@ -70,16 +71,11 @@ $> make You should get the following output: ~~~ -rebar3 eunit +rebar3 ct ===> Verifying dependencies... +===> Analyzing applications... ===> Compiling installing -===> Performing EUnit tests... -. - -Top 1 slowest tests (0.000 seconds, 0.0% of total time): - installing_test:installing_test/0: module 'installing_test' - 0.000 seconds - -Finished in 0.032 seconds -1 tests, 0 failures +===> Running Common Test suites... +%%% installing_SUITE: . +All 1 tests passed. ~~~