1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-02 04:53:33 +02:00
Commit Graph

140 Commits

Author SHA1 Message Date
Luna Nova
0c5704ecee
home-manager: make newsReadIdsFile more reliable
Specifically, avoid duplicate remove duplicate slashes in the
`news-read-ids` file path.

Also quote the use of `newsReadIdsFile` to reduce problems with
potential spaces.
2024-04-25 13:01:58 +02:00
dotconfig404
33a20182e3
home-manager: improve session variables comment 2024-04-23 19:49:42 +02:00
Robert Helgesson
178e26895b
home-manager: error out on missing option argument
Instead of an error

    line 958: $1: unbound variable

we now emit an error such as

    missing argument for --cores

Note, this is not perfect. In many cases you still get sub-optimal
error messages.
2024-04-18 17:25:13 +02:00
Robert Helgesson
1c2c5e4cab
home-manager: fix nix-build option -q
The `-q` option does not actually exist, nix-build expects `--quiet`.
2024-03-22 19:46:20 +01:00
Robert Helgesson
3d6791b389
home-manager: add Nix sanity check
This should ensure that the necessary profile directories are created.
2024-02-15 22:05:29 +01:00
Robert Helgesson
07fd41171f
home-manager: fix incorrect log message 2024-02-15 13:10:07 +01:00
Robert Helgesson
7889bfb475
home-manager: overrideable URLs in generated flake
When using the `init` sub-command, it is now possible to set the Home
Manager and Nixpkgs input URLs. Note, for now these options are
considered experimental.
2024-02-14 15:10:53 +01:00
Scott Stevenson
b319781e30
home-manager: Check VISUAL before EDITOR for editor
Check VISUAL for a visual editor before EDITOR, as per Unix convention
and as followed by Git, crontab, mutt, and other tools.
2024-02-05 23:22:43 +01:00
Robert Helgesson
4256729006
treewide: deprecate DRY_RUN_CMD and DRY_RUN_NULL
As a replacement, this adds the `run` helper function.
2024-01-24 13:36:05 +01:00
Robert Helgesson
7403ed4980
home-manager: internalize uninstall
This adds a Boolean option `uninstall`. When enabled this option will
reset side-effecting configurations to their "empty" state. The intent
is that this will cause the activation script to remove all managed
files and packages.

Doing it this way should hopefully be more robust than the previous
solution. It also allows a somewhat more convenient uninstall process
when using Flakes; put `uninstall = true` in your existing
configuration and then do a switch.

Also add simple uninstall test in CI test job.
2024-01-13 00:32:31 +01:00
Robert Helgesson
294c13fa4b
home-manager: update --version to 24.05 2024-01-06 00:16:14 +01:00
Robert Helgesson
e8aaced73e
home-manager: sort list packages output
Fixes #4788
2023-12-18 23:05:17 +01:00
e-nikolov
a2e592cc49
home-manager: improve nix profile detection
If `nix.settings.use-xdg-base-directories` is true, the
`~/.nix-profile` directory may not exist, and `home.profileDirectory`
should be checked instead.

Co-authored-by: Bruno BELANYI <bruno@belanyi.fr>
2023-12-17 12:22:53 +01:00
Robert Helgesson
aeb2232d7a
home-manager: set stable release to 23.11 2023-11-24 09:23:25 +01:00
Shawn Morel
7af969886b
home-manager: improve comment in example configuration 2023-11-19 10:10:20 +01:00
Robert Helgesson
e63c30fe97
home-manager: fix assignment to read-only variable
Fixes #4519
2023-10-04 00:15:24 +02:00
e-nikolov
ae896c810f
home-manager: set profile path variables lazily
We only need the Home Manager path variables when performing a few
operations, so only set the variables for those operations.

This avoids problems on fresh installations, where no profile
directory exists.

Fixes #4403
2023-09-30 10:38:31 +02:00
Thomas de Queiroz Barros
f07207f8ca
home-manager: fix typo 2023-09-13 23:45:52 +02:00
Robert Helgesson
c3ab5ea047
home-manager: handle profile list in Nix >2.17
Nix 2.17 changed the format of the `nix profile list` output. This
commit adds support for parsing the new JSON profile list format.

