Skip to content

Commit

Permalink
Make sure derivations built with native optimizations don't collide.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurnevsky committed Dec 15, 2024
1 parent 6810b79 commit e06851b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
28 changes: 15 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,29 @@
[ inputs.agenix.packages.${pkgs.system}.default ];
})
];
llamaOverride = pkgs: llama:
import ./modules/with-native-optimizations.nix (llama.overrideAttrs
(old: {
postInstall = (old.postInstall or "") + ''
find $out/bin -type f ! -wholename '*/llama*' -exec ${pkgs.util-linux}/bin/rename "" 'llama-' {} \;
'';
}));
llamaDefault = { pkgs, ... }: {
llamaOverride = pkgs: config: llama:
import ./modules/with-native-optimizations.nix
config.networking.hostName (llama.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
find $out/bin -type f ! -wholename '*/llama*' -exec ${pkgs.util-linux}/bin/rename "" 'llama-' {} \;
'';
}));
llamaDefault = { pkgs, config, ... }: {
environment.systemPackages = [
(llamaOverride pkgs inputs.llama-cpp.packages.${pkgs.system}.default)
(llamaOverride pkgs config
inputs.llama-cpp.packages.${pkgs.system}.default)
];
};
llamaOpencl = { pkgs, ... }: {
llamaOpencl = { pkgs, config, ... }: {
environment.systemPackages = [
(llamaOverride pkgs inputs.llama-cpp.packages.${pkgs.system}.opencl)
(llamaOverride pkgs config
inputs.llama-cpp.packages.${pkgs.system}.opencl)
];
};
llamaRocm = gpuTargets:
{ pkgs, ... }: {
{ pkgs, config, ... }: {
environment.systemPackages = [
(llamaOverride pkgs
(llamaOverride pkgs config
(inputs.llama-cpp.packages.${pkgs.system}.rocm.override {
rocmGpuTargets = gpuTargets;
}))
Expand Down
1 change: 1 addition & 0 deletions machines/pc/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
environment.systemPackages = with pkgs; [
radeontop
(import ../../modules/with-native-optimizations.nix
config.networking.hostName
(pkgs.callPackage ../../modules/stable-diffusion-cpp.nix {
useRocm = true;
gpuTargets = "gfx1100";
Expand Down
4 changes: 2 additions & 2 deletions modules/with-native-optimizations.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
drv:
hostname: drv:

drv.overrideAttrs (old: {
pname = old.pname + "-unsafe";
pname = old.pname + "-" + hostname + "-unsafe";
NIX_CFLAGS_COMPILE = [ "-O3" "-march=native" "-mtune=native" ];
NIX_ENFORCE_NO_NATIVE = false;
preferLocalBuild = true;
Expand Down

0 comments on commit e06851b

Please sign in to comment.