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

init: nixgl module #5355

Merged
merged 9 commits into from
Oct 25, 2024
Merged

init: nixgl module #5355

merged 9 commits into from
Oct 25, 2024

Conversation

Smona
Copy link
Contributor

@Smona Smona commented Apr 30, 2024

Description

This PR integrates nixGL into home manager in a way that does not introduce a nixGL dependency, and attempts to make user configuration as simple as possible. This accomplishes the same goal as #5332, namely making it simpler for users to run applications which require libGL on non-nixos systems managed by home manager. There's some elaboration on why I think this is a better API in the original issue.

It makes use of a wrapper which I have been using for some months to run a few GPU-bound applications on Ubuntu. Judging by post reactions it seems that many other users have also found success with this wrapper. By default it is a a no-op, but if a user has configured a nixGL.prefix, then it will symlink all files from the original package into a new one, except for binaries which are replaced by a wrapper script calling them with the configured prefix. Unlike other wrappers proposed in #3968, all derivation attributes from the original package are preserved, so the result of the wrapper can be passed along to program modules for additional overriding. And since the program binary itself is replaced, the program will be launched in the nixGL context regardless of where it is called from (terminal, desktop file, etc).

The wrapper function is made available on lib.nixGL.wrap, so users can wrap applications which require libGL like so:

    home.packages = [ (config.lib.nixGL.wrap pkgs.example) ];

    programs.kitty.package = (config.lib.nixGL.wrap pkgs.kitty);

I'm very open to changing option/wrapper paths if it would help get this merged. Just having the wrapper and the option would be enough for users to wrap packages with nixGL ergonomically.

Wrapping packages by default

The default no-op behavior and derivation attribute preservation of this wrapper means that HM modules for applications could wrap their default package with nixGL. This would have the benefit of tracking which applications need nixGL to function properly on non-nixos systems, and saving end users time by making nixGL.prefix the only option they need to set to get these applications working. If a user wanted to undo the default wrapping for certain applications, they could simply override programs.<application>.package to a non-wrapped package. This PR originally included examples for kitty and firefox, which both benefit from nixGL on non-nixos systems. However, @exzombie brought up some valid concerns about doing this, particularly detecting and preventing double-wrapping, so in the interest of getting the wrapper itself merged this default wrapping has been removed, to be left for future improvement.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

    TODO

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@kira-bruneau @rycee

Alternative to #5332
Closes #3968

@jonahbron
Copy link

This is great! Would it work for passing into programs.${program}.package as well?

@Smona
Copy link
Contributor Author

Smona commented May 1, 2024

@jonahbron yes! the wrapped package can be used interchangeably with the original one, so you can pass it to any option that's expecting a package.

@neiios
Copy link
Contributor

neiios commented May 4, 2024

Just tried out the PR, and it seems to not work with packages like easyeffects that use a separate debug output. At the same time, the module works well with other programs like mpv.

# this one doesnt work for me
services.easyeffects = {
  enable = true;
  package = (config.lib.nixGL.wrap pkgs.easyeffects);
};

When using the snippet above I get this error trace:

error: builder for '/nix/store/2gkv48bzdgrvkd6vnscjbgc8y175hmnv-nixGL-easyeffects-7.1.6.drv' failed to produce output path for output 'debug' at '/nix/store/2gkv48bzdgrvkd6vnscjbgc8y175hmnv-nixGL-easyeffects-7.1.6.drv.chroot/nix/store/aw3ajpz9s05n44kmzjgc2844y5qw15sb-nixGL-easyeffects-7.1.6-debug'
error: 1 dependencies of derivation '/nix/store/q1y0c3d2lpb5djkxr38m7823abyjkpzz-easyeffects.service.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mn47qf0y738dmap03p38b5pspalckcnw-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3fld8n8hwynfhq4pbchhbrf6vr6rwlqj-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/b5mqsb81l7y7vrs2y4nlr21jx9w0q6hk-nixGL-easyeffects-7.1.6-fish-completions.drv' failed to build
error: 1 dependencies of derivation '/nix/store/317843r43f295ad9sylz9mlysyrs8caw-home-manager-generation.drv' failed to build

@Smona can this issue be reproduced on your end?

@Smona
Copy link
Contributor Author

Smona commented May 4, 2024

@neiios thank you for testing it! That's an interesting test case since I can't imagine easyeffects benefiting from nixGL. But I could see this potentially affecting other packages with debug outputs.

