feat: internal namespacing and callPackageWith for better ux

This commit is contained in:
Jake Hamilton 2023-01-15 14:52:52 -08:00
parent 0ba4256dbd
commit 7def9101de
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
7 changed files with 70 additions and 60 deletions

View file

@ -5,7 +5,7 @@
let
inherit (core-inputs.flake-utils-plus.lib) filterPackages;
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs;
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs callPackageWith;
user-shells-root = snowfall-lib.fs.get-snowfall-file "shells";
in
@ -18,19 +18,23 @@ in
create-shells =
{ channels
, src ? user-shells-root
, pkgs ? channels.nixpkgs
, overrides ? { }
, alias ? { }
}:
let
user-shells = snowfall-lib.fs.get-default-nix-files-recursive src;
create-shell-metadata = shell:
{
name = builtins.unsafeDiscardStringContext (snowfall-lib.path.get-parent-directory shell);
drv = channels.nixpkgs.callPackage shell {
let
extra-inputs = pkgs // {
inherit channels;
lib = snowfall-lib.internal.system-lib;
inputs = snowfall-lib.flake.without-src user-inputs;
};
in
{
name = builtins.unsafeDiscardStringContext (snowfall-lib.path.get-parent-directory shell);
drv = callPackageWith extra-inputs shell { };
};
shells-metadata = builtins.map create-shell-metadata user-shells;
merge-shells = shells: metadata:
@ -41,8 +45,6 @@ in
aliased-shells = mapAttrs (name: value: shells-without-aliases.${value}) alias;
shells = shells-without-aliases // aliased-shells // overrides;
in
filterPackages
channels.nixpkgs.system
shells;
filterPackages pkgs.system shells;
};
}