From a8025edb45ce976f1715d6494ea91af3db7917e5 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Wed, 8 Oct 2025 23:28:36 -0500 Subject: [PATCH] refactor(shell): use create-simple-derivations helper --- snowfall-lib/shell/default.nix | 51 ++-------------------------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/snowfall-lib/shell/default.nix b/snowfall-lib/shell/default.nix index fae6832..5173e37 100644 --- a/snowfall-lib/shell/default.nix +++ b/snowfall-lib/shell/default.nix @@ -4,20 +4,9 @@ snowfall-lib, snowfall-config, }: -let - inherit (core-inputs.flake-utils-plus.lib) filterPackages; - inherit (core-inputs.nixpkgs.lib) - assertMsg - foldl - mapAttrs - callPackageWith - ; - - user-shells-root = snowfall-lib.fs.get-snowfall-file "shells"; -in { shell = { - ## Create flake output packages. + ## Create flake output shells. ## Example Usage: ## ```nix ## create-shells { inherit channels; src = ./my-shells; overrides = { inherit another-shell; }; alias = { default = "another-shell"; }; } @@ -27,41 +16,7 @@ in ## { another-shell = ...; my-shell = ...; default = ...; } ## ``` #@ Attrs -> Attrs - 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: - let - extra-inputs = pkgs // { - inherit channels; - lib = snowfall-lib.internal.system-lib; - inputs = snowfall-lib.flake.without-src user-inputs; - namespace = snowfall-config.namespace; - }; - in - { - # We are building flake outputs based on file paths. Nix doesn't allow this - # so we have to explicitly discard the string's path context to use it as an attribute name. - 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: - shells - // { - ${metadata.name} = metadata.drv; - }; - shells = snowfall-lib.attrs.merge-with-aliases merge-shells shells-metadata alias // overrides; - in - filterPackages pkgs.stdenv.hostPlatform.system shells; + create-shells = args: + snowfall-lib.internal.create-simple-derivations (args // { type = "shells"; }); }; }