From b3cec2fd69ca035f680d71f7a0462304189a42af Mon Sep 17 00:00:00 2001 From: pingu Date: Thu, 23 May 2024 00:41:31 +0200 Subject: [PATCH] Mjapp --- .envrc | 1 + .formatter.exs | 4 ++++ .gitignore | 38 ++++++++++++++++++++--------- README.md | 19 +++++++++++++++ flake.lock | 43 +++++++++++++++++++++++++++++++++ flake.nix | 52 ++++++++++++++++++++++++++++++++++++++++ lib/elixirsssh.ex | 25 +++++++++++++++++++ mix.exs | 29 ++++++++++++++++++++++ test/elixirsssh_test.exs | 8 +++++++ test/test_helper.exs | 1 + 10 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 .envrc create mode 100644 .formatter.exs create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 lib/elixirsssh.ex create mode 100644 mix.exs create mode 100644 test/elixirsssh_test.exs create mode 100644 test/test_helper.exs 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/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index fc5d8e3..7d4ddaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,28 @@ -# ---> Elixir -/_build -/cover -/deps -/doc -/.fetch -erl_crash.dump -*.ez -*.beam -/config/*.secret.exs -.elixir_ls/ +# The directory Mix will write compiled artifacts to. +/_build/ +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +elixirsssh-*.tar + +# Temporary files, for example, from tests. +/tmp/ + +.direnv/ diff --git a/README.md b/README.md index 4727aeb..9014d97 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # Elixirsssh +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `elixirsssh` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:elixirsssh, "~> 0.1.0"} + ] +end +``` + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at . + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0e5add5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1716312448, + "narHash": "sha256-PH3w5av8d+TdwCkiWN4UPBTxrD9MpxIQPDVWctlomVo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e381a1288138aceda0ac63db32c7be545b446921", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "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..4ce4d66 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = { + nixpkgs, + systems, + ... + } @ inputs: let + inherit (nixpkgs) lib; + + # Set the Erlang version + erlangVersion = "erlang_26"; + # Set the Elixir version + elixirVersion = "elixir_1_15"; + + eachSystem = f: + nixpkgs.lib.genAttrs (import systems) ( + system: + f (import nixpkgs { + inherit system; + overlays = [ + (final: _: let + erlang = final.beam.interpreters.${erlangVersion}; + beamPackages = final.beam.packages.${erlangVersion}; + elixir = beamPackages.${elixirVersion}; + in { + inherit erlang elixir; + inherit (beamPackages) elixir-ls hex; + }) + ]; + }) + ); + in { + # packages = eachSystem (pkgs: + # ); + + devShells = eachSystem ( + pkgs: { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + erlang + elixir + elixir-ls + ]; + }; + } + ); + }; +} diff --git a/lib/elixirsssh.ex b/lib/elixirsssh.ex new file mode 100644 index 0000000..dc02ac1 --- /dev/null +++ b/lib/elixirsssh.ex @@ -0,0 +1,25 @@ +defmodule Elixirsssh do + use Application + + def start(_type, _args) do + IO.puts(hello()) + {:ok, self()} + end + + @moduledoc """ + Documentation for `Elixirsssh`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> Elixirsssh.hello() + :world + + """ + def hello do + :world + end +end diff --git a/mix.exs b/mix.exs new file mode 100644 index 0000000..234fc06 --- /dev/null +++ b/mix.exs @@ -0,0 +1,29 @@ +defmodule Elixirsssh.MixProject do + use Mix.Project + + def project do + [ + app: :elixirsssh, + version: "0.1.0", + elixir: "~> 1.15", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger], + mod: {Elixirsssh, []} + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/test/elixirsssh_test.exs b/test/elixirsssh_test.exs new file mode 100644 index 0000000..70633ab --- /dev/null +++ b/test/elixirsssh_test.exs @@ -0,0 +1,8 @@ +defmodule ElixirssshTest do + use ExUnit.Case + doctest Elixirsssh + + test "greets the world" do + assert Elixirsssh.hello() == :world + end +end diff --git a/test/test_helper.exs b/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start()