mirror of
https://github.com/nix-community/raspberry-pi-nix.git
synced 2025-11-09 03:56:03 +01:00
add hardware.raspberrypi.config-generated option
outputs the generated config as text
This commit is contained in:
parent
6e0da67830
commit
24f5b92db8
1 changed files with 118 additions and 100 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
{ lib, config, pkgs, ... }:
|
{ lib, config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.hardware.raspberry-pi;
|
cfg = config.hardware.raspberry-pi;
|
||||||
render-raspberrypi-config = let
|
render-raspberrypi-config =
|
||||||
|
let
|
||||||
render-options = opts:
|
render-options = opts:
|
||||||
lib.strings.concatStringsSep "\n" (render-dt-kvs opts);
|
lib.strings.concatStringsSep "\n" (render-dt-kvs opts);
|
||||||
render-dt-param = x: "dtparam=" + x;
|
render-dt-param = x: "dtparam=" + x;
|
||||||
|
|
@ -22,10 +23,12 @@ let
|
||||||
(render-dt-kvs params);
|
(render-dt-kvs params);
|
||||||
render-dt-overlays = overlays:
|
render-dt-overlays = overlays:
|
||||||
lib.strings.concatMapStringsSep "\n" render-dt-overlay
|
lib.strings.concatMapStringsSep "\n" render-dt-overlay
|
||||||
(lib.attrsets.mapAttrsToList (k: v: {
|
(lib.attrsets.mapAttrsToList
|
||||||
|
(k: v: {
|
||||||
overlay = k;
|
overlay = k;
|
||||||
args = render-dt-kvs v.params;
|
args = render-dt-kvs v.params;
|
||||||
}) (lib.filterAttrs (k: v: v.enable) overlays));
|
})
|
||||||
|
(lib.filterAttrs (k: v: v.enable) overlays));
|
||||||
render-config-section = k:
|
render-config-section = k:
|
||||||
{ options, base-dt-params, dt-overlays }:
|
{ options, base-dt-params, dt-overlays }:
|
||||||
let
|
let
|
||||||
|
|
@ -34,17 +37,21 @@ let
|
||||||
(render-base-dt-params base-dt-params)
|
(render-base-dt-params base-dt-params)
|
||||||
(render-dt-overlays dt-overlays)
|
(render-dt-overlays dt-overlays)
|
||||||
]);
|
]);
|
||||||
in ''
|
in
|
||||||
|
''
|
||||||
[${k}]
|
[${k}]
|
||||||
${all-config}
|
${all-config}
|
||||||
'';
|
'';
|
||||||
in conf:
|
in
|
||||||
|
conf:
|
||||||
lib.strings.concatStringsSep "\n"
|
lib.strings.concatStringsSep "\n"
|
||||||
(lib.attrsets.mapAttrsToList render-config-section conf);
|
(lib.attrsets.mapAttrsToList render-config-section conf);
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
hardware.raspberry-pi = {
|
hardware.raspberry-pi = {
|
||||||
config = let
|
config =
|
||||||
|
let
|
||||||
rpi-config-param = {
|
rpi-config-param = {
|
||||||
options = {
|
options = {
|
||||||
enable = lib.mkEnableOption "attr";
|
enable = lib.mkEnableOption "attr";
|
||||||
|
|
@ -108,19 +115,30 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in lib.mkOption {
|
in
|
||||||
|
lib.mkOption {
|
||||||
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
|
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config-generated = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "the config text generated by raspberrypi.hardware.config";
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
|
|
||||||
config-output = lib.mkOption {
|
config-output = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
default = pkgs.writeTextFile {
|
default = pkgs.writeTextFile {
|
||||||
name = "config.txt";
|
name = "config.txt";
|
||||||
text = ''
|
text = ''
|
||||||
# This is a generated file. Do not edit!
|
# This is a generated file. Do not edit!
|
||||||
${render-raspberrypi-config cfg.config}
|
${cfg.config-generated}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
config = {
|
||||||
|
hardware.raspberry-pi.config-generated = render-raspberrypi-config cfg.config;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue