mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
pam: add module
Also make it possible to set session variables using PAM rather than Bash.
This commit is contained in:
parent
f35b9a9970
commit
5fbbbd1ea4
5 changed files with 47 additions and 4 deletions
|
@ -8,6 +8,7 @@ let
|
|||
modules = [
|
||||
./home-environment.nix
|
||||
./manual.nix
|
||||
./misc/pam.nix
|
||||
./programs/bash.nix
|
||||
./programs/beets.nix
|
||||
./programs/eclipse.nix
|
||||
|
|
|
@ -150,7 +150,24 @@ in
|
|||
default = {};
|
||||
type = types.attrs;
|
||||
example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
|
||||
description = "Environment variables to always set at login.";
|
||||
description = ''
|
||||
Environment variables to always set at login.
|
||||
'';
|
||||
};
|
||||
|
||||
home.sessionVariableSetter = mkOption {
|
||||
default = "pam";
|
||||
type = types.enum [ "pam" "bash" ];
|
||||
example = "bash";
|
||||
description = ''
|
||||
Identifies the module that should set the session variables.
|
||||
</para><para>
|
||||
If "bash" is set then <varname>config.bash.enable</varname>
|
||||
must also be enabled.
|
||||
</para><para>
|
||||
If "pam" is set then PAM must be used to set the system
|
||||
environment.
|
||||
'';
|
||||
};
|
||||
|
||||
home.packages = mkOption {
|
||||
|
|
20
modules/misc/pam.nix
Normal file
20
modules/misc/pam.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
homeCfg = config.home;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {};
|
||||
|
||||
config = mkIf (homeCfg.sessionVariableSetter == "pam") {
|
||||
home.file.".pam_environment".text =
|
||||
concatStringsSep "\n" (
|
||||
mapAttrsToList (n: v: "${n} OVERRIDE=${v}") homeCfg.sessionVariables
|
||||
) + "\n";
|
||||
};
|
||||
}
|
|
@ -127,7 +127,8 @@ in
|
|||
home.file.".profile".text = ''
|
||||
# -*- mode: sh -*-
|
||||
|
||||
${envVarsStr}
|
||||
${optionalString (config.home.sessionVariableSetter == "bash")
|
||||
envVarsStr}
|
||||
|
||||
${cfg.profileExtra}
|
||||
'';
|
||||
|
|
|
@ -72,8 +72,12 @@ in
|
|||
home.file.".xsession" = {
|
||||
mode = "555";
|
||||
text = ''
|
||||
# Rely on Bash to set session variables.
|
||||
. "$HOME/.profile"
|
||||
${
|
||||
# If we want bash to set the session variables then we need
|
||||
# to pull in .profile since that's where they are.
|
||||
optionalString (config.home.sessionVariableSetter == "bash")
|
||||
". \"$HOME/.profile\""
|
||||
}
|
||||
|
||||
systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS
|
||||
systemctl --user import-environment DISPLAY
|
||||
|
|
Loading…
Reference in a new issue