Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/nixos #1250

Merged
merged 8 commits into from
May 6, 2024
Merged

Fix/nixos #1250

merged 8 commits into from
May 6, 2024

Conversation

misumisumi
Copy link
Collaborator

@misumisumi misumisumi commented Apr 29, 2024

I found two problems with the previous PR.
One is with errors in the current release version of NixOS (23.11), another is with luarocks not being set in the path.
I will therefore fix these issues.
For verification purposes, we have also created a minimal devshell environment that runs the settings of this repository.
This will make it possible to verify using a nix environment, even if NixOS or HomeManager are not in place.
Since NVIM_APPNAME is used, there is no impact on the existing environment.
If there is a slight problem, you may need to put in the effort to keep flake.lock up to date.
This can be automated with github actions, just like updating lazy-lock.json.
Also, since it doesn't relate to the module part, you may want to update it only when necessary.
I would like to add github actions if necessary.

@CharlesChiuGit
If possible, could you please confirm if this devshell works in an arm Mac environment?
It will start with nix develop.

add formatter setting for .nix file
nixos/neovim/default.nix Outdated Show resolved Hide resolved
nixos/neovim/default.nix Outdated Show resolved Hide resolved
@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Apr 30, 2024

If possible, could you please confirm if this devshell works in an arm Mac environment?

i think it does?
image

but when i'm using your fork:

$ nix develop
trace: true
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'devshell'
         whose name attribute is located at /nix/store/rzkl4xygy3z1glq8cgrv5cc075ylxs0g-source/nix/mkNakedShell.nix:30:11

       … while evaluating attribute 'args' of derivation 'devshell'
         at /nix/store/rzkl4xygy3z1glq8cgrv5cc075ylxs0g-source/nix/mkNakedShell.nix:38:3:
           37|   # Bring in the dependencies on `nix-build`
           38|   args = [ "-ec" "${coreutils}/bin/ln -s ${profile} $out; exit 0" ];
             |   ^
           39|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Package ‘acl-2.3.2’ in /nix/store/qxrwp9qzj2by5vqy4gm6f29njjkw4cna-source/pkgs/development/libraries/acl/default.nix:28 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

error: Package ‘acl-2.3.2’ in /nix/store/qxrwp9qzj2by5vqy4gm6f29njjkw4cna-source/pkgs/development/libraries/acl/default.nix:28 is not available on the requested hostPlatform:

maybe add this package?

i tried use nix develop --impure, but the error remain the same w/ lacking acl-2.3.2.

@CharlesChiuGit
Copy link
Collaborator

This can be automated with github actions, just like updating lazy-lock.json.
Also, since it doesn't relate to the module part, you may want to update it only when necessary.
I would like to add github actions if necessary.

agree, it would be nice.

@misumisumi
Copy link
Collaborator Author

I tried excluding unsupported packages, will this work?

@misumisumi
Copy link
Collaborator Author

This can be automated with github actions, just like updating lazy-lock.json.
Also, since it doesn't relate to the module part, you may want to update it only when necessary.
I would like to add github actions if necessary.

I had raised an ambiguous problem.,
Is this a positive statement, whether it is better to add a workflow or not?

@CharlesChiuGit
Copy link
Collaborator

Is this a positive statement, whether it is better to add a workflow or not?

ys, add a github action would be nice.

nixos/neovim/default.nix Outdated Show resolved Hide resolved
fixed an issue where conditional branching based on version was not appropriate.
fixed extraHaskellPackages document
filtered packages of buildEnv by unsupport system
move luarocks to extraPackages from extraLuaPackages
add tree-sitter cli
flake.nix Outdated Show resolved Hide resolved
add environment to evaluate nvimdots in a nix environment.
@misumisumi
Copy link
Collaborator Author

I try not to place lazy-lock.json under $XDG_CONFIG_HOME/nvimdots, but should I place it there?
I have been avoiding the lock file because it seems to be updated on the first startup.

@misumisumi
Copy link
Collaborator Author

Before adding the github actions, I'll check them for a bit.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Apr 30, 2024

copilot.lua and nvim-nio keeps failing to checkout no matter what i do, but it works fine outside nix devshell.
image
i tried remove those two plugins in ~/.local/share/nvimdots/site/lazy and let lazy reinstall it, but it just keeps failing. I cant tell what could cause the issue.

@CharlesChiuGit
Copy link
Collaborator

I have been avoiding the lock file because it seems to be updated on the first startup.

interesing, this issue doesn't seem to happen on my end.

I try not to place lazy-lock.json under $XDG_CONFIG_HOME/nvimdots, but should I place it there?

i'm fine placing the lock file in or out, as long as it got managed by the user or via our nvim config. Personally i like to place the lock file in $XDG_CONFIG_HOME/nvimdots, so it's faster for me to debug if needed.

@Jint-lzxy
Copy link
Collaborator

i tried remove those two plugins in ~/.local/share/nvimdots/site/lazy and let lazy reinstall it, but it just keeps failing. I cant tell what could cause the issue.

@CharlesChiuGit Would verbose logging provide additional insights?

cd ~/.local/share/nvimdots/site/lazy/copilot.lua/
git status && GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=1 GIT_TRACE_SETUP=1 GIT_TRACE_SHALLOW=1 git restore --source=HEAD :/

I once came across this and eventually realized it was a permission issue. Specifically, the default umask got accidentally changed, leaving that git folder wide open for everyone.


By the way can u please help me do a sanity check to ensure that the executables are correctly linked on macOS? I'm just diving into Nix so I might not be much help here. Basically, all u need to do is run otool -L on some of the MachO binaries produced by Nix or Mason and confirm whether they're indeed using packages (libraries) provided by Nix rather than those by the system (this ensures that dyld is doing the right thing and that packages can be located correctly with our config).

