From df79b8dc4a6a5c0d56d713557bc429c978b80a54 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 19 Dec 2024 21:39:53 -0600 Subject: [PATCH] Work on elixir template --- templates/elixir/flake.nix | 3 +++ templates/elixir/nix/checks.nix | 17 +++++++++++++++++ templates/elixir/nix/overlays.nix | 15 ++++----------- templates/elixir/nix/packages.nix | 9 +++++---- 4 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 templates/elixir/nix/checks.nix diff --git a/templates/elixir/flake.nix b/templates/elixir/flake.nix index aaeea38..7d30b37 100644 --- a/templates/elixir/flake.nix +++ b/templates/elixir/flake.nix @@ -1,6 +1,8 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + git-hooks.url = "github:cachix/git-hooks.nix"; + git-hooks.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = inputs: let @@ -8,6 +10,7 @@ in { overlays = import nix/overlays.nix; packages = call (import nix/packages.nix); + checks = call (import nix/checks.nix); devShells = call (import nix/shells.nix); }; } diff --git a/templates/elixir/nix/checks.nix b/templates/elixir/nix/checks.nix new file mode 100644 index 0000000..d6e6f79 --- /dev/null +++ b/templates/elixir/nix/checks.nix @@ -0,0 +1,17 @@ +{ + git-hooks, + pkgs, + ... +}: { + git-hooks = git-hooks.lib.${pkgs.system}.run { + src = ./..; + hooks = { + alejandra.enable = true; + convco.enable = true; + credo.enable = true; + dialyzer.enable = true; + mix-format.enable = true; + mix-test.enable = true; + }; + }; +} diff --git a/templates/elixir/nix/overlays.nix b/templates/elixir/nix/overlays.nix index bad02d4..8a9dcf7 100644 --- a/templates/elixir/nix/overlays.nix +++ b/templates/elixir/nix/overlays.nix @@ -1,16 +1,9 @@ { forSelf = final: prev: { - erlangPackages = prev.beam.packagesWith prev.erlang_28; - erlang = final.erlangPackages.erlang; - elixir = final.erlangPackages.elixir_1_17; - - mixRelease = final.erlangPackages.mixRelease.override { - elixir = final.elixir; - }; - fetchMixDeps = final.erlangPackages.fetchMixDeps.override { - elixir = final.elixir; - }; - + erlang = prev.beam.packagesWith prev.beam.interpreters.erlang_27; + elixir = final.erlang.elixir_1_18; + mixRelease = final.erlang.mixRelease.override {elixir = final.elixir;}; + fetchMixDeps = final.erlang.fetchMixDeps.override {elixir = final.elixir;}; elixir-ls = prev.elixir-ls.override {elixir = final.elixir;}; }; } diff --git a/templates/elixir/nix/packages.nix b/templates/elixir/nix/packages.nix index 22bd52b..ed886a4 100644 --- a/templates/elixir/nix/packages.nix +++ b/templates/elixir/nix/packages.nix @@ -4,19 +4,20 @@ ... }: let version = "1.0.0"; - src = ./.; + src = ../.; pname = "my-package"; in { - ${pname} = pkgs.beamPackages.mixRelease { + ${pname} = pkgs.mixRelease { inherit pname version src; - mixFodDeps = pkgs.beamPackages.fetchMixDeps { + mixFodDeps = pkgs.fetchMixDeps { inherit version src; pname = "mix-deps-${pname}"; - hash = pkgs.lib.fakeSha256; + sha256 = pkgs.lib.fakeSha256; }; # buildInputs = with pkgs; []; # HOME = "$(pwd)"; # MIX_XDG = "$HOME"; + # RELEASE_COOKIE = "test-cookie"; }; default = self.packages.${pkgs.system}.${pname};