Nixfmt Tree

This commit is contained in:
Lorenzo Good 2026-02-24 00:00:35 -08:00
parent d6bcf1a468
commit f173b9d236
Signed by: lorenzo
GPG key ID: 7FCD64BD81180ED0
23 changed files with 381 additions and 224 deletions

View file

@ -1,6 +1,7 @@
rec {
getSSHKeys = let
sshKeys = builtins.fromTOML (builtins.readFile ../data/ssh-keys.toml);
in
getSSHKeys =
let
sshKeys = builtins.fromTOML (builtins.readFile ../data/ssh-keys.toml);
in
name: (builtins.mapAttrs (_: value: builtins.attrValues value) sshKeys)."${name}";
}

View file

@ -1,25 +1,28 @@
nixpkgs: withSystem: let
nixpkgs: withSystem:
let
foelib = import ./default.nix nixpkgs withSystem;
in {
mkSystem = hostname: host-platform: modules:
withSystem host-platform
({pkgs, ...}:
in
{
mkSystem =
hostname: host-platform: modules:
withSystem host-platform (
{ pkgs, ... }:
nixpkgs.lib.nixosSystem {
modules =
[
{
nix.registry = {
nixpkgs.flake = nixpkgs;
p.flake = nixpkgs;
};
nixpkgs.pkgs = pkgs;
modules = [
{
nix.registry = {
nixpkgs.flake = nixpkgs;
p.flake = nixpkgs;
};
nixpkgs.pkgs = pkgs;
networking.hostName = hostname;
}
]
++ modules;
networking.hostName = hostname;
}
]
++ modules;
specialArgs = {
inherit hostname foelib;
};
});
}
);
}

View file

@ -1,28 +1,25 @@
pkgs: let
getPackages = dir: let
entries = builtins.readDir dir;
pkgs:
let
getPackages =
dir:
let
entries = builtins.readDir dir;
procEntry = name: type: let
path = dir + "/${name}";
procEntry =
name: type:
let
path = dir + "/${name}";
in
if type == "directory" then
(if builtins.pathExists (path + "/default.nix") then [ path ] else [ ])
else
[ ];
in
if type == "directory"
then
(
if builtins.pathExists (path + "/default.nix")
then [path]
else []
)
else [];
in
builtins.concatLists (
builtins.attrValues (
builtins.mapAttrs procEntry entries
)
);
builtins.concatLists (builtins.attrValues (builtins.mapAttrs procEntry entries));
buildPackage = path: {
name = builtins.baseNameOf (toString path);
value = pkgs.callPackage (path + "/default.nix") {};
value = pkgs.callPackage (path + "/default.nix") { };
};
in
builtins.listToAttrs (builtins.map buildPackage (getPackages ../packages))
builtins.listToAttrs (builtins.map buildPackage (getPackages ../packages))

View file

@ -1,47 +1,54 @@
rec {
findNixFiles = dir: let
inherit (builtins) attrNames readDir pathExists concatMap;
findNixFiles =
dir:
let
inherit (builtins)
attrNames
readDir
pathExists
concatMap
;
# Helper function to build full paths
fullPath = name: dir + "/${name}";
# Helper function to build full paths
fullPath = name: dir + "/${name}";
# Get directory contents
contents = readDir dir;
# Get directory contents
contents = readDir dir;
# Convert contents attrset to list of names
names = attrNames contents;
# Convert contents attrset to list of names
names = attrNames contents;
# Filter and process each item
processItem = name: let
path = fullPath name;
type = contents.${name};
# Filter and process each item
processItem =
name:
let
path = fullPath name;
type = contents.${name};
in
if type == "regular" && hasSuffix "nix" name then
[ path ]
else if type == "directory" && pathExists path then
findNixFiles path
else
[ ];
in
if type == "regular" && hasSuffix "nix" name
then [path]
else if type == "directory" && pathExists path
then findNixFiles path
else [];
in
concatMap processItem names;
getName = filename: let
parts = builtins.split "\\." filename;
base = builtins.head (builtins.split "\\." filename);
in
if builtins.length parts == 1
then filename
else base;
getName =
filename:
let
parts = builtins.split "\\." filename;
base = builtins.head (builtins.split "\\." filename);
in
if builtins.length parts == 1 then filename else base;
getSuffix = filename: let
parts = builtins.split "\\." filename;
end = builtins.tail (builtins.split "\\." filename);
in
if builtins.length parts == 1
then filename
else builtins.elemAt end (builtins.length end - 1);
getSuffix =
filename:
let
parts = builtins.split "\\." filename;
end = builtins.tail (builtins.split "\\." filename);
in
if builtins.length parts == 1 then filename else builtins.elemAt end (builtins.length end - 1);
hasSuffix = suffix: filename:
if (getSuffix filename) == suffix
then true
else false;
hasSuffix = suffix: filename: if (getSuffix filename) == suffix then true else false;
}