tools for building gleam projects with nix

buildGleamApplication: set default meta attributes

foxgirl.engineering ec4f21e3 c19c094f

verified
+46 -1
+8
CHANGELOG.md
··· 8 8 9 9 the format is based on [keep a changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [semantic versioning](https://semver.org/spec/v2.0.0.html). 10 10 11 + ## unreleased 12 + 13 + ### changed 14 + 15 + - added default meta attributes to `buildGleamApplication` derivations 16 + - `platforms`, `badPlatforms` based on runtime + gleam compiler 17 + - `mainProgram` based on generated script name 18 + 11 19 ## v1.1.0 - 2025-09-29 12 20 13 21 ### added
+38 -1
nix/build-gleam-application.nix
··· 37 37 buildGleamArgs ? { }, 38 38 gleamNixOverrides ? _: _: { }, 39 39 ... 40 - }: 40 + }@attrs: 41 41 42 42 let 43 43 derivationList = attrs: lib.filter (v: lib.isDerivation v) (lib.attrValues attrs); ··· 134 134 135 135 runHook postInstall 136 136 ''; 137 + 138 + meta = 139 + let 140 + runtimePlatforms = 141 + if finalAttrs.target == "erlang" then 142 + (finalAttrs.erlang.meta.platforms or lib.platforms.all) 143 + else 144 + ( 145 + if finalAttrs.jsRuntime != null then 146 + (finalAttrs.jsRuntime.meta.platforms or lib.platforms.all) 147 + else 148 + lib.platforms.all 149 + ); 150 + runtimeBadPlatforms = 151 + if finalAttrs.target == "erlang" then 152 + (finalAttrs.erlang.meta.badPlatforms or [ ]) 153 + else 154 + (if finalAttrs.jsRuntime != null then (finalAttrs.jsRuntime.meta.badPlatforms or [ ]) else [ ]); 155 + in 156 + ( 157 + if finalAttrs.target == "erlang" || finalAttrs.jsRuntime != null then 158 + { mainProgram = finalAttrs.pname; } 159 + else 160 + { } 161 + ) 162 + // (attrs.meta or { }) 163 + // { 164 + platforms = lib.intersectLists runtimePlatforms ( 165 + lib.intersectLists (finalAttrs.gleam.meta.platforms or lib.platforms.all) ( 166 + attrs.meta.platforms or lib.platforms.all 167 + ) 168 + ); 169 + badPlatforms = 170 + runtimeBadPlatforms 171 + ++ (finalAttrs.gleam.meta.badPlatforms or [ ]) 172 + ++ (attrs.meta.badPlatforms or [ ]); 173 + }; 137 174 }; 138 175 }