1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

foot: add module

Foot is a fast terminal emulator for Wayland. It can optionally be run
in a client-server configuration.

There are three unit tests to handle an empty configuration, the
default configuration, and systemd service file generation.
This commit is contained in:
Pierre Labadens 2021-05-14 22:42:00 +02:00 committed by Robert Helgesson
parent 73ecbd3722
commit ff616b2734
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
11 changed files with 180 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -64,6 +64,9 @@
/modules/programs/firefox.nix @rycee
/modules/programs/foot.nix @plabadens
/tests/modules/programs/foot @plabadens
/modules/programs/gh.nix @Gerschtli
/tests/modules/programs/gh @Gerschtli

View file

@ -2021,6 +2021,14 @@ in
for discussion.
'';
}
{
time = "2021-05-18T20:28:50+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'programs.foot'.
'';
}
];
};
}

View file

@ -68,6 +68,7 @@ let
(loadModule ./programs/feh.nix { })
(loadModule ./programs/firefox.nix { })
(loadModule ./programs/fish.nix { })
(loadModule ./programs/foot.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/fzf.nix { })
(loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/gh.nix { })

77
modules/programs/foot.nix Normal file
View file

@ -0,0 +1,77 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.foot;
iniFormat = pkgs.formats.ini { };
in {
meta.maintainers = with lib.maintainers; [ plabadens ];
options.programs.foot = {
enable = mkEnableOption "Foot terminal";
package = mkOption {
type = types.package;
default = pkgs.foot;
defaultText = literalExample "pkgs.foot";
description = "The foot package to install";
};
server.enable = mkEnableOption "Foot terminal server";
settings = mkOption {
type = iniFormat.type;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/foot/foot.ini</filename>. See <link
xlink:href="https://codeberg.org/dnkl/foot/src/branch/master/foot.ini"/>
for a list of available options.
'';
example = literalExample ''
{
main = {
term = "xterm-256color";
font = "Fira Code:size=11";
dpi-aware = "yes";
};
mouse = {
hide-when-typing = "yes";
};
}
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) {
source = iniFormat.generate "foot.ini" cfg.settings;
};
systemd.user.services = mkIf cfg.server.enable {
foot = {
Unit = {
Description =
"Fast, lightweight and minimalistic Wayland terminal emulator.";
Documentation = "man:foot(1)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${cfg.package}/bin/foot --server";
Restart = "on-failure";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
};
}

View file

@ -96,6 +96,7 @@ import nmt {
./modules/programs/abook
./modules/programs/autorandr
./modules/programs/firefox
./modules/programs/foot
./modules/programs/getmail
./modules/programs/i3status-rust
./modules/programs/ncmpcpp-linux

View file

@ -0,0 +1,5 @@
{
foot-example-settings = ./example-settings.nix;
foot-empty-settings = ./empty-settings.nix;
foot-systemd-user-service = ./systemd-user-service.nix;
}

View file

@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.foot.enable = true;
nixpkgs.overlays =
[ (self: super: { foot = pkgs.writeScriptBin "dummy-foot" ""; }) ];
nmt.script = ''
assertPathNotExists home-files/.config/foot
'';
};
}

View file

@ -0,0 +1,7 @@
[main]
dpi-aware=yes
font=Fira Code:size=11
term=xterm-256color
[mouse]
hide-when-typing=yes

View file

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.foot = {
enable = true;
package = pkgs.writeShellScriptBin "dummy-foot" "";
settings = {
main = {
term = "xterm-256color";
font = "Fira Code:size=11";
dpi-aware = "yes";
};
mouse = { hide-when-typing = "yes"; };
};
};
nmt.script = ''
assertFileContent \
home-files/.config/foot/foot.ini \
${./example-settings-expected.ini}
'';
};
}

View file

@ -0,0 +1,12 @@
[Install]
WantedBy=graphical-session.target
[Service]
ExecStart=@foot@/bin/foot --server
Restart=on-failure
[Unit]
After=graphical-session.target
Description=Fast, lightweight and minimalistic Wayland terminal emulator.
Documentation=man:foot(1)
PartOf=graphical-session.target

View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
package = pkgs.writeShellScriptBin "dummy-foot" "" // { outPath = "@foot@"; };
in {
config = {
programs.foot = {
inherit package;
enable = true;
server.enable = true;
};
nmt.script = ''
assertPathNotExists home-files/.config/foot/foot.ini
assertFileContent \
home-files/.config/systemd/user/foot.service \
${./systemd-user-service-expected.service}
'';
};
}