1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-09 12:49:44 +01:00
Commit graph

124 commits

Author SHA1 Message Date
Robert Helgesson
2102b4e7b3
home-environment: minor fix of DocBook code 2020-04-10 16:16:46 +02:00
Robert Helgesson
dd538c2969
home-environment: add option sessionVariablesExtra
This is an internal option for adding additional code to
`hm-session-vars.sh`.
2020-04-08 13:23:02 +02:00
Robert Helgesson
6e4b9af080
Switch to extended Nixpkg's lib
This change makes use of the `extend` function inside `lib` to inject
a new `hm` field containing the Home Manager library functions. This
simplifies use of the Home Manager library in the modules and reduces
the risk of accidental infinite recursion.

PR #994
2020-01-21 20:47:04 +01:00
Robert Helgesson
f65510b1d1
home-environment: make home.activation public
Also improve documentation and add an example.
2020-01-16 00:16:35 +01:00
Robert Helgesson
7f87329fca
home-environment: use DAG type in activation option 2020-01-16 00:16:35 +01:00
Robert Helgesson
d6b36f12ff
keyboard: make the model option optional
Also, actually use it in the call to setxkbmap.
2019-09-05 01:56:14 +02:00
Robert Helgesson
824d31a21c
keyboard: make layout and variant optional
Also default these options to `null` for state version ≥ 19.09.

Fixes #811

Suggested-by: Sean Marshallsay <srm.1708@gmail.com>
2019-09-05 01:56:06 +02:00
Robert Helgesson
eb1b86a5ec
Replace use of stdenv.shell by runtimeShell 2019-08-22 08:35:06 +02:00
Robert Helgesson
b6e613c771
Fix type of various sessionVariables options
Unfortunately, using `attrsOf` is not possible since it results in too
eager evaluation. In particular, the

    home.sessionVariables = {
      FOO = "Hello";
      BAR = "${config.home.sessionVariables.FOO} World!";
    };

example will cause an infinite recursion.

This commit restores the option type of

- `home.sessionVariables`,
- `pam.sessionVariables`,
- `programs.bash.sessionVariables`, and
- `programs.zsh.sessionVariables`

to `attrs`. It also adds test cases for the above options to avoid
regressions.

Fixes #659
2019-04-27 01:07:09 +02:00
Robert Helgesson
b6e1d82685
home-environment: make home.keyboard optional
When set to `null` then the `xsession` module will not attempt to
manage the keyboard settings.
2019-04-11 01:09:27 +02:00
Robert Helgesson
13d2c470be
home-environment: use attrsOf instead of attrs 2019-04-03 00:09:55 +02:00
Robert Helgesson
70d4cf2cd9
Remove some use of mkDerivation
Instead use `runCommand`, which by default uses `stdenvNoCC` resulting
in a reduced dependency footprint.

Fixes #612
2019-03-18 23:09:54 +01:00
Robert Helgesson
a09196c4ae
docs: add language attribute to program listings 2019-03-06 18:52:54 +01:00
Robert Helgesson
ef168979bf
nixos module: support NixOS user packages install
When using the NixOS module we cannot guarantee that the Nix store
will be writable during startup. Installing the user packages through
`nix-env -i` will fail in these cases.

This commit adds a NixOS option `home-manager.useUserPackages` that,
when enabled, installs user packages through the NixOS

    users.users.<name?>.packages

option.

Note, when submodule support and external package install is enabled
then the installed packages are not available in `~/.nix-profile`. We
therefore set `home.profileDirectory` directly to the HM profile
packages.
2019-02-16 21:42:47 +01:00
Robert Helgesson
ea74820176
home-environment: add option home.extraProfileCommands
This _internal_ option indicates extra commands that should be run in
the `postBuild` step of the profile environment build.

Fixes #386
2018-09-14 21:08:51 +02:00
Robert Helgesson
99c900946d
Avoid substitution for some derivations
In particular, don't bother attempting to do substitution of the home
files and home generation derivations since these rarely, if ever,
could be substituted.

