mirror of
https://github.com/thilobillerbeck/dotfiles.git
synced 2024-11-24 17:08:48 +01:00
several nixgl things
This commit is contained in:
parent
8346071197
commit
b3b0098eb5
3 changed files with 56 additions and 18 deletions
|
@ -1,6 +1,8 @@
|
||||||
{ ... }:
|
{ 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 = {
|
||||||
|
@ -14,4 +16,11 @@
|
||||||
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)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,15 @@ 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 = {
|
||||||
|
|
|
@ -1,17 +1,37 @@
|
||||||
{ pkgs, lib, ... }:
|
# Call once on import to load global context
|
||||||
|
{
|
||||||
|
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> { };
|
${
|
||||||
in pkg:
|
# Heavily inspired by https://stackoverflow.com/a/68523368/6259505
|
||||||
pkgs.runCommand "${pkg.name}-nixgl-wrapper" { } ''
|
pkgs.lib.concatStringsSep "\n" (map (outputName: ''
|
||||||
mkdir $out
|
echo "Copying output ${outputName}"
|
||||||
ln -s ${pkg}/* $out
|
set -x
|
||||||
rm $out/bin
|
cp -rs --no-preserve=mode "${pkg.${outputName}}" "''$${outputName}"
|
||||||
mkdir $out/bin
|
set +x
|
||||||
for bin in ${pkg}/bin/*; do
|
'') (old.outputs or ["out"]))
|
||||||
wrapped_bin=$out/bin/$(basename $bin)
|
}
|
||||||
echo -e "#!/bin/bash\nexec ${
|
|
||||||
lib.getExe nixgl.auto.nixGLDefault
|
rm -rf $out/bin/*
|
||||||
} $bin \$@" > $wrapped_bin
|
shopt -s nullglob # Prevent loop from running if no files
|
||||||
chmod +x $wrapped_bin
|
for file in ${pkg.out}/bin/*; do
|
||||||
done
|
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
|
||||||
|
shopt -u nullglob # Revert nullglob back to its normal default state
|
||||||
|
'';
|
||||||
|
}))
|
Loading…
Reference in a new issue