mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 09:05:58 -05:00
style: fmt
This commit is contained in:
@@ -90,7 +90,8 @@ in
|
|||||||
## ```
|
## ```
|
||||||
## Result: Merged items with aliases applied
|
## Result: Merged items with aliases applied
|
||||||
#@ (Attrs -> Attrs -> Attrs) -> [Attrs] -> Attrs -> Attrs
|
#@ (Attrs -> Attrs -> Attrs) -> [Attrs] -> Attrs -> Attrs
|
||||||
merge-with-aliases = merge-fn: items: alias:
|
merge-with-aliases =
|
||||||
|
merge-fn: items: alias:
|
||||||
let
|
let
|
||||||
merged = foldl merge-fn { } items;
|
merged = foldl merge-fn { } items;
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
## { another-check = ...; my-check = ...; default = ...; }
|
## { another-check = ...; my-check = ...; default = ...; }
|
||||||
## ```
|
## ```
|
||||||
#@ Attrs -> Attrs
|
#@ Attrs -> Attrs
|
||||||
create-checks = args:
|
create-checks =
|
||||||
snowfall-lib.internal.create-simple-derivations (args // { type = "checks"; });
|
args: snowfall-lib.internal.create-simple-derivations (args // { type = "checks"; });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,15 +50,13 @@ let
|
|||||||
# result: { x = nixpkgs.lib; }
|
# result: { x = nixpkgs.lib; }
|
||||||
get-libs =
|
get-libs =
|
||||||
attrs:
|
attrs:
|
||||||
fold
|
fold (
|
||||||
(name: acc:
|
name: acc:
|
||||||
let value = attrs.${name}; in
|
let
|
||||||
if builtins.isAttrs (value.lib or null)
|
value = attrs.${name};
|
||||||
then acc // { ${name} = value.lib; }
|
in
|
||||||
else acc
|
if builtins.isAttrs (value.lib or null) then acc // { ${name} = value.lib; } else acc
|
||||||
)
|
) { } (builtins.attrNames attrs);
|
||||||
{ }
|
|
||||||
(builtins.attrNames attrs);
|
|
||||||
|
|
||||||
# Remove the `self` attribute from an attribute set.
|
# Remove the `self` attribute from an attribute set.
|
||||||
# Type: Attrs -> Attrs
|
# Type: Attrs -> Attrs
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ let
|
|||||||
;
|
;
|
||||||
in
|
in
|
||||||
let
|
let
|
||||||
flake = let
|
flake =
|
||||||
|
let
|
||||||
## Remove the `self` attribute from an attribute set.
|
## Remove the `self` attribute from an attribute set.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
## ```nix
|
## ```nix
|
||||||
@@ -44,7 +45,8 @@ let
|
|||||||
## ```
|
## ```
|
||||||
#@ Attrs -> Attrs
|
#@ Attrs -> Attrs
|
||||||
without-src = flake-inputs: builtins.removeAttrs flake-inputs [ "src" ];
|
without-src = flake-inputs: builtins.removeAttrs flake-inputs [ "src" ];
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit without-self without-src;
|
inherit without-self without-src;
|
||||||
|
|
||||||
## Remove the `src` and `self` attributes from an attribute set.
|
## Remove the `src` and `self` attributes from an attribute set.
|
||||||
@@ -227,9 +229,7 @@ let
|
|||||||
(mapAttrs (home-name: _: flake-outputs.homeConfigurations.${home-name}))
|
(mapAttrs (home-name: _: flake-outputs.homeConfigurations.${home-name}))
|
||||||
(mapAttrs' (
|
(mapAttrs' (
|
||||||
name: value:
|
name: value:
|
||||||
nameValuePair
|
nameValuePair (if hasSuffix "@${system}" name then removeSuffix "@${system}" name else name) value
|
||||||
(if hasSuffix "@${system}" name then removeSuffix "@${system}" name else name)
|
|
||||||
value
|
|
||||||
))
|
))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ let
|
|||||||
inherit (core-inputs.nixpkgs.lib) id foldr flip;
|
inherit (core-inputs.nixpkgs.lib) id foldr flip;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
fp = let
|
fp =
|
||||||
|
let
|
||||||
## Compose two functions.
|
## Compose two functions.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
## ```nix
|
## ```nix
|
||||||
@@ -35,7 +36,8 @@ in
|
|||||||
## ```
|
## ```
|
||||||
#@ (a -> b) -> a -> b
|
#@ (a -> b) -> a -> b
|
||||||
call = f: x: f x;
|
call = f: x: f x;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit compose call;
|
inherit compose call;
|
||||||
|
|
||||||
## Compose many functions.
|
## Compose many functions.
|
||||||
|
|||||||
@@ -122,8 +122,7 @@ in
|
|||||||
## ```
|
## ```
|
||||||
#@ Path -> [Path]
|
#@ Path -> [Path]
|
||||||
get-directories-with-default =
|
get-directories-with-default =
|
||||||
path:
|
path: builtins.filter (dir: pathExists "${dir}/default.nix") (get-directories path);
|
||||||
builtins.filter (dir: pathExists "${dir}/default.nix") (get-directories path);
|
|
||||||
|
|
||||||
## Get files at a given path.
|
## Get files at a given path.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
@@ -234,7 +233,9 @@ in
|
|||||||
## [ "./something/some-directory/default.nix" ]
|
## [ "./something/some-directory/default.nix" ]
|
||||||
## ```
|
## ```
|
||||||
#@ Path -> [Path]
|
#@ 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".
|
## Get nix files at a given path not named "default.nix".
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
@@ -246,8 +247,9 @@ in
|
|||||||
## [ "./something/a.nix" ]
|
## [ "./something/a.nix" ]
|
||||||
## ```
|
## ```
|
||||||
#@ Path -> [Path]
|
#@ Path -> [Path]
|
||||||
get-non-default-nix-files = filter-files (f:
|
get-non-default-nix-files = filter-files (
|
||||||
snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix");
|
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.
|
## Get nix files at a given path not named "default.nix", traversing any directories within.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
@@ -259,7 +261,8 @@ in
|
|||||||
## [ "./something/some-directory/a.nix" ]
|
## [ "./something/some-directory/a.nix" ]
|
||||||
## ```
|
## ```
|
||||||
#@ Path -> [Path]
|
#@ Path -> [Path]
|
||||||
get-non-default-nix-files-recursive = filter-files-recursive (f:
|
get-non-default-nix-files-recursive = filter-files-recursive (
|
||||||
snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix");
|
f: snowfall-lib.path.has-file-extension "nix" f && builtins.baseNameOf f != "default.nix"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ let
|
|||||||
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home = let
|
home =
|
||||||
|
let
|
||||||
# Modules in home-manager expect `hm` to be available directly on `lib` itself.
|
# Modules in home-manager expect `hm` to be available directly on `lib` itself.
|
||||||
home-lib =
|
home-lib =
|
||||||
# NOTE: This prevents an error during evaluation if the input does
|
# NOTE: This prevents an error during evaluation if the input does
|
||||||
@@ -428,7 +429,8 @@ in
|
|||||||
++ shared-modules
|
++ shared-modules
|
||||||
++ shared-user-modules
|
++ shared-user-modules
|
||||||
++ system-modules;
|
++ system-modules;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit
|
inherit
|
||||||
home-lib
|
home-lib
|
||||||
split-user-and-host
|
split-user-and-host
|
||||||
|
|||||||
@@ -66,13 +66,14 @@ in
|
|||||||
internal = {
|
internal = {
|
||||||
inherit system-lib user-lib;
|
inherit system-lib user-lib;
|
||||||
|
|
||||||
create-simple-derivations = {
|
create-simple-derivations =
|
||||||
|
{
|
||||||
type,
|
type,
|
||||||
channels,
|
channels,
|
||||||
src ? snowfall-lib.fs.get-snowfall-file type,
|
src ? snowfall-lib.fs.get-snowfall-file type,
|
||||||
pkgs ? channels.nixpkgs,
|
pkgs ? channels.nixpkgs,
|
||||||
overrides ? {},
|
overrides ? { },
|
||||||
alias ? {},
|
alias ? { },
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
user-items = snowfall-lib.fs.get-default-nix-files-recursive src;
|
user-items = snowfall-lib.fs.get-default-nix-files-recursive src;
|
||||||
@@ -80,19 +81,19 @@ in
|
|||||||
create-metadata = item: {
|
create-metadata = item: {
|
||||||
name = snowfall-lib.path.get-output-name item;
|
name = snowfall-lib.path.get-output-name item;
|
||||||
drv = callPackageWith (
|
drv = callPackageWith (
|
||||||
pkgs // {
|
pkgs
|
||||||
|
// {
|
||||||
inherit channels;
|
inherit channels;
|
||||||
lib = system-lib;
|
lib = system-lib;
|
||||||
inputs = snowfall-lib.flake.without-src user-inputs;
|
inputs = snowfall-lib.flake.without-src user-inputs;
|
||||||
namespace = snowfall-config.namespace;
|
namespace = snowfall-config.namespace;
|
||||||
}
|
}
|
||||||
) item {};
|
) item { };
|
||||||
};
|
};
|
||||||
|
|
||||||
items-metadata = builtins.map create-metadata user-items;
|
items-metadata = builtins.map create-metadata user-items;
|
||||||
|
|
||||||
merge-items = items: metadata:
|
merge-items = items: metadata: items // { ${metadata.name} = metadata.drv; };
|
||||||
items // { ${metadata.name} = metadata.drv; };
|
|
||||||
|
|
||||||
items = snowfall-lib.attrs.merge-with-aliases merge-items items-metadata alias // overrides;
|
items = snowfall-lib.attrs.merge-with-aliases merge-items items-metadata alias // overrides;
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -5,7 +5,13 @@
|
|||||||
snowfall-config,
|
snowfall-config,
|
||||||
}:
|
}:
|
||||||
let
|
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-overlays-root = snowfall-lib.fs.get-snowfall-file "overlays";
|
||||||
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
|
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
|
||||||
@@ -191,7 +197,9 @@ in
|
|||||||
|
|
||||||
default-overlay =
|
default-overlay =
|
||||||
final: prev:
|
final: prev:
|
||||||
pipe [ package-overlays overlays ] [
|
pipe
|
||||||
|
[ package-overlays overlays ]
|
||||||
|
[
|
||||||
(builtins.map builtins.attrValues)
|
(builtins.map builtins.attrValues)
|
||||||
flatten
|
flatten
|
||||||
(builtins.map (overlay: overlay final prev))
|
(builtins.map (overlay: overlay final prev))
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ let
|
|||||||
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
|
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
package = let
|
package =
|
||||||
|
let
|
||||||
## Create flake output packages.
|
## Create flake output packages.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
## ```nix
|
## ```nix
|
||||||
@@ -89,7 +90,8 @@ in
|
|||||||
packages = snowfall-lib.attrs.apply-aliases-and-overrides packages-without-aliases alias overrides;
|
packages = snowfall-lib.attrs.apply-aliases-and-overrides packages-without-aliases alias overrides;
|
||||||
in
|
in
|
||||||
filterPackages pkgs.stdenv.hostPlatform.system packages;
|
filterPackages pkgs.stdenv.hostPlatform.system packages;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit create-packages;
|
inherit create-packages;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ let
|
|||||||
dirOf
|
dirOf
|
||||||
concatStringsSep
|
concatStringsSep
|
||||||
;
|
;
|
||||||
inherit (core-inputs.nixpkgs.lib) assertMsg last init hasPrefix;
|
inherit (core-inputs.nixpkgs.lib)
|
||||||
|
assertMsg
|
||||||
|
last
|
||||||
|
init
|
||||||
|
hasPrefix
|
||||||
|
;
|
||||||
|
|
||||||
file-name-regex = "(.*)\\.(.*)$";
|
file-name-regex = "(.*)\\.(.*)$";
|
||||||
in
|
in
|
||||||
@@ -131,9 +136,7 @@ in
|
|||||||
## "bar"
|
## "bar"
|
||||||
## ```
|
## ```
|
||||||
#@ Path -> String
|
#@ Path -> String
|
||||||
get-output-name = snowfall-lib.fp.compose
|
get-output-name = snowfall-lib.fp.compose builtins.unsafeDiscardStringContext get-parent-directory;
|
||||||
builtins.unsafeDiscardStringContext
|
|
||||||
get-parent-directory;
|
|
||||||
|
|
||||||
## Get the directory name for flake outputs.
|
## Get the directory name for flake outputs.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
@@ -145,9 +148,7 @@ in
|
|||||||
## "foo"
|
## "foo"
|
||||||
## ```
|
## ```
|
||||||
#@ Path -> String
|
#@ Path -> String
|
||||||
get-directory-name = snowfall-lib.fp.compose
|
get-directory-name = snowfall-lib.fp.compose builtins.unsafeDiscardStringContext baseNameOf;
|
||||||
builtins.unsafeDiscardStringContext
|
|
||||||
baseNameOf;
|
|
||||||
|
|
||||||
## Get relative module path from source directory.
|
## Get relative module path from source directory.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
## { another-shell = ...; my-shell = ...; default = ...; }
|
## { another-shell = ...; my-shell = ...; default = ...; }
|
||||||
## ```
|
## ```
|
||||||
#@ Attrs -> Attrs
|
#@ Attrs -> Attrs
|
||||||
create-shells = args:
|
create-shells =
|
||||||
snowfall-lib.internal.create-simple-derivations (args // { type = "shells"; });
|
args: snowfall-lib.internal.create-simple-derivations (args // { type = "shells"; });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ let
|
|||||||
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
system = let
|
system =
|
||||||
|
let
|
||||||
## Get the name of a system based on its file path.
|
## Get the name of a system based on its file path.
|
||||||
## Example Usage:
|
## Example Usage:
|
||||||
## ```nix
|
## ```nix
|
||||||
@@ -348,7 +349,8 @@ in
|
|||||||
);
|
);
|
||||||
in
|
in
|
||||||
created-systems;
|
created-systems;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit
|
inherit
|
||||||
get-inferred-system-name
|
get-inferred-system-name
|
||||||
is-darwin
|
is-darwin
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ in
|
|||||||
unused-overrides = builtins.removeAttrs overrides (
|
unused-overrides = builtins.removeAttrs overrides (
|
||||||
builtins.map (metadata: metadata.name) templates-metadata
|
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
|
in
|
||||||
templates;
|
templates;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user