I'm able to reproduce your issue with the same configuration, but interestingly that configuration builds just fine for me if I use the same wrapper as config.lib.nixGL.wrap imported from a local file. Going to have to look a bit deeper.

@michaelCTS michaelCTS mentioned this pull request May 6, 2024
6 tasks
@karmakarmeghdip
Copy link

Any updates on this? Will this be merged?

@Smona
Copy link
Contributor Author

Smona commented May 6, 2024

@neiios can you try again with 680108f? Overriding separateDebugInfo to false fixed your test case for me!

@neiios
Copy link
Contributor

neiios commented May 6, 2024

@neiios can you try again with 680108f? Overriding separateDebugInfo to false fixed your test case for me!

On the latest commit, easyeffects works for me as well!

@jonahbron
Copy link

jonahbron commented May 8, 2024

I tried the wrapper with Prusa Slicer today but it did not make a difference, the 3D viewer didn't work either way (it does when I download and install the binary from the website). Happy to help debug of there's any info I can provide. Here's the output:

$ prusa-slicer
Gtk-Message: 09:12:14.981: Failed to load module "canberra-gtk-module"
Gtk-Message: 09:12:14.983: Failed to load module "canberra-gtk-module"

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.117: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.118: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.120: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.121: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.123: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.123: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): GLib-WARNING **: 09:12:15.166: getpwuid_r(): failed due to unknown user id (750198)

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.309: gtk_widget_set_size_request: assertion 'width >= -1' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.309: gtk_widget_set_size_request: assertion 'width >= -1' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.318: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.318: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.319: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.319: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.320: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.320: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.320: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed

(prusa-slicer:58991): Gtk-CRITICAL **: 09:12:15.321: gtk_cell_layout_get_cells: assertion 'GTK_IS_CELL_LAYOUT (cell_layout)' failed
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it
09:12:17: Debug: window wxTreeCtrl@0x75bedb0 ("treeCtrl") lost focus even though it didn't have it

@Smona
Copy link
Contributor Author

Smona commented May 8, 2024

@jonahbron I don't see any libGL/GLX related errors in those logs, so my guess would be that those packaging issues are unrelated to this change? Especially given that Gtk-CRITICAL errors are considered known and ignored by the project. I would expect that if nixGL weren't working properly here, you would see glXChooseFBConfig failures instead.

@exzombie
Copy link
Contributor

I finally found some time to look at this. I like the approach, it is elegant. It falls a bit short, though. I'll work on extending if, hopefully later today. But I wanted to write this comment immediately just in case something comes up (as it often does) preventing me from working on this for another week.

The current implementation of wrapping falls short on packages that contain .desktop files which refer to the full path to the executable. For these packages, the binary is wrapped, but the .desktop file refers to the unwrapped binary. I have a solution to that, and plan to refactor it for inclusion into the module.

Using a single wrapper prefix can only provide OpenGL from a single vendor. This is insufficient because you surely also want Vulkan, and you may want some flexibility as to which vendor you use, e.g. for Prime offloading. This stuff gets hairy pretty fast. My own wrappers are more complete, and also quite straightforward to use, but the implementation is quite hairy. I'll try to refactor them and propose them for inclusion in this PR. My goal is to allow the user to fully use an Optimus laptop without having to know the internals of nixGL. And to keep things simple for people who don't have an Optimus laptop.

And last, I'm not convinced wrapping some packages by default the way it's done now is a good idea. If we wrap every package that needs this, it would be great, but it's not feasible. If we wrap just a couple of common packages, I imagine users would be stumped as to why some packages don't work while others do. If, instead, we wrap nothing by default, and clearly document (e.g. in the User Manual) that anything needing graphics acceleration needs to be wrapped and how to do it, it would empower users.

But, in the end, I don't have strong feelings about this. If someone wants to invest effort into wrapping lots of stuff by default, I wouldn't mind too much. Just note that the wrapper would need to be extended so as to detect and avoid double wrapping: I think it's a given that the project of default wrapping would take some time, and in the meantime, users would wrap stuff themselves. This would cause issues later when HM starts wrapping a package that wasn't wrapped before.

Which begs the question: has anyone tried simply wrapping all the packages in their home configuration? Perhaps it doesn't cause any problems, and we could go with that?

@Smona
Copy link
Contributor Author

Smona commented May 23, 2024

@exzombie thank you for the careful review! You brought up some very good points regarding wrapping packages by default, particularly the double-wrapping concern, so I've removed those changes from this PR for now.

