Skip to content

Commit

Permalink
treewide: allow patches everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Dec 11, 2024
1 parent a118d39 commit f6932bb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
7 changes: 2 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 15 additions & 4 deletions lib/flake-helpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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, ... }:
Expand Down Expand Up @@ -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
Expand All @@ -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 = [
(
{ ... }:
Expand Down
21 changes: 16 additions & 5 deletions patches/default.nix
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,9 +22,10 @@ if patches != [ ] then
{
patched = true;
nixpkgs = nixpkgs';
pkgs = import nixpkgs' args;
}
else
{
patched = false;
inherit nixpkgs;
inherit nixpkgs pkgs;
}

0 comments on commit f6932bb

Please sign in to comment.