Compare commits

..

No commits in common. "b3b0098eb5c012dbe82e7de5dff253f419b2db7e" and "212e521c7300abf21409d91a51b27f16c2a1eef0" have entirely different histories.

4 changed files with 27 additions and 65 deletions

View file

@ -1,8 +1,6 @@
{ pkgs, config, lib, inputs, ... }: { ... }:
let {
nixGL = import ./../../home-manager/utils/nixGLWrap.nix { inherit pkgs config; };
in {
imports = [ ./../../home-manager/modules/machine.nix ]; imports = [ ./../../home-manager/modules/machine.nix ];
machine = { machine = {
@ -16,11 +14,4 @@ in {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nixGLPrefix = lib.getExe pkgs.nixgl.nixGLIntel;
home.packages = with pkgs; [
(nixGL insomnia)
(nixGL inputs.muse-sounds-manager.packages.x86_64-linux.muse-sounds-manager)
];
} }

View file

@ -93,11 +93,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1713732794, "lastModified": 1713453913,
"narHash": "sha256-AYCofb8Zu4Mbc1lHDtju/uxeARawRijmOueAqEMEfMU=", "narHash": "sha256-vbXq52VRlL1defMHrwhsoeHm95O3mFefsSSJyNEghbA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "670d9ecc3e46a6e3265c203c2d136031a3d3548e", "rev": "178e26895b3aef028a00a32fb7e7ed0fc660645c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -215,11 +215,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1713543440, "lastModified": 1710868679,
"narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", "narHash": "sha256-V1o2bCZdeYKP/0zgVp4EN0KUjMItAMk6J7SvCXUI5IU=",
"owner": "guibou", "owner": "guibou",
"repo": "nixGL", "repo": "nixGL",
"rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", "rev": "d709a8abcde5b01db76ca794280745a43c8662be",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -281,11 +281,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1713714899, "lastModified": 1713248628,
"narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", "narHash": "sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U+ISA=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6143fc5eeb9c4f00163267708e26191d1e918932", "rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -55,15 +55,6 @@ with lib; {
description = "Whether to enable noise suppression or not"; description = "Whether to enable noise suppression or not";
}; };
}; };
nixGLPrefix = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Will be prepended to commands which require working OpenGL.
This needs to be set to the right nixGL package on non-NixOS systems.
'';
};
}; };
config = { config = {

View file

@ -1,37 +1,17 @@
# Call once on import to load global context { pkgs, lib, ... }:
{
pkgs,
config,
}:
# Wrap a single package
pkg:
if config.nixGLPrefix == ""
then pkg
else
# Wrap the package's binaries with nixGL, while preserving the rest of
# the outputs and derivation attributes.
(pkg.overrideAttrs (old: {
name = "nixGL-${pkg.name}";
buildCommand = ''
set -eo pipefail
${ let nixgl = import <nixgl> { };
# Heavily inspired by https://stackoverflow.com/a/68523368/6259505 in pkg:
pkgs.lib.concatStringsSep "\n" (map (outputName: '' pkgs.runCommand "${pkg.name}-nixgl-wrapper" { } ''
echo "Copying output ${outputName}" mkdir $out
set -x ln -s ${pkg}/* $out
cp -rs --no-preserve=mode "${pkg.${outputName}}" "''$${outputName}" rm $out/bin
set +x mkdir $out/bin
'') (old.outputs or ["out"])) for bin in ${pkg}/bin/*; do
} wrapped_bin=$out/bin/$(basename $bin)
echo -e "#!/bin/bash\nexec ${
rm -rf $out/bin/* lib.getExe nixgl.auto.nixGLDefault
shopt -s nullglob # Prevent loop from running if no files } $bin \$@" > $wrapped_bin
for file in ${pkg.out}/bin/*; do chmod +x $wrapped_bin
echo "#!${pkgs.bash}/bin/bash" > "$out/bin/$(basename $file)"
echo "exec -a \"\$0\" ${config.nixGLPrefix} $file \"\$@\"" >> "$out/bin/$(basename $file)"
chmod +x "$out/bin/$(basename $file)"
done done
shopt -u nullglob # Revert nullglob back to its normal default state ''
'';
}))