I'll review the rest of your proposed changes ASAP, since you've brought up a use case I didn't really consider. It looks like you primarily want to support customizing the opengl vendor on a per-package basis, but I also want to make sure config modules that use this wrapper can be easily re-used across systems with different graphics device setups for people like me who are reusing the same HM modules across multiple systems in a flake. We may want to just leave that up to user-defined settings which get passed into the wrapper along with the package, which I think your change would support. but I want to make sure I understand both use cases and how they interact first.

Copy link

@giggio giggio left a comment

Choose a reason for hiding this comment

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

See how I tested it: #3968 (comment)

modules/misc/nixgl.nix Outdated Show resolved Hide resolved
@AkechiShiro
Copy link

AkechiShiro commented Jun 18, 2024

Hello @Smona, thanks a lot for starting this effort.

Any way forward with this PR, could you please apply @XYenon's recommandation ?

If you are too busy to work on it, let me know, I'll see if I can help

@Smona
Copy link
Contributor Author

Smona commented Jun 19, 2024

I've applied part of @exzombie's suggestion, to rewrite .desktop files with absolute paths to the original derivation to point to the version wrapped with nixGL instead. Some of the other changes (the prime/offloading support) still have issues to work out, so we may want to hold off on those to get a basic version out sooner which supports the majority of use cases.

I've also switched to makeWrapper as suggested by @XYenon, with a small modification to correct the wrapper output path. The resulting script is mostly the same, but this has the benefit of consistency with the rest of HM/nixpkgs, and ensuring that the value of nixGL.prefix is a valid executable at build time.

Is there anything else needed to get this ready to merge?

modules/misc/nixgl.nix Outdated Show resolved Hide resolved
modules/misc/nixgl.nix Outdated Show resolved Hide resolved
modules/misc/nixgl.nix Outdated Show resolved Hide resolved
@exzombie
Copy link
Contributor

exzombie commented Jul 1, 2024

I've applied part of @exzombie's suggestion, to rewrite .desktop files with absolute paths to the original derivation to point to the version wrapped with nixGL instead. Some of the other changes (the prime/offloading support) still have issues to work out, so we may want to hold off on those to get a basic version out sooner which supports the majority of use cases.

I'm not familiar with how this kind of thing is handled in HM; is it acceptable to merge an "early preview", when it is known that the user-facing options will have to change in an incompatible manner in the future?

BTW, which issues have you found? I'm aware of the emacs problem you've had but that I couldn't reproduce to investigate. Was there something else?

Copy link
Contributor

@vigress8 vigress8 left a comment

Choose a reason for hiding this comment

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

Have been using this, works great

@timoleistner
Copy link

Works great, except that when I have hyprlands wayland.windowManager.hyprland.enable flag set to true while trying to (config.lib.nixGL.wrap pkgs.hyprland) in my home.packages, I have a package collision. If I dont use this flag I dont have the hyprland.nix config. Mentioned here for kitty.

@Smona
Copy link
Contributor Author

Smona commented Jul 17, 2024

@timoleistner you should just need to pass the wrapped hyprland to wayland.windowManager.hyprland.package, instead of including it in home.packages. that should be done in general for any programs which are configured via dedicated home-manager modules.

@timoleistner
Copy link

I see. This works. Amazing, thank you for this, I hope it gets merged soon.

@AkechiShiro
Copy link

What is currently blocking this PR at the moment, I don't think there are any pending changes requested ?

Are we waiting on feedback from more people to try the PR before it gets merged ?

@vigress8 @jonahbron @giggio @XYenon

@Smona
Copy link
Contributor Author

Smona commented Sep 25, 2024

My motivations for merging this as-is were 1) not wanting to delay merging of the basic functionality, and 2) a desire to be able to thoroughly test the contents of my PRs. At this point, it seems like keeping this PR simpler is not speeding up a merge, and may actually be blocking it. In the interest of uniting our efforts, I will gladly merge @exzombie's PR here once:

  • merge conflicts are resolved
  • The comment I just left is addressed.
  • I've been able to confirm that the functionality I need works (the parts covered by this change in its current state). I can commit to testing that within a week of the above two.

Even if there are problems with the multi-GPU side of that PR that I can't catch (I don't think there will be), multi-GPU support is the right goal to work towards, and any issues that might arise should be easily fixable post-merge, without changing the interface.

EDIT: I just want to say I appreciate @exzombie for working against this PR, so that the discussion isn't fractured and my commits can remain in the history :)

@exzombie
Copy link
Contributor

