From a345fb78490b851f5d2cb6c78f0a773ebc36465e Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Tue, 7 May 2024 20:52:31 -0400 Subject: [PATCH] feat: overhaul overlays module --- flake.nix | 14 +------------- overlays/default.nix | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 6dd3247..7662af8 100644 --- a/flake.nix +++ b/flake.nix @@ -60,19 +60,7 @@ # Accessible through 'nix build', 'nix shell', etc packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); - # This repo's overlay plus any other overlays you use - # If you want to use packages from flakes that are not nixpkgs (such as NUR), add their overlays here.\ - overlays = { - default = import ./overlays inputs; - pkg-sets = ( - final: prev: { - unstable = import inputs.unstable {system = final.system;}; - trunk = import inputs.trunk {system = final.system;}; - } - ); - rust-overlay = rust-overlay.overlays.default; - vscode-extensions = nix-vscode-extensions.overlays.default; - }; + overlays = import ./overlays {inherit inputs;}; overlaysModule = { nixpkgs.overlays = builtins.attrValues self.overlays; diff --git a/overlays/default.nix b/overlays/default.nix index a054471..85e4b9f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,13 +1,25 @@ -{ - nixpkgs, - unstable, - ... -}: let - inherit (nixpkgs.lib) composeManyExtensions; - inherit (builtins) attrNames readDir; - localOverlays = - map - (f: import (./default + "/${f}")) - (attrNames (readDir ./default)); -in - composeManyExtensions localOverlays +{inputs, ...}: { + rust-overlay = inputs.rust-overlay.overlays.default; + vscode-extensions = inputs.nix-vscode-extensions.overlays.default; + + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs final.pkgs; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +}