nixos/modules/system/nixpkgs.nix

79 lines
2.5 KiB
Nix
Raw Normal View History

2023-09-02 21:21:29 +08:00
inputs:
{
options.nixos.system.nixpkgs = let inherit (inputs.lib) mkOption types; in
{
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
oneapiArch = mkOption
{
type = types.nullOr types.nonEmptyStr;
default = inputs.config.nixos.system.nixpkgs.march;
};
2023-09-03 17:17:10 +08:00
cudaSupport = mkOption { type = types.bool; default = false; };
2023-09-02 21:21:29 +08:00
};
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) mkConditional;
inherit (inputs.config.nixos.system) nixpkgs;
in mkMerge
[
{
nixpkgs =
{
config.allowUnfree = true;
2023-09-03 17:17:10 +08:00
config.cudaSupport = nixpkgs.cudaSupport;
2023-09-10 12:53:27 +08:00
overlays = [(final: prev:
{
genericPackages =
import inputs.topInputs.nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; };
waydroid = final.unstablePackages.waydroid;
})];
2023-09-02 21:21:29 +08:00
};
}
(
mkConditional (nixpkgs.march != null)
{
2023-09-19 12:33:08 +08:00
programs.ccache.enable = true;
2023-09-02 21:21:29 +08:00
nixpkgs =
{
hostPlatform = { system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; };
config = { qchem-config.optArch = nixpkgs.march; oneapiArch = nixpkgs.oneapiArch; };
2023-09-10 16:40:19 +08:00
overlays = [(final: prev:
{
unstablePackages = import inputs.topInputs.nixpkgs-unstable
{
localSystem = { system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; };
config.allowUnfree = true;
};
})];
2023-09-02 21:21:29 +08:00
};
boot.kernelPatches =
[{
name = "native kernel";
patch = null;
extraStructuredConfig =
let
kernelConfig =
{
alderlake = "MALDERLAKE";
sandybridge = "MSANDYBRIDGE";
silvermont = "MSILVERMONT";
broadwell = "MBROADWELL";
znver2 = "MZEN2";
znver3 = "MZEN3";
};
2023-11-16 15:51:47 +08:00
in { GENERIC_CPU = inputs.lib.kernel.no; ${kernelConfig.${nixpkgs.march}} = inputs.lib.kernel.yes; };
2023-09-02 21:21:29 +08:00
}];
}
2023-09-10 16:40:19 +08:00
{
nixpkgs =
{
hostPlatform = "x86_64-linux";
overlays = [(final: prev: { unstablePackages = import inputs.topInputs.nixpkgs-unstable
{ localSystem.system = "x86_64-linux"; config.allowUnfree = true; }; })];
};
}
2023-09-02 21:21:29 +08:00
)
];
}