1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-24 03:59:46 +01:00
Commit graph

52 commits

Author SHA1 Message Date
Robert Hensing
26e72d85e6
home-manager: set module class to "homeManager"
This enables a module system feature documented here:
https://nixos.org/manual/nixpkgs/stable/index.html#module-system-lib-evalModules-param-class

For example, it allows a mistake to be caught, which is loading a
NixOS module into home-manager. This only works when the offending
module declares what it's for with a `_class` attribute.

It is not expected that users declare the `_type`, because the payoff
is small. It is only expected to be set by generic code, such as
functions or libraries that help with the "publishing" of modules
(e.g. flake-parts, flake-utils).

The class feature has been available in the module system since
https://github.com/NixOS/nixpkgs/pull/197547, merged May 6, 2023. It
has been part of all releases since 23.05-beta. The last NixOS release
that did _not_ support it has been end-of-life for close to a year
now.

Example:

    (lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      modules = [{ _class = "nixos"; imports = [ ./foo.nix ]; }];
    }).activation-script

Corresponding error:

    error: The module <unknown-file> was imported into homeManager instead of nixos.

(`<unknown-file>` can be improved by also setting `_file`, if known; a
much older feature)

PR #5339
2024-04-27 09:28:21 +02:00
Bjørn Forsman
f7848d3e5f
nixos: increase TimeoutStartSec from 1m30s to 5m
I'm experiencing timeouts for home-manager-$USER.service in my NixOS VM
tests. The NixOS testing framework increases the default timeout from
1m30 to 5m, but since home-manager specifies a timeout, that value wins.

There's no point in having a tight timeout value, so increase it to 5m.
2023-09-10 21:54:17 +02:00
TNE
ca4126e3c5
nixos: only refer to users.users if needed
Fixes a regression of GitHub issue #594. Before this commit,
attempting to dynamically configure Home Manager with contents of
nixos's users.users when using the nixos module would result in
infinite recursion.

PR #4368
2023-08-22 08:28:20 +02:00
Emily
9f9e277b60 treewide: remove now-redundant lib.mdDoc calls
These (and the `*MD` functions apart from `literalMD`) are now no-ops
in nixpkgs and serve no purpose other than to add additional noise and
potentially mislead people into thinking unmarked DocBook documentation
will still be accepted.

Note that if backporting changes including documentation to 23.05,
the `mdDoc` calls will need to be re-added.

To reproduce this commit, run:

    $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
      nix shell nixpkgs#coreutils \
      -c find . -name '*.nix' \
      -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
      --strip {} +
    $ ./format
2023-07-17 18:49:09 +01:00
Emily
36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00
Emily
3228f92b90 treewide: manually convert some docs to Markdown
These files all have options that trip up the `nix-doc-munge`
conversion tool for one reason or another (syntax that clashes with
Markdown, options that were already using Markdown syntax despite not
being marked that way, output that differs slightly after conversion,
syntax too elaborate to convert with some cheap regular expressions,
...). Translate them manually and do a little copyediting to options
in the vicinity while we're at it.
2023-07-17 16:49:35 +01:00
Rodney Lorrimar
3be2abb2e6
i18n: Use glibcLocales from NixOS if possible (#2333) (#4177)
This will reduce the system closure size by about 200MB under NixOS by
sharing the glibcLocales package.

When home-manager is installed on Linux without the NixOS module, all
glibc locales are installed, as before.

Resolves: #2333
2023-07-04 11:28:25 +02:00
ThinkChaos
d82c9af817
nixos: use lib argument instead of pkgs.lib (#3454)
This allows users to pass a lib with custom attributes and have those
available to custom HM modules.
2023-04-26 21:03:06 +02:00
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
Naïm Favier
70d5929885
integration-common: set hmModule's description directly
Removes the hack after https://github.com/NixOS/nixpkgs/pull/173621
landed.

(cherry picked from commit 0434f8e4ca)
2022-07-19 15:44:01 +02:00
Robert Helgesson
be3adf9920
Revert "integration-common: set hmModule's description directly"
This reverts commit 0434f8e4ca.
2022-06-27 08:58:54 +02:00
Naïm Favier
0434f8e4ca
integration-common: set hmModule's description directly
Removes the hack after https://github.com/NixOS/nixpkgs/pull/173621
landed.
2022-06-26 21:39:20 +02:00
Naïm Favier
586ac1fd58
Move integration-common.nix to nixos/common.nix 2022-06-19 00:45:18 +02:00
André Silva
87d30c1648
nixos: fix fontconfig mkDefault call (#3021) 2022-06-14 11:34:44 +02:00
Sandro
cd3dd2188c
nixos: allow setting fonts.fontconfig.enable without mkForce (#3014) 2022-06-13 20:00:51 +02:00
Naïm Camille Favier
64ab7d6e8d
Prepare inclusion in nixos-search (#2971)
* Add flake.lock and clean up flake.nix

Add a lockfile to work around https://github.com/NixOS/nix/issues/6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see https://github.com/nix-community/home-manager/pull/2442#issuecomment-1133670487

* nixos,nix-darwin: factor out into a common module

* nixos,nix-darwin: make `home-managers.users` shallowly visible

Make sure the option is included in the NixOS/nix-darwin manual (but the
HM submodule options aren't).

Also add a static description to the HM submodule type so that we don't need to
evaluate the submodules just to build the option manual. This makes
nixos-search able to index the home-manager flake.

Also clean up some TODOs.

* flake: add nmd and nmt

This avoids having to use `pkgs.fetchFromGitLab` in an IFD, which causes
issues when indexing packages with nixos-search because `pkgs` is
instantiated with every platform.
2022-06-07 20:45:06 +02:00
ilkecan
c2726860a2
nix-darwin,nixos: convert modulesPath to string (#2714)
`modulesPath` is usually used with antiquotation
(`"${modulesPath}/some-module.nix"`). Since antiquoted paths are copied
to the Nix store, one must explicitly do `"${toString
modulesPath}/some-module.nix"` to avoid that. Ideally `modulesPath`
should be a string to avoid this. Note that `modulesPath` is already
defined as a string in <home-manager>/modules/default.nix and
<nixpkgs>/nixos/lib/eval-config.nix.
2022-04-17 18:23:18 -04:00
Robert Helgesson
192675b149
docs: fix a few stray periods 2022-01-25 00:10:25 +01:00
Lorenzo Manacorda
39c5c7397e
docs: improve description of extraSpecialArgs 2021-11-13 01:01:01 +01:00
Bastien Rivière
8278c14f5f
nixos: replace types.anything with submodule type (#2396)
As discussed in this issue:
https://github.com/NixOS/nixpkgs/issues/140879
`types.anything` was never meant to be used for arbitrary modules.

Co-authored-by: Silvan Mosberger <github@infinisil.com>
2021-10-22 17:52:19 -04: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
Nicolas Berbiche
60ebc273c9
nix-darwin,nixos: add osConfig module argument (#2302)
Having either argument defined based on the OS is a problem when
trying to write generic Nix code.

The current workaround is to use accept both and specify a default
value for each argument:

```
{ config, lib, nixosConfig ? {}, darwinConfig ? {}, ... }:

let
  osConfig = nixosConfig // darwinConfig;
in
{
  # Do something with `osConfig`
}
```

With this commit, it becomes possible to do the following:

```
{ config, lib, osConfig, ... }:

{
  # Do something with `osConfig`
}
```
2021-10-06 16:32:13 +02:00
Naïm Favier
099cbcf13e
nixos: add modulesPath to specialArgs
Fixes #1792
2021-10-03 23:27:24 +02:00
Naïm Favier
b0651cc217
nixos: import existing environment during activation
If the user has a running systemd session, source their environment
from the systemd manager and export a few variables in order to allow
activation scripts to reload applications on the fly.

The list of variables to export is arbitrary and could be extended in
the future.

Fixes #1399, fixes #2112.
2021-09-23 23:09:00 +02:00
arcnmx
bd747c5a53
nixos: add timeout to hm-activate service
Oneshot services do not have a timeout by default, so a misbehaving
activation script can stall and prevent a system from ever booting.
2021-09-04 22:55:30 +02:00
Connor Prussin
f6d1cad6ba
[nixos] Fix race condition with user units (#2286)
One of the things managed by the `home-manager-<username>` unit is the systemd
user directory `.config/systemd/user`.  However, this directory needs to be in
place completely before systemd user sessions start up or the user sessions will
come up with an incomplete listing of enabled units, etc.

There was a race condition where nothing prevented
`systemd-user-sessions.service` from starting ahead of the systemd user
directory's initialization completing.  This commit makes
`home-manager-<username>` finishes _before_ we start
`systemd-user-sessions.service` to avoid such race condition.

This issue was probably not all that noticeable in most cases, but when using a
non-persistent root config (i.e. tmp on / or
https://grahamc.com/blog/erase-your-darlings) the race condition triggering
causes all kinds of issues on each reboot.
2021-08-21 22:14:40 -04:00
zseri
7c19bcb822
nixos: remove indirection via activate-${username}
Fixes #2191
2021-07-29 22:23:24 +02:00
Robert Helgesson
ddeeb031fd
nixos: add nix package to activation script path
Fixes #2178
2021-07-23 23:18:15 +02:00
Naïm Favier
4ed6705b0f
nixos: set stopIfChanged to false (#2105)
There is no ExecStop so we can just restart the service.
2021-06-14 20:49:38 +03:00
Pacman99
fedfd430f9
nixos/nix-darwin: switch sharedModules type to anything with custom check (#1880)
functionTo tries to evaluate functions too quickly and prevents modules
from accessing pkgs argument. fixes #1878.

Co-authored-by: Pacman99 <pachum99@gmail.com>
2021-03-25 22:01:16 -04:00
Pacman99
82d6ba7003
nixos,darwin: add sharedModules and extraSpecialArgs options (#1793)
This allows users of the nixos and nix-darwin module to set shared modules
for all users and extra specialArgs to be available to home-manager modules.

The latter is named extraSpecialArgs just like the argument to
modules/default.nix.
This could be confusing since the the two are independent in code,
but they do mean the same thing so I think the name fits.

Darwin can now refer to the global system configuration if used as a module
through the special `darwinConfig` argument.

Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
2021-02-21 01:02:25 -05:00
Robert Helgesson
5280360d6c
docs: NixOS and nix-darwin option documentation 2021-01-21 23:45:52 +01:00
uosis
7339784e07
nixos: pass system configuration to HM modules 2020-10-11 23:33:44 +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
Robert Helgesson
1a8ab9d9de
nixos, nix-darwin: fix user packages install
It is insufficient to install the packages in `home.packages`, it has
to be `home.path`, which includes configured extra package outputs or
profile commands.
2020-07-14 23:31:19 +02:00
Finn Behrens
5ba71ef91f
nixos: add mount check for home directory
PR #1271
2020-05-26 19:18:24 +02:00
Erik Arvstedt
efbe1383e6
nixos integration: add option 'useGlobalPkgs'
PR #1059
2020-03-07 14:25:00 +01:00
Robert Helgesson
45abf3d38a
Apply nixfmt on many files 2020-02-02 01:07:28 +01: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
a144c723a1
doc: surround name? with fancier characters 2019-09-01 21:28:40 +02:00
Robert Helgesson
eb1b86a5ec
Replace use of stdenv.shell by runtimeShell 2019-08-22 08:35:06 +02:00
Robert Helgesson
7834ffbbf1
nixos: pass on warnings to the system configuration
Fixes #804
2019-08-18 17:35:42 +02:00
Robert Helgesson
fa82ced414
nixos: use non-deprecated fontconfig option 2019-08-18 17:35:41 +02:00
Tobias Happ
9cc30b18f7
nixos: add backup file extension and verbosity options 2019-08-18 17:19:39 +02:00
Jaka Hudoklin
2e13c3cdfd
nixos: use usercfg.home.username for username
Use `usercfg.home.username` for username instead of attribute name,
as this way we can change username regardless of the name of the attribute.
2019-05-25 14:26:49 +02:00
Maximilian Bosch
0898b6b482
nixos module: evaluate assertions from Home Manager modules 2019-03-06 18:37:37 +01:00
Robert Helgesson
799a90ecfa
fontconfig: make fonts accessible when in NixOS module 2019-02-16 21:42:47 +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
Ingolf Wanger
fbdb5beb59
nixos: use correct username for systemd service 2019-02-10 00:46:44 +01:00
Robert Helgesson
2f372ab4d6
Clean up support code for Home Manager as a submodule
This removes the `nixosSubmodule` option in favor of a new option
`submoduleSupport.enable`. This name better indicates that the
submodule mode applies to both NixOS and nix-darwin.
2019-02-10 00:44:55 +01:00