Commit graph

85 commits

Author SHA1 Message Date
Robert Helgesson de0070c4cf
files: add preliminary support for full paths
This represents the first step in migrating `home.file` to support
arbitrary absolute paths. This is to allow Home Manager to manage
files anywhere, provided the user has sufficient privileges.

For example, with this change the configuration

    home.file."test/one".text = "foo";
    home.file."/test/two".text = "foo";

will result in the files "$HOME/test/one" and "/test/two",
respectively. Note, a relative file name will still be relative
`$HOME`.

To allow a reasonable transition between the old and new path handling
we introduce the notion of "generation directory layout version". The
version is simply a file `version` within the generation directory
containing a number indicating the version number.

The version 0 (also implied if the version file is missing) indicates
the legacy layout where managed file paths always are relative
`$HOME`.

Version 1 indicates the new layout where managed file paths are
relative `/`.
2021-07-27 23:42:51 +02:00
Robert Helgesson ddeeb031fd
nixos: add nix package to activation script path
Fixes #2178
2021-07-23 23:18:15 +02:00
Robert Helgesson ac319fd314
home-environment: add Nixpkgs release version check
This adds a warning when a release version mismatch is detected
between Home Manager and Nixpkgs.
2021-07-04 09:40:40 +02:00
Robert Helgesson 794d08a1d8
home-environment: generate checked activation script
By using `writeShellScript` when writing the activation script we
automatically get the right shebang and also get syntax validation.

Issue #2015
2021-05-18 00:18:57 +02:00
Robert Helgesson d57c59e7cb
home-environment: extra message on nix-env error
When profile installation fails during activation we'll print an extra
message that explain that, if the error is due to conflicting
packages, then it may be that the user has a manually installed copy
of the package.

Fixes #1244
2021-04-29 17:58:15 +02:00
ant-arctica 3a16ebdf72
home-manager: Add --flake option to home-manager (#1856)
Implements a --flake options for build and switch, along with the usual
flake related optons (for lock-files etc).

Configurations in the flake are automatically discovered in the
following order:
1. `outputs.homeConfigurations."$flake-uri"` (the `--flake parameter`)
2. `outputs.homeConfigurations."$USERNAME@$HOSTNAME"`
3. `outputs.homeConfigurations."$USERNAME"`

Make home-manager use default configuration from
~/.config/nixpkgs/flake.nix, if it exists and nothing else is
specified.

Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
2021-04-07 13:17:39 -04:00
Andrew Fontaine 0006da1381
home-environment: add option home.sessionPath
This option allows adding additional entries to `PATH`.
2020-10-05 21:06:42 +02:00
Robert Helgesson e6e49ad73c
home-environment: coerce home.homeDirectory to string
The home directory option should be a string without context to avoid
the directory being copied to the Nix store.

Fixes #1471
2020-09-02 22:37:21 +02:00
Robert Helgesson a49ce0e9ed
home-environment: use per-user profile path in /etc
Before the profile directory value would point directly to the build
output in the Nix store. Unfortunately this would cause an infinite
loop if the user's configuration directly or indirectly refers to the
profile directory value.

Fixes #1188
2020-07-14 23:31:20 +02:00
Jakub Fišer 479274775f
home-environment: add full locale options support
Allows setting every locale option independently. Also fixes `LC_`
order to match the order of `locale` command output for better
reference.

PR #1278
2020-06-06 21:23:01 +02:00
Robert Helgesson b95ad63201
Deprecate use of builtins.getEnv
This removes the use of the non-deterministic function
`builtins.getEnv` for state version ≥ 20.09.

PR #1269
2020-05-26 00:28:59 +02:00
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