-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
home-environment: allow adding to $PATH #1292
Conversation
Hmm looks like the build failed because fetching |
Does that work for you locally? I tried |
Either @rycee can restart the build on Travis or you can make some change and force-push, that might trigger the build as well. |
Hmm, I think I'm wrong and that does indeed work. I just needed to restart my system. |
1fb73ae
to
0bcac66
Compare
For reference, Nixos has the weird limited option:
what if you want to prepend to PATH instead ? can't you just modify |
Does that have a different effect:
See my previous comment: #1292 (comment) It doesn't work straightforwardly. |
Seems like it worked ?! this behaves no differently: if you change sessions variables, you have to relog, otherwise, you could change it into your shell variables. |
You're right, I forgot! |
0bcac66
to
7fa8fa2
Compare
@turion sorry for letting this stall for so long, but I've updated the documentation a bit more and fixed the default example. As for why this and not just I have The prepend/append issue is interesting, but I'm not sure what the best approach is to this beyond complicating this even further with something like |
I think this is a good option to add. @rycee probably your input is needed here :) |
one can already adjust the PATH via |
@teto How? Where? Through If in either of those options, how do we append to it across multiple Admittedly, it does feel slightly overkill, but at the same time, the current solutions feel... lacking. I'm not really sure what the best solution is though. |
I don't think this is overkill or overengineered. It abstracts adding directories to the PATH from the actual mechanism. It's good that one can configure the PATH variable without having to read the home-manager source code in order to understand where and when and how |
Perhaps it would suffice to fix the type of diff --git a/modules/home-environment.nix b/modules/home-environment.nix
index 209df4ff..7691e6a1 100644
--- a/modules/home-environment.nix
+++ b/modules/home-environment.nix
@@ -228,7 +228,11 @@ in
home.sessionVariables = mkOption {
default = {};
- type = types.attrs;
+ type = with types;
+ let
+ primitive = either bool (either int str);
+ var = either primitive (listOf str);
+ in attrsOf var;
example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
description = ''
Environment variables to always set at login.
diff --git a/modules/lib/shell.nix b/modules/lib/shell.nix
index 5e5743f5..7b57596d 100644
--- a/modules/lib/shell.nix
+++ b/modules/lib/shell.nix
@@ -2,7 +2,10 @@
rec {
# Produces a Bourne shell like variable export statement.
- export = n: v: ''export ${n}="${toString v}"'';
+ export = let
+ toShell = v:
+ if lib.isList v then lib.concatStringsSep ":" v else toString v;
+ in n: v: ''export ${n}="${toShell v}"'';
# Given an attribute set containing shell variable names and their
# assignment, this function produces a string containing an export Then the configuration
would place export PATH="$HOME/path1:$HOME/path2:$PATH" in It wouldn't correctly handle an empty |
@rycee Quick question: why would you use |
@berbiche I assume you mean |
This was my initial thought as well, @rycee, but I am relatively new to writing nix so
This was my big blocker though. |
But there are lots of session variables that aren't paths. |
04276f3
to
8f024ed
Compare
@rycee is there anything I can change here to move this along, aside from merge conflicts? |
This option allows adding additional entries to `PATH`.
ba28317
to
0006da1
Compare
I made some minor changes and merged to master. Thanks for the contribution! |
awesome, thanks @rycee |
Description
Sometimes I'll have some things installed to my dot files that provide
a collection of executables (doom-emacs, org-capture), or need a
$HOME/bin
or similar to keep a handful of quick scripts and wanted tobe able to do it decrlaratively.
Checklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Added myself as module maintainer. See example.
Added myself and the module files to
.github/CODEOWNERS
.