nixpkgs: allow to replace tensorflow

This commit is contained in:
陈浩南 2023-12-04 20:57:52 +08:00
parent 36e1faee0c
commit 44ae89efee
3 changed files with 35 additions and 15 deletions

View File

@ -1169,11 +1169,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1701660218,
"narHash": "sha256-hW/PSHXaF8L/06RN6fa/ZNyEjJCy0T2lN91dtBZ/FvE=",
"lastModified": 1701694102,
"narHash": "sha256-V51St+KHQoPiIma31qnl9tEV5+dC8f9a1AvV/hpq8mg=",
"owner": "CHN-beta",
"repo": "nixpkgs",
"rev": "3acbf3e037d3b8fafaac4a7e60defe9e8f741865",
"rev": "7b5fc5cb52b268ef5218bdd7a3aa31f9ac9a8efe",
"type": "github"
},
"original": {
@ -1185,11 +1185,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1701660161,
"narHash": "sha256-Q6N91xL87pMyKcV983ffJsjq13TItxdMNqMSPiBnUXY=",
"lastModified": 1701688908,
"narHash": "sha256-4m5mIRCsFSFsygGDiIz+7GKVbTsnUhcj7B9lRIAbTrY=",
"owner": "CHN-beta",
"repo": "nixpkgs",
"rev": "f90d85fe584c552c76252ccfa534ac30f2a6b4c6",
"rev": "26b8c3a268910f0adca218446c14aed9187e01ab",
"type": "github"
},
"original": {

View File

@ -88,7 +88,7 @@
})
(localLib.attrsToList
{
"pc" =
pc =
[
(inputs: { config.nixos =
{
@ -136,7 +136,7 @@
];
keepOutputs = true;
};
nixpkgs = { march = "alderlake"; cudaSupport = true; };
nixpkgs = { march = "alderlake"; cudaSupport = true; replaceTensorflow = true; };
gui = { enable = true; preferred = true; };
kernel.patches = [ "cjktty" ];
impermanence.enable = true;
@ -223,7 +223,7 @@
];
};})
];
"vps6" =
vps6 =
[
(inputs: { config.nixos =
{
@ -296,7 +296,7 @@
};
};})
];
"vps7" =
vps7 =
[
(inputs: { config.nixos =
{
@ -362,7 +362,7 @@
};
};})
];
"nas" =
nas =
[
(inputs: { config.nixos =
{
@ -460,7 +460,7 @@
users.users = [ "root" "chn" "xll" "zem" "yjq" "yxy" ];
};})
];
"yoga" =
yoga =
[
(inputs: { config.nixos =
{

View File

@ -4,12 +4,13 @@ inputs:
{
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
cudaSupport = mkOption { type = types.bool; default = false; };
replaceTensorflow = mkOption { type = types.bool; default = false; };
};
config =
let
inherit (builtins) map listToAttrs filter tryEval attrNames concatStringsSep;
inherit (builtins) map listToAttrs filter tryEval attrNames concatStringsSep toString;
inherit (inputs.lib) mkIf;
inherit (inputs.lib.strings) hasPrefix;
inherit (inputs.lib.strings) hasPrefix splitString;
inherit (inputs.localLib) mkConditional attrsToList;
inherit (inputs.config.nixos.system) nixpkgs;
in
@ -21,7 +22,7 @@ inputs:
hostPlatform = mkConditional (nixpkgs.march != null)
{ system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; }
"x86_64-linux";
noBuildPackages = [ "chromium" "electron" "webkitgtk" "python310Packages" "nodejs" "pandoc" ];
noBuildPackages = [ "chromium" "electron" "webkitgtk" "python310Packages" "nodejs" "pandoc" "fastfetch" ];
in
{
inherit hostPlatform;
@ -79,6 +80,25 @@ inputs:
(package: { name = package; value = genericPackages.${package}; })
replacedPackages))
)
// (
if nixpkgs.replaceTensorflow then
let
versionString =
concatStringsSep "" (inputs.lib.lists.take 2 (splitString "." genericPackages.python3.version));
pythonName = "python${versionString}";
in
{
${pythonName} = prev.${pythonName}.override { packageOverrides = final: prev:
{
tensorflow = prev.tensorflow.override
{
cudaSupport = false;
customBazelBuild = genericPackages.${pythonName}.pkgs.tensorflow.passthru.bazel-build;
};
};};
}
else {}
)
)];
};
programs.ccache = { enable = true; cacheDir = "/var/lib/ccache"; };