mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
Merge branch 'production' into next
This commit is contained in:
15
devices/jykang.xmuhpc/default.nix
Normal file
15
devices/jykang.xmuhpc/default.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
# sudo nix build --store 'local?store=/data/gpfs01/jykang/.nix/store&state=/data/gpfs01/jykang/.nix/state&log=/data/gpfs01/jykang/.nix/log' .#jykang
|
||||
# sudo nix-store --store 'local?store=/data/gpfs01/jykang/.nix/store&state=/data/gpfs01/jykang/.nix/state&log=/data/gpfs01/jykang/.nix/log' -qR ./result | sudo xargs nix-store --store 'local?store=/data/gpfs01/jykang/.nix/store&state=/data/gpfs01/jykang/.nix/state&log=/data/gpfs01/jykang/.nix/log' --export > data.nar
|
||||
# cat data.nar | nix-store --import
|
||||
inputs:
|
||||
let pkgs = import inputs.nixpkgs (import ../../modules/system/nixpkgs/buildNixpkgsConfig.nix
|
||||
{
|
||||
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
|
||||
nixpkgs = { march = null; cuda = null; nixRoot = "/data/gpfs01/jykang/.nix"; };
|
||||
});
|
||||
in pkgs.symlinkJoin
|
||||
{
|
||||
name = "jykang";
|
||||
paths = with pkgs; [ hello ];
|
||||
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
|
||||
}
|
||||
@@ -23,13 +23,14 @@
|
||||
version = inputs.self.rev or "dirty";
|
||||
stdenv = pkgs.pkgsStatic.gcc14Stdenv;
|
||||
};
|
||||
chn-bsub = pkgs.pkgsStatic.localPackages.chn-bsub;
|
||||
blog = pkgs.localPackages.blog;
|
||||
inherit (pkgs.localPackages) blog;
|
||||
inherit (pkgs.localPackages.pkgsStatic) chn-bsub;
|
||||
vaspberry = pkgs.pkgsStatic.localPackages.vaspberry.override
|
||||
{
|
||||
gfortran = pkgs.pkgsStatic.gfortran;
|
||||
lapack = pkgs.pkgsStatic.openblas;
|
||||
};
|
||||
jykang = import ../devices/jykang.xmuhpc inputs;
|
||||
}
|
||||
// (builtins.listToAttrs (builtins.map
|
||||
(system: { inherit (system) name; value = system.value.config.system.build.toplevel; })
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.nixpkgs = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
|
||||
cuda = mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule { options =
|
||||
{
|
||||
capabilities = mkOption { type = types.nullOr (types.nonEmptyListOf types.nonEmptyStr); default = null; };
|
||||
forwardCompat = mkOption { type = types.nullOr types.bool; default = false; };
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) nixpkgs; in
|
||||
{
|
||||
nixpkgs =
|
||||
let
|
||||
hostPlatform = if nixpkgs.march != null
|
||||
then { system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; }
|
||||
else "x86_64-linux";
|
||||
cudaConfig = inputs.lib.optionalAttrs (nixpkgs.cuda != null)
|
||||
(
|
||||
{ cudaSupport = true; }
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.cuda.capabilities != null)
|
||||
{ cudaCapabilities = nixpkgs.cuda.capabilities; })
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.cuda.forwardCompat != null)
|
||||
{ cudaForwardCompat = nixpkgs.cuda.forwardCompat; })
|
||||
);
|
||||
allowInsecurePredicate = p: inputs.lib.warn
|
||||
"Allowing insecure package ${p.name or "${p.pname}-${p.version}"}" true;
|
||||
in
|
||||
{
|
||||
inherit hostPlatform;
|
||||
config = cudaConfig //
|
||||
{
|
||||
inherit allowInsecurePredicate;
|
||||
allowUnfree = true;
|
||||
qchem-config = { optArch = nixpkgs.march; useCuda = nixpkgs.cuda != null; };
|
||||
android_sdk.accept_license = true;
|
||||
}
|
||||
// (if nixpkgs.march == null then {} else
|
||||
{
|
||||
# TODO: change znver4 after update oneapi
|
||||
# TODO: test znver3 do use AVX
|
||||
oneapiArch = let match = {}; in match.${nixpkgs.march} or nixpkgs.march;
|
||||
nvhpcArch = nixpkgs.march;
|
||||
# contentAddressedByDefault = true;
|
||||
enableCcache = true;
|
||||
});
|
||||
overlays =
|
||||
[(final: prev:
|
||||
let
|
||||
inherit (final) system;
|
||||
genericPackages = import inputs.topInputs.nixpkgs
|
||||
{ inherit system; config = { allowUnfree = true; inherit allowInsecurePredicate; }; };
|
||||
in
|
||||
{ inherit genericPackages; }
|
||||
// (
|
||||
let
|
||||
source =
|
||||
{
|
||||
"pkgs-23.11" = "nixpkgs-23.11";
|
||||
"pkgs-23.05" = "nixpkgs-23.05";
|
||||
pkgs-unstable =
|
||||
{
|
||||
source = "nixpkgs-unstable";
|
||||
overlay = final: prev:
|
||||
{
|
||||
ollama = prev.ollama.override { cudaPackages = final.cudaPackages_12_8; };
|
||||
}
|
||||
// inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
pythonPackagesExtensions = prev.pythonPackagesExtensions or [] ++ [(final: prev:
|
||||
{
|
||||
scipy = prev.scipy.overridePythonAttrs (prev:
|
||||
{ disabledTests = prev.disabledTests or [] ++ [ "test_hyp2f1" ]; });
|
||||
rapidocr-onnxruntime = prev.rapidocr-onnxruntime.overridePythonAttrs { doCheck = false; };
|
||||
cfn-lint = prev.cfn-lint.overridePythonAttrs { doCheck = false; };
|
||||
})];
|
||||
rapidjson = prev.rapidjson.overrideAttrs { doCheck = false; };
|
||||
ctranslate2 = (prev.ctranslate2.override { withCUDA = false; withCuDNN = false; })
|
||||
.overrideAttrs (prev:
|
||||
{ cmakeFlags = prev.cmakeFlags or [] ++ [ "-DENABLE_CPU_DISPATCH=OFF" ]; });
|
||||
};
|
||||
};
|
||||
};
|
||||
packages = name: import inputs.topInputs.${source.${name}.source or source.${name}}
|
||||
{
|
||||
localSystem = hostPlatform;
|
||||
config = cudaConfig //
|
||||
{
|
||||
allowUnfree = true;
|
||||
# contentAddressedByDefault = true;
|
||||
inherit allowInsecurePredicate;
|
||||
};
|
||||
overlays = [(source.${name}.overlay or (_: _: {}))];
|
||||
};
|
||||
in builtins.listToAttrs (builtins.map
|
||||
(name: { inherit name; value = packages name; }) (builtins.attrNames source))
|
||||
)
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
# -march=xxx cause embree build failed
|
||||
# https://github.com/embree/embree/issues/115
|
||||
embree = prev.embree.override { stdenv = final.genericPackages.stdenv; };
|
||||
simde = prev.simde.override { stdenv = final.genericPackages.stdenv; };
|
||||
})
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march == "silvermont")
|
||||
{ c-blosc = prev.c-blosc.overrideAttrs { doCheck = false; }; })
|
||||
)];
|
||||
};
|
||||
programs.ccache = { enable = true; cacheDir = "/var/lib/ccache"; };
|
||||
nix.settings.extra-sandbox-paths = [ inputs.config.programs.ccache.cacheDir ];
|
||||
boot.kernelPatches = inputs.lib.mkIf (nixpkgs.march != null)
|
||||
[{
|
||||
name = "native kernel";
|
||||
patch = null;
|
||||
extraStructuredConfig =
|
||||
let kernelConfig = { znver2 = "MZEN2"; znver3 = "MZEN3"; znver4 = "MZEN4"; };
|
||||
in
|
||||
{
|
||||
GENERIC_CPU = inputs.lib.kernel.no;
|
||||
${kernelConfig.${nixpkgs.march} or "M${inputs.lib.toUpper nixpkgs.march}"} = inputs.lib.kernel.yes;
|
||||
};
|
||||
}];
|
||||
};
|
||||
}
|
||||
97
modules/system/nixpkgs/buildNixpkgsConfig.nix
Normal file
97
modules/system/nixpkgs/buildNixpkgsConfig.nix
Normal file
@@ -0,0 +1,97 @@
|
||||
# inputs = { lib, topInputs, ...}; nixpkgs = { march, cuda, nixRoot };
|
||||
{ inputs, nixpkgs }:
|
||||
let
|
||||
platformConfig =
|
||||
if nixpkgs.march == null then { system = "x86_64-linux"; }
|
||||
else { hostPlatform = { system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; }; };
|
||||
cudaConfig = inputs.lib.optionalAttrs (nixpkgs.cuda != null)
|
||||
(
|
||||
{ cudaSupport = true; }
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.cuda.capabilities != null)
|
||||
{ cudaCapabilities = nixpkgs.cuda.capabilities; })
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.cuda.forwardCompat != null)
|
||||
{ cudaForwardCompat = nixpkgs.cuda.forwardCompat; })
|
||||
);
|
||||
allowInsecurePredicate = p: inputs.lib.warn "Allowing insecure package ${p.name or "${p.pname}-${p.version}"}" true;
|
||||
in platformConfig //
|
||||
{
|
||||
config = cudaConfig //
|
||||
{
|
||||
inherit allowInsecurePredicate;
|
||||
allowUnfree = true;
|
||||
qchem-config = { optArch = nixpkgs.march; useCuda = nixpkgs.cuda != null; };
|
||||
android_sdk.accept_license = true;
|
||||
}
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
# TODO: change znver4 after update oneapi
|
||||
# TODO: test znver3 do use AVX
|
||||
oneapiArch = let match = {}; in match.${nixpkgs.march} or nixpkgs.march;
|
||||
nvhpcArch = nixpkgs.march;
|
||||
# contentAddressedByDefault = true;
|
||||
enableCcache = true;
|
||||
})
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.nixRoot == null)
|
||||
{ nix = { storeDir = "${nixpkgs.nixRoot}/store"; stateDir = "${nixpkgs.nixRoot}/var"; }; });
|
||||
overlays =
|
||||
[(final: prev:
|
||||
let
|
||||
inherit (final) system;
|
||||
genericPackages = import inputs.topInputs.nixpkgs
|
||||
{ inherit system; config = { allowUnfree = true; inherit allowInsecurePredicate; }; };
|
||||
in
|
||||
{ inherit genericPackages; }
|
||||
// (
|
||||
let
|
||||
source =
|
||||
{
|
||||
"pkgs-23.11" = "nixpkgs-23.11";
|
||||
"pkgs-23.05" = "nixpkgs-23.05";
|
||||
pkgs-unstable =
|
||||
{
|
||||
source = "nixpkgs-unstable";
|
||||
overlay = final: prev:
|
||||
{
|
||||
ollama = prev.ollama.override { cudaPackages = final.cudaPackages_12_8; };
|
||||
}
|
||||
// inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
pythonPackagesExtensions = prev.pythonPackagesExtensions or [] ++ [(final: prev:
|
||||
{
|
||||
scipy = prev.scipy.overridePythonAttrs (prev:
|
||||
{ disabledTests = prev.disabledTests or [] ++ [ "test_hyp2f1" ]; });
|
||||
rapidocr-onnxruntime = prev.rapidocr-onnxruntime.overridePythonAttrs { doCheck = false; };
|
||||
cfn-lint = prev.cfn-lint.overridePythonAttrs { doCheck = false; };
|
||||
})];
|
||||
rapidjson = prev.rapidjson.overrideAttrs { doCheck = false; };
|
||||
ctranslate2 = (prev.ctranslate2.override { withCUDA = false; withCuDNN = false; })
|
||||
.overrideAttrs (prev:
|
||||
{ cmakeFlags = prev.cmakeFlags or [] ++ [ "-DENABLE_CPU_DISPATCH=OFF" ]; });
|
||||
};
|
||||
};
|
||||
};
|
||||
packages = name: import inputs.topInputs.${source.${name}.source or source.${name}}
|
||||
{
|
||||
localSystem = platformConfig.hostPlatform or { inherit (platformConfig) system; };
|
||||
config = cudaConfig //
|
||||
{
|
||||
allowUnfree = true;
|
||||
# contentAddressedByDefault = true;
|
||||
inherit allowInsecurePredicate;
|
||||
};
|
||||
overlays = [(source.${name}.overlay or (_: _: {}))];
|
||||
};
|
||||
in builtins.listToAttrs (builtins.map
|
||||
(name: { inherit name; value = packages name; }) (builtins.attrNames source))
|
||||
)
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
# -march=xxx cause embree build failed
|
||||
# https://github.com/embree/embree/issues/115
|
||||
embree = prev.embree.override { stdenv = final.genericPackages.stdenv; };
|
||||
simde = prev.simde.override { stdenv = final.genericPackages.stdenv; };
|
||||
})
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march == "silvermont")
|
||||
{ c-blosc = prev.c-blosc.overrideAttrs { doCheck = false; }; })
|
||||
)];
|
||||
}
|
||||
34
modules/system/nixpkgs/default.nix
Normal file
34
modules/system/nixpkgs/default.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.nixpkgs = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
|
||||
cuda = mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule { options =
|
||||
{
|
||||
capabilities = mkOption { type = types.nullOr (types.nonEmptyListOf types.nonEmptyStr); default = null; };
|
||||
forwardCompat = mkOption { type = types.nullOr types.bool; default = false; };
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) nixpkgs; in
|
||||
{
|
||||
nixpkgs = import ./buildNixpkgsConfig.nix { inherit inputs; nixpkgs = nixpkgs // { nixRoot = null; }; };
|
||||
programs.ccache = { enable = true; cacheDir = "/var/lib/ccache"; };
|
||||
nix.settings.extra-sandbox-paths = [ inputs.config.programs.ccache.cacheDir ];
|
||||
boot.kernelPatches = inputs.lib.mkIf (nixpkgs.march != null)
|
||||
[{
|
||||
name = "native kernel";
|
||||
patch = null;
|
||||
extraStructuredConfig =
|
||||
let kernelConfig = { znver2 = "MZEN2"; znver3 = "MZEN3"; znver4 = "MZEN4"; };
|
||||
in
|
||||
{
|
||||
GENERIC_CPU = inputs.lib.kernel.no;
|
||||
${kernelConfig.${nixpkgs.march} or "M${inputs.lib.toUpper nixpkgs.march}"} = inputs.lib.kernel.yes;
|
||||
};
|
||||
}];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user