Commit Graph

90 Commits

Author SHA1 Message Date
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
Judson f82246171b
files: backup file collisions
When a configuration file would be written to an existing file, rather
than failing switch (and having the user have to move or delete those
files), move the files automatically to a new path.

Closes #585
2019-06-09 14:26:12 +02:00
Robert Helgesson 3bb7c75db3
home-manager: add uninstall command 2019-04-28 18:40:41 +02:00
Robert Helgesson 67aee78fdf
home-manager: remove unnecessary error message
An error message about the erroneous option is already printed by
`getopts` so there is no need to print it again.
2019-04-10 01:31:22 +02:00
zimbatm 571e17410a
home-manager: add edit command
With this change, running

    home-manager edit

opens `$HOME_MANAGER_CONFIG` in `$EDITOR`.

This is mainly for convenience. Users should not have to remember the
exact location of the Home Manager configuration.
2018-12-04 23:17:19 +01:00
Alex Brandt 3b9b897af3
home-manager: add generation expiration command
This adds a new command to the home-manager shell script that allows
generations to be removed that are older than an given absolute or
relative date.

This allows users to manage the expiration of their home-manager
generations separately from their system or user profiles via
nix-collect-garbage. It is most important if the user desires to have
a convenient way to have different expiration times for Home Manager
generations than other system or user profiles.
2018-10-18 23:12:29 +02:00
Robert Helgesson 859c132ee2
home-manager: enable build output during switch
Fixes #352
2018-08-28 00:17:57 +02:00
Robert Helgesson 39213a1847
home-manager: fix work directory when building generation 2018-07-31 21:05:05 +02:00
Robert Helgesson 4f67e8d0c3
home-manager: fix GC issue
It was previously possible to create the news information and lose it
in a Nix GC before being able to view it. This also causes a switch to
error out. This change makes the news information a root in the
garbage collector.

Note, this change also removes the need for `nix eval` so the
`doBuildAttr` function is simplified accordingly.

Fixes #327
2018-07-31 13:42:56 +02:00
Robert Helgesson f4a1a5e94c
home-manager: resolve default configuration file path
Home Manager needs an absolute and resolved path to its configuration
file. The default configuration path is absolute but not necessarily
resolved. For example, some users may have `~/.config` be a symbolic
link to somewhere else. We therefore run the default configuration
path through the `realpath` tool to resolve it.

Fixes #304
2018-07-12 00:30:54 +02:00
Robert Helgesson dadfaed829
home-manager: add support for the nix tool
This adds an experimantal, undocumented, and unsupported flag `-2` for
the `home-manager` command that enables the use of the new `nix`
command instead of `nix-build`.
2018-07-08 23:24:35 +02:00
Robert Helgesson 06e7d087f2
home-manager: colorize only when connected to terminal
Before, the output of `home-manager generations` would be colorized
even when used in a pipeline.
2018-03-03 22:00:02 +01:00
Robert Helgesson 81fb420457
home-manager: switch NIX_PATH order
This new order allows overriding the home-manager path from the
command line using `home-manager -I home-manager=/a/b/c`.
2018-01-28 18:37:01 +01:00
Robert Helgesson 5fe8d574ca
home-manager: add shellcheck directives 2018-01-27 09:49:35 +01:00
Robert Helgesson a9dc7fa7cc
home-manager: improve the generation timestamp format 2018-01-27 09:47:30 +01:00
Mario Rodas 21fefbc8f6
home-manager: check whether a command is passed
"set -u" treats unset variables as an error, and $1 is unbound when no
command is passed.
2018-01-22 19:18:10 +01:00
Robert Helgesson 04ea044917
home-manager: look for '--help' on command line
This is a special case to work around the lack of long options in
`getopts`.
2017-11-12 14:11:59 +01:00
Robert Helgesson 66219f23bb
home-manager: add 'remove-generations' command
This command allows the user to immediately remove specific
generations from the profiles directory.
2017-11-12 14:07:41 +01:00