@misumisumi
Copy link
Collaborator Author

misumisumi commented Apr 30, 2024

By the way can u please help me do a sanity check to ensure that the executables are correctly linked on macOS? I'm just diving into Nix so I might not be much help here. Basically, all u need to do is run otool -L on some of the MachO binaries produced by Nix or Mason and confirm whether they're indeed using packages (libraries) provided by Nix rather than those by the system (this ensures that dyld is doing the right thing and that packages can be located correctly with our config).

Maybe I can incorporate a simple test script into flake.nix.
However, I have never written a proper test script, so I need to check the home-manager test scripts, etc.
I'm busy tomorrow, so I'll work on it again after Thursday.

P.S
It seems better to use ldd or patchelf, which are also available on Linux, instead of otool.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

copilot.lua and nvim-nio keeps failing to checkout no matter what i do, but it works fine outside nix devshell.

@Jint-lzxy
omg, it suddenly works w/o any modification. it's so weird lol
image

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

can u please help me do a sanity check to ensure that the executables are correctly linked on macOS?

sure, let me check. hope i will know how to use those tools soon lol

@misumisumi
Copy link
Collaborator Author

misumisumi commented May 2, 2024

Fixed three things:

  1. Put lazy-lock.json under $XDG_CONFIG_HOME/$NVIM_APPNAME.
  2. Rename test.nix to testEnv.nix.
  3. Adding check-linker script.
    This is simply script to check whether binary installed by mason link to /nix/store.
    Print cmd name and target lib if not link.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

seems working exactly like we wanted!
image

but i think we can add "echo done" at the end of the loop

@misumisumi misumisumi force-pushed the fix/nixos branch 2 times, most recently from 7a3649a to 85133d7 Compare May 2, 2024 06:26
@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

image

i think this pr lgtm, is there anything still need further modification?

@misumisumi
Copy link
Collaborator Author

misumisumi commented May 2, 2024

I have probrem, loop never ends on linux.
Please wait a moment while I fix it.

add script to check whether binary of installed by mason link to `/nix/store`
rename test.nix to testEnv.nix
put `lazy-lock.json` under `$XDG_CONFIG_HOME/$NVIM_APPNAME`
@misumisumi misumisumi force-pushed the fix/nixos branch 4 times, most recently from cd8f895 to e929c3f Compare May 2, 2024 08:29
@CharlesChiuGit
Copy link
Collaborator

seems like we need to use multiple version of glibc on aarch64-linux?
image

@misumisumi
Copy link
Collaborator Author

misumisumi commented May 2, 2024

Can you check node path with readlink -f $(which node)?
Maybe use system wide node.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

image
oh damn, it is using the system node i set.

so devshell or home-manager will inherit OS environment?
is there anyway to exclude OS environment?

@misumisumi
Copy link
Collaborator Author

so devshell or home-manager will inherit OS environment?

I don't know if home-manager completely replaces PATH etc.
devshell can decide for itself whether to replace it or not (like a shell script).
Here, withNodeJs (in programs.neovim.withNodeJs) is set to append to $PATH, so it inherits the current system settings.
You can replace paths in the same way as in the shell environment.
Currently, this is not possible on the home-manager side.
This is to respect the paths in the development environment.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 2, 2024

i disable system node temporarily and enter devshell, now all node/npm related installation works properly.

@misumisumi
Copy link
Collaborator Author

misumisumi commented May 2, 2024

Finally, regarding the github actions that update flake.lock, should I update flake.lock when updating lazy-lock.json, or should I update flake.lock separately?
Also, is it better to open a PR before updating, like with dependabot?

@CharlesChiuGit
Copy link
Collaborator

I prefer update flake.lock separately, since I think update it once a month is enough.

And I prefer to update flake.lock directly w/o opening a PR.

add workflow of auto update flake.lock
@misumisumi
Copy link
Collaborator Author

I add workflow of auto flake update.
This is called at 2:30 (UTC) of 1st of every month

@misumisumi
Copy link
Collaborator Author

I think all the work is completed, what do you think?

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented May 3, 2024

Is this error been fixed?

error: Package ‘glibc-nolibgcc-2.39-5’ in /nix/store/qxrwp9qzj2by5vqy4gm6f29njjkw4cna-source/pkgs/development/libraries/glibc/default.nix:184 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"

i cant test it right now since i don't have my mac around at the weekend.

Copy link
Collaborator

@CharlesChiuGit CharlesChiuGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image
looks fine on both aarch64-darwin and aarch64-linux

@CharlesChiuGit CharlesChiuGit merged commit 121b180 into ayamir:main May 6, 2024
2 checks passed
@Jint-lzxy
Copy link
Collaborator

can u please help me do a sanity check to ensure that the executables are correctly linked on macOS?

sure, let me check. hope i will know how to use those tools soon lol

@CharlesChiuGit Apple does indeed have a thorough documentation on dynamic library usage tucked away in its documentation archives (way better than what it offers nowadays lol). It's definitely worth a look if u're into this stuff XD

@misumisumi
Copy link
Collaborator Author

@CharlesChiuGit @CharlesChiuGit
The wiki needs to be updated.
We'll be working on that soon.
We'll report back here when it's done.

@misumisumi misumisumi mentioned this pull request May 7, 2024
@CharlesChiuGit CharlesChiuGit mentioned this pull request Jun 26, 2024
3 tasks
@misumisumi misumisumi deleted the fix/nixos branch July 2, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants