1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-05 02:39:45 +01:00
Commit graph

61 commits

Author SHA1 Message Date
Smaug123
b787726a84
home-manager: extract inline shell script to file 2024-04-06 10:04:27 +02:00
V
17431970b4
files: fix activation under Nix 2.3
In Nix 2.3, all GC roots must be stored under `/nix/var/nix/gcroots`,
unless `--indirect` is specified. In Nix 2.4 and above, this flag is
ignored, because all GC roots created by `--add-root` are indirect.

Change-Id: I3eb3d7bc774af2ff336a2cdf312d30a99cdcb928
2024-03-08 23:54:42 +01:00
V
b3a9fb9d05
treewide: stop run from discarding error messages
In most cases where this function is used, suppressing only the standard
output is more appropriate. Culling diagnostic output hides error
messages and makes debugging more difficult and confusing.

`$DRY_RUN_NULL`, which the `--silence` flag replaced, was used both for
suppressing standard output on its own, and for doing so along with
diagnostic output; however, when the `run` function was added this
distinction was lost, and both outputs would be discarded.

This reintroduces the needed functionality, and changes usages of
`--silence` to `--quiet` where previously only standard output was
suppressed, or where this should have probably been the case anyway.

Change-Id: Ifb1b52a1d1eea0117261c782d686ad7c71b43162
2024-03-08 23:54:42 +01:00
Robert Helgesson
e84811035d
treewide: deprecate VERBOSE_ECHO
The shell function `verboseEcho` can be used in its stead.
2024-01-24 13:36:05 +01:00
Robert Helgesson
190c6f4609
home-manager: avoid running empty nix profile remove
We only want to run `nix profile remove` if there is actually anything
to remove.
2024-01-24 13:36:05 +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
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
3222c99a91 treewide: convert parameterized docs to Markdown
Parameterized documentation generators like this can't be converted
automatically.
2023-07-17 16:49:35 +01:00
Naïm Favier
d9995d94f1
lib/file-type: fix xrefs (#4007)
Currently they all point to `home.file`.
2023-05-22 22:48:23 +02: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
Lars Mühmel
7efca2ca18
files: allow disabling creation of a file
PR #3622
2023-01-26 22:31:16 +01:00
Naïm Favier
69806e9378
files: avoid surprises when linking files (#3018) 2023-01-09 13:00:21 +01: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
171702dd88
files: avoid cleanup if old home-files is missing 2022-03-26 15:05:43 +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
Smaug123
bb72555852
files: quote cmp file arguments
Before this change, a warning would be printed to the console if you
tried to manage a file in a path containing a space. For example,
`vscodium`'s `userSettings` file on Darwin is at
`~/Library/Application Support/VSCodium/User/settings.json`.
2021-10-30 19:15:34 +02:00
Samuel Ainsworth
562449b503
files: clarify "Please move the above files" message 2021-09-15 00:25:00 +02:00
Naïm Favier
5569770d1e
files: move dry run logic out of onChange hooks
Fixes #751
2021-08-17 22:14:32 +02:00
piegames
7f976da068
files: ignore conflict when files are identical
When the target file exists but has the exact same content then we
will now skip creation of the link from the source file.

Fixes #1213
2021-07-29 23:01:52 +02:00
Robert Helgesson
9b7a90daa1
files: minor cleanup 2021-06-28 23:17:00 +02:00
Robert Helgesson
2aeaf65e8f
files: assert that target files are unique
Fixes #1807
2021-06-27 17:10:45 +02:00
bb010g
c982c19f53
files: properly escape shell arguments 2021-06-14 23:10:19 +02:00
Robert Helgesson
d2aaeac42c
files: remove assertion on recursive onChange
See discussion in

  https://github.com/nix-community/home-manager/pull/2031
2021-05-30 11:54:33 +02:00
Robert Helgesson
07ad6a4f76
files: fix use of onChange with directory source
Previously, the comparison would not handle directory comparison
correctly, always finding that the source and target differed. This
would trigger the `onChange` script on each activation.

Fixes #2004
2021-05-29 21:52:37 +02:00
Robert Helgesson
4fe5afa755
files: make sure the target file name is escaped
The previous implementation would allow variables to sneak into the
file names. This commit makes sure the resulting target file path
exactly matches the expected path.
2020-08-29 18:22:03 +02:00
zowoq
3b33862b04
files: reference lndir through xorg
The xlibs attribute set is deprecated and is an alias for xorg.

PR #1304
2020-06-06 13:24:51 +02:00
piegames
6c7a031367
files: print source path for detected collision
PR #1236
2020-05-17 21:49:18 +02:00
Cole Helbling
645149d77b
files: fix warning message
PR #1241
2020-05-17 21:20:40 +02:00
Robert Helgesson
91551c09d4
files: add helper function mkOutOfStoreSymlink
Using this function it is possible to make `home.file` create a
symlink to a path outside the Nix store. For example, a Home Manager
configuration containing

    home.file."foo".source = config.lib.file.mkOutOfStoreSymlink ./bar;

would upon activation create a symlink `~/foo` that points to the
absolute path of the `bar` file relative the configuration file.

PR #1211
2020-05-02 01:22:14 +02:00
Robert Helgesson
37694e9f51
files: add force flag
Enabling this flag for a `home.file` entry causes the target to be
unconditionally overwritten. The option is not visible in
documentation for now and shouldn't be relied on for general use.
2020-03-17 23:42:26 +01:00
Robert Helgesson
7a3e2cc063
files: use nix-env to create profile links 2020-02-15 23:53:39 +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
Philip Stears
0e9b7aab3c
files: additional support for symlinked /nix
In the case where `/nix` is a link, for example, on macOS Catalina,
`builtins.storeDir` returns `/nix`, not the canonical location.

This causes tests on existing files to result in Home Manager thinking
those files are outside of the store.

This change uses `readlink` on the store path so that the tests work
as intended.
2019-11-26 22:22:19 +01:00
Anton Plotnikov
b1dd373f5a
files: update script to support linked Nix store 2019-11-22 20:16:42 +01: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
Will Dietz
f56256f488
files: fix find invocation broken in c94eaa0e
Add parens to expression so the `-exec` includes files matching both.

Otherwise (before this change) the `-exec` is only invoked for
links (`-type l`):

    file or (link -> doexec)
      =>
    (file or link) -> doexec
2019-04-30 15:07:47 +02:00
Robert Helgesson
c94eaa0e6c
files: replace unnecessary use of xargs 2019-04-27 13:48:57 +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
7c04351a57
files: allow a wider range of source file names
In particular support source files whose name start with `.` or
contain characters not allowed in the nix store, such as spaces.

Also add some test cases for `home.file`.
2019-01-19 12:44:58 +01: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
Andrew Scott
30cba446f2
files: add onChange option
This option allows execution of arbitrary shell code when a file that
is linked into the home directory has been changed between
generations.
2018-07-27 22:07:12 +02:00
Robert Helgesson
f0d207f380
Add dag library to config.lib
Also replace all imports of `dag.nix` by the entry in `config.lib`.
2017-12-26 17:27:21 +01:00
Silvan Mosberger
8d360c5a57
systemd: remove filename hack 2017-12-12 18:05:04 +01:00
Cornelius Mika
f6900f0689
files: improve 'target not in $HOME' check
Check for prefix instead of inclusion.
2017-12-12 17:46:48 +01:00
Robert Helgesson
6764c26954
files: remove mode option
This option was deprecated >1 month ago and is therefore removed as
per the corresponding news entry.
2017-12-11 15:14:45 +01:00
Robert Helgesson
4fce730326
files: log when creating home file links 2017-11-15 18:31:04 +01:00
Robert Helgesson
9206f363ff
files: fix order of activation actions
Specifically, move the cleanup phase to before we switch over the
generation links in `gcroots` and `profiles`.

Fixes https://github.com/rycee/home-manager/issues/134
2017-11-15 18:26:42 +01:00
Robert Helgesson
7a9c873093
files: add special handling of systemd files
Unfortunately systemd derives nonsensical unit names when the unit
file is a link to a link to a file. This commit ensures that any file
whose target path matches the pattern `*/systemd/user/*` will be
reachable with only one link hop.

This also reverts f52ec0df7c, which
contained a temporary fix. This commit is an improvements in that it
is more explicit and also handles unit files given directly as a home
file source.
2017-11-12 00:56:34 +01:00
Robert Helgesson
d7537777c3
files: improve keyword for inheriting executable bit 2017-11-12 00:13:29 +01:00