Compare commits

..

No commits in common. "870bbb1f3738736ea248c171685bffdb242e294a" and "d85a6b963f85ae81904c94789167ae337891c6d2" have entirely different histories.

3 changed files with 59 additions and 52 deletions

View file

@ -197,8 +197,8 @@ in {
inherit root base; inherit root base;
inherit (node) system; inherit (node) system;
_cerulean = { _cerulean = {
inherit inputs userArgs ceruleanArgs; inherit inputs userArgs;
specialArgs = userArgs // ceruleanArgs; args = ceruleanArgs;
}; };
}; };
specialArgs = assert (userArgs specialArgs = assert (userArgs
@ -209,7 +209,7 @@ in {
`specialArgs` are like super important to Cerulean my love... </3 `specialArgs` are like super important to Cerulean my love... </3
But `args.${argName}` is a reserved argument name :( But `args.${argName}` is a reserved argument name :(
'')); ''));
ceruleanArgs._cerulean.specialArgs; userArgs // ceruleanArgs;
in in
lib.nixosSystem { lib.nixosSystem {
inherit (node) system; inherit (node) system;

View file

@ -25,16 +25,15 @@
pathExists pathExists
; ;
in { in {
config = {
home-manager = { home-manager = {
users = users =
config.users.users config.users.users
|> attrNames |> attrNames
|> filter (x: pathExists (root + "/homes/${x}")) |> filter (x: pathExists (root + "/homes/${x}"))
|> (x: |> (x: lib.genAttrs x (y: import (root + "/homes/${y}")));
lib.genAttrs x (y:
import (root + "/homes/${y}")));
extraSpecialArgs = _cerulean.specialArgs; extraSpecialArgs = _cerulean.args;
sharedModules = [ sharedModules = [
# user configuration # user configuration
(import (root + "/nixpkgs.nix")) (import (root + "/nixpkgs.nix"))
@ -42,4 +41,5 @@ in {
(import ./nixpkgs.nix (args // {contextName = "homes";})) (import ./nixpkgs.nix (args // {contextName = "homes";}))
]; ];
}; };
};
} }

View file

@ -26,10 +26,11 @@
cfg = config.nixpkgs.channels; cfg = config.nixpkgs.channels;
in { in {
options.nixpkgs.channels = lib.mkOption { options.nixpkgs.channels = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrsOf (lib.types.attrs);
default = {}; default = {};
description = "Declare package repositories"; description = "Declare package repositories per module context (nixos, home-manager, etc)";
example = { example = {
"homes" = {
"pkgs" = { "pkgs" = {
source = "inputs.nixpkgs"; source = "inputs.nixpkgs";
system = "x86-64-linux"; system = "x86-64-linux";
@ -42,51 +43,57 @@ in {
source = "inputs.nixpkgs-unstable"; source = "inputs.nixpkgs-unstable";
system = "x86-64-linux"; system = "x86-64-linux";
config = { config = {
allowUnfree = false; allowUnfree = true;
allowBroken = true; allowBroken = false;
};
}; };
}; };
}; };
}; };
config = let config = let
# TODO: use lib.types.submodule to restrict what options
# TODO: can be given to `nixpkgs.channels.${moduleName}.${name}`
decl =
cfg.${contextName} or cfg.default;
repos = repos =
cfg decl
|> (xs: removeAttrs xs ["default"])
|> mapAttrs ( |> mapAttrs (
name: args: name: args:
lib.mkForce ( lib.mkForce (
assert args ? source assert args ? source
|| abort '' || abort ''
`nixpkgs.channels.${name}` missing required attribute "source" ${toString ./.}
`nixpkgs.channels.${contextName}.${name}` missing required attribute "source"
''; '';
import args.source ({inherit system;} // (removeAttrs args ["source"])) ((removeAttrs args ["source"])
// {inherit system;})
|> import args.source
) )
); );
# XXX: TODO: would it work to use `base` instead of having default?
defaultPkgs =
cfg.default or (throw ''
Your `nixpkgs.nix` file does not declare a default package source.
Ensure you set `nixpkgs.channels.*.default = ...;`
'');
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.
_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 then {
# DEBUG: defaultPkgs flake.source = lib.mkOverride 200 defaultPkgs.source;
{ config = lib.mkOverride 200 defaultPkgs.config;
flake.source = lib.mkOverride 200 (defaultPkgs.source or null);
overlays = lib.mkOverride 200 (defaultPkgs.overlays or {});
config = lib.mkOverride 200 (defaultPkgs.config or {});
} }
else if contextName == "homes" else if contextName == "homes"
then { then {
# XXX: XXX: XXX: OH OH OH OMG, its because aurora never defines pkgs
config = lib.mkOverride 200 (defaultPkgs.config or {}); config = lib.mkOverride 200 (defaultPkgs.config or {});
# XXX: WARNING: TODO: modify options so overlays must always be given as the correct type
overlays = lib.mkOverride 200 (defaultPkgs.overlays or []); overlays = lib.mkOverride 200 (defaultPkgs.overlays or []);
} }
else {}; else {};