From 6963ec3fef90670ec89eecccc93742d129ba3037 Mon Sep 17 00:00:00 2001 From: "Adam C. Stephens" Date: Mon, 15 Dec 2025 10:20:28 -0500 Subject: [PATCH 1/2] use packages from callPackages --- lib/deps_nix.ex | 14 ++++++++++---- lib/deps_nix/derivation.ex | 6 +++--- lib/deps_nix/fetch_from_github.ex | 2 +- shells/local.nix | 1 + test/deps_nix/derivation_test.exs | 2 +- test/deps_nix/fetch_from_github_test.exs | 2 +- test/deps_nix/special_treatment_test.exs | 6 +++--- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/deps_nix.ex b/lib/deps_nix.ex index b44e5eb..e130ef8 100644 --- a/lib/deps_nix.ex +++ b/lib/deps_nix.ex @@ -208,11 +208,17 @@ defmodule DepsNix do output, """ { - pkgs, lib, beamPackages, + cmake, + extend, + lexbor, + fetchFromGitHub, overrides ? (x: y: { }), overrideFenixOverlay ? null, + pkg-config, + vips, + writeText, }: let @@ -221,7 +227,7 @@ defmodule DepsNix do workarounds = { portCompiler = _unusedArgs: old: { - buildPlugins = [ pkgs.beamPackages.pc ]; + buildPlugins = [ beamPackages.pc ]; }; rustlerPrecompiled = @@ -231,7 +237,7 @@ defmodule DepsNix do }: old: let - extendedPkgs = pkgs.extend fenixOverlay; + extendedPkgs = extend fenixOverlay; fenixOverlay = if overrideFenixOverlay == null then import "${ @@ -331,7 +337,7 @@ defmodule DepsNix do preBuild = '' install -Dm644 \ -t _build/c/third_party/lexbor/$LEXBOR_GIT_SHA/build \ - ${pkgs.lexbor}/lib/liblexbor_static.a + ${lexbor}/lib/liblexbor_static.a ''; }; }; diff --git a/lib/deps_nix/derivation.ex b/lib/deps_nix/derivation.ex index 7107729..95d4622 100644 --- a/lib/deps_nix/derivation.ex +++ b/lib/deps_nix/derivation.ex @@ -162,7 +162,7 @@ defmodule DepsNix.Derivation do VIX_COMPILATION_MODE = "PLATFORM_PROVIDED_LIBVIPS"; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ pkg-config vips ]; @@ -183,7 +183,7 @@ defmodule DepsNix.Derivation do inherit version; name = "#{drv.name}";#{format_app_config_path(drv)} - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ cmake lexbor ]; @@ -222,7 +222,7 @@ defmodule DepsNix.Derivation do patches = [ - (pkgs.writeText "unicode-accessible-data-dir.patch" '' + (writeText "unicode-accessible-data-dir.patch" '' diff --git a/lib/unicode.ex b/lib/unicode.ex index 8224c3c..3c0bb3a 100644 --- a/lib/unicode.ex diff --git a/lib/deps_nix/fetch_from_github.ex b/lib/deps_nix/fetch_from_github.ex index 9a121b7..cd121b6 100644 --- a/lib/deps_nix/fetch_from_github.ex +++ b/lib/deps_nix/fetch_from_github.ex @@ -22,7 +22,7 @@ defmodule DepsNix.FetchFromGitHub do defimpl String.Chars do def to_string(%DepsNix.FetchFromGitHub{} = g) do """ - pkgs.fetchFromGitHub { + fetchFromGitHub { owner = "#{g.owner}"; repo = "#{g.repo}"; rev = "#{g.rev}"; diff --git a/shells/local.nix b/shells/local.nix index 8c86e9f..3bae58b 100644 --- a/shells/local.nix +++ b/shells/local.nix @@ -20,6 +20,7 @@ mkShell { }; in [ + beamPackages.hex elixir_1_19 elixir-ls gh diff --git a/test/deps_nix/derivation_test.exs b/test/deps_nix/derivation_test.exs index dd566c4..3241808 100644 --- a/test/deps_nix/derivation_test.exs +++ b/test/deps_nix/derivation_test.exs @@ -325,7 +325,7 @@ defmodule DepsNix.DerivationTest do app_config_path: "foo" } |> to_string() == """ - heroicons = pkgs.fetchFromGitHub { + heroicons = fetchFromGitHub { owner = "tailwindlabs"; repo = "heroicons"; rev = "88ab3a0d790e6a47404cba02800a6b25d2afae50"; diff --git a/test/deps_nix/fetch_from_github_test.exs b/test/deps_nix/fetch_from_github_test.exs index ae1fd48..0a51e34 100644 --- a/test/deps_nix/fetch_from_github_test.exs +++ b/test/deps_nix/fetch_from_github_test.exs @@ -13,7 +13,7 @@ defmodule DepsNix.FetchFromGitHubTest do } |> to_string() == """ - pkgs.fetchFromGitHub { + fetchFromGitHub { owner = "sstoltze"; repo = "tds"; rev = "somegithash"; diff --git a/test/deps_nix/special_treatment_test.exs b/test/deps_nix/special_treatment_test.exs index 420fb69..05801ad 100644 --- a/test/deps_nix/special_treatment_test.exs +++ b/test/deps_nix/special_treatment_test.exs @@ -35,7 +35,7 @@ defmodule DepsNix.SpecialTreatmentTest do }; patches = [ - (pkgs.writeText "unicode-accessible-data-dir.patch" '' + (writeText "unicode-accessible-data-dir.patch" '' diff --git a/lib/unicode.ex b/lib/unicode.ex index 8224c3c..3c0bb3a 100644 --- a/lib/unicode.ex @@ -144,7 +144,7 @@ defmodule DepsNix.SpecialTreatmentTest do VIX_COMPILATION_MODE = "PLATFORM_PROVIDED_LIBVIPS"; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ pkg-config vips ]; @@ -191,7 +191,7 @@ defmodule DepsNix.SpecialTreatmentTest do name = "lazy_html"; appConfigPath = ./config; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ cmake lexbor ]; From 12903faa02a43131b096fec4a2dc260989b75d86 Mon Sep 17 00:00:00 2001 From: "Adam C. Stephens" Date: Mon, 15 Dec 2025 10:20:28 -0500 Subject: [PATCH 2/2] update example extending beamPackages is a cleaner way to enforce a specific elixir version --- fixtures/example/deps.nix | 24 +++++++++++++++--------- fixtures/example/package.nix | 15 ++------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/fixtures/example/deps.nix b/fixtures/example/deps.nix index 1e6261e..26915a0 100644 --- a/fixtures/example/deps.nix +++ b/fixtures/example/deps.nix @@ -1,9 +1,15 @@ { - pkgs, lib, beamPackages, + cmake, + extend, + lexbor, + fetchFromGitHub, overrides ? (x: y: { }), overrideFenixOverlay ? null, + pkg-config, + vips, + writeText, }: let @@ -12,7 +18,7 @@ let workarounds = { portCompiler = _unusedArgs: old: { - buildPlugins = [ pkgs.beamPackages.pc ]; + buildPlugins = [ beamPackages.pc ]; }; rustlerPrecompiled = @@ -22,7 +28,7 @@ let }: old: let - extendedPkgs = pkgs.extend fenixOverlay; + extendedPkgs = extend fenixOverlay; fenixOverlay = if overrideFenixOverlay == null then import "${ @@ -118,7 +124,7 @@ let ''; preBuild = '' - install -Dm644 -t _build/c/third_party/lexbor/$LEXBOR_GIT_SHA/build ${pkgs.lexbor}/lib/liblexbor_static.a + install -Dm644 -t _build/c/third_party/lexbor/$LEXBOR_GIT_SHA/build ${lexbor}/lib/liblexbor_static.a ''; }; }; @@ -210,7 +216,7 @@ let name = "bandit"; appConfigPath = ./config; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "mtrudel"; repo = "bandit"; rev = "4f15f029e7aa17f8e7f98d55b0e94c684dee0971"; @@ -803,7 +809,7 @@ let in drv; - heroicons = pkgs.fetchFromGitHub { + heroicons = fetchFromGitHub { owner = "tailwindlabs"; repo = "heroicons"; rev = "88ab3a0d790e6a47404cba02800a6b25d2afae50"; @@ -918,7 +924,7 @@ let name = "lazy_html"; appConfigPath = ./config; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ cmake lexbor ]; @@ -1489,7 +1495,7 @@ let }; patches = [ - (pkgs.writeText "unicode-accessible-data-dir.patch" '' + (writeText "unicode-accessible-data-dir.patch" '' diff --git a/lib/unicode.ex b/lib/unicode.ex index 8224c3c..3c0bb3a 100644 --- a/lib/unicode.ex @@ -1577,7 +1583,7 @@ let VIX_COMPILATION_MODE = "PLATFORM_PROVIDED_LIBVIPS"; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = [ pkg-config vips ]; diff --git a/fixtures/example/package.nix b/fixtures/example/package.nix index f6b23b7..8ab2e79 100644 --- a/fixtures/example/package.nix +++ b/fixtures/example/package.nix @@ -5,25 +5,14 @@ let src = ./.; - erlang = pkgs.beam.interpreters.erlang_28; - beamUpstream = pkgs.beam.packagesWith erlang; - elixir = beamUpstream.elixir_1_19; - - beamPackages = beamUpstream // rec { - inherit erlang elixir; - hex = beamUpstream.hex.override { inherit elixir; }; - buildMix = beamUpstream.buildMix.override { inherit elixir erlang hex; }; - }; + beamPackages = pkgs.beamMinimal28Packages.extend (_: prev: { elixir = prev.elixir_1_19; }); mixNixDeps = pkgs.callPackages ./deps.nix { beamPackages = beamPackages; }; in beamPackages.buildMix { - inherit - src - elixir - ; + inherit src; name = "example"; version = "0.1.0";