lib.buildNixpkgsConfig: fix for non-nixos usage

This commit is contained in:
2025-07-21 18:09:13 +08:00
parent 01bde3548b
commit 80b9ae7d8a
5 changed files with 12 additions and 7 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"; };
nixpkgs = { march = "haswell"; cuda = null; nixRoot = "/data/gpfs01/jykang/.nix"; nixos = false; };
});
in pkgs.symlinkJoin
{

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"; };
nixpkgs = { march = null; cuda = null; nixRoot = "/public/home/xmuhk/.nix"; nixos = false; };
});
lumericalLicenseManager =
let

View File

@@ -1,9 +1,13 @@
# inputs = { lib, topInputs, ...}; nixpkgs = { march, cuda, nixRoot };
# inputs = { lib, topInputs, ...}; nixpkgs = { march, cuda, nixRoot, nixos };
{ 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; }; }; };
else
{
${if nixpkgs.nixos then "hostPlatform" else "localSystem"} =
{ system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; };
};
cudaConfig = inputs.lib.optionalAttrs (nixpkgs.cuda != null)
(
{ cudaSupport = true; }
@@ -83,7 +87,7 @@ in platformConfig //
};
packages = name: import inputs.topInputs.${source.${name}.source or source.${name}}
{
localSystem = platformConfig.hostPlatform or { inherit (platformConfig) system; };
localSystem = platformConfig.hostPlatform or platformConfig.localSystem or platformConfig;
inherit config;
overlays = [(source.${name}.overlay or (_: _: {}))];
};

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; };
nixpkgs = { march = null; cuda = null; nixRoot = null; nixos = false; };
});
hpcstat =
let

View File

@@ -15,7 +15,8 @@ inputs:
};
config = let inherit (inputs.config.nixos.system) nixpkgs; in
{
nixpkgs = inputs.localLib.buildNixpkgsConfig { inherit inputs; nixpkgs = nixpkgs // { nixRoot = null; }; };
nixpkgs = inputs.localLib.buildNixpkgsConfig
{ inherit inputs; nixpkgs = nixpkgs // { nixRoot = null; nixos = true; }; };
boot.kernelPatches = inputs.lib.mkIf (nixpkgs.march != null)
[{
name = "native kernel";