Skip to content

Commit

Permalink
Add per-system nixpkgs overrides
Browse files Browse the repository at this point in the history
This is useful for working around build issue on some platform in the
latest commit.
  • Loading branch information
yelite committed Aug 14, 2024
1 parent bc7a952 commit b181564
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ have more complex tasks to accomplish within the flake.
# Whether the nixpkgs used in lite-config should also be set as the `pkgs` arg for
# the perSystem module.
setPerSystemPkgs = true;
# Useful for using a pinned nixpkgs for a particular platform. To
# workaround broken packages in the latest commit.
perSystemOverrides = {
"aarch64-darwin" = {
nixpkgs = inputs.nixpkgs-darwin;
config = {};
};
};
};
# The home-manager flake to use.
Expand Down
41 changes: 40 additions & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,44 @@ toplevel @ {
{ allowUnfree = true; }
'';
};
perSystemOverrides = mkOption {
default = {};
type = types.attrsOf (types.submodule {
options = {
nixpkgs = mkOption {
type = types.path;
default = inputs.nixpkgs;
defaultText = literalExpression "inputs.nixpkgs";
description = ''
The nixpkgs flake to use for this system.
'';
};
config = mkOption {
default = {};
type = types.attrs;
description = ''
The configuration of the Nix Packages collection for this system.
'';
example =
literalExpression
''
{ allowUnfree = true; }
'';
};
};
});
description = ''
Overrides for the nixpkgs used in a particular system. Useful for choosing
a pinned nixpkgs commit for some platform.
'';
example =
literalExpression
''
{
"aarch64-darwin" = inputs.nixpkgs-darwin;
}
'';
};
overlays = mkOption {
default = [];
type = types.listOf overlayType;
Expand Down Expand Up @@ -343,7 +381,8 @@ in {
}: {
_file = ./.;
config = let
selectedPkgs = import cfg.nixpkgs.nixpkgs {
systemNixpkgs = cfg.nixpkgs.perSystemOverrides.${system} or cfg.nixpkgs;
selectedPkgs = import systemNixpkgs.nixpkgs {
inherit system;
overlays = cfg.nixpkgs.overlays;
config = cfg.nixpkgs.config;
Expand Down

0 comments on commit b181564

Please sign in to comment.