Move "system" options to "build" add UCI system options
This commit is contained in:
parent
807ee39110
commit
2999346274
14
README.md
14
README.md
|
@ -34,7 +34,12 @@ let
|
|||
({ pkgs, ... }: {
|
||||
|
||||
# find target/variant for an old Fritzbox
|
||||
system.profile = "avm_fritz7412";
|
||||
build.profile = "avm_fritz7412";
|
||||
|
||||
system.settings = {
|
||||
hostname = "testrouter";
|
||||
description = "nix-openwrt-imagebuilder example";
|
||||
};
|
||||
|
||||
# add package to include in the image, ie. packages that you don't
|
||||
# want to install manually later
|
||||
|
@ -76,7 +81,12 @@ in sys.config.system.build.image
|
|||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
modules = [
|
||||
({ pkgs, ... }: {
|
||||
system.profile = "avm_fritz7412";
|
||||
build.profile = "avm_fritz7412";
|
||||
|
||||
system.settings = {
|
||||
hostname = "testrouter";
|
||||
description = "nix-openwrt-imagebuilder example";
|
||||
};
|
||||
|
||||
# add package to include in the image, ie. packages that you don't
|
||||
# want to install manually later
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
system.profile = "avm_fritz7412";
|
||||
build.profile = "avm_fritz7412";
|
||||
|
||||
system.settings = {
|
||||
description = "nix-openwrt-imagebuilder example";
|
||||
timezone = "CET-1CEST,M3.5.0,M10.5.0/3";
|
||||
};
|
||||
|
||||
packages.include = [ "tcpdump" "vxlan" "kmod-vxlan" ];
|
||||
|
||||
|
|
|
@ -1,12 +1,40 @@
|
|||
{ config, lib, pkgs, profiles, ... }:
|
||||
|
||||
{
|
||||
system.build.image = import ../../builder.nix {
|
||||
inherit pkgs;
|
||||
inherit (config.system) release target variant profile;
|
||||
inherit (config) files extraFiles;
|
||||
packages = config.packages.include
|
||||
++ map (x: "-${x}") config.packages.exclude;
|
||||
disabledServices = config.services.disabled;
|
||||
let cfg = config.build;
|
||||
in {
|
||||
options.build = with lib; {
|
||||
profile = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = "Hardware profile";
|
||||
};
|
||||
release = mkOption {
|
||||
type = types.str;
|
||||
default = "21.02.3";
|
||||
description = "OpenWRT release";
|
||||
};
|
||||
target = mkOption {
|
||||
type = types.str;
|
||||
description = "OpenWRT target";
|
||||
};
|
||||
variant = mkOption {
|
||||
type = types.str;
|
||||
description = "Hardware variant";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
build = lib.mkIf (cfg.profile != null) (lib.mapAttrs (_: lib.mkDefault) {
|
||||
inherit (profiles.identifyProfile cfg.profile) target variant;
|
||||
});
|
||||
system.build.image = import ../../builder.nix {
|
||||
inherit pkgs;
|
||||
inherit (cfg) release target variant profile;
|
||||
inherit (config) files extraFiles;
|
||||
packages = config.packages.include
|
||||
++ map (x: "-${x}") config.packages.exclude;
|
||||
disabledServices = config.services.disabled;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,48 +2,31 @@
|
|||
|
||||
let cfg = config.system;
|
||||
in {
|
||||
options.system = with lib;
|
||||
let nullOrStr = types.nullOr types.str;
|
||||
in {
|
||||
|
||||
build = mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
Attribute set of derivations used to construct the system.
|
||||
'';
|
||||
type = types.submoduleWith {
|
||||
modules =
|
||||
[{ freeformType = with types; lazyAttrsOf (uniq unspecified); }];
|
||||
};
|
||||
};
|
||||
|
||||
profile = mkOption {
|
||||
type = nullOrStr;
|
||||
default = null;
|
||||
description = "Hardware profile";
|
||||
};
|
||||
|
||||
release = mkOption {
|
||||
type = types.str;
|
||||
default = "21.02.3";
|
||||
description = "OpenWRT release";
|
||||
};
|
||||
|
||||
target = mkOption {
|
||||
type = types.str;
|
||||
description = "OpenWRT target";
|
||||
};
|
||||
|
||||
variant = mkOption {
|
||||
type = types.str;
|
||||
description = "Hardware variant";
|
||||
};
|
||||
options.system = with lib; {
|
||||
|
||||
settings = mkOption {
|
||||
default = { };
|
||||
type = types.uciSection;
|
||||
description = ''
|
||||
See <link xlink:href="https://openwrt.org/docs/guide-user/base-system/system_configuration"/>'';
|
||||
};
|
||||
|
||||
config.system = lib.mkIf (cfg.profile != null)
|
||||
(lib.mapAttrs (_: lib.mkDefault) {
|
||||
inherit (profiles.identifyProfile cfg.profile) target variant;
|
||||
});
|
||||
build = mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
Attribute set of derivations used to construct the system.
|
||||
'';
|
||||
type = types.submoduleWith {
|
||||
modules =
|
||||
[{ freeformType = with types; lazyAttrsOf (uniq unspecified); }];
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config.uci.batch = lib.toUciBatch {
|
||||
config = "system";
|
||||
type = "system";
|
||||
} cfg.settings;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ let
|
|||
inherit pkgs;
|
||||
profiles = import ../profiles.nix {
|
||||
inherit pkgs;
|
||||
inherit (config.system) release;
|
||||
inherit (config.build) release;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue