summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-10-19 23:25:15 +0200
committerDaiderd Jordan <daiderd@gmail.com>2016-10-19 23:31:43 +0200
commitce690db770d88decba4d279b05a4ef2af7a67204 (patch)
treee7aa690d809d6960f3c278e71363abdef8b2e668
parent491e06ab15c46c04d1f0f5a73049a5d51964ef19 (diff)
added support for environment.variables
-rw-r--r--config.nix11
-rw-r--r--modules/environment.nix24
2 files changed, 33 insertions, 2 deletions
diff --git a/config.nix b/config.nix
index 75a8bcd..c4d5a8f 100644
--- a/config.nix
+++ b/config.nix
@@ -14,6 +14,7 @@ let
};
config =
+ { config, lib, pkgs, ... }:
{
environment.systemPackages =
[ pkgs.lnl.vim
@@ -30,14 +31,16 @@ let
pkgs.nox
];
- environment.etc."profile".text = ''
- export HOMEBREW_CASK_OPTS="--appdir=/Applications/cask"
+ environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
+ environment.etc."profile".text = ''
conf=$HOME/src/nixpkgs-config
pkgs=$HOME/.nix-defexpr/nixpkgs
alias ls='ls -G'
alias l='ls -hl'
+
+ source ${config.system.build.setEnvironment}
'';
environment.etc."tmux.conf".text = ''
@@ -49,6 +52,8 @@ let
set -g base-index 1
set -g renumber-windows on
+ setw -g mode-keys vi
+
bind c new-window -c '#{pane_current_path}'
bind % split-window -v -c '#{pane_current_path}'
bind '"' split-window -h -c '#{pane_current_path}'
@@ -102,6 +107,8 @@ in {
set et sw=2 ts=2
set bs=indent,start
+ set nowrap
+
set list
set listchars=tab:»·,trail:·,extends:⟩,precedes:⟨
set fillchars+=vert:\ ,stl:\ ,stlnc:\
diff --git a/modules/environment.nix b/modules/environment.nix
index 68c5677..ace1b1c 100644
--- a/modules/environment.nix
+++ b/modules/environment.nix
@@ -6,6 +6,12 @@ let
cfg = config.environment;
+ exportVariables =
+ mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
+
+ exportedEnvVars =
+ concatStringsSep "\n" exportVariables;
+
in {
options = {
@@ -31,10 +37,28 @@ in {
description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
};
+ environment.variables = mkOption {
+ default = {};
+ description = ''
+ A set of environment variables used in the global environment.
+ These variables will be set on shell initialisation.
+ The value of each variable can be either a string or a list of
+ strings. The latter is concatenated, interspersed with colon
+ characters.
+ '';
+ type = types.attrsOf (types.loeOf types.str);
+ apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
+ };
+
+
};
config = {
+ system.build.setEnvironment = pkgs.writeText "set-environment" ''
+ ${exportedEnvVars}
+ '';
+
system.path = pkgs.buildEnv {
name = "system-path";
paths = cfg.systemPackages;