Open georgewsinger opened 3 years ago
Haa, damned, indeed, that's a regression introduced by #79 that I merged too quickly.
Thank you for the report. You can try previous commit as a workaround.
Haa, damned, indeed, that's a regression introduced by #79 that I merged too quickly.
Thank you for the report. You can try previous commit as a workaround.
For what it's worth, I believe I'm running into the same issue even with non-NixOS Nix. At the very least trying to build with #79 fails by default, but it could also be some other issue. However, I am able to get around it with --arg enable32bits false
.
I'm also getting a similar error when trying to use it with Home Manager on a non-NixOS system.
You can workaround it with:
nix-build ./default.nix -A nixGLIntel --arg enable32bits false
@guibou Thanks for the advice. I'm new to Nix so I'm not too familiar with everything yet. To be clear, I'm not using nix-build
to build nixGL though, I'm instead using import
in a shell script used by writeShellScriptBin
in my Home Manager configuration. So instead of:
#!/bin/sh
${(import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) {}).auto.nixGLDefault}/bin/nixGL ${program}/bin/${program} "$@"
Should I do something like the following instead?
#!/bin/sh
nix-build -E '${(import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) {})}' -A nixGLIntel --arg enable32bits false
nixGLIntel ${program}/bin/${program} "$@"
I tried the above but it failed to build.
Ha, @nothingnesses, that's an interesting use case.
You see the {}
in import (fetchGit {...}) {HERE}
, this is where you put this kind of options.
So you should use:
#!/bin/sh
nix-build -E '${(import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) {enable32bits = false;})}' -A nixGLIntel
This being said, I don't really understand your program. The nix-build
line will build nixGL
, but not "install" it, so the following nixGLIntel
call won't find the one you just built.
@guibou Thanks. The function is supposed to be used to wrap packages that require OpenGL, but the logic in the function/script was wrong as it wasn't using the proper path/name. I guess the proper way to do it would be to explicitly have the name as an argument, so something like the following instead (using an overlay instead of let...in
):
{ config, pkgs, ... }:
with builtins;
{
home = {
homeDirectory = "/home/a";
packages = with pkgs; [
(nix_gl alacritty "alacritty")
];
stateVersion = "21.11";
username = "a";
};
nixpkgs = {
overlays = [
(self: super: {
nix_gl = program: name: pkgs.writeShellScriptBin name ''
${(import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) { enable32bits = false; }).auto.nixGLDefault}/bin/nixGL ${program}/bin/${name} "$@"
'';
})
];
};
targets.genericLinux.enable = true;
}
That seems to produce the correct script, although running which alacritty
doesn't seem to point to it. I'll try and figure out why that is in the meantime, but anyway, thanks again!
@nothingnesses Works for me in this context:
λ walrus ~ → which alacritty
alacritty not found
λ walrus ~ → nix-shell foo.nix
warning: unknown setting 'experimental-features'
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
building '/nix/store/d44zxq8g1arcscnn5sbgwmgj4qh63486-impure-nvidia-version-file.drv'...
cp: cannot stat '/proc/driver/nvidia/version': No such file or directory
these derivations will be built:
/nix/store/gbidrl2zjn1q03gsxvd1z8r9mgx360ha-nixGLCommon.drv
/nix/store/62j8fr6hmz1mwhb32hkh63wg67piqggv-alacritty.drv
these paths will be fetched (1.71 MiB download, 6.38 MiB unpacked):
/nix/store/5llslggc76v41076p82ni4flsmsmfpq4-alacritty-0.9.0-terminfo
/nix/store/f94gg2wxj9rvgk2p4gm0dg8rrgvii59c-alacritty-0.9.0
copying path '/nix/store/5llslggc76v41076p82ni4flsmsmfpq4-alacritty-0.9.0-terminfo' from 'https://cache.nixos.org'...
warning: unknown setting 'experimental-features'
building '/nix/store/gbidrl2zjn1q03gsxvd1z8r9mgx360ha-nixGLCommon.drv'...
copying path '/nix/store/f94gg2wxj9rvgk2p4gm0dg8rrgvii59c-alacritty-0.9.0' from 'https://cache.nixos.org'...
building '/nix/store/62j8fr6hmz1mwhb32hkh63wg67piqggv-alacritty.drv'...
[nix-shell:~]$ which alacritty
/nix/store/l8ghw77j4jn4nfd7mkhd34s83980sm9i-alacritty/bin/alacritty
[nix-shell:~]$ cat /nix/store/l8ghw77j4jn4nfd7mkhd34s83980sm9i-alacritty/bin/alacritty
#!/nix/store/qfb4j7w2fjjq953nd9xncz5mymj5n0kb-bash-5.1-p8/bin/bash
/nix/store/krr2df6s6qh6vdgd8nlk602y9d4ld18s-nixGLCommon/bin/nixGL /nix/store/f94gg2wxj9rvgk2p4gm0dg8rrgvii59c-alacritty-0.9.0/bin/alacritty "$@"
with:
with import <nixpkgs> { };
let
nix_gl = program: name: pkgs.writeShellScriptBin name ''
${(import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) { enable32bits = false; }).auto.nixGLDefault}/bin/nixGL ${program}/bin/${name} "$@"
'';
in
mkShell {
buildInputs = [(nix_gl alacritty "alacritty")];
}
I highly encourage you to not use advanced nix code inside nix string interpolation.
Also, nixGLDefault
is a bit super hackish. If you know your nixGL driver (intel or nvidia), I encourage you to use the right version directory.
Aside: I'm closing the issue, with #83 it should build correctly without the enable32bits = false
fix.
@guibou The fix from #83 seems to work well. I've taken your advice about string interpolation and nixGLDefault
and have found out that I can just use the pname
attribute instead of explicitly passing in the name. I'm now using something similar to the following instead, which seems to work well:
{ config, pkgs, ... }:
with builtins;
{
home = {
homeDirectory = "/home/a";
packages = with pkgs; [
(nix_gl alacritty)
];
stateVersion = "21.11";
username = "a";
};
nixpkgs = {
overlays = [
(self: super: {
nix_gl_go = (import (fetchGit {
ref = "main";
url = "https://github.com/guibou/nixGL.git";
}) {}).nixGLIntel;
nix_gl = program: pkgs.writeShellScriptBin program.pname ''
${self.nix_gl_go}/bin/nixGLIntel ${program}/bin/${program.pname} "$@"
'';
})
];
};
targets.genericLinux.enable = true;
}
Thanks again!
The compile error is fixed with https://github.com/NixOS/nixpkgs/pull/140484
Attempting to compile in NixOS:
The command used to build:
The
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
is likely the issue, but I added it because without I get:I'm running against
nixos-unstable
with an nvidia card. My intended use case is to help a program usually runned with an nvidia driver run instead with software rendering.