Skip to content

Commit

Permalink
Cleanup unused
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGillion <[email protected]>
  • Loading branch information
brianmcgillion committed Jan 27, 2025
1 parent 9fcf786 commit b7c90c8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 127 deletions.
2 changes: 0 additions & 2 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ runCommandLocal "ghaf-doc"
# set the package Meta info
meta = {
description = "Ghaf Documentation";
# TODO should we Only push docs from one Architecture?
platforms = [
"x86_64-linux"
"aarch64-linux"
];
};
}
Expand Down
1 change: 0 additions & 1 deletion hydrajobs/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ in
intel-vm-debug.x86_64-linux = self.packages.x86_64-linux.vm-debug;
nxp-imx8mp-evk-debug.x86_64-linux = self.packages.aarch64-linux.nxp-imx8mp-evk-debug;
docs.x86_64-linux = self.packages.x86_64-linux.doc;
docs.aarch64-linux = self.packages.aarch64-linux.doc;
# Build cross-compiled images
nvidia-jetson-orin-agx-debug-from-x86_64.x86_64-linux =
self.packages.x86_64-linux.nvidia-jetson-orin-agx-debug-from-x86_64;
Expand Down
113 changes: 2 additions & 111 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ let
inherit (inputs) nixpkgs;
in
nixpkgs.lib.extend (
lib: _:
# some utils for importing trees
rec {
lib: _: {
/*
*
Filters Nix packages based on the target system platform.
Expand All @@ -38,6 +36,7 @@ nixpkgs.lib.extend (
- [system] Target system platform (e.g., "x86_64-linux").
- [pkgsSet] a set of Nix packages.
*/
# TODO should this be replaced with flake-parts pkgs-by-name
platformPkgs =
system:
lib.filterAttrs (
Expand All @@ -54,113 +53,5 @@ nixpkgs.lib.extend (
in
lib.elem system platforms
);

/*
*
Flattens a _tree_ of the shape that is produced by rakeLeaves.
An attrset with names in the spirit of the Reverse DNS Notation form
that fully preserve information about grouping from nesting.
# Example
```
flattenTree {
a = {
b = {
c = <path>;
};
};
}
=> { "a.b.c" = <path>; }
```
*/
flattenTree =
tree:
let
op =
sum: path: val:
let
pathStr = builtins.concatStringsSep "." path; # dot-based reverse DNS notation
in
if builtins.isPath val then
# builtins.trace "${toString val} is a path"
(sum // { "${pathStr}" = val; })
else if builtins.isAttrs val then
# builtins.trace "${builtins.toJSON val} is an attrset"
# recurse into that attribute set
(recurse sum path val)
else
# ignore that value
# builtins.trace "${toString path} is something else"
sum;

recurse =
sum: path: val:
builtins.foldl' (sum: key: op sum (path ++ [ key ]) val.${key}) sum (builtins.attrNames val);
in
recurse { } [ ] tree;

/*
*
Recursively collect the nix files of _path_ into attrs.
Return an attribute set where all `.nix` files and directories with `default.nix` in them
are mapped to keys that are either the file with .nix stripped or the folder name.
All other directories are recursed further into nested attribute sets with the same format.
# Example
Example file structure:
```
./core/default.nix
./base.nix
./main/dev.nix
./main/os/default.nix
```
```nix
rakeLeaves .
=> {
core = ./core;
base = base.nix;
main = {
dev = ./main/dev.nix;
os = ./main/os;
};
}
```
*/

rakeLeaves =
dirPath:
let
seive =
file: type:
# Only rake `.nix` files or directories
(type == "regular" && lib.hasSuffix ".nix" file) || (type == "directory");

collect = file: type: {
name = lib.removeSuffix ".nix" file;
value =
let
path = dirPath + "/${file}";
in
if (type == "regular") || (type == "directory" && builtins.pathExists (path + "/default.nix")) then
path
# recurse on directories that don't contain a `default.nix`
else
rakeLeaves path;
};

files = lib.filterAttrs seive (builtins.readDir dirPath);
in
lib.filterAttrs (_n: v: v != { }) (lib.mapAttrs' collect files);

importLeaves =
#
# Create an import stanza by recursing a directory to find all default.nix and <file.nix>
# files beneath withough manually having to list all the subsequent files.
#
path: builtins.attrValues (lib.mapAttrs (_: import) (rakeLeaves path));
}
)
13 changes: 0 additions & 13 deletions lib/ghaf-modules.nix

This file was deleted.

0 comments on commit b7c90c8

Please sign in to comment.