Commit Graph

251 Commits

Author SHA1 Message Date
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Peder Bergebakken Sundt
8c8c27bb19 treewide: remove unused inputs 2024-09-18 01:00:07 +02:00
Sandro
021e453cc6
Merge pull request #328839 from trofi/lua5_4-update 2024-08-22 11:50:48 +02:00
Martin Weinelt
93f4195fe0
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
- pkgs/applications/graphics/seamly2d/default.nix
2024-07-26 18:05:04 +02:00
Sigmanificient
6dd44107ac treewide: remove unused lib (and other) arguments 2024-07-26 11:18:09 +02:00
Sergei Trofimovich
69ba3f70eb lua5_4: 5.4.6 -> 5.4.7
Changes: https://www.lua.org/work/diffs-lua-5.4.6-lua-5.4.7.html
2024-07-21 07:24:01 +01:00
Matthieu C.
29cc0b4a6b generateLuarocksConfig: dont generate rocks_subdir by default
Goal is to make generateLuarocksConfig appropriate in more scenarios, in my case, to generate rocks.nvim luarocks config

We override the luarocks default for rocks_subdir to avoid conflicts when creating lua environments but it is not appropriate for other scenarios
so let's not default to it in the "lib" function.
2024-07-10 23:08:40 +02:00
github-actions[bot]
4bba3c5730
Merge master into staging-next 2024-07-05 12:01:14 +00:00
Matthieu C.
8a0c6be458 generateLuarocksConfig: dont hardcode local_cache
I tried using luaLib.generateLuarocksConfig outside nixpkgs, to generate a rocks.nvim config but it adds a `local_cache = ""` configuration line that is painful to remove so let's not add it in the first place, and let the caller set it if needed.
2024-07-05 13:32:47 +02:00
Martin Weinelt
de245ec4a5
Merge remote-tracking branch 'origin/master' into staging-next 2024-06-25 13:00:25 +02:00
Matthieu C.
e511f674e1 luarocks: use self.pname for an effective overrideAttrs
luarocks-nix store path was ..luarocks-version instead of ...luarocks-nix-version. This fixes it
2024-06-24 23:06:30 +02:00
Matthieu C.
665f3f694b lua: take into propagated-build-inputs when building LUA_PATH
so far we ignored propagated-build-inputs
2024-06-12 15:31:04 +02:00
Matthieu C.
2ea757a029 luaPackages.luarocks: generate luarocks as well
When installing a lua package that depends on luarocks, luarocks was not
capable of recognizing the luarocks module: https://github.com/NixOS/nixpkgs/issues/316009 .

As explained here https://github.com/luarocks/luarocks/issues/1659,
luarocks needs a manifest to recognize the package.
I first attempted to generate a manifest with `luarocks-admin
make-manifest` on our current manual luarocks derivation but this ended
up being too hackish as the `make-manifest` requires a .rockspec or
.rock to work, which we had not.

