From ffbc7e723d78f479256828102c9eb367831982f1 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:27 +0200 Subject: [PATCH] home-manager: add config file attribute --- home-manager/default.nix | 8 ++++++-- home-manager/home-manager | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index b2c137b0..979f9aa8 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -9,11 +9,15 @@ let homeManagerExpr = pkgs.writeText "home-manager.nix" '' - { pkgs ? import {}, confPath }: + { pkgs ? import {}, confPath, confAttr }: let env = import { - configuration = import confPath; + configuration = + let + conf = import confPath; + in + if confAttr == "" then conf else conf.''${confAttr}; pkgs = pkgs; }; in diff --git a/home-manager/home-manager b/home-manager/home-manager index 6f8e4f60..d6d17053 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -82,6 +82,7 @@ function doBuild() { nix-build $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ + --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ -A activation-script \ -o "$output" } @@ -121,6 +122,8 @@ function doHelp() { echo echo " -f FILE The home configuration file." echo " Default is '~/.config/nixpkgs/home.nix'." + echo " -A ATTRIBUTE Optional attribute that selects a configuration" + echo " expression in the configuration file." echo " -I PATH Add a path to the Nix expression search path." echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" @@ -135,8 +138,9 @@ function doHelp() { } EXTRA_NIX_PATH=() +HOME_MANAGER_CONFIG_ATTRIBUTE="" -while getopts f:I:vnh opt; do +while getopts f:I:A:vnh opt; do case $opt in f) HOME_MANAGER_CONFIG="$OPTARG" @@ -144,6 +148,9 @@ while getopts f:I:vnh opt; do I) EXTRA_NIX_PATH+=("$OPTARG") ;; + A) + HOME_MANAGER_CONFIG_ATTRIBUTE="$OPTARG" + ;; v) export VERBOSE=1 ;;