Add overlay and example NixOS configuration

This commit is contained in:
Lan Tian 2025-12-08 19:46:57 -08:00
parent b865f72390
commit b4b0598879
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B
2 changed files with 64 additions and 7 deletions

View File

@ -41,11 +41,26 @@ Add this repo to the inputs section of your `flake.nix`:
}
```
And then specify `inputs.nix-cachyos-kernel.legacyPackages.${pkgs.system}.linuxPackages-cachyos-latest` (or other variants you'd like) in your `boot.kernelPackages` option:
Add the repo's overlay in your NixOS configuration, this will expose the packages in this flake as `pkgs.cachyosKernels.*`.
Then specify `pkgs.cachyosKernels.linuxPackages-cachyos-latest` (or other variants you'd like) in your `boot.kernelPackages` option.
### Example configuration
```nix
{ pkgs, inputs, ... }:
{
boot.kernelPackages = inputs.nix-cachyos-kernel.legacyPackages.${pkgs.system}.linuxPackages-cachyos-latest
nixosConfigurations.example = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(
{ pkgs, ... }:
{
nixpkgs.overlays = [ self.overlay ];
boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest;
# ... your other configs
}
)
];
};
}
```

View File

@ -20,7 +20,19 @@
lib,
...
}:
{
let
loadPackages =
pkgs:
lib.removeAttrs
(pkgs.callPackage ./kernel-cachyos {
inherit inputs;
})
[
"override"
"overrideDerivation"
];
in
rec {
systems = [
"x86_64-linux"
"aarch64-linux"
@ -33,12 +45,42 @@
}:
rec {
# Legacy packages contain linux-cachyos-* and linuxPackages-cachyos-*
legacyPackages = pkgs.callPackage ./kernel-cachyos {
inherit inputs;
};
legacyPackages = loadPackages pkgs;
# Packages only contain linux-cachyos-* due to Flake schema requirements
packages = lib.filterAttrs (_: lib.isDerivation) legacyPackages;
};
flake = {
overlay = self.overlays.default;
overlays.default = final: prev: {
cachyosKernels = loadPackages prev;
};
nixosConfigurations = lib.genAttrs systems (
system:
inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
(
{ pkgs, ... }:
{
nixpkgs.overlays = [ self.overlay ];
boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest;
# Minimal config to make test configuration build
boot.loader.grub.devices = [ "/dev/vda" ];
fileSystems."/" = {
device = "tmpfs";
fsType = "tmpfs";
};
system.stateVersion = lib.trivial.release;
}
)
];
}
);
};
}
);
}