From b7c90c8256529826c51ba3596188717d912ca026 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Mon, 27 Jan 2025 08:30:58 +0400 Subject: [PATCH] Cleanup unused Signed-off-by: Brian McGillion --- docs/default.nix | 2 - hydrajobs/flake-module.nix | 1 - lib.nix | 113 +------------------------------------ lib/ghaf-modules.nix | 13 ----- 4 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 lib/ghaf-modules.nix diff --git a/docs/default.nix b/docs/default.nix index 3a0dc50fc..b10297b93 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -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" ]; }; } diff --git a/hydrajobs/flake-module.nix b/hydrajobs/flake-module.nix index 213682223..d97547a82 100644 --- a/hydrajobs/flake-module.nix +++ b/hydrajobs/flake-module.nix @@ -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; diff --git a/lib.nix b/lib.nix index 26a4e4f8d..c378d7e01 100644 --- a/lib.nix +++ b/lib.nix @@ -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. @@ -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 ( @@ -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 = ; - }; - }; - } - => { "a.b.c" = ; } - ``` - */ - 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 - # files beneath withough manually having to list all the subsequent files. - # - path: builtins.attrValues (lib.mapAttrs (_: import) (rakeLeaves path)); } ) diff --git a/lib/ghaf-modules.nix b/lib/ghaf-modules.nix deleted file mode 100644 index c594e6098..000000000 --- a/lib/ghaf-modules.nix +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-FileCopyrightText: 2022-2023 TII (SSRC) and the Ghaf contributors -# SPDX-FileCopyrightText: 2023 TII (SSRC) and the Ghaf contributors -# -# SPDX-License-Identifier: Apache-2.0 -{ lib }: -let - inherit (builtins) readFile filter; - inherit (lib) filesystem hasInfix hasSuffix; - - isDesiredFile = path: hasSuffix ".nix" path && hasInfix "options" (readFile path); - modulesDirectoryFiles = filesystem.listFilesRecursive ../modules; -in -filter isDesiredFile modulesDirectoryFiles