From f6932bbb1d3c68e60a732f8fd702b2a61ec11354 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 11 Dec 2024 14:52:51 +0000 Subject: [PATCH] treewide: allow patches everywhere --- flake.nix | 7 ++----- lib/flake-helpers.nix | 19 +++++++++++++++---- patches/default.nix | 21 ++++++++++++++++----- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index e632778b..b909383e 100644 --- a/flake.nix +++ b/flake.nix @@ -211,11 +211,8 @@ (flake-utils.lib.eachDefaultSystem ( system: let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = [ self.overlays.default ]; - }; + n = import ./patches { inherit self nixpkgs system; }; + inherit (n) pkgs; in { devShells.default = pkgs.mkShell { diff --git a/lib/flake-helpers.nix b/lib/flake-helpers.nix index bcc8c02f..298c383d 100644 --- a/lib/flake-helpers.nix +++ b/lib/flake-helpers.nix @@ -70,10 +70,13 @@ in }: let inherit (self.outputs.nixosConfigurations.${hostname}) config; - n = import ../patches { inherit nixpkgs system; }; + n = import ../patches { inherit self nixpkgs system; }; nixosSystem = - if n.patched then import (n.nixpkgs + "/nixos/lib/eval-config.nix") else n.nixpkgs.lib.nixosSystem; + if n.patched then + (import (n.nixpkgs + "/nixos/lib/eval-config.nix")) + else + n.nixpkgs.lib.nixosSystem; in { nixosConfigurations.${hostname} = nixosSystem { @@ -109,14 +112,18 @@ in mkNixDarwinConfig = { hostname, + system ? "aarch64-darwin", nix-darwin ? inputs.nix-darwin, + nixpkgs ? inputs.nixpkgs, extraModules ? [ ], }: let - inherit (self.outputs.darwinConfigurations.${hostname}) pkgs; + n = import ../patches { inherit self nixpkgs system; }; + inherit (n) pkgs; in { darwinConfigurations.${hostname} = nix-darwin.lib.darwinSystem { + inherit pkgs system; modules = [ ( { lib, ... }: @@ -154,6 +161,7 @@ in deviceType ? "desktop", extraModules ? [ ], system ? "x86_64-linux", + nixpkgs ? inputs.nixpkgs, home-manager ? inputs.home-manager, # This value determines the Home Manager release that your # configuration is compatible with. This helps avoid breakage @@ -165,9 +173,12 @@ in # changes in each release. stateVersion ? "24.05", }: + let + n = import ../patches { inherit self nixpkgs system; }; + in { homeConfigurations.${hostname} = home-manager.lib.homeManagerConfiguration { - pkgs = self.outputs.legacyPackages.${system}; + inherit (n) pkgs; modules = [ ( { ... }: diff --git a/patches/default.nix b/patches/default.nix index a154e48e..400f47f1 100644 --- a/patches/default.nix +++ b/patches/default.nix @@ -1,8 +1,18 @@ -{ nixpkgs, system, ... }: +{ + self, + nixpkgs, + system, + ... +}: let - inherit (nixpkgs.legacyPackages.${system}) applyPatches callPackage; - patches = callPackage ./patches.nix { }; - nixpkgs' = applyPatches { + args = { + inherit system; + config.allowUnfree = true; + overlays = [ self.overlays.default ]; + }; + pkgs = import nixpkgs args; + patches = pkgs.callPackage ./patches.nix { }; + nixpkgs' = pkgs.applyPatches { inherit patches; name = "nixpkgs-patched"; src = nixpkgs; @@ -12,9 +22,10 @@ if patches != [ ] then { patched = true; nixpkgs = nixpkgs'; + pkgs = import nixpkgs' args; } else { patched = false; - inherit nixpkgs; + inherit nixpkgs pkgs; }