Fixes #330
2018-07-31 21:16:36 +02:00
Malte Brandy
c18b1328a5
Parametrize path to profile directory 2018-07-31 16:04:19 +02:00
Robert Helgesson
19b4002f25
home-environment: use nix-env from PATH
It is safest to use the system install of Nix since that will be
compatible with the running nix-daemon and/or databases.

Also add a printout of the used Nix version in the activation script
when running in verbose mode.

Fixes #218.
2018-02-27 20:31:03 +01:00
Robert Helgesson
9ea353569a
Remove deprecated option home.sessionVariableSetter 2018-02-08 22:54:29 +01:00
Robert Helgesson
1bc59f7290
allow Home Manager to be used as a NixOS module
This is a NixOS module that is intended to be imported into a NixOS
system configuration. It allows the system users to be set up directly
from the system configuration.

The actual profile switch is performed by a oneshot systemd unit per
configured user that acts much like the regular `home-manager switch`
command.

With this implementation, the NixOS module does not work properly with
the `nixos-rebuild build-vm` command. This can be solved by using the
`users.users.<name?>.packages` option to install packages but this
does not work flawlessly with certain Nixpkgs packages. In particular,
for programs using the Qt libraries.
2018-02-07 20:50:01 +01:00
Robert Helgesson
18159c85b9
home-environment: deprecate option home.sessionVariableSetter 2018-01-08 21:40:32 +01:00
Robert Helgesson
e624b9aa6a
home-environment: install hm-session-vars.sh file
This is a file containing all session variables exported using a
Bourne-compatible syntax.
2018-01-07 17:52:13 +01:00
Robert Helgesson
df6590abfc
home-environment: describe session variable values a bit 2018-01-07 16:59:22 +01:00
Robert Helgesson
33af9948e5
home-environment: describe session variable trickyness 2018-01-07 16:59:22 +01:00
Robert Helgesson
59f44c1189
home-environment: run activation script in $HOME
This avoids issues when starting the activation script somewhere
inaccessible.
2018-01-05 08:09:18 +01:00
Robert Helgesson
02219dcd79
home-environment: minor code simplification 2018-01-05 08:05:53 +01:00
Robert Helgesson
f0d207f380
Add dag library to config.lib
Also replace all imports of `dag.nix` by the entry in `config.lib`.
2017-12-26 17:27:21 +01:00
Robert Helgesson
e75b68e391
home-environment: make username and home directory writable
In certain cases it makes sense to override the target username and
home directory. In particular, if you're building a configuration for
a remote profile.
2017-12-13 16:31:35 +01:00
Robert Helgesson
28e00b68fd
home-environment: optionally empty PATH in activation
This adds the option `home.emptyActivationPath` that, when enabled,
will cause the activation script to ignore the calling user's `PATH`.
The option is disabled by default to match current behavior but the
intent is to change this in the future to reduce risk of accidental
dependencies of the environment.
2017-12-11 17:03:34 +01:00
Cornelius Mika
b8ddb11796
use buildCommand for single phase builds 2017-11-06 14:24:04 +01:00
Cornelius Mika
f04cc227a6
home-environment: clean up activation script creation 2017-11-06 14:24:04 +01:00
Silvan Mosberger
0f43d5df6a
home-environment: add extraBuilderCommands option 2017-10-21 00:22:05 +02:00
Robert Helgesson
30b9d7f00e
Use only tools from Nixpkgs in activation script
Note, we still pull in the user's `PATH` in case the user has defined
their own activation blocks that depend on additional tools.
Eventually this will be deprecated and removed.

