Skip to content

Commit

Permalink
feat(flake): inputs as GC roots
Browse files Browse the repository at this point in the history
  • Loading branch information
panchoh committed Feb 16, 2024
1 parent 0d85363 commit dea3433
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/collect-flake-inputs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
flake: let
collectFlakeInputs = input:
[input]
++ builtins.concatMap collectFlakeInputs (
builtins.attrValues (
input.inputs or {}
)
);
in
collectFlakeInputs flake
2 changes: 1 addition & 1 deletion lib/configurations.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ builtins.listToAttrs (
specialArgs =
inputs
// {
inherit (inputs.self.lib) hmModule;
inherit (inputs.self.lib) flakeInputsClosure hmModule;
inherit box;
};
};
Expand Down
2 changes: 2 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
inputs: {
flakeInputsClosure = import ./collect-flake-inputs.nix inputs.self;

boxen = import ./boxen.nix inputs;

fmt-alejandra = import ./fmt-alejandra.nix inputs;
Expand Down
16 changes: 16 additions & 0 deletions modules/traits/flake-sources/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
config,
lib,
flakeInputsClosure,
...
}: let
cfg = config.traits.flake-sources;
in {
options.traits.flake-sources = {
enable = lib.mkEnableOption "flake inputs as GC roots (recursively)" // {default = true;};
};

config = lib.mkIf cfg.enable {
system.extraDependencies = flakeInputsClosure;
};
}

0 comments on commit dea3433

Please sign in to comment.