support nixpkgs.channels.*.default

This commit is contained in:
do butterflies cry? 2026-02-14 16:00:34 +10:00
parent b7838874d8
commit 93aa29dc10
2 changed files with 14 additions and 31 deletions

View file

@ -37,10 +37,8 @@ in {
extraSpecialArgs = {inherit root system;} // (specialArgs.inputs or {}); extraSpecialArgs = {inherit root system;} // (specialArgs.inputs or {});
sharedModules = [ sharedModules = [
# user configuration # user configuration
# (import (root + "/nixpkgs.nix"))
(import (root + "/nixpkgs.nix")) (import (root + "/nixpkgs.nix"))
# options declarations # options declarations
# (import ./nixpkgs.nix (args // {contextName = "homes";}))
(import ./nixpkgs.nix (args // {contextName = "homes";})) (import ./nixpkgs.nix (args // {contextName = "homes";}))
]; ];

View file

@ -21,7 +21,6 @@
inherit inherit
(builtins) (builtins)
mapAttrs mapAttrs
typeOf
; ;
cfg = config.nixpkgs.channels; cfg = config.nixpkgs.channels;
@ -52,11 +51,6 @@ in {
}; };
}; };
# or abort ''
# `nixpkgs.channels.${contextName}` does not exist, but neither does `nixpkgs.channels.default`!
# A channel configuration must be declared for module context "${contextName}".
# ''
config = let config = let
# TODO: use lib.types.submodule to restrict what options # TODO: use lib.types.submodule to restrict what options
# TODO: can be given to `nixpkgs.channels.${moduleName}.${name}` # TODO: can be given to `nixpkgs.channels.${moduleName}.${name}`
@ -68,7 +62,6 @@ in {
|> mapAttrs ( |> mapAttrs (
name: args: name: args:
lib.mkForce ( lib.mkForce (
# builtins.trace "SAVE ME GOT NAME: ${name}" (
assert args ? source assert args ? source
|| abort '' || abort ''
${toString ./.} ${toString ./.}
@ -77,39 +70,31 @@ in {
((removeAttrs args ["source"]) ((removeAttrs args ["source"])
// {inherit system;}) // {inherit system;})
|> import args.source |> import args.source
# DEBUG: |> lib.mkOverride 200
) )
# )
); );
in { in {
# NOTE: _module.args is a special option that allows us to # NOTE: _module.args is a special option that allows us to
# NOTE: set extend specialArgs from inside the modules. # NOTE: set extend specialArgs from inside the modules.
# "pkgs" is unique since the nix module system already handles it
# DEBUG: _module.args = lib.mkOverride 200 (
# _module.args = (
# if contextName == "hosts"
# then repos
# else
# assert (
# repos
# |> builtins.attrNames
# |> map (x: "\"${x}\"")
# |> builtins.concatStringsSep " "
# |> (x: "FUCK YOU SO BAD: { ${x} }")
# |> abort
# );
# removeAttrs repos ["pkgs"]
# );
_module.args = repos; _module.args = repos;
nixpkgs = nixpkgs = let
defaultPkgs =
decl.default or (throw ''
Your `nixpkgs.nix` file does not declare a default package source.
Ensure you set `nixpkgs.channels.*.default = ...;`
'');
in
if contextName == "hosts" if contextName == "hosts"
then {flake.source = lib.mkIf (decl ? pkgs) (lib.mkOverride 200 decl.pkgs.source);} then {
flake.source = lib.mkOverride 200 defaultPkgs.source;
config = lib.mkOverride 200 defaultPkgs.config;
}
else if contextName == "homes" else if contextName == "homes"
then { then {
config = decl.pkgs.config or {}; # XXX: XXX: XXX: OH OH OH OMG, its because aurora never defines pkgs
config = lib.mkOverride 200 (defaultPkgs.config or {});
# XXX: WARNING: TODO: modify options so overlays must always be given as the correct type # XXX: WARNING: TODO: modify options so overlays must always be given as the correct type
overlays = decl.pkgs.overlays or []; overlays = lib.mkOverride 200 (defaultPkgs.overlays or []);
} }
else {}; else {};
}; };