nixos: rewrite gui module
parent
48966025df
commit
7ee13bad02
@ -1,57 +1,120 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
toDhall = lib.generators.toDhall { };
|
||||
cfg = config.genode.gui;
|
||||
|
||||
domains' = lib.attrsets.mapAttrsToList (mapKey: attrs: {
|
||||
inherit mapKey;
|
||||
mapValue = lib.attrsets.mapAttrsToList
|
||||
(mapKey: mapValue: { inherit mapKey mapValue; }) attrs;
|
||||
}) cfg.domains;
|
||||
|
||||
let cfg = config.genode.gui;
|
||||
in {
|
||||
options.genode.gui = {
|
||||
enable = mkEnableOption "Genode Gui service";
|
||||
consoleLog = { enable = mkEnableOption "console log"; };
|
||||
enable = lib.mkEnableOption "Genode Gui service";
|
||||
consoleLog = {
|
||||
enable = lib.mkEnableOption "console log";
|
||||
layer = lib.mkOption {
|
||||
type = lib.types.ints.positive;
|
||||
default = 1;
|
||||
};
|
||||
};
|
||||
|
||||
policies = lib.mkOption {
|
||||
type = with lib.types; listOf path;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of policies to append to the Genode GUI server.
|
||||
Type is Init.Config.Policy.Type.
|
||||
'';
|
||||
};
|
||||
|
||||
domains = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf str);
|
||||
description = ''
|
||||
List of domains to configure at the Gui server.
|
||||
Partially documented at the Nitpicker README,
|
||||
consult the implementation when in doubt.
|
||||
<link xlink:href="https://github.com/genodelabs/genode/blob/master/repos/os/src/server/nitpicker/README"/>
|
||||
'';
|
||||
example = {
|
||||
pointer = {
|
||||
layer = "1";
|
||||
content = "client";
|
||||
label = "no";
|
||||
origin = "pointer";
|
||||
};
|
||||
default = {
|
||||
layer = "2";
|
||||
color = "#052944";
|
||||
hover = "always";
|
||||
focus = "click";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
genode.gui.enable = cfg.consoleLog.enable;
|
||||
genode.gui.enable = lib.mkDefault cfg.consoleLog.enable;
|
||||
|
||||
genode.gui.policies = lib.optional cfg.consoleLog.enable
|
||||
(builtins.toFile ("consoleLog-gui-policy.dhall") ''
|
||||
let Init = (env:DHALL_SIGIL).Init
|
||||
|
||||
in Init.Config.Policy::{
|
||||
, service = "Gui"
|
||||
, label = Init.LabelSelector.prefix "consoleLog"
|
||||
, attributes = toMap { domain = "consoleLog" }
|
||||
}
|
||||
'');
|
||||
|
||||
genode.gui.domains.consoleLog = lib.mkIf cfg.consoleLog.enable {
|
||||
layer = toString cfg.consoleLog.layer;
|
||||
label = "no";
|
||||
content = "client";
|
||||
};
|
||||
|
||||
hardware.genode.framebuffer.enable = cfg.enable;
|
||||
|
||||
genode.core.children.nitpicker = mkIf cfg.enable {
|
||||
binary = pkgs.genodePackages.nitpicker;
|
||||
genode.core.children.nitpicker = lib.mkIf cfg.enable (let
|
||||
nitpicker' = lib.getEris' "bin" pkgs.genodePackages.nitpicker "nitpicker";
|
||||
in {
|
||||
binary = nitpicker'.cap;
|
||||
extraErisInputs = [ nitpicker' ];
|
||||
configFile = pkgs.writeText "nitpicker.dhall" ''
|
||||
let Init = (env:DHALL_SIGIL).Init
|
||||
|
||||
in ${./nitpicker.dhall}
|
||||
{ policies =
|
||||
[ Init.Config.Policy::{
|
||||
, service = "Gui"
|
||||
, label = Init.LabelSelector.prefix "consoleLog"
|
||||
, attributes = toMap { domain = "default" }
|
||||
}
|
||||
]
|
||||
}
|
||||
${./nitpicker.dhall} {domains = ${toDhall domains'}, policies = [ ${
|
||||
lib.strings.concatStringsSep ", " cfg.policies
|
||||
} ] }
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
genode.core.romModules = mkIf cfg.consoleLog.enable {
|
||||
"TerminusTTF.ttf" = pkgs.buildPackages.terminus_font_ttf
|
||||
+ "/share/fonts/truetype/TerminusTTF.ttf";
|
||||
genode.core.romModules = lib.mkIf cfg.consoleLog.enable {
|
||||
"FiraCode-VF.ttf" = pkgs.buildPackages.fira-code
|
||||
+ "/share/fonts/truetype/FiraCode-VF.ttf";
|
||||
};
|
||||
|
||||
genode.core.children.consoleLog = mkIf cfg.consoleLog.enable {
|
||||
binary = pkgs.genodePackages.init;
|
||||
extraInputs = with pkgs.genodePackages; [
|
||||
gui_fb
|
||||
log_core
|
||||
libc
|
||||
terminal
|
||||
terminal_log
|
||||
vfs_ttf
|
||||
];
|
||||
genode.core.children.consoleLog = lib.mkIf cfg.consoleLog.enable (let
|
||||
erisInputs = (lib.attrsets.mapAttrs (_: lib.getEris "bin") {
|
||||
inherit (pkgs.genodePackages) gui_fb log_core terminal terminal_log;
|
||||
}) // (lib.attrsets.mapAttrs (_: lib.getEris "lib") {
|
||||
inherit (pkgs.genodePackages) vfs_ttf;
|
||||
});
|
||||
in {
|
||||
package = pkgs.genodePackages.init;
|
||||
coreROMs = [ "core_log" "kernel_log" ];
|
||||
extraErisInputs = builtins.attrValues erisInputs;
|
||||
configFile = pkgs.writeText "consoleLog.dhall" ''
|
||||
${./consoleLog.dhall} { fontFile = "TerminusTTF.ttf" }
|
||||
${./consoleLog.dhall} ${
|
||||
toDhall (lib.attrsets.mapAttrs (_: builtins.getAttr "cap") erisInputs
|
||||
// {
|
||||
fontFile = "FiraCode-VF.ttf";
|
||||
})
|
||||
}
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue