Skip to content

Commit

Permalink
Add more debug information; Add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
pedorich-n committed Dec 4, 2024
1 parent 25db96a commit 7955ae5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
11 changes: 8 additions & 3 deletions builder/module-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
let
inherit (import ../files.nix {
inherit pkgs;
inherit (config) release feedsSha256;
inherit (config) release;
inherit (config.hardware) target;
variant = config.hardware.subtarget;
packagesArch = config.hardware.arch;
sha256 = config.sumsFileSha256;
feedsSha256 = config.feedsHash;
sha256 = config.sumsFileHash;
}) variantFiles profiles expandDeps corePackages packagesByFeed allPackages;


Expand Down Expand Up @@ -83,7 +84,11 @@ let
in
if matches != [ ]
then builtins.getAttr (builtins.elemAt matches 0) variantFiles
else throw "No valid image builder found!";
else
builtins.throw ''
No valid image builder found!
Expected filenames: ${lib.concatStringsSep ", " possibleFileNames}
'';
in
{

Expand Down
3 changes: 0 additions & 3 deletions builder/module-docs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ let

config._module = {
check = false; # Don't check for unset variables
args = {
inherit pkgs lib; # Provide pkgs and lib to modules
};
};
};

Expand Down
22 changes: 14 additions & 8 deletions builder/module-options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
let
latestRelease = import ../latest-release.nix;

releaseHashes = import ../hashes/${config.release}.nix;
hashedTarget = releaseHashes.targets.${config.hardware.target}.${config.hardware.subtarget};
hashedFeeds = releaseHashes.packages.${config.hardware.arch};

defaultSumsFileSha256 = hashedTarget.sha256;
releaseHashesFile = ../hashes/${config.release}.nix;
releaseHashes =
if (builtins.pathExists releaseHashesFile)
then import releaseHashesFile
else builtins.throw "No hashed information found about OpenWRT ${config.release}";
hashedTarget = releaseHashes.targets.${config.hardware.target}.${config.hardware.subtarget} or
(builtins.throw "No hashed information for OpenWRT ${config.release} found for ${config.hardware.target}/${config.hardware.subtarget}");
hashedFeeds = releaseHashes.packages.${config.hardware.arch} or
(builtins.throw "No hashed information for OpenWRT ${config.release} about packages found for ${config.hardware.arch} architecture");

defaultSumsFileHash = hashedTarget.sha256;

# TODO: get rid of `pkgs`
profiles = import ../profiles.nix { pkgs = null; inherit (config) release; };
Expand Down Expand Up @@ -203,17 +209,17 @@ in
};
};

sumsFileSha256 = lib.mkOption {
sumsFileHash = lib.mkOption {
type = lib.types.nonEmptyStr;
default = defaultSumsFileSha256;
default = defaultSumsFileHash;
example = "sha256-O/7C9+OlfTx+iSao/GITKgPktk9iqchRTQNNYsLil2g=";
internal = true;
description = ''
`sha256` sum of `sha256sums` file from OpenWRT
'';
};

feedsSha256 = lib.mkOption {
feedsHash = lib.mkOption {
type = lib.types.attrsOf lib.types.raw;
default = hashedFeeds;
example = lib.options.literalExpression ''
Expand Down
3 changes: 3 additions & 0 deletions files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
, release ? import ./latest-release.nix
# OpenWRT target
, target
# TODO: rename to subtarget
, variant ? "generic"
# Checksum of the `sha256sums` file
# TODO: rename to sha56sumsHash
, sha256
# Checksum of a feed's `Packages` file
# TODO: rename to feedsHash
, feedsSha256
# Manually specify packages' arch for OpenWRT<19 releases without profiles.json
, packagesArch ? null
Expand Down
1 change: 1 addition & 0 deletions profiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ in rec {
)
) hashes.targets
else
# TODO: check if file exists first
import ./cached-profiles/${release}.nix;

# filters hardware profiles from all boards.json files
Expand Down

0 comments on commit 7955ae5

Please sign in to comment.