From cb207114a773d5ba9fc4531feaed948ef586d62e Mon Sep 17 00:00:00 2001 From: bluepython508 <16466646+bluepython508@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:37:00 +0100 Subject: [PATCH] Initial Elixir project --- .envrc | 1 + .formatter.exs | 4 ++++ .gitignore | 30 ++++++++++++++++++++++++++++++ README.md | 21 +++++++++++++++++++++ default.nix | 24 ++++++++++++++++++++++++ flake.lock | 39 +++++++++++++++++++++++++++++++++++++++ flake.nix | 27 +++++++++++++++++++++++++++ lib/frajtano.ex | 2 ++ mix.exs | 23 +++++++++++++++++++++++ shell.nix | 24 ++++++++++++++++++++++++ test/frajtano_test.exs | 4 ++++ test/test_helper.exs | 1 + 12 files changed, 200 insertions(+) create mode 100644 .envrc create mode 100644 .formatter.exs create mode 100644 .gitignore create mode 100644 README.md create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 lib/frajtano.ex create mode 100644 mix.exs create mode 100644 shell.nix create mode 100644 test/frajtano_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 new file mode 100644 index 0000000..1f19321 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +/.direnv/ +# 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"). +frajtano-*.tar + +# Temporary files, for example, from tests. +/tmp/ + +/.nix-hex +/.nix-mix diff --git a/README.md b/README.md new file mode 100644 index 0000000..e45c6f7 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Frajtano + +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `frajtano` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:frajtano, "~> 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/default.nix b/default.nix new file mode 100644 index 0000000..4d863e4 --- /dev/null +++ b/default.nix @@ -0,0 +1,24 @@ +{ + mixRelease, + fetchMixDeps, + elixir, +}: +mixRelease rec { + pname = "frajtano"; + version = "0.0.1"; + + inherit elixir; + src = builtins.path { + path = ./.; + name = "${pname}-source"; + filter = path: _type: baseNameOf path != "flake.nix" && baseNameOf path != "flake.lock"; + }; + mixFodDeps = fetchMixDeps { + pname = "mix-deps-${pname}"; + inherit version src; + sha256 = "sha256-lknkq6b1yDOLgTpR/tPEk9UKqpqQT6H1N5g15M60nCA="; + }; + + ELIXIR_MAKE_CACHE_DIR = "/tmp/.elixir-make-cache"; + meta.mainProgram = "${pname}"; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..35e2471 --- /dev/null +++ b/flake.lock @@ -0,0 +1,39 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1721924956, + "narHash": "sha256-Sb1jlyRO+N8jBXEX9Pg9Z1Qb8Bw9QyOgLDNMEpmjZ2M=", + "path": "/nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source", + "rev": "5ad6a14c6bf098e98800b091668718c336effc95", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..08a0b24 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "frajtano: an ssh agent multiplexer"; + + outputs = { + self, + nixpkgs, + systems, + }: let + inherit (nixpkgs) lib; + eachSystem = f: + lib.genAttrs (import systems) (system: + f { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + ownPkgs = self.packages.${system}; + }); + in { + devShells = eachSystem ({pkgs, ownPkgs, ...}: { + default = pkgs.beam.packages.erlang_26.callPackage ./shell.nix { + inherit ownPkgs; + }; + }); + packages = eachSystem ({pkgs, ...}: { + default = pkgs.beam.packages.erlang_26.callPackage ./default.nix {}; + }); + }; +} diff --git a/lib/frajtano.ex b/lib/frajtano.ex new file mode 100644 index 0000000..1c04d30 --- /dev/null +++ b/lib/frajtano.ex @@ -0,0 +1,2 @@ +defmodule Frajtano do +end diff --git a/mix.exs b/mix.exs new file mode 100644 index 0000000..2580338 --- /dev/null +++ b/mix.exs @@ -0,0 +1,23 @@ +defmodule Frajtano.MixProject do + use Mix.Project + + def project do + [ + app: :frajtano, + version: "0.0.1", + elixir: "~> 1.16", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + def application do + [ + extra_applications: [:logger] + ] + end + + defp deps do + [] + end +end diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0b1308e --- /dev/null +++ b/shell.nix @@ -0,0 +1,24 @@ +{ + lib, + pkgs, + ownPkgs, + mkShell, + elixir-ls, + inotify-tools, +}: +mkShell { + inputsFrom = [ ownPkgs.default ]; + packages = + [elixir-ls] + ++ lib.lists.optional (pkgs.system == "x86_64-linux") inotify-tools + ++ lib.lists.optionals (pkgs.system == "aarch64-darwin") (with pkgs.darwin.apple_sdk.frameworks; [ + CoreFoundation + CoreServices + ]); + shellHook = '' + mkdir -p .nix-mix + mkdir -p .nix-hex + export MIX_HOME=$PWD/.nix-mix + export HEX_HOME=$PWD/.nix-hex + ''; +} diff --git a/test/frajtano_test.exs b/test/frajtano_test.exs new file mode 100644 index 0000000..2c99ade --- /dev/null +++ b/test/frajtano_test.exs @@ -0,0 +1,4 @@ +defmodule FrajtanoTest do + use ExUnit.Case + doctest Frajtano +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()