Commit Graph

107 Commits

Author SHA1 Message Date
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
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
polykernel 9de77227d7
home-manager: fix home-manager build error (#2514)
Two misplaced quotations were introduced in `doBuild` by https://github.com/nix-community/home-manager/pull/2501, which
caused the parameter expansion of DRY_RUN to include an extraneous tab. Since the flake uri is passed
later into the command, Nix assumes the whitespace sequence as the flake uri and returns that it is not
a valid flake reference.

This PR removes the misplaced quotations in `doBuild` and also places the flake uri as the first argument for
calls to `doBuildFlake` for consistency with `doBuildAttr`. Placing the uri first in the command line also guards
against possible security issues if arbitrary uris are expanded prior to the user given uri.
2021-11-28 20:48:21 -05:00
Robert Helgesson 579f2e8beb
Switch to 22.05 as current development release 2021-11-25 22:29:49 +01:00
polykernel 609370699f
home-manager: do not build news when using flake (#2501)
Currently, the `buildNews` and `doBuildAttrs` are always called
unconditionally even if a flake configuration is specified. This cause
it to always fail prior to the actual build performed by `doBuildAttrs`
because `setConfigFIle` can not find the home-manager configuration file.
As a result, an error message specifying no configuration file is shown.

Furthermore, if a user has remnant legacy configuration, the `doSwitch` and
`doBuild` functions will effectively build the activationPackage twice, with
the legacy configuration overriding the flake configuration.

A conditional check for FLAKE_CONFIG_URI was added to mitigate this by building
the legacy configuration when no flake configuration is present. There is one
exception which is when a flake configuration exists in the default location, where
the user can not build the legacy configuration as along as the file is present.
However, the tradeoff is acceptable as it matches current behavior when FLAKe_CONFIG_URI
is set for instantiation, and an user is unlikely to simulataneously switch
between the two mechanisms.

An abstract function for building flakes `doBuildFlake` was created to match
`doBuildAttrs` for  manageing options and build flags.

The --no-write-lock-file flag was removed from the --debug case as it is already
matched previously at the --recreate-lock-file case.
2021-11-24 19:09:53 -05:00
Sandro Jäckel 398c0b36a3
home-manager: properly forward exit codes 2021-11-19 23:47:57 +01:00
Sandro 3f12ce5f7d
home-manager: forward --no-write-lock-file (#2471) 2021-11-14 23:00:26 -05:00
Sandro 71902bc913
home-manager: fix command line option for nix build 2021-10-30 23:30:46 +02:00
c4605 1a6df903e3
home-manager: add command line argument `--impure` 2021-08-19 00:07:49 +02:00
Timur Demin d11afee973
home-manager: allow remote builders for nix-build (#2268)
This allows running home-manager with --builders option passed through
to nix-build, which will then pass build execution to remote builders on
other machines.

This may be useful with relatively complex home-manager configurations
where building on a local machine is not feasible.
2021-08-17 16:53:44 -04:00
Sandro Jäckel 5f6364fc28
home-manager: add `--no-out-link` command line option
When this option is used then `home-manager build` will not produce a
`result` link in the current working directory.
2021-07-29 16:04:41 +02:00
Dusk Banks 63af2d3e4c
home-manager: add `home-manager option`
This adds functionality much like that provided by `nixos-option`.
2021-06-15 23:46:45 +02:00
bb010g 5eb199e937
home-manager: pass on `--debug` option (#2049)
* man-home-manager: remove trailing whitespace

* home-manager: pass on `--debug` option
2021-06-05 16:11:06 -06:00
Robert Helgesson 19d95258ac
docs: set current version to 21.11 2021-06-05 20:05:04 +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
Sandro 90223cf3eb
home-manager: allow overriding pkgs with --arg(str) (#1889) 2021-03-31 19:40:37 +02:00
Teo Ljungberg 69e2693342
home-manager: respect NO_COLOR environment variable
This makes Home Manager respect the NO_COLOR environment variable to
disable coloring from output generated by Home Manager.

This initiative can be found more on https://no-color.org/
2021-03-03 23:28:06 +01:00
Robert Helgesson 46a750f94f
home-manager: use 21.05 as next version
Fixes #1662
2021-02-05 22:09:00 +01:00
Robert Helgesson fd79015c0f
home-manager: pass `-j` to nix-build
Fixes #1596
2020-11-13 23:56:57 +01:00
Robert Helgesson ef72617c4a
home-manager: add `--version` option 2020-11-03 23:12:24 +01:00
Samuel Ainsworth 7e5fee4268
home-manager: handle `$EDITOR` containing spaces
The quoted `$EDITOR` causes errors when using values containing
arguments, eg. "code --wait". This is in contrast to the majority of
tools (git, etc.) that do support this usage.

Fixes #1496
2020-10-08 23:17:28 +02:00
Robert Helgesson 2c6a023744
home-manager: remove home-manager-path on uninstall
Fixes #1443
2020-08-14 23:19:48 +02:00
Dmitry Kalinkin dc227b579d
home-manager: respect NIX_STATE_DIR
This allows to install home-manager on a system without root access.

PR #1196
2020-06-14 20:41:55 +02:00
Robert Helgesson 687395ebda
home-manager: remove unsupported `-2` option
This option used to make the `home-manager` command use the `nix` tool
from Nix 2. Unfortunately the `nix` tool is a bit experimental and it
is best to await its stabilization before supporting it in Home
Manager.
2020-04-18 11:37:06 +02:00
Robert Helgesson e5325c2274
home-manager: fix shellcheck warning 2020-04-18 11:37:05 +02:00
Timo Kaufmann 5969551a5c
home-manager: add instantiate subcommand
It can be useful to simply instantiate a Home Manager configuration
without actually building it, for example for the purpose of
pre-building it with some custom command.

PR #1099
2020-03-25 21:16:43 +01:00
Chris Hodapp 9ab59dd6ac
home-manager: handle args with spaces to doBuildAttr
Presently, if you pass an argument with spaces in it to `doBuildAttr`,
it will be split it into multiple arguments to `nix build` or
`nix-build`. This situation arises, for example, on systems with
spaces in `XDG_DATA_HOME`.

Specifically, the `home-manager` script errors out in trying to
address the `read-news` state file. With this change, argument
separation should be preserved properly in `doBuildAttr`.

PR #1044
2020-02-24 23:51:36 +01:00
Robert Helgesson e1153f4d2e
home-manager: make sure all files are uninstalled
This forces the `home.file` option to be completely empty when
switching to the uninstall configuration. This is necessary to guard
against files are added by default in Home Manager, such as
`$XDG_CACHE_HOME/.keep`.
2020-02-15 19:26:23 +01:00
oxalica 7c30831e8f
home-manager: fix pass-through option passing
This resolves, e.g., the errors occurring when passing empty arguments
like `--option builders ''`.

Closes #967
2020-01-01 12:27:29 +01:00
Robert Helgesson 7c2532d9f9
home-manager: add --(no-)substitute options
Fixes #312
2019-12-01 10:43:39 +01:00
Robert Helgesson 8ab1d22a82
home-manager: support `--option` argument
Fixes #784
2019-08-30 00:52:09 +02:00
Robert Helgesson 8fe4e0879c
home-manager: support a few extra pass-through options
These options will be passed through to the `nix-build` tool.
2019-08-26 23:06:36 +02:00
Robert Helgesson 6bec9547c6
home-manager: exit directly after printing help 2019-08-26 23:06:36 +02:00
Robert Helgesson 42732990cd
home-manager: rewrite argument parsing
This rewrite allows "long options" but unfortunately does not allow
merged options such as `-vn`.

Also improve the home-manager manual page, with this it should include
all sub-commands and arguments.

Finally, include the home-manager manual page in the generated HTML
documentation.
2019-06-09 22:19:03 +02:00