summaryrefslogtreecommitdiffhomepage
path: root/gleam/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'gleam/flake.nix')
-rw-r--r--gleam/flake.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/gleam/flake.nix b/gleam/flake.nix
new file mode 100644
index 0000000..57c92e3
--- /dev/null
+++ b/gleam/flake.nix
@@ -0,0 +1,61 @@
+{
+ description = "ssp-reader: a reader for the .ssp document abstraction, in Gleam";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+ outputs = { self, nixpkgs }:
+ let
+ system = "x86_64-linux"; # adjust for aarch64-linux / darwin
+ pkgs = import nixpkgs { inherit system; };
+
+ name = "ssp_reader";
+
+ /* The builder, nix-gleam's, kept here in nix-gleam/ (see the README
+ there). It fetches each Hex dependency on its own, with the
+ checksum gleam has already written into manifest.toml, so there is
+ no hash in this file to keep up to date, and nothing a run of gleam
+ could make come out differently.
+ */
+ inherit (pkgs.callPackage ./nix-gleam { }) buildGleamApplication;
+ in {
+ packages.${system} = {
+ default = self.packages.${system}.${name};
+
+ /* The reader as an escript: precompiled Erlang in a single file,
+ which needs only erlang to run, no gleam and no dependencies.
+ Verified reproducible: a second export is byte identical.
+ nix-gleam builds an erlang-shipment by default; the build phase
+ is replaced, its configure phase having already put the
+ dependencies in place.
+ */
+ ${name} = buildGleamApplication {
+ pname = name;
+ version = "2.0.0";
+ src = ./.;
+ nativeBuildInputs = [ pkgs.makeWrapper ];
+ buildPhase = ''
+ runHook preBuild
+ export HOME=$TMPDIR
+ gleam export escript
+ runHook postBuild
+ '';
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out/bin
+ install -m755 ${name} $out/bin/${name}
+ wrapProgram $out/bin/${name} \
+ --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.beamPackages.erlang pkgs.coreutils ]}
+ runHook postInstall
+ '';
+ meta = {
+ description = "reads a .ssp document abstraction and says what is in it";
+ mainProgram = name;
+ };
+ };
+ };
+
+ devShells.${system}.default = pkgs.mkShell {
+ packages = [ pkgs.gleam pkgs.beamPackages.erlang pkgs.rebar3 ];
+ };
+ };
+}