See #99.
2017-10-20 19:04:33 +02:00
Robert Helgesson
b9f49cee45
home-environment: use makeBinPath for activation PATH 2017-10-19 22:44:02 +02:00
Silvan Mosberger
3bc3b34d97
home-environment: add username and homeDirectory options 2017-10-15 17:15:16 +02:00
Silvan Mosberger
f0a1d69f50
Separate home files module from home-environment.nix 2017-10-15 17:14:32 +02:00
Robert Helgesson
c07fa70d58
home-environment: add option home.extraOutputsToInstall 2017-10-15 15:58:34 +02:00
Robert Helgesson
a8e08d14bb
Mark rycee as maintainer for a bunch of modules 2017-09-26 23:40:31 +02:00
Robert Helgesson
742d1889c5
lib: make dag.nix take lib as argument 2017-09-21 13:19:29 +02:00
Robert Helgesson
6ecf9e091c
home-environment: fail if a home.file is outside $HOME 2017-09-13 15:23:43 +02:00
Robert Helgesson
e561beab44
home-environment: include home path in generation directory
Technically not necessary but it was a bit silly to leave out this
important directory from the generation directory. This also makes it
more convenient to browse the installed packages after a
`home-manager build`.
2017-08-27 00:18:13 +02:00
Richard Yang
42f5d4404d
home-environment: use relative latest profile link
Using a relative path prevents the latest version from being garbage
collected.
2017-08-22 09:23:03 +02:00
Cornelius Mika
3dba6fc95c
home-environment: replace superfluous spaces in debug messages 2017-08-21 18:50:21 +02:00
Cornelius Mika
1eee82272a
home-environment: only notify about path deletion on verbose output 2017-08-21 18:50:21 +02:00
Cornelius Mika
da5b7bea78
home-environment: fix error when deleting empty directories
With --ignore-fail-on-non-empty, non-emptiness is the only failure
that gets ignored by rmdir. In the case that rmdir reaches $HOME and
considers deleting it, it will detect insufficient permissions and
subsequently exit with an error, even if $HOME is not empty.

Prevent this by calling rmdir with a relative path that excludes
$HOME.
2017-08-21 18:43:17 +02:00
Nikita Uvarov
cde8e02bf2
zsh: add module 2017-08-16 13:58:30 +02:00
Robert Helgesson
d807a5c314
home-environment: fix cleanup of user replaced directories
We must only follow the symbolic link once (i.e., not use the `-e`
option) since otherwise the pattern will not match when
`home.file.xyz.source` is a directory.
2017-07-22 00:38:12 +02:00
Robert Helgesson
5862a05fb1
home-environment: avoid harmless but scary error message 2017-07-22 00:18:31 +02:00
Robin Stumm
89dc8c2004
home-environment: fix home.activation.checkLinkTargets
Problem
-------

We resolve symlinks from inside `/nix/store/HASH-home-manager-files`
into the nix store as `/nix/store/HASH-DRVNAME` which does not match
the pattern.

This happened to me because I pull in some repos in via `home.file`.
The `home-manager-files` derivation links to the repo's derivation in
the nix store. For example:

    let nanorcs = fetchFromGitHub {
      owner = "scopatz";
      repo = "nanorc";
      …
    }; in [
      {
        target = ".nano";
        source = nanorcs;
      }
      {
        target = ".nanorc";
        source = "${nanorcs}/nanorc";
      }
    ]

Solution
--------

Call `readlink` without `-e` to obtain only the first redirection from
`~` to `/nix/store/HASH-home-manager-files`.
2017-07-08 00:38:57 +02:00
Robert Helgesson
8af6838869
home-environment: prevent delete of non-managed files
When a file has disappeared between the previous and the next
generations then its symlink in `$HOME` is typically deleted. With
this commit we refuse to delete the path unless we are reasonably
certain it is a symlink into a Home Manager generation.
2017-06-29 01:03:39 +02:00
Robert Helgesson
02288320d0
home-environment: use explicit PATH in activation
In the activation script we expect to use the tools provided by GNU
Core Utilities and GNU Bash. This commit therefore explicitly add
these first in the `PATH` environment variable.
2017-05-16 22:04:19 +02:00
Robert Helgesson
3ee505179f
home-environment: colorize activation output slightly 2017-05-14 16:17:38 +02:00
Robert Helgesson
a9da4575f5
home-environment: run file collision check in function 2017-05-14 14:02:11 +02:00
Robert Helgesson
88ec7145ba
home-environment: prevent overwriting existing files
This should reduce the risk of overwriting an existing file in the
user's home directory. A file will only be replaced if it is a link
pointing to a home-manager tree inside the Nix store.

