Hi!

El 2026-01-18 17:13, Ashvith Shetty escribió:
Hi,

On Thu, 2026-01-15 at 15:44 +0000, Ashish SHUKLA wrote:
Which library are you trying to package ? In absence of a build
system,

I am trying to package
[evolved.lua](https://github.com/BlackMATov/evolved.lua).

I would find the closest resembling build system to go with, usually it's gnu-build-system (if they've a Makefile or something), or copy-build-system.

This is what my package expression looks like:

```scm
(define-module (packages lua)
  #:use-module (gnu packages lua)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix build-system copy))

(define-public lua-evolved
  (package
    (name "lua-evolved")
    (version "1.7.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/BlackMATov/evolved.lua";)
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
"0bl4709qm2j0lmvvk8pdgr5f0c5mnrmlk9fvgiv1z0hap7fwpm9w"))))
    (build-system copy-build-system)
    (arguments
     (let* ((lua-version (version-major+minor (package-version lua)))
            (share (string-append "share/lua/" lua-version))
            (lua-path (string-append share "/?.lua")))
         (list
          #:install-plan
          #~`(("." #$share #:include-regexp
("evolved\\.[(lua|d\\.ts)]+$")))
          ;; Maybe I am mistaken, but we don't need to
          ;; modify phase?
          #:phases
          #~(modify-phases %standard-phases
               (add-before 'install 'set-env
                  (lambda _
                     (setenv "LUA_PATH" #$lua-path)))))))
    (home-page "https://github.com/BlackMATov/evolved.lua";)
    (synopsis "Evolved ECS for Lua")
    (description "@code{evolved.lua} is a fast and flexible ECS
(Entity-Component-System) library for Lua. It is designed to be
simple and easy to use, while providing all the features needed to
create complex systems with blazing performance.")
    (license license:expat)))
```

What you need here is a search-path[0] definition, and not the `setenv' in post install:

```diff
diff --git a/guix/abbe/packages/lua.scm b/guix/abbe/packages/lua.scm
index 2357942..a2a8bbe 100644
--- a/guix/abbe/packages/lua.scm
+++ b/guix/abbe/packages/lua.scm
@@ -352,15 +352,15 @@
         (list
          #:install-plan
          #~`(("." #$share #:include-regexp
-("evolved\\.[(lua|d\\.ts)]+$")))
-          ;; Maybe I am mistaken, but we don't need to
-          ;; modify phase?
-          #:phases
-          #~(modify-phases %standard-phases
-               (add-before 'install 'set-env
-                  (lambda _
-                     (setenv "LUA_PATH" #$lua-path)))))))
+               ("evolved\\.[(lua|d\\.ts)]+$"))))))
    (home-page "https://github.com/BlackMATov/evolved.lua";)
+    (native-search-paths
+     (list (search-path-specification
+             (variable "LUA_PATH")
+             (file-type 'regular)
+             (file-pattern "\\.lua$")
+             (files (list
+                     (string-append "share/lua/" (version-major+minor 
(package-version lua))))))))
    (synopsis "Evolved ECS for Lua")
    (description "@code{evolved.lua} is a fast and flexible ECS
(Entity-Component-System) library for Lua. It is designed to be
```

With this change:

-------------------------------------------------------------------------------------------------
% guix shell --pure -L guix lua-evolved [email protected]  --search-paths
export PATH="/gnu/store/6nwggy1vd3368hpin7qgl2zs2imi8501-profile/bin"
export LUA_PATH="/gnu/store/6nwggy1vd3368hpin7qgl2zs2imi8501-profile/share/lua/5.3/evolved.lua"

% guix shell --pure -L guix lua-evolved [email protected]  -- lua
Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
@> require "evolved"
table: 0x3d704d20
@>
-------------------------------------------------------------------------------------------------

'-L guix' is my guix packages load path, and '[email protected]' is what 'lua' is currently set to despite having 5.4 in the tree as well.

The way LUA_PATH works is different from how other such environment variables work which makes it hard to set it up, having to explicitly list all files.

Other alternative, if we're not to do this search-path dance, then other alternative would be manually exporting `LUA_PATH' in `guix shell':

-------------------------------------------------------------------------------------------------
% LUA_PATH=$GUIX_ENVIRONMENT/share/lua/5.3/?.lua lua
Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
@> (require "os").getenv "LUA_PATH"
/gnu/store/6nwggy1vd3368hpin7qgl2zs2imi8501-profile/share/lua/5.3/?.lua
@> require "evolved"
table: 0xa9be340
@>
-------------------------------------------------------------------------------------------------


References:
[0] (info "(guix)Search Paths")

HTH
--
Ashish SHUKLA | GPG: F682 CDCC 39DC 0FEA E116  20B6 C746 CFA9 E74F A4B0
             | GPG: 01DE 145E 35D8 C87E 956E  FEC9 D4C4 4BDA 2C98 C654

"If I destroy you, what business is it of yours ?" (Dark Forest, Liu Cixin)

Attachment: signature.asc
Description: PGP signature

Reply via email to