flake.lib.buildNixpkgsConfig: add rocm support

This commit is contained in:
2025-08-19 17:30:54 +08:00
parent 8befb38d31
commit d33f1a8e22
6 changed files with 11 additions and 9 deletions

View File

@@ -5,7 +5,7 @@
let pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
{
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; cuda = null; nixRoot = "/data/gpfs01/jykang/.nix"; nixos = false; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/jykang/.nix"; nixos = false; };
});
in pkgs.symlinkJoin
{

View File

@@ -46,7 +46,7 @@ inputs:
];
remote.master.host.srv2-node0 = [ "skylake" ];
};
nixpkgs.march = "znver5";
nixpkgs = { march = "znver5"; rocm = true; };
sysctl.laptop-mode = 5;
};
hardware.gpu.type = "amd";

View File

@@ -3,7 +3,7 @@ let
pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
{
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = null; cuda = null; nixRoot = "/public/home/xmuhk/.nix"; nixos = false; };
nixpkgs = { march = null; nixRoot = "/public/home/xmuhk/.nix"; nixos = false; };
});
lumericalLicenseManager =
let

View File

@@ -1,4 +1,4 @@
# inputs = { lib, topInputs, ...}; nixpkgs = { march, cuda, nixRoot, nixos, arch };
# inputs = { lib, topInputs, ...}; nixpkgs = { march, cuda, nixRoot, nixos, arch, rocm };
{ inputs, nixpkgs }:
let
platformConfig =
@@ -8,7 +8,7 @@ let
${if nixpkgs.nixos then "hostPlatform" else "localSystem"} =
{ system = "${nixpkgs.arch or "x86_64"}-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; };
};
cudaConfig = inputs.lib.optionalAttrs (nixpkgs.cuda != null)
cudaConfig = inputs.lib.optionalAttrs (nixpkgs.cuda or null != null)
(
{ cudaSupport = true; }
// (inputs.lib.optionalAttrs (nixpkgs.cuda.capabilities != null)
@@ -16,8 +16,9 @@ let
// (inputs.lib.optionalAttrs (nixpkgs.cuda.forwardCompat != null)
{ cudaForwardCompat = nixpkgs.cuda.forwardCompat; })
);
rocmConfig = inputs.lib.optionalAttrs (nixpkgs.rocm or false) { rocmSupport = true; };
allowInsecurePredicate = p: inputs.lib.warn "Allowing insecure package ${p.name or "${p.pname}-${p.version}"}" true;
config = cudaConfig
config = cudaConfig // rocmConfig
// {
inherit allowInsecurePredicate;
allowUnfree = true;
@@ -30,7 +31,7 @@ let
nvhpcArch = nixpkgs.march;
# contentAddressedByDefault = true;
})
// (inputs.lib.optionalAttrs (nixpkgs.nixRoot != null)
// (inputs.lib.optionalAttrs (nixpkgs.nixRoot or null != null)
{ nix = { storeDir = "${nixpkgs.nixRoot}/store"; stateDir = "${nixpkgs.nixRoot}/state"; }; });
in platformConfig //
{

View File

@@ -3,7 +3,7 @@
pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
{
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = null; cuda = null; nixRoot = null; nixos = false; };
nixpkgs = { march = null; nixos = false; };
});
hpcstat =
let

View File

@@ -12,13 +12,14 @@ inputs:
};});
default = null;
};
rocm = mkOption { type = types.bool; default = false; };
};
config = let inherit (inputs.config.nixos.system) nixpkgs; in
{
nixpkgs = inputs.localLib.buildNixpkgsConfig
{
inherit inputs;
nixpkgs = nixpkgs // { nixRoot = null; nixos = true; inherit (inputs.config.nixos.model) arch; };
nixpkgs = nixpkgs // { nixos = true; inherit (inputs.config.nixos.model) arch; };
};
boot.kernelPatches = inputs.lib.mkIf (nixpkgs.march != null)
[{