EDIT: I just want to say I appreciate @exzombie for working against this PR, so that the discussion isn't fractured and my commits can remain in the history :)

Oh, you're welcome. Truth be told, I would have kept your commits even if I were to open a new PR; it's important to give credit where credit's due. I wish there was a straightforward way to credit all those who have posted partial solutions to the various issues, there was a lot to learn from about this problem.

Anyway, I'll take a look at your comment in the coming days, then rebase. I never had a non-flake HM setup, so I'll need to think about this.

@Smona
Copy link
Contributor Author

Smona commented Oct 20, 2024

Okay, I've merged @exzombie's work into this PR! I think we're all aligned on the options interface now, and this change now includes support for dual-graphics systems.

Anyone who's following this PR and wants to help get it merged, please test the integration again with the latest commits and leave your feedback here. Most of you will only need to set nixGL.packages (and possibly nixGL.defaultWrapper if you use nvidia and/or prime). It would be especially helpful for those with dual-graphics systems to test the offload wrappers and prime support.

Thanks again @exzombie for making this integration work for more people!

@bevicted
Copy link

bevicted commented Oct 21, 2024

EDIT:

My original question was basically: where do I set nixGL.prefix, because it doesn't seem to work for me but I see it everywhere else.

Solution:
Nowhere, after reading the added doc in the PR I assume the behavior was changed, what I needed to do with home manager is:

(only including relevant parts)

# flake.nix
# include nixgl as an input and output
{
  inputs = {
    nixgl = {
      url = "github:nix-community/nixGL";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = {nixpkgs, nixgl, etc...};
    let
      # I passed it down as an overlay as well, hence pkgs.nixgl in home.nix
      # I have no idea why the passed down `nixgl` doesn't have the wrapper packages
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
          nixgl.overlay
        ];
      };
    in {

}
# home.nix
{ config, pkgs, nixgl, ... }:

{
  imports = [
    # TODO: remove when https://github.com/nix-community/home-manager/pull/5355 gets merged:
    (builtins.fetchurl {
      url = "https://raw.githubusercontent.com/Smona/home-manager/nixgl-compat/modules/misc/nixgl.nix";
      sha256 = "1krclaga358k3swz2n5wbni1b2r7mcxdzr6d7im6b66w3sbpvnb3";
    })
  ];

  nixGL = {
    packages = nixgl.packages; # you must set this or everything will be a noop
    defaultWrapper = "mesa"; # choose from options
  };

  home.packages = [
    pkgs.nixgl.nixGLIntel # change this to what you need, find options in nixgl repo, use `home-manager switch --impure` when using nvidia or build will fail
    (config.lib.nixGL.wrap pkgs.alacritty)
  ];
}

I've spent a day on getting Alacritty installed by home-manager running, I am a broken man, I just hope this comment helps someone.

@Smona you're doing the lord's work

@jackmac92
Copy link
Contributor

jackmac92 commented Oct 22, 2024

awesome work @Smona @exzombie ! I also got alacritty working for the first time following @bevicted's steps

misc questions:

  • Any common errors to look out for when using vulkan?
  • web browser/firefox setup? I wrapped firefox but still got Blocklisted; failure code FEATURE_FAILURE_GLXTEST_FAILED
  • darwin support? I tried running on darwin but got a valgrind related build error

@exzombie
Copy link
Contributor

@jackmac92

  • Any common errors to look out for when using vulkan?

If your distro is "recent", in the sense that its executables use libraries sufficiently similar to those in the version of nixpkgs you are using, you would probably be fine. On my Ubuntu 22.04 system, I never noticed any issues until I updated to nixpkgs 24.05.

The issues arise when the wrapped program runs an executable provided by the distro, which I expect alacritty to do quite a lot. In that case, the library overrides needed for Vulkan can introduce symbol conflicts when libraries provided by nixpkgs are newer and have a different ABI than those in the distro. Something like the error shown below. For alacritty, a possible workaround would might be to unset LD_LIBRARY_PATH in your shell. But there are other programs spawning executables, and in that case, the problem is harder to solve.

/nix/store/ynz405a4ngxijdmdz1qjmfb0ffgigx98-emacs-pgtk-29.1/bin/emacs: /nix/store/xpxln7rqi3pq4m0xpnawhxb2gs0mn1s0-gcc-12.3.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.31' not found (required by /nix/store/7byfnpsk04l3q8rvvwc06acwjbkiy0j2-webkitgtk-2.42.4+abi=4.0/lib/libjavascriptcoregtk-4.0.so.18)

@Smona
Copy link
Contributor Author

Smona commented Oct 22, 2024

@jackmac92 AFAIK nixGL is not required on darwin. I'm able to run kitty for example on darwin with no nixGL.packages set.

As far as firefox, what does your configuration look like? I tested it (without vulkan), and for me it was reporting hardware-accelerated WebRender. That computer runs Ubuntu 24, so I have to keep a flake input with a relatively old version of nixpkgs pinned for that installation (compatible with their gnome version). That might be helping with library conflicts.

@jackmac92
Copy link
Contributor

@Smona Ahh ok good to know re: darwin, I just had some config shared between linux/darwin for mpv and was testing that build. But can separate those concerns in my config

I'm using the home-manager setup for firefox, and tested pkgs.firefox-bin w/ and w/o vulkan enabled, and pkgs.firefox w/o vulkan enabled.

But, I've been updating my flake often recently. Maybe it's my pinned version of nixpkgs that is the issue? Mind sharing the nixpkgs pin you're using later?

Not sure if it is relevant, but below are my nixpkgs inputs, that I updated yesterday

    nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/master";

Smona and others added 9 commits October 25, 2024 10:20
This module enables wrapping programs which require access to libGL
with nixGL on non-NixOS systems.
Some desktop files will refer to the absolute path of the original
derivation, which would bypass nixGL wrapping. So we need to replace the
path with the path to the wrapper derivation to ensure the wrapped
version is always launched.
makeWrapper is more consistent with the rest of nixpkgs & home-manager,
so it should be a little more maintainable. It can also validate that
the wrapper command is executable at build time.
@rycee rycee merged commit 5feb9db into nix-community:master Oct 25, 2024
3 checks passed
@rycee
Copy link
Member

rycee commented Oct 25, 2024

Thanks, great stuff! Merged to master now 🙂

@ambroisie
Copy link
Contributor

@Smona I get an errors on my (flakes-based) setup when trying to use the module:

error: attribute 'system' missing
at /nix/store/bnwq0xfkxzfqzd2679a3j8pihpis4rks-source/modules/misc/nixgl.nix:147:27:
  146|       # First, let's see if we have a flake.
  147|       if builtins.hasAttr pkgs.system cfg.packages then
     |                           ^
  148|         cfg.packages.${pkgs.system}.${packageAttr}
Did you mean one of mystem, systemc, systemd, syntex or systemfd?

I'm not sure why though, I do have pkgs = import inputs.nixpkgs { inherit system; /* ... */ } in my home-manager.lib.homeManagerConfiguration call.

@exzombie
Copy link
Contributor

exzombie commented Nov 2, 2024

I'm not sure why though, I do have pkgs = import inputs.nixpkgs { inherit system; /* ... */ } in my home-manager.lib.homeManagerConfiguration call.

It looks to me like that's the problem. In a flake, you don't import nixpkgs, you get it as an argument to the outputs. Take a look at the HM flake template.

@ambroisie
Copy link
Contributor

Unfortunately, this messes with my ability to overlay a custom lib to be used in my configuration (see #3969 IIRC).

In general, I don't think we should be relying on how the pkgs attribute was created, whether by importing it with a configuration, or through inheriting legacyPackages (IMO the trouble with multiple evaluations of nixpkgs is overstated for end-user configurations anyway...). Hyrum's law would probably come back to bite later.

@exzombie
Copy link
Contributor

exzombie commented Nov 4, 2024

In general, I don't think we should be relying on how the pkgs attribute was created,

I won't argue with that. Let me just point out that in the case of NixGL, there is a difference in package structure when you import NixGL, vs. when you get it as a flake input. So, you don't necessarily end up with the same thing. Don't ask me why they've done it that way.

That said, I don't think this should be a problem with nixpkgs. I mean, when I run pkgs = import <nixpkgs> {} in REPL, the expression pkgs.system evaluates successfully. I've no idea why yours doesn't have that attribute.

@ambroisie
Copy link
Contributor

Yeah I also tried it in the REPL and didn't reproduce the lack of system, not sure what's going on there exactly...

@ambroisie
Copy link
Contributor

I've just added a tracing log to my configuration, pkgs.system is set when I call homeManagerConfiguration { pkgs = import nixpkgs { ... }; }... Not sure what sheds it exactly, could be home-manager itself is doing something here.

@Smona
Copy link
Contributor Author

Smona commented Nov 14, 2024

@ambroisie can you open a separate issue for that? I think replying on this thread pings quite a few people.

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.

feature request: nixGL integration