feat: aliases and custom snowfall root
This commit is contained in:
parent
d8a08681a9
commit
cbe1b6e0fb
9 changed files with 126 additions and 85 deletions
|
|
@ -4,20 +4,22 @@
|
|||
}:
|
||||
|
||||
let
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl;
|
||||
inherit (core-inputs.flake-utils-plus.lib) filterPackages;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs;
|
||||
|
||||
user-shells-root = snowfall-lib.fs.get-file "shells";
|
||||
user-shells-root = snowfall-lib.fs.get-snowfall-file "shells";
|
||||
in
|
||||
{
|
||||
shell = {
|
||||
# Create flake output packages.
|
||||
# Type: Attrs -> Attrs
|
||||
# Usage: create-shells { inherit channels; src = ./my-shells; overrides = { inherit another-shell; default = "my-shell"; }; }
|
||||
# Usage: create-shells { inherit channels; src = ./my-shells; overrides = { inherit another-shell; }; alias = { default = "another-shell"; }; }
|
||||
# result: { another-shell = ...; my-shell = ...; default = ...; }
|
||||
create-shells =
|
||||
{ channels
|
||||
, src ? user-shells-root
|
||||
, overrides ? { }
|
||||
, alias ? { }
|
||||
}:
|
||||
let
|
||||
user-shells = snowfall-lib.fs.get-default-nix-files-recursive src;
|
||||
|
|
@ -35,19 +37,12 @@ in
|
|||
shells // {
|
||||
${metadata.name} = metadata.drv;
|
||||
};
|
||||
shells-without-default = foldl merge-shells { } shells-metadata;
|
||||
default-shell =
|
||||
if overrides.default or null == null then
|
||||
{ }
|
||||
else if builtins.isAttrs overrides.default then
|
||||
{ default = overrides.default; }
|
||||
else if shells-without-default.${overrides.default} or null != null then
|
||||
{ default = shells-without-default.${overrides.default}; }
|
||||
else
|
||||
{ };
|
||||
overrides-without-default = builtins.removeAttrs overrides [ "default" ];
|
||||
shells = shells-without-default // default-shell // overrides-without-default;
|
||||
shells-without-aliases = foldl merge-shells { } shells-metadata;
|
||||
aliased-shells = mapAttrs (name: value: shells-without-aliases.${value}) alias;
|
||||
shells = shells-without-aliases // aliased-shells // overrides;
|
||||
in
|
||||
shells;
|
||||
filterPackages
|
||||
channels.nixpkgs.system
|
||||
shells;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue