style(nix): apply nix fmt

Normalize formatting with the treefmt-based nix fmt configuration.
This commit is contained in:
anntnzrb
2026-02-04 23:33:00 -05:00
committed by mjallen18
parent 797700f47a
commit 70ad5e14ae
20 changed files with 40 additions and 102 deletions

View File

@@ -1,7 +1,6 @@
{
pkgs,
lib,
options,
config,
inputs,
...

View File

@@ -1,7 +1,6 @@
inputs@{
pkgs,
lib,
options,
config,
...
}:

View File

@@ -1,7 +1,6 @@
args@{
pkgs,
lib,
options,
config,
...
}:

View File

@@ -1,12 +1,8 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
let
inherit (core-inputs.nixpkgs.lib)
assertMsg
mapAttrsToList
mapAttrs
flatten
@@ -95,7 +91,7 @@ in
let
merged = foldl merge-fn { } items;
in
merged // mapAttrs (name: value: merged.${value}) alias;
merged // mapAttrs (_name: value: merged.${value}) alias;
## Apply aliases and overrides to an already-merged attribute set.
## Use this when you have a pre-built attribute set (e.g., from fix).
@@ -108,7 +104,7 @@ in
apply-aliases-and-overrides =
items: alias: overrides:
let
aliased = mapAttrs (name: value: items.${value}) alias;
aliased = mapAttrs (_name: value: items.${value}) alias;
in
items // aliased // overrides;
};

View File