If an existing file is detected an error is written indicating the
file's path and the activation will terminate before any mutation
occurs.

Fixes #6
2017-05-06 13:01:01 +02:00
Robert Helgesson
7e58b6bb35
home-environment: always link new and clean old generation
Previously the home files were not linked if the generation hadn't
changed. Unfortunately, this would mean that, if a file link was
removed for some reason it would not be recreated by running a switch
command.
2017-05-06 00:43:53 +02:00
Robert Helgesson
8fab2a5d9b
Add basic directed acyclic graph data structure
Also make use of this instead of Nixpkgs's strings-with-deps library
in activation script generation.
2017-05-04 00:39:36 +02:00
Robert Helgesson
4f1eec8180
Avoid undefined variables in activation script 2017-03-29 00:11:01 +02:00
Robert Helgesson
fea693ba16
Use stricter Bash settings in activation script
For example, with these settings Bash will complain if uninitialized
variables are used. Some code has been improved to run cleanly with
these settings.
2017-03-25 21:57:03 +01:00
Robert Helgesson
207c349825
home-environment: allow directory as home file
Fixes issue #5.
2017-03-12 22:39:51 +01:00
Robert Helgesson
ee9bc66f69
home-environment: show full file path in error
The file name alone may be misleading.
2017-02-21 21:55:07 +01:00
Robert Helgesson
a3900340e4
home-environment: check files for '.' prefix
Nix does not allow files whose name start with a '.' in the Nix store.
This commit makes a not of this fact in the `home.file.source` option
and also adds an assertion verifying that no such file is given.

Closes #4
2017-02-21 21:41:05 +01:00
Robin Stumm
fa73a7f916
home-environment: fix evaluation error on undefined lang.base 2017-02-12 10:41:15 +01:00
Robert Helgesson
ebe01057f8
home-environment: reduce verbosity 2017-02-09 22:32:09 +01:00
Robert Helgesson
6794efdf68
home-environment: add link for current profile
This link is needed to make the `delete-older-than` option for
`nix-collect-garbage` work as expected.
2017-02-05 23:00:04 +01:00
Robert Helgesson
34d472886d
home-environment: do not nix-env -i on dry run 2017-02-05 11:51:33 +01:00
Robert Helgesson
deaa6d3dd4
Add configurable verbosity during activation 2017-01-21 12:27:50 +01:00
Robert Helgesson
86217419e7
home-environment: handle no home files
If no files should be installed into the home directory then an error
would occur since the directory holding the files would never be
created. With this change the directory is unconditionally created.
2017-01-17 22:12:51 +01:00
Robert Helgesson
5221dee9ce
home-environment: use Bash to set variables
Until a few more standard variables are available to PAM it is a bit
risky to default to it.
2017-01-17 01:13:31 +01:00
Robert Helgesson
5fbbbd1ea4
pam: add module
Also make it possible to set session variables using PAM rather than
Bash.
2017-01-16 23:54:45 +01:00
Robert Helgesson
f35b9a9970
Add initial section of activation script
The initial section creates some useful variables for use by later
activation sections.
2017-01-16 20:33:53 +01:00
Robert Helgesson
b1f84ada60
Support dry run in activation script
If the `DRY_RUN` variable is set then no actual change should be
performed. Only printing what actions would be taken.
2017-01-16 00:16:22 +01:00
Robert Helgesson
071e631648
Improve a few description fields 2017-01-15 23:42:48 +01:00
Robert Helgesson
43fd747ba7
Use a generation directory
Before we put only user files in the generation directory but that was
quite limiting. In particular, we lost track of the activation script.
2017-01-15 23:41:20 +01:00
Robert Helgesson
d7d02c3ce8
Initial import 2017-01-14 13:15:24 +01:00