From 421dcc35c56bce06d75f541b225767e59305f375 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 28 May 2009 12:06:54 +0000 Subject: [PATCH] * Moved the Bash configuration to modules/programs/bash. svn path=/nixos/branches/modular-nixos/; revision=15759 --- etc/default.nix | 51 ++++--------------- modules/config/fonts.nix | 34 ++++++------- modules/module-list.nix | 1 + modules/programs/bash/bash.nix | 42 +++++++++++++++ .../programs/bash/bashrc-user.sh | 0 {etc => modules/programs/bash}/bashrc.sh | 1 - {etc => modules/programs/bash}/inputrc | 0 {etc => modules/programs/bash}/profile.sh | 0 system/system-options.nix | 6 --- 9 files changed, 69 insertions(+), 66 deletions(-) create mode 100644 modules/programs/bash/bash.nix rename etc/skel/bashrc => modules/programs/bash/bashrc-user.sh (100%) rename {etc => modules/programs/bash}/bashrc.sh (98%) rename {etc => modules/programs/bash}/inputrc (100%) rename {etc => modules/programs/bash}/profile.sh (100%) diff --git a/etc/default.nix b/etc/default.nix index efb0ea1ee291..37c0a360d8df 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -35,13 +35,6 @@ in ###### implementation let - shellInit = config.environment.shellInit; - nixEnvVars = config.nix.envVars; - modulesTree = config.system.modulesTree; - wrapperDir = config.security.wrapperDir; - systemPath = config.system.path; - binsh = config.system.build.binsh; - optional = pkgs.lib.optional; @@ -99,31 +92,6 @@ let target = "default/useradd"; } - { # Script executed when the shell starts as a non-login shell (system-wide version). - source = pkgs.substituteAll { - src = ./bashrc.sh; - inherit systemPath wrapperDir modulesTree; - defaultLocale = config.i18n.defaultLocale; - inherit nixEnvVars shellInit; - }; - target = "bashrc"; - } - - { # Script executed when the shell starts as a login shell. - source = ./profile.sh; - target = "profile"; - } - - { # Configuration for readline in bash. - source = ./inputrc; - target = "inputrc"; - } - - { # Script executed when the shell starts as a non-login shell (user version). - source = ./skel/bashrc; - target = "skel/.bashrc"; - } - ] # A bunch of PAM configuration files for various programs. @@ -184,15 +152,16 @@ let inherit (pkgs.stringsWithDeps) noDepEntry fullDepEntry packEntry; copyScript = {source, target, mode ? "644", own ? "root.root"}: - assert target != "nixos"; '' - source="${source}" - target="/etc/${target}" - mkdir -p $(dirname "$target") - test -e "$target" && rm -f "$target" - cp "$source" "$target" - chown ${own} "$target" - chmod ${mode} "$target" - ''; + assert target != "nixos"; + '' + source="${source}" + target="/etc/${target}" + mkdir -p $(dirname "$target") + test -e "$target" && rm -f "$target" + cp "$source" "$target" + chown ${own} "$target" + chmod ${mode} "$target" + ''; makeEtc = import ../helpers/make-etc.nix { inherit (pkgs) stdenv; diff --git a/modules/config/fonts.nix b/modules/config/fonts.nix index 4f540619a45d..f03d457a8bc7 100644 --- a/modules/config/fonts.nix +++ b/modules/config/fonts.nix @@ -155,24 +155,22 @@ let in { - require = [ - options - ]; + require = [options]; - system = { - build = { - inherit x11Fonts; - }; - }; + system.build.x11Fonts = x11Fonts; - environment = { - # Configuration file for fontconfig used to locate - # (X11) client-rendered fonts. - etc = mkIf config.fonts.enableFontConfig [{ - source = pkgs.makeFontsConf { - fontDirectories = config.fonts.fonts; - }; - target = "fonts/fonts.conf"; - }]; - }; + environment.etc = mkIf config.fonts.enableFontConfig + [ { # Configuration file for fontconfig used to locate + # (X11) client-rendered fonts. + source = pkgs.makeFontsConf { + fontDirectories = config.fonts.fonts; + }; + target = "fonts/fonts.conf"; + } + ]; + + environment.shellInit = + '' + export FONTCONFIG_FILE=/etc/fonts/fonts.conf + ''; } diff --git a/modules/module-list.nix b/modules/module-list.nix index 96e276df98d2..5b7d2f7836c2 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -8,6 +8,7 @@ ./config/users-groups.nix ./installer/grub/grub.nix ./legacy.nix + ./programs/bash/bash.nix ./programs/ssh.nix ./programs/ssmtp.nix ./security/setuid-wrappers.nix diff --git a/modules/programs/bash/bash.nix b/modules/programs/bash/bash.nix new file mode 100644 index 000000000000..e7be3b5e1029 --- /dev/null +++ b/modules/programs/bash/bash.nix @@ -0,0 +1,42 @@ +# This module defines global configuration for the Bash shell, in +# particular /etc/bashrc and /etc/profile. + +{config, pkgs, ...}: + +{ + environment.etc = + [ { # /etc/bashrc: script executed when the shell starts as a + # non-login shell. /etc/profile also sources this file, so + # most global configuration (such as environment variables) + # should go into this script. + source = pkgs.substituteAll { + src = ./bashrc.sh; + systemPath = config.system.path; + wrapperDir = config.security.wrapperDir; + modulesTree = config.system.modulesTree; + defaultLocale = config.i18n.defaultLocale; + nixEnvVars = config.nix.envVars; + shellInit = config.environment.shellInit; + }; + target = "bashrc"; + } + + { # Script executed when the shell starts as a login shell. + source = ./profile.sh; + target = "profile"; + } + + { # Template for ~/.bashrc: script executed when the shell + # starts as a non-login shell. + source = ./bashrc-user.sh; + target = "skel/.bashrc"; + } + + { # Configuration for readline in bash. + source = ./inputrc; + target = "inputrc"; + } + ]; + + system.build.binsh = pkgs.bashInteractive; +} diff --git a/etc/skel/bashrc b/modules/programs/bash/bashrc-user.sh similarity index 100% rename from etc/skel/bashrc rename to modules/programs/bash/bashrc-user.sh diff --git a/etc/bashrc.sh b/modules/programs/bash/bashrc.sh similarity index 98% rename from etc/bashrc.sh rename to modules/programs/bash/bashrc.sh index ea3f398c8f29..ad6e5d3f2477 100644 --- a/etc/bashrc.sh +++ b/modules/programs/bash/bashrc.sh @@ -5,7 +5,6 @@ export MODULE_DIR=@modulesTree@/lib/modules export NIXPKGS_CONFIG=/nix/etc/config.nix export NIXPKGS_ALL=/etc/nixos/nixpkgs export PAGER="less -R" -export FONTCONFIG_FILE=/etc/fonts/fonts.conf export LANG=@defaultLocale@ export EDITOR=nano export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info diff --git a/etc/inputrc b/modules/programs/bash/inputrc similarity index 100% rename from etc/inputrc rename to modules/programs/bash/inputrc diff --git a/etc/profile.sh b/modules/programs/bash/profile.sh similarity index 100% rename from etc/profile.sh rename to modules/programs/bash/profile.sh diff --git a/system/system-options.nix b/system/system-options.nix index 01bff26b87c3..53705900b641 100644 --- a/system/system-options.nix +++ b/system/system-options.nix @@ -39,10 +39,4 @@ in # config.system.activationScripts # ../system/activate-configuration.nix ]; - - system = { - build = { - binsh = pkgs.bashInteractive; - }; - }; }