GNU Screen and its screenrc

I’m giving up on tmux for now and returning to screen, but I have trouble giving it the screenrc.

Any pointers as to how I include this file in the configuration?:wink:

I haven’t used screen yet, but if I understand correctly, the screenrc needs to placed in your home folder. For such config files most people use home-manager to declaratively manage such files.
I think home.file.".screenrc".text = ... should be the right option for this file.

1 Like

ok, I found this:

{ config, lib, pkgs, ... }:

let
  inherit (lib) mkOption mkIf types;
  cfg = config.programs.screen;
in

{
  ###### interface

  options = {
    programs.screen = {

      screenrc = mkOption {
        default = "";
        description = lib.mdDoc ''
          The contents of /etc/screenrc file.
        '';
        type = types.lines;
      };
    };
  };

  ###### implementation

  config = mkIf (cfg.screenrc != "") {
    environment.etc.screenrc.text = cfg.screenrc;

    environment.systemPackages = [ pkgs.screen ];
    security.pam.services.screen = {};
  };

}

in

, so I tried to include that like

imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./screen.nix
    ];

, but then it says:

building Nix...
building the system configuration...
error: The option `programs.screen.screenrc' in `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/programs/screen.nix' is already declared in `/etc/nixos/screen.nix'.
(use '--show-trace' to show detailed location information)

So, should I edit directly this file in /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/programs/screen.nix ?:wink:

Right, so I should just override the variable in configuration.nix, but which variable?

programs.screen.screenrc.default=’’’’;?

ok, I found this

programs.screen.screenrc

    The contents of /etc/screenrc file.

    Type: strings concatenated with "\n"

    Default: ""

    Declared by:

in
https://nixos.org/manual/nixos/stable/options.html

, and indeed, this works to populate /etc/screenrc;)

, but when I launch screen, it’s not reading it.

Weird

1 Like

Oh, I’m sorry I somehow missed, that NixOS already has a screenrc option. Why screen is not using the provided config I don’t know. Does it work when pointing screen explicitly to the config file with screen -c /etc/screenrc ?

No, I tried that. It’s not reading it at all. Really weird.

screen -c /etc/screenrc

I am connected to the machine via ssh, though, but does this have any relevance?

indeed, it works;)

I had to ssh -t
of course;)

Thanks