diff --git a/devices/jykang.xmuhpc/default.nix b/devices/jykang.xmuhpc/default.nix index d50a1d22..d6e15465 100644 --- a/devices/jykang.xmuhpc/default.nix +++ b/devices/jykang.xmuhpc/default.nix @@ -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 { diff --git a/devices/pc/default.nix b/devices/pc/default.nix index 2a8ef206..0cc8c9a9 100644 --- a/devices/pc/default.nix +++ b/devices/pc/default.nix @@ -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"; diff --git a/devices/xmuhk/default.nix b/devices/xmuhk/default.nix index dbe1d475..1b8ff9f6 100644 --- a/devices/xmuhk/default.nix +++ b/devices/xmuhk/default.nix @@ -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 diff --git a/flake/lib/buildNixpkgsConfig/default.nix b/flake/lib/buildNixpkgsConfig/default.nix index 642ec84f..eeb2ca0c 100644 --- a/flake/lib/buildNixpkgsConfig/default.nix +++ b/flake/lib/buildNixpkgsConfig/default.nix @@ -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 // { diff --git a/flake/packages.nix b/flake/packages.nix index 56de7eec..e8292857 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -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 diff --git a/modules/system/nixpkgs.nix b/modules/system/nixpkgs.nix index adda0699..c256fe23 100644 --- a/modules/system/nixpkgs.nix +++ b/modules/system/nixpkgs.nix @@ -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) [{