Fixes #4298
2023-08-13 01:18:17 +02:00
Robert Helgesson
3db43afcb4
home-manager: rework news command
This new way of handling news should also work in Nix Flake setups.
2023-07-31 12:43:36 +02:00
Robert Helgesson
729ab77f9e
home-manager: skip manual in uninstall configuration
No need to spend time building a manual when doing the install. Also
helps if the manual, for whatever reason, doesn't build.
2023-07-31 10:02:47 +02:00
Rosario Pulella
1e7ba7102e
home-manager: remove Home Manager default paths
This removes the hard-coded fallback Home Manager paths. Specifically

    ${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager

and

    "$HOME/.nixpkgs/home-manager"

Use `@HOME_MANAGER_PATH@` if it has been provided and points to
something that exists. Warn the user if it does not point to
something.

If we have not been provided with a `@HOME_MANAGER_PATH@` that exists,
then for both hard-coded paths show a warning if something exists
where the paths are pointing.

This no longer attempts to use either of the hard-coded paths as
fallback for the Home Manager path.
2023-07-16 10:09:22 +02:00
Carl Dong
8c66b46a86
home-manager: Use path: URI type for flake default (#3646)
Nix interprets a path-like URI as a git repository if any of the path's
parents is a git repository. Since home-manager uses a default flake URI
of ~/.config/nixpkgs/flake.nix, if you have a git repository as your
home directory and a '*' .gitignore it leads to the following problems:

    evaluating derivation 'git+file:///Users/dongcarl?dir=.config%2fnixpkgs#homeConfigurations."dongcarl".activationPackage'
    The following paths are ignored by one of your .gitignore files:
    .config

This is solved by explicitly specifying the `path:` URI type prefix for
the default flake URI argument.
2023-07-03 17:00:10 +02:00
Rosario Pulella
edf9cf6523
home-manager: prioritize -I parameters
In 176e455 the order between the action of `-I` parameters getting
added to `EXTRA_NIX_PATH` and the action of a static path getting
added to `EXTRA_NIX_PATH` was reversed, also reversing the order of
`-I` parameters and the static `-I home-manager=...` leading to the
static `-I home-manager=...` to always come before any of the `-I`
parameters to later calls to Nix commands.

This made it impossible to override the static Home Manager path when
calling the home-manager tool with `-I home-manager=...`. This was
previously possible.
2023-06-18 00:42:49 +02:00
Robert Helgesson
f1490b8caf
Switch current unstable version to 23.11 2023-05-31 19:11:30 +02:00
Robert Helgesson
33ccc5c285
Switch stable branch to release-23.05 2023-05-31 19:11:29 +02:00
Robert Helgesson
13a74643d7
home-manager: fix error message in flake check
Before this commit, running the hasFlakeSupport function causes an
error message

    error: experimental Nix feature 'nix-command' is disabled; use
    '--extra-experimental-features nix-command' to override

when the Nix installation does not support the nix tool. The error
message should not be visible to the user since its just part of the
Flake support check.
2023-05-21 23:23:14 +02:00
Robert Helgesson
47d6c3f652
home-manager: fix variable name 2023-04-21 12:23:36 +02:00
Stel Abrego
342fd40ccb
home-manager: fix config file variable check (#3901) 2023-04-21 11:40:20 +02:00
Paulo L F Casaretto
8506c69222
home-manager: quote username in init template
This helps when the username contains, for example, the '.' character.
2023-04-19 22:01:23 +02:00
Robert Helgesson
d1d0ee37c3
home-manager: ignore errors from notify-send
Fixes #3878
2023-04-17 00:46:17 +02:00
Robert Helgesson
6e57fc4705
home-manager: add some i18n context 2023-04-11 22:45:41 +02:00
Robert Helgesson
93f5cb2482
home-manager: migrate profiles to nix state directory
If the user runs a recent Nix version that places per-user profiles in
`$XDG_STATE_DIR/nix/profiles`, then migrate the home-manager profile
there.

Also clean up `setupVars` a bit.
2023-04-10 13:52:02 +02:00
Robert Helgesson
d80bf24dab
home-manager: error out when showing news in flake 2023-03-25 16:30:58 +01:00
Robert Helgesson
7720f200ea
home-manager: make generated home.nix more helpful
This adds a few commented example configuration elements to help guide
the user to possible usages.
2023-03-21 08:41:28 +01:00
Robert Helgesson
c8cb60b8a1
home-manager: add init command to main tool
The init command is essentially the old install script but integrated
into the home-manager tool. This simplifies things slightly since we
can use the existing code infrastructure.

The init command is Nix flake aware in the sense that, if we detect
that the user's Nix setup supports flakes, then we also create an
initial `flake.nix` file.

Finally, we update the installation instructions for the Nix flakes
standalone setup to use the new init command.

Zsh completion update provided by Anund <anundm@gmail.com>.
2023-03-15 22:47:04 +01:00
Robert Helgesson
cae54dc45c
home-manager: change default configuration home
This changes the default configuration location for Home Manager
configurations from

    $XDG_CONFIG_HOME/nixpkgs

to

    $XDG_CONFIG_HOME/home-manager

The old location is still supported but using it will trigger a
warning message.

Fixes #3640
2023-03-14 23:10:54 +01:00
Robert Helgesson
f69816489d
home-manager: handle missing per-user profiles directory
Specifically, if the global per-user profiles path do not exist and we
cannot create it during the activation, then place our profile in the
Home Manager data directory. We prefer to use the global location,
though, since it makes it visible to `nix-collect-garbage`.

This is intended to improve compatibility with Nix version 2.14 and
later, which no longer creates the per-user directories.

Also, use the Home Manager data directory to manage the gcroot for the
current generation. It does not have to sit in the global per-user
gcroots directory since it should never be eligible for GC.
2023-03-07 23:53:06 +01:00
Robert Helgesson
0f3dfc16d0
home-manager: fix nix-env uninstall command 2023-03-07 23:53:05 +01:00
Robert Helgesson
fc3432bac2
home-manager: make --version report 23.05-pre
It is a bit misleading to report 22.11 when running from the master
branch.
2023-02-26 17:07:31 +01:00
Bernardo Meurer
6d2ba4654d
home-manager: pass --refresh to nix (#3624)
This flag is useful to force Nix to re-fetch cached flakes. Without it,
you cannot deploy from a non-local flake in quick succession, since the
caching causes the flake to not be re-fetched.
2023-02-05 11:14:03 +01:00
Zhaofeng Li
176e455371
home-manager: Add home-manager search path to EXTRA_NIX_PATH (#3241) 2023-01-10 10:35:00 +01:00
Anders Kaseorg
c55fa26ce0
home-manager: pass -L/--print-build-logs to nix build
When building from a flake, `nix build` hides the build output by
default, with a `-L`/`--print-build-logs` option to show it. Pass this
option along from `home-manager` if the user provides it.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-12-25 12:09:29 +01:00
Kamal Al Marhubi
e7eba9cc46
home-manager: refine flake URI lookup
Depending on DHCP settings you might end up with different output from
running `hostname`. Eg, your local hostname is `mylaptop`, and your
home router is configured with a local domain of `.hoome.arpa`. In
this case:

    $ hostname
    mylaptop.home.arpa
    $ hostname -s
    mylaptop

If you then go to cafe which has its router configured with `.lan` as
its local domain. Then, if your DHCP settings accept the local domain
from the router,

    $ hostname
    myalaptop.lan
    $ hostname -s
    mylaptop

With the pre-existing behaviour, if you had a
`"me@mylaptop.home.arpa"` entry in `outputs.homeConfigurations`,
running `home-manager switch` would fail:

    $ home-manager switch
    error: flake 'git+file:///home/me/.config/nixpkgs' does not provide
    attribute 'packages.aarch64-darwin.homeConfigurations."me".activationPackage',
    'legacyPackages.aarch64-darwin.homeConfigurations."me".activationPackage'
    or 'homeConfigurations."me".activationPackage'

After this commit, you can put configuration in a `"me@mylaptop"`
entry in `outputs.homeConfigurations`, and everything will work on
either network.
2022-12-19 15:12:44 +01:00
Robert Helgesson
71fa4cdf9c
home-manager: update stable version to 22.11 2022-12-02 11:49:58 +01:00
Robert Helgesson
ebe6d2c747
home-manager: set state version when uninstalling
Otherwise the switch exits with an error.

Fixes #3320
2022-10-11 09:31:29 +02:00
Robert Helgesson
888eac32bd
home-manager: fix command option
Fixes #2844
2022-03-27 09:43:19 +02: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
Shamrock Lee
23a9f9127c
home-manager: add more pass-through options
Specifically, pass through --[extra-]experimental-features to Nix.
2022-02-15 22:45:59 +01:00
Robert Helgesson
adaea605db
home-manager: document the --version command option
Fixes #2604
2022-01-02 08:33:32 +01:00