Merge pull request #262133 from h7x4/cleanup-screen-module

nixos/screen: clean up module
This commit is contained in:
Peder Bergebakken Sundt 2023-12-02 15:56:45 +01:00 committed by GitHub
commit 1079eccc63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 16 deletions

View file

@ -8,7 +8,7 @@ In addition to numerous new and upgraded packages, this release has the followin
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
- Create the first release note entry in this section!
- `screen`'s module has been cleaned, and will now require you to set `programs.screen.enable` in order to populate `screenrc` and add the program to the environment.
## New Services {#sec-release-24.05-new-services}

View file

@ -1,33 +1,41 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkOption mkIf types;
cfg = config.programs.screen;
in
{
###### interface
options = {
programs.screen = {
enable = lib.mkEnableOption (lib.mdDoc "screen, a basic terminal multiplexer");
screenrc = mkOption {
default = "";
description = lib.mdDoc ''
The contents of /etc/screenrc file.
package = lib.mkPackageOptionMD pkgs "screen" { };
screenrc = lib.mkOption {
type = with lib.types; nullOr lines;
example = ''
defscrollback 10000
startup_message off
'';
type = types.lines;
description = lib.mdDoc "The contents of {file}`/etc/screenrc` file";
};
};
};
###### implementation
config = mkIf (cfg.screenrc != "") {
environment.etc.screenrc.text = cfg.screenrc;
environment.systemPackages = [ pkgs.screen ];
config = {
# TODO: Added in 24.05, remove before 24.11
assertions = [
{
assertion = cfg.screenrc != null -> cfg.enable;
message = "`programs.screen.screenrc` has been configured, but `programs.screen.enable` is not true";
}
];
} // lib.mkIf cfg.enable {
environment.etc.screenrc = {
enable = cfg.screenrc != null;
text = cfg.screenrc;
};
environment.systemPackages = [ cfg.package ];
security.pam.services.screen = {};
};
}