@@ -1,8 +1,5 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
{
check = {

View File

@@ -6,7 +6,7 @@ core-inputs: user-options:
let
raw-snowfall-config = user-options.snowfall or { };
snowfall-config = raw-snowfall-config // {
src = user-options.src;
inherit (user-options) src;
root = raw-snowfall-config.root or user-options.src;
namespace = raw-snowfall-config.namespace or "internal";
meta = {
@@ -16,7 +16,7 @@ let
};
user-inputs = user-options.inputs // {
src = user-options.src;
inherit (user-options) src;
};
inherit (core-inputs.nixpkgs.lib)
@@ -73,7 +73,7 @@ let
snowfall-lib-dirs =
let
files = builtins.readDir snowfall-lib-root;
dirs = filterAttrs (name: kind: kind == "directory") files;
dirs = filterAttrs (_name: kind: kind == "directory") files;
names = builtins.attrNames dirs;
in
names;
@@ -94,7 +94,7 @@ let
merge-deep libs
);
snowfall-top-level-lib = filterAttrs (name: value: !builtins.isAttrs value) snowfall-lib;
snowfall-top-level-lib = filterAttrs (_name: value: !builtins.isAttrs value) snowfall-lib;
base-lib = merge-shallow [
core-inputs.nixpkgs.lib
@@ -113,7 +113,7 @@ let
attrs = {
inherit (user-options) inputs;
snowfall-inputs = core-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
lib = merge-shallow [
base-lib
{ ${snowfall-config.namespace} = user-lib; }

View File

@@ -6,8 +6,6 @@
}:
let
inherit (core-inputs.nixpkgs.lib)
assertMsg
foldl
filterAttrs
const
mapAttrs
@@ -15,11 +13,9 @@ let
hasSuffix
removeSuffix
nameValuePair
traceVal
pipe
;
in
let
flake =
let
## Remove the `self` attribute from an attribute set.
@@ -103,8 +99,8 @@ let
get-libs =
attrs:
pipe attrs [
(filterAttrs (name: value: builtins.isAttrs (value.lib or null)))
(mapAttrs (name: value: value.lib))
(filterAttrs (_name: value: builtins.isAttrs (value.lib or null)))
(mapAttrs (_name: value: value.lib))
];
};
@@ -191,7 +187,7 @@ let
channelsConfig = full-flake-options.channels-config or full-flake-options.channelsConfig or { };
channels = mapAttrs (
channel: config:
_channel: config:
config
// {
overlaysBuilder = snowfall-lib.overlay.create-overlays-builder {
@@ -206,7 +202,7 @@ let
snowfall = {
config = snowfall-config;
raw-config = full-flake-options.snowfall or { };
user-lib = snowfall-lib.internal.user-lib;
inherit (snowfall-lib.internal) user-lib;
};
};

View File

@@ -1,11 +1,7 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
let
inherit (builtins) baseNameOf dirOf;
inherit (core-inputs.nixpkgs.lib) id foldr flip;
in
{
@@ -35,7 +31,7 @@ in
## 1
## ```
#@ (a -> b) -> a -> b
call = f: x: f x;
call = f: f;
in
{
inherit compose call;

View File

@@ -6,16 +6,11 @@
}:
let
inherit (builtins) readDir pathExists;
inherit (core-inputs) flake-utils-plus;
inherit (core-inputs.nixpkgs.lib)
assertMsg
filterAttrs
mapAttrsToList
flatten
pipe
;
file-name-regex = "(.*)\\.(.*)$";
in
{
fs = rec {
@@ -95,7 +90,7 @@ in
get-entries-by-kind =
kind-predicate: path:
pipe (safe-read-directory path) [
(filterAttrs (name: kind: kind-predicate kind))
(filterAttrs (_name: kind-predicate))
(mapAttrsToList (name: _: "${path}/${name}"))
];
@@ -151,7 +146,7 @@ in
let
entries = safe-read-directory path;
filtered-entries = filterAttrs (
name: kind: (is-file-kind kind) || (is-directory-kind kind)
_name: kind: (is-file-kind kind) || (is-directory-kind kind)
) entries;
map-file =
name: kind:

View File

@@ -9,23 +9,12 @@ let
assertMsg
foldl
head
tail
concatMap
optionalAttrs
optional
mkIf
filterAttrs
mapAttrs'
mkMerge
mapAttrsToList
optionals
mkDefault
mkAliasDefinitions
mkAliasAndWrapDefinitions
mkOption
types
hasInfix
hasSuffix
pipe
;
@@ -41,13 +30,13 @@ in
# not exist.
if user-inputs ? home-manager then
snowfall-lib.internal.system-lib.extend (
final: prev:
_final: prev:
# NOTE: This order is important, this library's extend and other utilities must write
# _over_ the original `system-lib`.
snowfall-lib.internal.system-lib
// prev
// {
hm = snowfall-lib.internal.system-lib.home-manager.hm;
inherit (snowfall-lib.internal.system-lib.home-manager) hm;
}
)
else
@@ -130,7 +119,7 @@ in
format = "home";
inputs = snowfall-lib.flake.without-src user-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
# NOTE: home-manager has trouble with `pkgs` recursion if it isn't passed in here.
inherit pkgs lib;
@@ -226,7 +215,7 @@ in
user-home-modules-list = mapAttrsToList (
module-path: module:
args@{ pkgs, ... }:
args:
(module args)
// {
_file = "${user-homes-root}/${module-path}/default.nix";
@@ -296,8 +285,7 @@ in
};
extra-special-args-module =
args@{
config,
{
pkgs,
system ? pkgs.stdenv.hostPlatform.system,
target ? system,
@@ -337,7 +325,7 @@ in
other-modules = users.users.${name}.modules or [ ];
user-name = created-user.specialArgs.user;
in
args@{
{
config,
options,
pkgs,
@@ -392,7 +380,7 @@ in
(
(users.users.${name}.specialArgs or { })
// {
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
}
)
[
@@ -407,7 +395,7 @@ in
home-manager = {
users.${user-name} = mkIf config.snowfallorg.users.${user-name}.home.enable (
{ pkgs, ... }:
{ ... }:
{
imports = (home-config.imports or [ ]) ++ other-modules ++ [ user-module ];
config = builtins.removeAttrs home-config [ "imports" ];

View File

@@ -1,9 +1,6 @@
# This code is adapted from flake-utils-plus:
# https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a/lib/options.nix
{
lib,
config,
user-inputs,
core-inputs,
...
}:

View File

@@ -17,7 +17,7 @@ let
core-inputs-libs = snowfall-lib.flake.get-libs (snowfall-lib.flake.without-self core-inputs);
user-inputs-libs = snowfall-lib.flake.get-libs (snowfall-lib.flake.without-self user-inputs);
snowfall-top-level-lib = filterAttrs (name: value: !builtins.isAttrs value) snowfall-lib;
snowfall-top-level-lib = filterAttrs (_name: value: !builtins.isAttrs value) snowfall-lib;
base-lib = snowfall-lib.attrs.merge-shallow [
core-inputs.nixpkgs.lib
@@ -36,7 +36,7 @@ let
attrs = {
inputs = snowfall-lib.flake.without-snowfall-inputs user-inputs;
snowfall-inputs = core-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
lib = snowfall-lib.attrs.merge-shallow [
base-lib
{ "${snowfall-config.namespace}" = user-lib; }
@@ -86,7 +86,7 @@ in
inherit channels;
lib = system-lib;
inputs = snowfall-lib.flake.without-src user-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
}
) item { };
};

View File

@@ -5,14 +5,8 @@
snowfall-config,
}:
let
inherit (builtins) baseNameOf;
inherit (core-inputs.nixpkgs.lib)
foldl
mapAttrs
hasSuffix
isFunction
splitString
tail
;
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
@@ -49,7 +43,7 @@ in
# NOTE: home-manager *requires* modules to specify named arguments or it will not
# pass values in. For this reason we must specify things like `pkgs` as a named attribute.
${metadata.name} =
args@{ pkgs, ... }:
args:
let
system = args.system or args.pkgs.stdenv.hostPlatform.system;
target = args.target or system;
@@ -74,7 +68,7 @@ in
lib = snowfall-lib.internal.system-lib;
inputs = snowfall-lib.flake.without-src user-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
};
imported-user-module = import metadata.path;
user-module =

View File

@@ -6,9 +6,7 @@
}:
let
inherit (core-inputs.nixpkgs.lib)
assertMsg
foldl
concatStringsSep
pipe
flatten
;
@@ -114,8 +112,7 @@ in
${namespace} = (prev.${namespace} or { }) // user-packages;
};
create-overlay = (
overlays: file:
create-overlay = overlays: file:
let
# 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.
@@ -145,20 +142,19 @@ in
user-overlay-packages = user-overlay final prev-with-packages;
outputs = user-overlay-packages;
in
if user-overlay-packages.__dontExport or false == true then
if user-overlay-packages.__dontExport or false then
outputs // { __dontExport = true; }
else
outputs;
fake-overlay-result = overlay fake-pkgs fake-pkgs;
in
if fake-overlay-result.__dontExport or false == true then
if fake-overlay-result.__dontExport or false then
overlays
else
overlays
// {
${name} = overlay;
}
);
};
overlays = foldl create-overlay { } user-overlays;
@@ -171,9 +167,8 @@ in
# 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 file);
overlay =
final: prev:
_final: prev:
let
channels = channel-systems.${prev.system};
packages = snowfall-lib.package.create-packages {
inherit namespace;
channels = channel-systems.${prev.system};

View File

@@ -5,13 +5,10 @@
snowfall-config,
}:
let
inherit (core-inputs.flake-utils-plus.lib) filterPackages allSystems;
inherit (core-inputs.flake-utils-plus.lib) filterPackages;
inherit (core-inputs.nixpkgs.lib)
assertMsg
fix
foldl
mapAttrs
filterAttrs
callPackageWith
;

View File

@@ -1,8 +1,6 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
let
inherit (builtins)

View File

@@ -1,8 +1,5 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
{
shell = {

View File

@@ -5,7 +5,7 @@
snowfall-config,
}:
let
inherit (builtins) dirOf baseNameOf;
inherit (builtins) baseNameOf;
inherit (core-inputs.nixpkgs.lib)
assertMsg
fix
@@ -13,7 +13,6 @@ let
concatMap
foldl
optionals
singleton
;
virtual-systems = import ./virtual-systems.nix;
@@ -291,7 +290,7 @@ in
virtual = (get-virtual-system-type target) != "";
inputs = snowfall-lib.flake.without-src user-inputs;
namespace = snowfall-config.namespace;
inherit (snowfall-config) namespace;
};
};

View File

@@ -5,7 +5,7 @@ args@{
...
}:
let
lib = core-inputs.nixpkgs.lib;
inherit (core-inputs.nixpkgs) lib;
nixosModulesPath = core-inputs.nixpkgs + "/nixos/modules";
nixosArgs = builtins.removeAttrs args [ "format" ];
@@ -57,7 +57,7 @@ let
getImageVariant =
variant:
let
config = (mkSystem [ ]).config;
inherit ((mkSystem [ ])) config;
images = getImages config;
in
assert lib.assertMsg (lib.hasAttr variant images)
@@ -176,7 +176,7 @@ let
specialHandlers = {
docker = (mkBuild [ dockerModule ]).tarball;
vm = (mkBuild [ vmModule ]).vm;
inherit ((mkBuild [ vmModule ])) vm;
vm-bootloader = (mkBuild [ vmBootloaderModule ]).vm;
vm-nogui = (mkBuild [ vmNoGuiModule ]).vm;
iso = (mkBuild [ isoModule ]).isoImage;
@@ -186,7 +186,7 @@ let
kexec-bundle = (mkBuild [ kexecBundleModule ]).kexec_bundle;
};
imageHandlers = lib.mapAttrs (_: variant: getImageVariant variant) imageVariants;
imageHandlers = lib.mapAttrs (_: getImageVariant) imageVariants;
formatHandlers = imageHandlers // specialHandlers;
in
formatHandlers.${format} or (throw "Unsupported virtual system format '${format}'.")

View File

@@ -1,12 +1,8 @@
{
core-inputs,
user-inputs,
snowfall-lib,
snowfall-config,
}:
let
inherit (builtins) baseNameOf;
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs;
user-templates-root = snowfall-lib.fs.get-snowfall-file "templates";
in