From 7955ae52fe9a354c118ca950595bf942d6c23e5e Mon Sep 17 00:00:00 2001 From: Nikita Pedorich Date: Wed, 4 Dec 2024 19:40:03 +0900 Subject: [PATCH] Add more debug information; Add TODOs --- builder/module-config.nix | 11 ++++++++--- builder/module-docs.nix | 3 --- builder/module-options.nix | 22 ++++++++++++++-------- files.nix | 3 +++ profiles.nix | 1 + 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/builder/module-config.nix b/builder/module-config.nix index 8d7395de..2ae417c9 100644 --- a/builder/module-config.nix +++ b/builder/module-config.nix @@ -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; @@ -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 { diff --git a/builder/module-docs.nix b/builder/module-docs.nix index 8aa95c2c..9771ffd3 100644 --- a/builder/module-docs.nix +++ b/builder/module-docs.nix @@ -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 - }; }; }; diff --git a/builder/module-options.nix b/builder/module-options.nix index 2bed62ab..2f2408a4 100644 --- a/builder/module-options.nix +++ b/builder/module-options.nix @@ -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; }; @@ -203,9 +209,9 @@ 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 = '' @@ -213,7 +219,7 @@ in ''; }; - feedsSha256 = lib.mkOption { + feedsHash = lib.mkOption { type = lib.types.attrsOf lib.types.raw; default = hashedFeeds; example = lib.options.literalExpression '' diff --git a/files.nix b/files.nix index 036758f8..9bf69f49 100644 --- a/files.nix +++ b/files.nix @@ -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 diff --git a/profiles.nix b/profiles.nix index c333f0b7..47d2757e 100644 --- a/profiles.nix +++ b/profiles.nix @@ -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