From fbb1bbf0970c4d02086ef65078f7949f58d9171b Mon Sep 17 00:00:00 2001 From: Lars Wikman Date: Sat, 17 May 2025 20:16:50 +0200 Subject: [PATCH] Implement a generator starting point for igniter-based generator --- lib/mix/tasks/nerves/new.ex | 344 +--------------------- templates/new/.formatter.exs | 8 - templates/new/.gitignore | 17 -- templates/new/README.md | 33 --- templates/new/config/config.exs | 25 -- templates/new/config/host.exs | 21 -- templates/new/config/target.exs | 95 ------ templates/new/lib/app_name.ex | 18 -- templates/new/lib/app_name/application.ex | 43 --- templates/new/mix.exs | 69 ----- templates/new/rel/vm.args.eex | 62 ---- templates/new/rootfs_overlay/etc/iex.exs | 4 - templates/new/test/app_name_test.exs | 8 - templates/new/test/test_helper.exs | 1 - 14 files changed, 12 insertions(+), 736 deletions(-) delete mode 100644 templates/new/.formatter.exs delete mode 100644 templates/new/.gitignore delete mode 100644 templates/new/README.md delete mode 100644 templates/new/config/config.exs delete mode 100644 templates/new/config/host.exs delete mode 100644 templates/new/config/target.exs delete mode 100644 templates/new/lib/app_name.ex delete mode 100644 templates/new/lib/app_name/application.ex delete mode 100644 templates/new/mix.exs delete mode 100644 templates/new/rel/vm.args.eex delete mode 100644 templates/new/rootfs_overlay/etc/iex.exs delete mode 100644 templates/new/test/app_name_test.exs delete mode 100644 templates/new/test/test_helper.exs diff --git a/lib/mix/tasks/nerves/new.ex b/lib/mix/tasks/nerves/new.ex index cb1b4b1..939060d 100644 --- a/lib/mix/tasks/nerves/new.ex +++ b/lib/mix/tasks/nerves/new.ex @@ -1,151 +1,21 @@ -# SPDX-FileCopyrightText: 2016 Justin Schneck -# SPDX-FileCopyrightText: 2017 Frank Hunleth -# SPDX-FileCopyrightText: 2019 Milton Mazzarri -# SPDX-FileCopyrightText: 2019 Todd Resudek -# SPDX-FileCopyrightText: 2020 TORIFUKU Kaiou -# SPDX-FileCopyrightText: 2022 Jason Axelson -# SPDX-FileCopyrightText: 2022 Jon Carstens +# SPDX-FileCopyrightText: 2025 Frank Hunleth +# SPDX-FileCopyrightText: 2025 Lars Wikman # # SPDX-License-Identifier: Apache-2.0 # defmodule Mix.Tasks.Nerves.New do - @shortdoc "Creates a new Nerves application" - @moduledoc """ - Creates a new Nerves project - - mix nerves.new PATH [--module MODULE] [--app APP] [--target TARGET] [--cookie STRING] [--no-nerves-pack] - - The project will be created at PATH. The application name and module name - will be inferred from PATH unless `--module` or `--app` is given. - - An `--app` option can be given in order to name the OTP application for the - project. - - A `--module` option can be given in order to name the modules in the - generated code skeleton. - - A `--target` option can be given to limit support to one or more of the - [officially Nerves - systems](https://hexdocs.pm/nerves/supported-targets.html). - - A `--cookie` options can be given to set the Erlang distribution - cookie in `vm.args`. This defaults to a randomly generated string. - - Generate a project without `nerves_pack` support by passing - `--no-nerves-pack`. - - ## Examples - - mix nerves.new blinky - - Is equivalent to: - - mix nerves.new blinky --module Blinky - - Generate a project that only supports Raspberry Pi 3 - - mix nerves.new blinky --target rpi3 - - Generate a project that supports Raspberry Pi 3 and Raspberry Pi Zero - - mix nerves.new blinky --target rpi3 --target rpi0 - - Generate a project without `nerves_pack` - - mix nerves.new blinky --no-nerves-pack - """ - use Mix.Task - import Mix.Generator - - @nerves Path.expand("../../../..", __DIR__) - - @bootstrap_vsn Mix.Project.config()[:version] - @bootstrap_vsn_no_patch ( - v = Version.parse!(@bootstrap_vsn) - "#{v.major}.#{v.minor}" - ) - @nerves_vsn "1.10" - @nerves_dep ~s[{:nerves, "~> #{@nerves_vsn}", runtime: false}] - @shoehorn_vsn "0.9.1" - @runtime_vsn "0.13.0" - @ring_logger_vsn "0.11.0" - @nerves_pack_vsn "0.7.1" - @toolshed_vsn "0.4.0" - - @elixir_requirement "~> 1.13" - - @targets [ - {:rpi, "1.24"}, - {:rpi0, "1.24"}, - {:rpi2, "1.24"}, - {:rpi3, "1.24"}, - {:rpi3a, "1.24"}, - {:rpi4, "1.24"}, - {:rpi5, "0.2"}, - {:bbb, "2.19"}, - {:osd32mp1, "0.15"}, - {:x86_64, "1.24"}, - {:grisp2, "0.8"}, - {:mangopi_mq_pro, "0.6"} - ] - - @new [ - {:eex, "new/config/config.exs", "config/config.exs"}, - {:eex, "new/config/host.exs", "config/host.exs"}, - {:eex, "new/config/target.exs", "config/target.exs"}, - {:eex, "new/lib/app_name.ex", "lib/app_name.ex"}, - {:eex, "new/lib/app_name/application.ex", "lib/app_name/application.ex"}, - {:eex, "new/test/test_helper.exs", "test/test_helper.exs"}, - {:eex, "new/test/app_name_test.exs", "test/app_name_test.exs"}, - {:eex, "new/rel/vm.args.eex", "rel/vm.args.eex"}, - {:eex, "new/rootfs_overlay/etc/iex.exs", "rootfs_overlay/etc/iex.exs"}, - {:text, "new/.gitignore", ".gitignore"}, - {:text, "new/.formatter.exs", ".formatter.exs"}, - {:eex, "new/mix.exs", "mix.exs"}, - {:eex, "new/README.md", "README.md"}, - {:keep, "new/rel", "rel"} - ] @reserved_names ~w[nerves] - # Embed all defined templates - root = Path.expand("../../../../templates", __DIR__) - - for {format, source, _} <- @new do - unless format == :keep do - @external_resource Path.join(root, source) - defp render(unquote(source)), do: unquote(File.read!(Path.join(root, source))) - end - end - @switches [ app: :string, module: :string, - target: :keep, - cookie: :string, - nerves_pack: :boolean, - source_date_epoch: :integer + target: :keep ] @impl Mix.Task - def run([version]) when version in ~w(-v --version) do - Mix.shell().info("Nerves Bootstrap v#{@bootstrap_vsn}") - end - def run(argv) do - unless Version.match?(System.version(), @elixir_requirement) do - Mix.raise(""" - Nerves Bootstrap v#{@bootstrap_vsn} creates projects that require Elixir #{@elixir_requirement}. - - You have Elixir #{System.version()}. Please update your Elixir version or downgrade - the version of Nerves Bootstrap that you're using. - - See https://hexdocs.pm/nerves/installation.html for more information on - setting up your environment. - """) - end - {opts, argv} = case OptionParser.parse(argv, strict: @switches) do {opts, argv, []} -> @@ -161,119 +31,27 @@ defmodule Mix.Tasks.Nerves.New do [path | _] -> app = opts[:app] || Path.basename(Path.expand(path)) - check_application_name!(app, !!opts[:app]) - mod = opts[:module] || Macro.camelize(app) - check_module_name_validity!(mod) - check_module_name_availability!(mod) - run(app, mod, path, opts) + run_new(app, opts) end end - defp run(app, _mod, _path, _opts) when app in @reserved_names, + defp run_new(app, _opts) when app in @reserved_names, do: Mix.raise("New projects cannot be named '#{app}'") - defp run(app, mod, path, opts) do - System.delete_env("MIX_TARGET") - - nerves_path = nerves_path(path, Keyword.get(opts, :dev, false)) - in_umbrella? = in_umbrella?(path) - nerves_pack? = Keyword.get(opts, :nerves_pack, true) - - targets = Keyword.get_values(opts, :target) - default_targets = Keyword.keys(@targets) - - targets = - Enum.map(targets, fn target -> - target = String.to_atom(target) - - unless target in default_targets do - targets = Enum.map_join(@targets, "\n ", &elem(&1, 0)) - - Mix.raise(""" - Unknown target #{inspect(target)} - - Officially supported targets: - #{targets} - - If you don't want any of these targets, one option is to pick one - and change the references to it in the resulting mix.exs. - """) - end - - Enum.find(@targets, &(elem(&1, 0) == target)) - end) - - targets = if targets == [], do: @targets, else: targets - cookie = opts[:cookie] - source_date_epoch = Keyword.get(opts, :source_date_epoch, generate_source_date_epoch()) - elixir_version = System.version() |> Version.parse!() - - binding = [ - app_name: app, - app_module: mod, - bootstrap_vsn: @bootstrap_vsn_no_patch, - shoehorn_vsn: @shoehorn_vsn, - runtime_vsn: @runtime_vsn, - ring_logger_vsn: @ring_logger_vsn, - elixir_req: "~> #{elixir_version.major}.#{elixir_version.minor}", - nerves_dep: nerves_dep(nerves_path), - in_umbrella: in_umbrella?, - nerves_pack?: nerves_pack?, - nerves_pack_vsn: @nerves_pack_vsn, - toolshed_vsn: @toolshed_vsn, - targets: targets, - cookie: cookie, - source_date_epoch: source_date_epoch - ] - - copy_from(path, binding, @new) - # Parallel installs - install? = Mix.shell().yes?("\nFetch and install dependencies?") - - File.cd!(path, fn -> - if install? && Code.ensure_loaded?(Hex) do - cmd("mix deps.get") - end - - cmd("mix format") - - print_mix_info(path) - end) - end - - defp recompile(regex) do - if Code.ensure_loaded?(Regex) and function_exported?(Regex, :recompile!, 1) do - apply(Regex, :recompile!, [regex]) - else - regex - end - end - - defp cmd(cmd) do - Mix.shell().info([:green, "* running ", :reset, cmd]) - - case Mix.shell().cmd(cmd, quiet: true) do - 0 -> - true - - _ -> - Mix.shell().error([ - :red, - "* error ", - :reset, - "command failed to execute, " <> - "please run the following command again after installation: \"#{cmd}\"" - ]) - - false - end + defp run_new(app, opts) do + System.cmd("mix", ["new", app] ++ OptionParser.to_argv(opts), into: IO.stream(:stdio, :line)) + File.cd!(app) + Mix.Task.run("igniter.install", ["nerves"]) + print_mix_info(app) end defp print_mix_info(path) do command = ["$ cd #{path}"] Mix.shell().info(""" + TODO: Update to be correct to new ways... + Your Nerves project was created successfully. You should now pick a target. See https://hexdocs.pm/nerves/supported-targets.html @@ -304,102 +82,4 @@ defmodule Mix.Tasks.Nerves.New do defp switch_to_string({name, nil}), do: name defp switch_to_string({name, val}), do: name <> "=" <> val - - defp check_application_name!(name, from_app_flag) do - unless name =~ recompile(~r/^[a-z][\w_]*$/) do - extra = - if from_app_flag do - "" - else - ". The application name is inferred from the path, if you'd like to " <> - "explicitly name the application then use the `--app APP` option." - end - - Mix.raise( - "Application name must start with a letter and have only lowercase " <> - "letters, numbers and underscore, got: #{inspect(name)}" <> extra - ) - end - end - - defp check_module_name_validity!(name) do - unless name =~ recompile(~r/^[A-Z]\w*(\.[A-Z]\w*)*$/) do - Mix.raise( - "Module name must be a valid Elixir alias (for example: Foo.Bar), got: #{inspect(name)}" - ) - end - end - - defp check_module_name_availability!(name) do - name = Module.concat(Elixir, name) - - if Code.ensure_loaded?(name) do - Mix.raise("Module name #{inspect(name)} is already taken, please choose another name") - end - end - - defp nerves_dep("deps/nerves"), do: @nerves_dep - defp nerves_dep(path), do: ~s[{:nerves, path: #{inspect(path)}, runtime: false, override: true}] - - defp nerves_path(path, true) do - absolute = Path.expand(path) - relative = Path.relative_to(absolute, @nerves) - - if absolute == relative do - Mix.raise("--dev project must be inside Nerves directory") - end - - relative - |> Path.split() - |> Enum.map(fn _ -> ".." end) - |> Path.join() - end - - defp nerves_path(_path, false) do - "deps/nerves" - end - - defp copy_from(target_dir, binding, mapping) when is_list(mapping) do - app_name = Keyword.fetch!(binding, :app_name) - - Enum.each(mapping, fn {format, source, target_path} -> - target = Path.join(target_dir, String.replace(target_path, "app_name", app_name)) - - case format do - :keep -> - File.mkdir_p!(target) - - :text -> - create_file(target, render(source)) - - :append -> - append_to(Path.dirname(target), Path.basename(target), render(source)) - - :eex -> - contents = EEx.eval_string(render(source), binding, file: source, trim: false) - create_file(target, contents) - end - end) - end - - defp append_to(path, file, contents) do - file = Path.join(path, file) - File.write!(file, File.read!(file) <> contents) - end - - defp in_umbrella?(app_path) do - umbrella = Path.expand(Path.join([app_path, "..", ".."])) - - File.exists?(Path.join(umbrella, "mix.exs")) && - Mix.Project.in_project(:umbrella_check, umbrella, fn _ -> - path = Mix.Project.config()[:apps_path] - path && Path.expand(path) == Path.join(umbrella, "apps") - end) - catch - _, _ -> false - end - - defp generate_source_date_epoch() do - DateTime.utc_now() |> DateTime.to_unix() - end end diff --git a/templates/new/.formatter.exs b/templates/new/.formatter.exs deleted file mode 100644 index 8aab4bc..0000000 --- a/templates/new/.formatter.exs +++ /dev/null @@ -1,8 +0,0 @@ -# Used by "mix format" -[ - inputs: [ - "{mix,.formatter}.exs", - "{config,lib,test}/**/*.{ex,exs}", - "rootfs_overlay/etc/iex.exs" - ] -] diff --git a/templates/new/.gitignore b/templates/new/.gitignore deleted file mode 100644 index 069b8ba..0000000 --- a/templates/new/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# 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/ - -# If the VM crashes, it generates a dump, let's ignore it too. -erl_crash.dump - -# Temporary files, for example, from tests. -/tmp/ diff --git a/templates/new/README.md b/templates/new/README.md deleted file mode 100644 index f19979d..0000000 --- a/templates/new/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# <%= app_module %> - -**TODO: Add description** - -## Targets - -Nerves applications produce images for hardware targets based on the -`MIX_TARGET` environment variable. If `MIX_TARGET` is unset, `mix` builds an -image that runs on the host (e.g., your laptop). This is useful for executing -logic tests, running utilities, and debugging. Other targets are represented by -a short name like `rpi3` that maps to a Nerves system image for that platform. -All of this logic is in the generated `mix.exs` and may be customized. For more -information about targets see: - -https://hexdocs.pm/nerves/supported-targets.html - -## Getting Started - -To start your Nerves app: - * `export MIX_TARGET=my_target` or prefix every command with - `MIX_TARGET=my_target`. For example, `MIX_TARGET=rpi3` - * Install dependencies with `mix deps.get` - * Create firmware with `mix firmware` - * Burn to an SD card with `mix burn` - -## Learn more - - * Official docs: https://hexdocs.pm/nerves/getting-started.html - * Official website: https://nerves-project.org/ - * Forum: https://elixirforum.com/c/nerves-forum - * Elixir Slack #nerves channel: https://elixir-slack.community/ - * Elixir Discord #nerves channel: https://discord.gg/elixir - * Source: https://github.com/nerves-project/nerves diff --git a/templates/new/config/config.exs b/templates/new/config/config.exs deleted file mode 100644 index 4080a95..0000000 --- a/templates/new/config/config.exs +++ /dev/null @@ -1,25 +0,0 @@ -# This file is responsible for configuring your application and its -# dependencies. -# -# This configuration file is loaded before any dependency and is restricted to -# this project. -import Config - -# Enable the Nerves integration with Mix -Application.start(:nerves_bootstrap) - -# Customize non-Elixir parts of the firmware. See -# https://hexdocs.pm/nerves/advanced-configuration.html for details. - -config :nerves, :firmware, rootfs_overlay: "rootfs_overlay" - -# Set the SOURCE_DATE_EPOCH date for reproducible builds. -# See https://reproducible-builds.org/docs/source-date-epoch/ for more information - -config :nerves, source_date_epoch: "<%= source_date_epoch %>" - -if Mix.target() == :host do - import_config "host.exs" -else - import_config "target.exs" -end diff --git a/templates/new/config/host.exs b/templates/new/config/host.exs deleted file mode 100644 index 166f24d..0000000 --- a/templates/new/config/host.exs +++ /dev/null @@ -1,21 +0,0 @@ -import Config - -# Add configuration that is only needed when running on the host here. - -config :nerves_runtime, - kv_backend: - {Nerves.Runtime.KVBackend.InMemory, - contents: %{ - # The KV store on Nerves systems is typically read from UBoot-env, but - # this allows us to use a pre-populated InMemory store when running on - # host for development and testing. - # - # https://hexdocs.pm/nerves_runtime/readme.html#using-nerves_runtime-in-tests - # https://hexdocs.pm/nerves_runtime/readme.html#nerves-system-and-firmware-metadata - - "nerves_fw_active" => "a", - "a.nerves_fw_architecture" => "generic", - "a.nerves_fw_description" => "N/A", - "a.nerves_fw_platform" => "host", - "a.nerves_fw_version" => "0.0.0" - }} diff --git a/templates/new/config/target.exs b/templates/new/config/target.exs deleted file mode 100644 index 754057e..0000000 --- a/templates/new/config/target.exs +++ /dev/null @@ -1,95 +0,0 @@ -import Config - -# Use Ringlogger as the logger backend and remove :console. -# See https://hexdocs.pm/ring_logger/readme.html for more information on -# configuring ring_logger. - -config :logger, backends: [RingLogger] - -# Use shoehorn to start the main application. See the shoehorn -# library documentation for more control in ordering how OTP -# applications are started and handling failures. - -config :shoehorn, init: [:nerves_runtime<%= if nerves_pack? do %>, :nerves_pack<% end %>] -<%= if nerves_pack? do %> -# Erlinit can be configured without a rootfs_overlay. See -# https://github.com/nerves-project/erlinit/ for more information on -# configuring erlinit. - -# Advance the system clock on devices without real-time clocks. -config :nerves, :erlinit, update_clock: true - -# Configure the device for SSH IEx prompt access and firmware updates -# -# * See https://hexdocs.pm/nerves_ssh/readme.html for general SSH configuration -# * See https://hexdocs.pm/ssh_subsystem_fwup/readme.html for firmware updates - -keys = - System.user_home!() - |> Path.join(".ssh/id_{rsa,ecdsa,ed25519}.pub") - |> Path.wildcard() - -if keys == [], - do: - Mix.raise(""" - No SSH public keys found in ~/.ssh. An ssh authorized key is needed to - log into the Nerves device and update firmware on it using ssh. - See your project's config.exs for this error message. - """) - -config :nerves_ssh, - authorized_keys: Enum.map(keys, &File.read!/1) - -# Configure the network using vintage_net -# -# Update regulatory_domain to your 2-letter country code E.g., "US" -# -# See https://github.com/nerves-networking/vintage_net for more information -config :vintage_net, - regulatory_domain: "00", - config: [ - {"usb0", %{type: VintageNetDirect}}, - {"eth0", - %{ - type: VintageNetEthernet, - ipv4: %{method: :dhcp} - }}, - {"wlan0", %{type: VintageNetWiFi}} - ] - -config :mdns_lite, - # The `hosts` key specifies what hostnames mdns_lite advertises. `:hostname` - # advertises the device's hostname.local. For the official Nerves systems, this - # is "nerves-<4 digit serial#>.local". The `"nerves"` host causes mdns_lite - # to advertise "nerves.local" for convenience. If more than one Nerves device - # is on the network, it is recommended to delete "nerves" from the list - # because otherwise any of the devices may respond to nerves.local leading to - # unpredictable behavior. - - hosts: [:hostname, "nerves"], - ttl: 120, - - # Advertise the following services over mDNS. - services: [ - %{ - protocol: "ssh", - transport: "tcp", - port: 22 - }, - %{ - protocol: "sftp-ssh", - transport: "tcp", - port: 22 - }, - %{ - protocol: "epmd", - transport: "tcp", - port: 4369 - } - ]<% end %> - -# Import target specific config. This must remain at the bottom -# of this file so it overrides the configuration defined above. -# Uncomment to use target specific configurations - -# import_config "#{Mix.target()}.exs" diff --git a/templates/new/lib/app_name.ex b/templates/new/lib/app_name.ex deleted file mode 100644 index d919d5d..0000000 --- a/templates/new/lib/app_name.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule <%= app_module %> do - @moduledoc """ - Documentation for `<%= app_module %>`. - """ - - @doc """ - Hello world. - - ## Examples - - iex> <%= app_module %>.hello() - :world - - """ - def hello do - :world - end -end diff --git a/templates/new/lib/app_name/application.ex b/templates/new/lib/app_name/application.ex deleted file mode 100644 index ce3f751..0000000 --- a/templates/new/lib/app_name/application.ex +++ /dev/null @@ -1,43 +0,0 @@ -defmodule <%= app_module %>.Application do - # See https://hexdocs.pm/elixir/Application.html - # for more information on OTP Applications - @moduledoc false - - use Application - - @impl true - def start(_type, _args) do - children = - [ - # Children for all targets - # Starts a worker by calling: <%= app_module %>.Worker.start_link(arg) - # {<%= app_module %>.Worker, arg}, - ] ++ target_children() - - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options - opts = [strategy: :one_for_one, name: <%= app_module %>.Supervisor] - Supervisor.start_link(children, opts) - end - - # List all child processes to be supervised - if Mix.target() == :host do - defp target_children() do - [ - # Children that only run on the host during development or test. - # In general, prefer using `config/host.exs` for differences. - # - # Starts a worker by calling: Host.Worker.start_link(arg) - # {Host.Worker, arg}, - ] - end - else - defp target_children() do - [ - # Children for all targets except host - # Starts a worker by calling: Target.Worker.start_link(arg) - # {Target.Worker, arg}, - ] - end - end -end diff --git a/templates/new/mix.exs b/templates/new/mix.exs deleted file mode 100644 index 0d69565..0000000 --- a/templates/new/mix.exs +++ /dev/null @@ -1,69 +0,0 @@ -defmodule <%= app_module %>.MixProject do - use Mix.Project - - @app :<%= app_name %> - @version "0.1.0" - @all_targets <%= inspect(Enum.map(targets, &elem(&1, 0))) %> - - def project do - [ - app: @app, - version: @version, - elixir: "<%= elixir_req %>", - archives: [nerves_bootstrap: "~> <%= bootstrap_vsn %>"],<%= if in_umbrella do %> - deps_path: "../../deps", - build_path: "../../_build", - config_path: "../../config/config.exs", - lockfile: "../../mix.lock",<% end %> - start_permanent: Mix.env() == :prod, - deps: deps(), - releases: [{@app, release()}], - preferred_cli_target: [run: :host, test: :host] - ] - end - - # Run "mix help compile.app" to learn about applications. - def application do - [ - extra_applications: [:logger, :runtime_tools], - mod: {<%= app_module %>.Application, []} - ] - end - - # Run "mix help deps" to learn about dependencies. - defp deps do - [ - # Dependencies for all targets - <%= nerves_dep %>, - {:shoehorn, "~> <%= shoehorn_vsn %>"}, - {:ring_logger, "~> <%= ring_logger_vsn %>"}, - {:toolshed, "~> <%= toolshed_vsn %>"}, - - # Allow Nerves.Runtime on host to support development, testing and CI. - # See config/host.exs for usage. - {:nerves_runtime, "~> <%= runtime_vsn %>"},<%= if nerves_pack? do %> - - # Dependencies for all targets except :host - {:nerves_pack, "~> <%= nerves_pack_vsn %>", targets: @all_targets},<% end %> - - # Dependencies for specific targets - # NOTE: It's generally low risk and recommended to follow minor version - # bumps to Nerves systems. Since these include Linux kernel and Erlang - # version updates, please review their release notes in case - # changes to your application are needed. -<%= Enum.map_join(targets, ",\n", &~s| {:nerves_system_#{elem(&1, 0)}, "~> #{elem(&1, 1)}", runtime: false, targets: :#{elem(&1, 0)}}|) %> - ] - end - - def release do - [ - overwrite: true, -<%= if nerves_pack? do %> # Erlang distribution is not started automatically. - # See https://hexdocs.pm/nerves_pack/readme.html#erlang-distribution -<% end %> cookie: <%= if cookie do %>"<%= cookie %>"<% else %>"#{@app}_cookie"<% end %>, - include_erts: &Nerves.Release.erts/0, - steps: [&Nerves.Release.init/1, :assemble], - strip_beams: Mix.env() == :prod or [keep: ["Docs"]] - ] - end -end diff --git a/templates/new/rel/vm.args.eex b/templates/new/rel/vm.args.eex deleted file mode 100644 index f8f4ddb..0000000 --- a/templates/new/rel/vm.args.eex +++ /dev/null @@ -1,62 +0,0 @@ -## Customize flags given to the VM: https://www.erlang.org/doc/apps/erts/erl_cmd.html - -## Do not set -name or -sname here. Prefer configuring them at runtime -## Configure -setcookie in the mix.exs release section or at runtime - -## Number of dirty schedulers doing IO work (file, sockets, and others) -##+SDio 5 - -## Increase number of concurrent ports/sockets -##+Q 65536 - -## Tweak GC to run more often -##-env ERL_FULLSWEEP_AFTER 10 - -## Use Ctrl-C to interrupt the current shell rather than invoking the emulator's -## break handler and possibly exiting the VM. -+Bc - -# Allow time warps so that the Erlang system time can more closely match the -# OS system time. -+C multi_time_warp - -## Load code at system startup -## See https://www.erlang.org/doc/system/system_principles.html#code-loading-strategy --mode embedded - -# Load code as per the boot script since not using archives -# See https://www.erlang.org/doc/man/init.html#command-line-flags --code_path_choice strict - -## Disable scheduler busy wait to reduce idle CPU usage and avoid delaying -## other OS processes. See https://www.erlang.org/doc/apps/erts/erl_cmd.html#+sbwt -+sbwt none -+sbwtdcpu none -+sbwtdio none - -## Save the shell history between reboots -## See https://www.erlang.org/doc/apps/kernel/kernel_app for additional options --kernel shell_history enabled - -## Enable heartbeat monitoring of the Erlang runtime system --heart -env HEART_BEAT_TIMEOUT 30 - -## Start the Elixir shell - --noshell<%= if Version.match?(System.version(), ">= 1.15.0") do %> --user elixir --run elixir <%= if Version.match?(System.version(), ">= 1.17.0"), do: "start_cli", else: "start_iex" %> -<% else %> --user Elixir.IEx.CLI -<% end %> - -## Enable colors in the shell --elixir ansi_enabled true - -## Options added after -extra are interpreted as plain arguments and can be -## retrieved using :init.get_plain_arguments(). Options before the "--" are -## interpreted by Elixir and anything afterwards is left around for other IEx -## and user applications. --extra --no-halt --- ---dot-iex /etc/iex.exs diff --git a/templates/new/rootfs_overlay/etc/iex.exs b/templates/new/rootfs_overlay/etc/iex.exs deleted file mode 100644 index 74ee8d6..0000000 --- a/templates/new/rootfs_overlay/etc/iex.exs +++ /dev/null @@ -1,4 +0,0 @@ -NervesMOTD.print() - -# Add Toolshed helpers to the IEx session -use Toolshed diff --git a/templates/new/test/app_name_test.exs b/templates/new/test/app_name_test.exs deleted file mode 100644 index 1fd1da0..0000000 --- a/templates/new/test/app_name_test.exs +++ /dev/null @@ -1,8 +0,0 @@ -defmodule <%= app_module %>Test do - use ExUnit.Case - doctest <%= app_module %> - - test "greets the world" do - assert <%= app_module %>.hello() == :world - end -end diff --git a/templates/new/test/test_helper.exs b/templates/new/test/test_helper.exs deleted file mode 100644 index 869559e..0000000 --- a/templates/new/test/test_helper.exs +++ /dev/null @@ -1 +0,0 @@ -ExUnit.start()