Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pass through individual channel configuration #128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions snowfall-lib/flake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
snowfall-lib,
snowfall-config,
}: let
inherit (core-inputs.nixpkgs.lib) assertMsg foldl filterAttrs const;
inherit (core-inputs.nixpkgs.lib) const filterAttrs mapAttrs traceVal;
in rec {
flake = rec {
## Remove the `self` attribute from an attribute set.
Expand Down Expand Up @@ -128,6 +128,7 @@ in rec {
inherit namespace;
extra-overlays = full-flake-options.extra-exported-overlays or {};
};
channels = full-flake-options.channels or {};

outputs-builder = channels: let
user-outputs-builder =
Expand Down Expand Up @@ -172,12 +173,22 @@ in rec {
darwinModules = darwin-modules;
homeModules = home-modules;

channelsConfig = full-flake-options.channels-config or {};

channels.nixpkgs.overlaysBuilder = snowfall-lib.overlay.create-overlays-builder {
inherit namespace;
extra-overlays = full-flake-options.overlays or [];
};
channelsConfig =
full-flake-options.channels-config
or full-flake-options.channelsConfig
or {};

channels =
mapAttrs
(channel: config:
config
// {
overlaysBuilder = snowfall-lib.overlay.create-overlays-builder {
inherit namespace;
extra-overlays = full-flake-options.overlays or [];
};
})
({nixpkgs = {};} // channels);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the default nixpkgs here if we are allowing fully dynamic channel configuration? I think it is possible that the user has channels other than one named nixpkgs. The previous version of Snowfall Lib made the assumption that inputs.nixpkgs would always exist, but maybe we don't need to anymore.

Copy link
Author

@lpchaim lpchaim Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's still desirable as a fallback. As is, removing it means no inputs are processed at all if the user doesn't go out of their way to configure specific channels, which breaks some valid configurations.

I tried to automatically discover nixpkgs inputs to apply the overlays to all of them out of the box and found some existing solutions but since they tended to feel quite hacky, I went with this because it's backwards compatible with the original behavior while still allowing for user customization. I figured nixpkgs + a handful of oddball channels would fit the vast majority of use cases, so it didn't sound worth the trouble.


outputsBuilder = outputs-builder;

Expand Down