From b4b0598879d937f291af5681c1a0a0e719808d0e Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Mon, 8 Dec 2025 19:46:57 -0800 Subject: [PATCH] Add overlay and example NixOS configuration --- README.md | 21 ++++++++++++++++++--- flake.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 575f895..63076f8 100644 --- a/README.md +++ b/README.md @@ -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 + } + ) + ]; + }; } ``` diff --git a/flake.nix b/flake.nix index 01687ac..1798496 100644 --- a/flake.nix +++ b/flake.nix @@ -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; + } + ) + ]; + } + ); + }; } ); }