style: fmt

This commit is contained in:
anntnzrb
2025-10-09 00:06:31 -05:00
parent e0be5043e5
commit 7d7ff85b41
14 changed files with 1008 additions and 987 deletions

View File

@@ -90,7 +90,8 @@ in
## ```
## Result: Merged items with aliases applied
#@ (Attrs -> Attrs -> Attrs) -> [Attrs] -> Attrs -> Attrs
merge-with-aliases = merge-fn: items: alias:
merge-with-aliases =
merge-fn: items: alias:
let
merged = foldl merge-fn { } items;
in

View File

@@ -16,7 +16,7 @@
## { another-check = ...; my-check = ...; default = ...; }
## ```
#@ Attrs -> Attrs
create-checks = args:
snowfall-lib.internal.create-simple-derivations (args // { type = "checks"; });
create-checks =
args: snowfall-lib.internal.create-simple-derivations (args // { type = "checks"; });
};
}

View File

@@ -50,15 +50,13 @@ let
# result: { x = nixpkgs.lib; }
get-libs =
attrs:
fold
(name: acc:
let value = attrs.${name}; in
if builtins.isAttrs (value.lib or null)
then acc // { ${name} = value.lib; }
else acc
)
{ }
(builtins.attrNames attrs);
fold (
name: acc:
let
value = attrs.${name};
in
if builtins.isAttrs (value.lib or null) then acc // { ${name} = value.lib; } else acc
) { } (builtins.attrNames attrs);
# Remove the `self` attribute from an attribute set.
# Type: Attrs -> Attrs

View File

@@ -20,7 +20,8 @@ let
;
in
let
flake = let
flake =
let
## Remove the `self` attribute from an attribute set.
## Example Usage:
## ```nix
@@ -44,7 +45,8 @@ let
## ```
#@ Attrs -> Attrs
without-src = flake-inputs: builtins.removeAttrs flake-inputs [ "src" ];
in {
in
{
inherit without-self without-src;
## Remove the `src` and `self` attributes from an attribute set.
@@ -227,9 +229,7 @@ let
(mapAttrs (home-name: _: flake-outputs.homeConfigurations.${home-name}))
(mapAttrs' (
name: value:
nameValuePair
(if hasSuffix "@${system}" name then removeSuffix "@${system}" name else name)
value
nameValuePair (if hasSuffix "@${system}" name then removeSuffix "@${system}" name else name) value
))
];
};

View File

@@ -9,7 +9,8 @@ let
inherit (core-inputs.nixpkgs.lib) id foldr flip;
in
{
fp = let
fp =
let
## Compose two functions.
## Example Usage:
## ```nix
@@ -35,7 +36,8 @@ in
## ```
#@ (a -> b) -> a -> b
call = f: x: f x;
in {
in
{
inherit compose call;
## Compose many functions.

View File

@@ -122,8 +122,7 @@ in
## ```
#@ Path -> [Path]
get-directories-with-default =
path:
builtins.filter (dir: pathExists "${dir}/default.nix") (get-directories path);
path: builtins.filter (dir: pathExists "${dir}/default.nix") (get-directories path);
## Get files at a given path.
## Example Usage:
@@ -234,7 +233,9 @@ in
## [ "./something/some-directory/default.nix" ]
## ```
#@ Path -> [Path]
get-default-nix-files-recursive = filter-files-recursive (f: builtins.baseNameOf f == "default.nix");
get-default-nix-files-recursive = filter-files-recursive (
f: builtins.baseNameOf f == "default.nix"
);
## Get nix files at a given path not named "default.nix".
## Example Usage:
@@ -246,8 +247,9 @@ in
## [ "./something/a.nix" ]
## ```
#@ Path -> [Path]
get-non-default-nix-files = filter-files (f:
snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix");
get-non-default-nix-files = filter-files (
f: snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix"
);
## Get nix files at a given path not named "default.nix", traversing any directories within.
## Example Usage:
@@ -259,7 +261,8 @@ in
## [ "./something/some-directory/a.nix" ]
## ```
#@ Path -> [Path]
get-non-default-nix-files-recursive = filter-files-recursive (f:
snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix");
get-non-default-nix-files-recursive = filter-files-recursive (
f: snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix"
);
};
}

View File

@@ -33,7 +33,8 @@ let
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
in
{
home = let
home =
let
# Modules in home-manager expect `hm` to be available directly on `lib` itself.
home-lib =
# NOTE: This prevents an error during evaluation if the input does
@@ -428,7 +429,8 @@ in
++ shared-modules
++ shared-user-modules
++ system-modules;
in {
in
{
inherit
home-lib
split-user-and-host

View File

@@ -66,13 +66,14 @@ in
internal = {
inherit system-lib user-lib;
create-simple-derivations = {
create-simple-derivations =
{
type,
channels,
src ? snowfall-lib.fs.get-snowfall-file type,
pkgs ? channels.nixpkgs,
overrides ? {},
alias ? {},
overrides ? { },
alias ? { },
}:
let
user-items = snowfall-lib.fs.get-default-nix-files-recursive src;
@@ -80,19 +81,19 @@ in
create-metadata = item: {
name = snowfall-lib.path.get-output-name item;
drv = callPackageWith (
pkgs // {
pkgs
// {
inherit channels;
lib = system-lib;
inputs = snowfall-lib.flake.without-src user-inputs;
namespace = snowfall-config.namespace;
}
) item {};
) item { };
};
items-metadata = builtins.map create-metadata user-items;
merge-items = items: metadata:
items // { ${metadata.name} = metadata.drv; };
merge-items = items: metadata: items // { ${metadata.name} = metadata.drv; };
items = snowfall-lib.attrs.merge-with-aliases merge-items items-metadata alias // overrides;
in

View File

@@ -5,7 +5,13 @@
snowfall-config,
}:
let
inherit (core-inputs.nixpkgs.lib) assertMsg foldl concatStringsSep pipe flatten;
inherit (core-inputs.nixpkgs.lib)
assertMsg
foldl
concatStringsSep
pipe
flatten
;
user-overlays-root = snowfall-lib.fs.get-snowfall-file "overlays";
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
@@ -191,7 +197,9 @@ in
default-overlay =
final: prev:
pipe [ package-overlays overlays ] [
pipe
[ package-overlays overlays ]
[
(builtins.map builtins.attrValues)
flatten
(builtins.map (overlay: overlay final prev))

View File

@@ -18,7 +18,8 @@ let
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
in
{
package = let
package =
let
## Create flake output packages.
## Example Usage:
## ```nix
@@ -89,7 +90,8 @@ in
packages = snowfall-lib.attrs.apply-aliases-and-overrides packages-without-aliases alias overrides;
in
filterPackages pkgs.stdenv.hostPlatform.system packages;
in {
in
{
inherit create-packages;
};
}

View File

@@ -11,7 +11,12 @@ let
dirOf
concatStringsSep
;
inherit (core-inputs.nixpkgs.lib) assertMsg last init hasPrefix;
inherit (core-inputs.nixpkgs.lib)
assertMsg
last
init
hasPrefix
;
file-name-regex = "(.*)\\.(.*)$";
in
@@ -131,9 +136,7 @@ in
## "bar"
## ```
#@ Path -> String
get-output-name = snowfall-lib.fp.compose
builtins.unsafeDiscardStringContext
get-parent-directory;
get-output-name = snowfall-lib.fp.compose builtins.unsafeDiscardStringContext get-parent-directory;
## Get the directory name for flake outputs.
## Example Usage:
@@ -145,9 +148,7 @@ in
## "foo"
## ```
#@ Path -> String
get-directory-name = snowfall-lib.fp.compose
builtins.unsafeDiscardStringContext
baseNameOf;
get-directory-name = snowfall-lib.fp.compose builtins.unsafeDiscardStringContext baseNameOf;
## Get relative module path from source directory.
## Example Usage:

View File

@@ -16,7 +16,7 @@
## { another-shell = ...; my-shell = ...; default = ...; }
## ```
#@ Attrs -> Attrs
create-shells = args:
snowfall-lib.internal.create-simple-derivations (args // { type = "shells"; });
create-shells =
args: snowfall-lib.internal.create-simple-derivations (args // { type = "shells"; });
};
}

View File

@@ -22,7 +22,8 @@ let
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
in
{
system = let
system =
let
## Get the name of a system based on its file path.
## Example Usage:
## ```nix
@@ -348,7 +349,8 @@ in
);
in
created-systems;
in {
in
{
inherit
get-inferred-system-name
is-darwin

View File

@@ -56,7 +56,8 @@ in
unused-overrides = builtins.removeAttrs overrides (
builtins.map (metadata: metadata.name) templates-metadata
);
templates = snowfall-lib.attrs.merge-with-aliases merge-templates templates-metadata alias // unused-overrides;
templates =
snowfall-lib.attrs.merge-with-aliases merge-templates templates-metadata alias // unused-overrides;
in
templates;
};