It seemed simpled to just rename the current manual luarocks derivation to luarocks_bootstrap
in order to break cyclic dependencies in buildLuarocksPackage and add a
generated luarocks derivation. Previously it was impossible to test
luarocks because of the cyclic dependency but we will now be able to
test the generated derivation.
2024-05-31 19:59:29 +02:00
Sigmanificient
203a48ad35 pkgs/development: remove unused fetchpatch arguments 2024-05-24 02:53:57 +02:00
Matthieu C.
6427d04c23 lua:: reworked setup-hook to source utils.sh
which contains lua shell utilities that can be reused during the
creation of an environment.
Makes sense because the generation of LUA_PATH is a bit different than
other ecosystems.
2024-05-01 00:18:44 +02:00
Matthieu C.
a4d954080f lua: fixed the way to create environments
`paths =  requiredLuaModules (extraLibs ++ [ lua ] );` would discard lua
and so in absence of a propagated lua, the lua.withPackages would return
an empty bin/ directory.
2024-05-01 00:11:49 +02:00
Vladimír Čunát
3bcf0470d8
Revert #303176: "buildLuarocksPackage: rework fixup phase"
This reverts commit ddefcf284c.
Breakages need figuring out, reverting for now:
https://github.com/NixOS/nixpkgs/pull/303176#issuecomment-2053910614
2024-04-15 07:17:32 +02:00
Matthieu Coudron
ddefcf284c buildLuarocksPackage: rework fixup phase
I was working on lua tests, enabling nlua and I started overriding
postFixup, which removed the default phase for build-luarocks-package so
instead let's make it a proper phase.
2024-04-11 00:30:31 +02:00
Matthieu Coudron
c55b4dbcd2 lua: fix setup-hook *.lua matching
the setup-hook checks if a derivation contains lua files matching
lua_path patterns. We use bash's globstar extension for that but
`**.lua` doesn't return files in subfolders, it has to be `**/*.lua`.
Adjust the pattern accordingly.
2024-04-02 11:20:36 +02:00
Matthieu Coudron
b8be016426 lua.tests.checkSetupHook: test lua setup hook for http package
the 'http' package is an interesting one to test because all its lua
files are in a 'http' subfolder, ie., there is no share/lua/5.1/*.lua,
only share/lua/5.1/http/*.lua files unlike most packages. This tests we
can match those subfolders.
2024-04-02 11:20:36 +02:00
Matthieu Coudron
0c9417100f lua: update setup-hook to limit LUA_PATH size
now that the lua interpreters include working directories with `./?.lua`
in LUA_PATH, the current test includes every derivation which quickly
becomes unreadable and unpractical.
The test is adapted to add a folder only if it can find lua files in the
subfolder.
2024-03-16 14:37:10 +01:00
Matthieu Coudron
815d3683f7 lua.tests: update golden values for default LUA_PATH
when LUA_PATH contains `;;`, it is replaced by `;LUA_PATH_DEFAULT;` in
lua 5.1:
Updated 69ea087dff/loadlib.c (L599)
More recent versions might be smarter ?
65b07dd53d/loadlib.c (L301)
2024-03-16 14:37:10 +01:00
Matthieu Coudron
640cdcb814 lua: smarter/more correct patching
In order to have the 'reset' LUA_PATH (aka `;;`) work, and for purity
reasons(removing /usr paths) we(I) decided to patch the lua interpreters default LUA_PATH.
Turns out the interpreters have different defaults and the patch was too
coarse.
There is smarter patching that can be done via LUA_ROOT.

Also luajit doesn't need patching at all since LUA_ROOT is set via the
build system.
2024-03-16 14:37:09 +01:00
binarycat
b309d4fdcc lua: actually fix longstanding bug in lua envHook causing relative module imports to stop working
somehow, between all my testing, all the code review, and my code being copy-pasted into
other people's PRs, noone noticed the glaring issue in the singular line of code i committed.

there was a missing negation.  this has now been fixed.
2024-03-11 10:55:46 -04:00
Matthieu Coudron
50e877ed89 buildLuarocksPackage: accept structured luarocks config
There is an arbitrary mapping being done right now between
nixpkgs lua infrastructre and luarocks config schema.
This is confusing if you use lua so let's make it possible to use the
lua names in the nixpkgs, thanks to the lib.generators.toLua convertor.

The only nixpkgs thing to remember should be to put the config into `luarocksConfig`

`buildLuarocksPackage.extraVariables` should become `buildLuarocksPackage.luarocksConfig.variables`
2024-02-17 15:58:13 +01:00
Matthieu Coudron
000b7bfd47
buildLuarocksPackage: ability to self reference extraConfig (#288253)
makes overrideAttrs for lua packages even more powerful.
As a consequence, it simplifies the implementation of buildNeovimPlugin.
2024-02-12 18:11:24 +01:00
Matthieu Coudron
089f45ce69
buildLuarocksPackage: remove rockspecDir (#288036)
it was used only once and complexifies the buildLuarocksPackage function uselessly.
because buildLuarocksPackage accepts ... args, it wont trigger eval failures but this may break out of tree packages where the build can't find the rockspec anymore. Specify the path via `knownRockspec` if that's the case.
2024-02-11 15:09:01 +01:00
Matthieu Coudron
ff5b2d7d00 lua.tests: add test for relative import
better error message as well
extracted from https://github.com/NixOS/nixpkgs/pull/273342

written by heyarne
2024-02-06 23:21:41 +01:00
Jan Tojnar
80020c7db4 Merge branch 'master' into staging-next
; Conflicts:
;	pkgs/development/lua-modules/generated-packages.nix
;	pkgs/development/lua-modules/overrides.nix
2023-12-31 02:31:32 +01:00
Sergei Trofimovich
09a5f17eec lua-wrapper: fix luaPath and luaCpath definitions
Before the change:

    $ nix-instantiate --eval --strict --expr 'with import ./. {}; with corsix-th.luaEnv; [luaPath luaCpath]'
    error:
       error: attribute 'lib' missing

After the change:

    $ nix-instantiate --eval --strict --expr 'with import ./. {}; with corsix-th.luaEnv; [luaPath luaCpath]'
    [ "/nix/store/f17ah5zjri1yjacc1c50g9xlr8qqwbgh-lua-5.2.4-env/share/lua/5.2/?.lua;/nix/store/f17ah5zjri1yjacc1c50g9xlr8qqwbgh-lua-5.2.4-env/share/lua/5.2/?/init.lua" "/nix/store/f17ah5zjri1yjacc1c50g9xlr8qqwbgh-lua-5.2.4-env/lib/lua/5.2/?.so" ]
2023-12-30 22:37:06 +01:00
github-actions[bot]
93bd5ac278
Merge staging-next into staging 2023-12-15 18:01:36 +00:00
Adam Joseph
80472e3754 treewide: add __attrsFailEvaluation and __recurseIntoDerivationForReleaseJobs 2023-12-15 05:13:46 -08:00
Vladimír Čunát
f5eed8de6a
Merge #224295: lua: split manual into separate output
...into staging
2023-12-13 10:41:30 +01:00
Matthieu Coudron
e03c9c3f1b
buildLuarocksPackage: save luarocks config as derivation (#269402)
* buildLuarocksPackage: save luarocks config as derivation

while debugging luarocks packages, it's exhausting to have to build
them, look at what random folder they've been built to finally look for
their config.


With this you can run
    nix build lua51Packages.plenary-nvim.configFile -f . 

and infer what luarocks will do.

* Update pkgs/development/interpreters/lua-5/build-luarocks-package.nix

Co-authored-by: Marc Jakobi <mrcjkb89@outlook.com>

---------

Co-authored-by: Marc Jakobi <mrcjkb89@outlook.com>
2023-11-24 00:08:45 +01:00
Matthieu Coudron
79245fc3e7
lua: use finalAttrs for interpreters (#264381) 2023-11-23 10:19:14 +01:00
Matthieu Coudron
64b50c6f93 luaPackages: introduce an alias mechanism
so that we can deprecate modules
2023-10-14 22:03:12 +02:00
Adam Joseph
cbc8aa437c treewide: use uncurried version of makeScopeWithSplicing 2023-08-14 02:51:10 +03:00
Silvan Mosberger
a0b8caf3bc
Revert "lib.customisation: uncurry makeScopeWithSplicing" 2023-07-28 23:04:09 +02:00
Artturin
3716ef19d8 lib.makeScopeWithSplicing: provide default for keep,extra
These are often unneeded by the user.
2023-07-28 17:41:01 +03:00
Adam Joseph
cb13669b00 lib.customisation: uncurry makeScopeWithSplicing
Deeply-curried functions are pretty error-prone in untyped languages
like Nix.  This is a particularly bad case because
`top-level/splice.nix` *also* declares a makeScopeWithSplicing, but
it takes *two fewer arguments*.

Let's switch to attrset-passing form, to provide some minimal level
of sanity-checking.
2023-07-27 21:31:59 -07:00
Matthieu Coudron
34b3a809ef buildLuarocksPackage: rename file to match its role 2023-07-10 10:34:34 +02:00
Felix Buehler
6672dde558 treewide: use optionalAttrs instead of 'else {}' 2023-06-25 11:01:34 -03:00
Dmitry Bogatov
496a143d84
Update pkgs/development/interpreters/lua-5/interpreter.nix
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-06-06 11:27:43 +00:00
Weijia Wang
c5f569a09a lua5_4: 5.4.4 -> 5.4.6 2023-05-26 09:19:41 +03:00
Adam Joseph
d128d47318 buildLuaPackage: fix cross
buildLuaPackage accesses lua.pkgs.luarocks, which became unspliced
at some point.  Let's use callPackage to get it, so we can be sure
it will be spliced.
2023-05-09 14:15:07 -07:00
Sandro
cac19e0266
trivial-builders: move into the directory named alike (#223429)
While searching for something different I wondered why there is a
trivial-builders.nix file next to the trivial-builders directory where
only tests live. Lets fix that.
2023-05-06 00:16:26 +02:00
Matthieu Coudron
26dd4a84ed buildLuarocksPackage: fixes attributes being ignored
follow up of https://github.com/NixOS/nixpkgs/pull/224553 where
some arguments got ignored whil they were before taken into account.
2023-04-27 22:22:01 +02:00
Matthieu Coudron
30a70671f4 buildLuaPackage: enable __structuredAttrs rocks
it makes overriding easier, instead of having to know internals to
decide which of `sqlite = prev.luaLib.overrideLuarocks prev.sqlite (drv: {` or
`sqlite = prev.sqlite.overrideAttrs (drv: {` just use the latter
2023-04-22 22:09:35 +02:00
Anderson Torres
ae21df36c5 build-lua-package.nix: change self to finalAttrs 2023-04-20 22:22:23 -03:00
Dmitry Bogatov
c0bc18bf2f lua: split manual into separate output
Also, make sure that "doc" outputs of different versions of lua are
co-installable, so user can install multiple manuals and read them
side-by-side.
2023-04-01 20:31:59 -04:00