diff --git a/.gitignore b/.gitignore index 49cac37..07cd09e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -# Devenv +# Devenv/Nix .devenv* devenv.local.nix devenv.local.yaml +/result # direnv .direnv diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d1c051e --- /dev/null +++ b/default.nix @@ -0,0 +1,38 @@ +{ pkgs ? import {} }: + +pkgs.stdenv.mkDerivation { + pname = "gulie"; + version = "0.1.0"; + + src = ./.; + + nativeBuildInputs = [ pkgs.makeWrapper ]; + buildInputs = [ pkgs.guile ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + # Install Guile source modules + install -d $out/share/guile/site/3.0 + cp -r gulie $out/share/guile/site/3.0/ + + # Install binary, patching the shebang to use the Nix store guile + install -D -m 755 bin/gulie $out/bin/gulie + substituteInPlace $out/bin/gulie \ + --replace-fail '#!/usr/bin/env -S guile' '#!${pkgs.guile}/bin/guile' + + # Wrap so GUILE_LOAD_PATH is set at runtime — modules live under site/3.0 + wrapProgram $out/bin/gulie \ + --set GUILE_LOAD_PATH "$out/share/guile/site/3.0" + + runHook postInstall + ''; + + meta = with pkgs.lib; { + description = "Linter and formatter for Guile Scheme"; + mainProgram = "gulie"; + platforms = platforms.unix; + }; +}