Commit Graph

103 Commits

Author SHA1 Message Date
Robert Helgesson 886675991b
home-environment: reset PATH in activation script
Starting with state version 22.11 we completely reset the PATH
variable in the activation script. This is to avoid impurities and
unexpected results if the activation script accidentally uses a
command found in the user's PATH.
2022-11-07 15:09:36 +01:00
David Arnold 989d4fa536
home-environment: remove no-op commands 2022-11-06 00:15:35 +01:00
Ronny Pfannschmidt ccc9164b76
home-environment: fix activation on new style profiles
When using the new style profiles we get conflicts when trying to
replace the old `home-path` derivation. To avoid this conflict we
delete the old `home-path` before the install.

Unfortunately, `nix profile` does not yet have a equivalent for
`nix-env --set` and we have to do this hackish workaround. See

  https://github.com/NixOS/nix/issues/6349

for the associated issue in Nix.

Fixes #2848
2022-11-06 00:12:08 +01:00
Robert Helgesson 423211401c
home-environment: update hm-version generation
Instead of home-made script use the Nixpkgs library functions. This
will hopefully be more robust and give more accurate results.
2022-10-28 22:51:35 +02:00
Robert Helgesson f67649307d
home-environment: make getVersion more robust 2022-10-27 22:20:37 +02:00
Robert Helgesson 32fe7d2ebb
home-environment: add hm-version file
This commits adds a file `hm-version` to the generated generation
directory. This file will contain the release version, and if
available, the Git commit hash.
2022-10-27 14:51:48 +02:00
Robert Helgesson 76fbb1b15e
treewide: replace <link> by <xref> where appropriate 2022-08-26 00:07:08 +02:00
Kat Inskip d49d68f419
home-manager: Fix cross-compiles, fixes #2675 (#2893) 2022-04-14 20:58:15 -04:00
Moises Nessim 2f58d0a3de
nix: add support for `nix profile`
PR #2833

Co-authored-by: David Arnold <dar@xoe.solutions>
Co-authored-by: Florian Franzen <Florian.Franzen@gmail.com>
2022-03-26 15:11:28 +01:00
Robert Helgesson 8e7a10602d
treewide: make a few more strings translatable 2022-01-02 11:56:52 +01:00
Robert Helgesson 9bcad20013
home-manager: add basic i18n support
The support for translated strings is, for now, limited to strings
generated in Bash code.
2021-12-13 21:47:28 +01:00
Robert Helgesson dc2a4e4146
Switch to 21.11 as stable release 2021-11-25 22:22:26 +01:00
Robert Helgesson 8230decb3f
home-environment: make `home.profileDirectory` public
This option has been stable for a long time and may be generally
useful.
2021-11-19 23:58:22 +01:00
Robert Helgesson be1ad30503
Remove remaining `allowSubstitutes = false`
See, e.g., https://github.com/NixOS/nix/issues/4442 for wider
discussions.
2021-11-12 23:24:08 +01:00
Robert Helgesson 7f416c9e2f
home: use literalExpression 2021-11-07 09:10:57 +01:00
oberblastmeister f6f013f764
home: shell agnostic aliases (#2347) 2021-11-06 10:10:15 -06:00
Joscha 21590d40c1
home-environment: document escaping of home.sessionPath 2021-11-02 00:08:57 +01:00
Nicolas Berbiche 2e1a5b53ec
xsession: don't reset the inherited keyboard options
If the keyboard configuration is an empty set, don't run the setxkbmap
service.

The default values for all keyboard options are null or empty so long
as the state version is set to 19.09 or higher (21.05 being the latest
version).
2021-11-01 22:42:47 +01:00
Naïm Favier bd11e2c5e6
Replace usage of `literalExample`
Instead use the new function `literalExpression`. See

  https://github.com/NixOS/nixpkgs/pull/136909
2021-10-13 00:16:10 +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