diff options
| author | seth <[email protected]> | 2024-03-09 18:32:23 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-03-09 18:32:23 -0500 |
| commit | c76dc8f7aeb99be22d2b256c12076a177f659321 (patch) | |
| tree | 9f44686736417265255f14c0d4129cb5f61f14b1 /modules/flake | |
| parent | 969a413567138af67f69635aa90d6389d44310f2 (diff) | |
flakeModules: init openwrt-imagebuilder module
Diffstat (limited to 'modules/flake')
| -rw-r--r-- | modules/flake/default.nix | 1 | ||||
| -rw-r--r-- | modules/flake/openwrt.nix | 67 |
2 files changed, 68 insertions, 0 deletions
diff --git a/modules/flake/default.nix b/modules/flake/default.nix index c653708..04c495d 100644 --- a/modules/flake/default.nix +++ b/modules/flake/default.nix @@ -1,4 +1,5 @@ { configurations = import ./configurations.nix; + openwrt = import ./openwrt.nix; terranix = import ./terranix.nix; } diff --git a/modules/flake/openwrt.nix b/modules/flake/openwrt.nix new file mode 100644 index 0000000..bdf4235 --- /dev/null +++ b/modules/flake/openwrt.nix @@ -0,0 +1,67 @@ +{ + config, + lib, + withSystem, + inputs, + ... +}: let + namespace = "openWrtImages"; + cfg = config.${namespace}; + + inherit + (lib) + literalExpression + mdDoc + mkOption + types + ; + + openWrtSubmodule = { + freeformType = types.attrsOf types.anything; + options = { + profile = mkOption { + type = types.str; + example = literalExpression "netgear_wac104"; + description = mdDoc '' + Device profile to build images for. + ''; + }; + + release = mkOption { + type = types.str; + default = "23.05.0"; + example = literalExpression "23.05.2"; + description = mdDoc '' + OpenWRT release to base image off of + ''; + }; + }; + }; +in { + options.${namespace} = mkOption { + type = types.attrsOf (types.submodule openWrtSubmodule); + default = {}; + description = mdDoc '' + Generated OpenWRT images + ''; + }; + + config.flake.legacyPackages.x86_64-linux = { + ${namespace} = withSystem "x86_64-linux" ( + {pkgs, ...}: let + profileFromRelease = release: + (inputs.openwrt-imagebuilder.lib.profiles { + inherit pkgs release; + }) + .identifyProfile; + + mkImage = {profile, ...} @ args: + inputs.openwrt-imagebuilder.lib.build ( + profileFromRelease args.release profile + // builtins.removeAttrs args ["profile" "release"] + ); + in + lib.mapAttrs (lib.const mkImage) cfg + ); + }; +} |
