Commit graph

135 commits

Author SHA1 Message Date
Kim Lindberger
9de98e038a
Merge pull request #188 from kuruczgy/add-var-lib-nixos-assertion
nixos: Add assertion for persisting UIDs/GIDs
2024-08-19 22:11:47 +02:00
Kim Lindberger
23c1f06316
Merge pull request #190 from linj-fork/pr/do-nothing-if-no-config
nixos: avoid side effects to fileSystems if possible
2024-06-22 23:28:11 +02:00
Lin Jian
837e71297f
nixos: avoid side effects to fileSystems if possible
This is a good idea in itself.

Additionally, it avoids issues if users want to use mkDefault in their
fileSystems config and have no persistent directories.
2024-06-23 02:06:24 +08:00
Kim Lindberger
363b3e8622
Merge pull request #189 from nix-community/nixos-disable-module
nixos: Disable module if no persistent storage paths are defined or all are disabled
2024-06-22 16:49:39 +02:00
talyz
d8feb6f8bf
nixos: Disable module if no persistent storage paths are defined...
...or all are disabled.
2024-06-22 16:46:48 +02:00
talyz
27979f1c3a
README: Grammar fix 2024-06-09 13:26:10 +02:00
talyz
f6a5d85f70
README: Document the NixOS module's enable option 2024-06-09 13:22:16 +02:00
talyz
8ea418ec4f
nixos: Remove unused library function imports 2024-06-09 12:21:29 +02:00
György Kurucz
213f8050c9 nixos: Add assertion for persisting UIDs/GIDs
Fixes #178
2024-06-05 16:51:52 +02:00
Kim Lindberger
a33ef102a0
Merge pull request #162 from willbush/feature/readme-add-blog-post
Readme: add blog post to further reading
2024-02-26 18:25:31 +01:00
Will Bush
d5f1ed7141
readme: add blog post to further reading 2024-02-24 16:01:57 -06:00
Andrey Butirsky
cd13c2917e Update README.org: fix broken links 2024-01-30 13:35:36 -05:00
Carl Thomé
033643a45a Fix grammar 2023-12-26 21:48:28 -08:00
talyz
3d599bd65e
Partial revert of 8d16ac9798
Fixes #157.
2023-12-26 17:01:15 +01:00
talyz
8d16ac9798 lib: Remove sanitizeName, replace usage with escapeSystemdPath 2023-12-26 00:46:15 -03:00
Kim Lindberger
123e94200f
Merge pull request #136 from mohe2015/fix-script-bug
Fix error when target is `/`
2023-12-19 12:09:31 +01:00
Kim Lindberger
f1fe8fcf3e
Merge pull request #135 from eyJhb/home-persistentstorage
home-manager: add persistentStoragePath option
2023-12-19 11:58:13 +01:00
talyz
0c893cf08a README: Expand with more details on system setup and a better intro 2023-12-18 22:22:16 -03:00
Maximilian Bosch
0f317c2e9e Fix build with documentation.nixos.includeAllModules = true;
This includes the options of all modules used in the evaluation, not
just the ones from `<nixpkgs/nixos>` in the local manual.

Right now this breaks with

    error: attribute '"‹name›"' missing

because the submodule `environment.persistence` doesn't have
actual declarations when building the manual, but a dummy only to evaluate
the sub-options (including their defaults which is the cause of the
error) and generate documentation from that.

Using `defaultText` prevents that because there's no need anymore to
evaluate the `default` values of the options.
2023-10-14 13:14:41 -04:00
Alois Wohlschlager
e9643d08d0 nixos: Prevent redundant fstrim
The fstrim service, when enabled, by default trims all mounts listed in
fstab (as long as the underlying device supports discard), including
bind mounts. With impermanence, this can lead to a significant number of
redundant trim operations, since the persistent volume is trimmed once
for itself and then again once per persistent directory each. On my
system, this leads to fstrim.service taking about 10 minutes, during
which the system usability is somewhat degraded. In addition, it may be
desired to disable trim for a certain filesystem entirely, for example
when using btrfs with discard=async.

Mark our bind mounts with the X-fstrim.notrim option, which is ignored
by mount, but instructs fstrim to skip the mount point in question. The
persistent filesystem is still trimmed properly, since it has to be
listed in fstab itself as well.
2023-09-13 10:32:25 -06:00
Moritz Hedtke
bcfdc06b23 Fix error when target is / 2023-08-17 20:13:20 +02:00
eyjhb
554d7e6fd1
forgot te replace persistentStoragePath occurrence 2023-08-17 10:33:14 +02:00
eyjhb
dc6d092da5
home-manager: add persistentStoragePath option 2023-08-17 09:54:14 +02:00
Kim Lindberger
e3a7acd113
Merge pull request #134 from nix-community/generic-subvol-names
nixos: Introduce `persistentStoragePath` option
2023-07-31 11:56:12 +02:00
talyz
e985164ad5
nixos: Introduce persistentStoragePath option
This allows the path to persistent storage to be defined through an
option in the submodule, not just by the submodule name, i.e. instead
of

```nix
environment.persistence."/persistent" = {
  files = [ ... ]
  directories = [ ... ]
};
```

you could specify

```nix
environment.persistence.main = {
  persistentStoragePath = "/persistent";
  files = [ ... ]
  directories = [ ... ]
};
```

which is good for readability and when you want to split the config
between multiple files.

Fixes #117.
2023-06-24 17:37:01 +02:00
Kim Lindberger
89253fb151
Merge pull request #125 from ReneHollander/master
Skip generating bind mounts if no bind mounts are configured.
2023-05-16 21:15:34 +02:00
Rene Hollander
6f4fc9d70c
Skip generating bind mounts if no bind mounts are configured.
This fixes #105 by no longer generating an empty bash function. Empty
functions in bash are invalid, which cause the activation to fail.
2023-05-15 19:48:16 +02:00
Kim Lindberger
ec1a8e70d6
Merge pull request #128 from lovesegfault/disable
feat(nixos): allow persistant locations to be disabled
2023-05-15 11:54:52 +02:00
Bernardo Meurer
5a39142bbb
feat(nixos): allow persistant locations to be disabled 2023-05-14 17:02:35 -04:00
Kim Lindberger
df1692e2d9
Merge pull request #126 from alois31/assertion-hotfix
nixos: Fix collision detection logic
2023-04-23 18:46:51 +02:00
Alois Wohlschlager
2d575226bf
nixos: Fix collision detection logic
The logic for detecting whether a file or directory is specified
multiple times was not updated to account for the recent
file/filePath and directory/dirPath changes. This can lead to spurious
failures like the following if the same home-relative path is persisted
for different users:

       Failed assertions:
       - environment.persistence:
           The following directories were specified two or more
           times:
             .cache
             .config
             .local/share
             .local/state
             .gnupg
             .ssh

In addition, the assertion may falsely not trigger in the contrived
situation where the same entity is persisted both in a per-user
configuration (using the relative path) and the global configuration
(using the absolute path).

Fix these situations by checking the absolute paths again using
filePath and dirPath.
2023-04-23 16:14:43 +02:00
Kim Lindberger
c3f7012dc3
Merge pull request #109 from nix-community/dir-creation-order
nixos: Improve directory creation and permission and ownership assignment
2023-04-23 08:20:41 +02:00
talyz
170e9b105d
README: Add matrix room link
Also, remove the unrelated name explanation.
2023-04-23 08:16:13 +02:00
talyz
b4160ba71d
nixos: Rewrite directory creation for saner default permissions
Construct directory items for all parent directories of the user
specified files and directories, assigning better default permissions
and ownership to each and removing this responsibility from the
create-directories script.

This means that all parent directories of root directories will now
have the default permissions and ownership, not inherit them from the
child. User directories are assigned default user ownership. The home
directory itself is handled specially to make sure it is owned by the
user, not readable by anyone else and its parent gets default root
ownership.

To illustrate this with an example, here is a directory specification
and the ownership and permissions that could potentially be assigned
to the parent directories, given none of them yet exist in persistent
storage:

environment.persistence."/persistent" = {
  users.talyz = {
    directories = [
      { directory = ".local/share/secret"; mode = "0500"; }
    ];
  };
};

Before:
/home                            talyz:talyz   0500
/home/talyz                      talyz:talyz   0500
/home/talyz/.local               talyz:talyz   0500
/home/talyz/.local/share         talyz:talyz   0500
/home/talyz/.local/share/secret  talyz:talyz   0500

After:
/home                            root:root     0755
/home/talyz                      talyz:talyz   0700
/home/talyz/.local               talyz:talyz   0755
/home/talyz/.local/share         talyz:talyz   0755
/home/talyz/.local/share/secret  talyz:talyz   0500
2023-04-23 08:16:07 +02:00
talyz
d30c421e4e
nixos: Change internal file and directory semantics
This adds the new internal options `home`, `filePath` and
`dirPath`. Whereas previously `file` and `directory` would be
rewritten to the full path for user files and directories, they now
keep the value specified by the user. The new `filePath` and `dirPath`
options fill their previous use where the full path is required. In
addition, the new `home` option can be used to get the path to the
user's home directory for a specific file or directory item; for root
items it's set to `null`.
2023-04-23 08:16:01 +02:00
talyz
cc00a2a523
nixos: Use coercedTo type rather than manually converting from str
This simplifies the code quite a bit and should be easier to maintain.
2023-04-23 08:15:55 +02:00
talyz
d144e365cf
all: Line up lib inherits vertically 2023-04-23 08:15:49 +02:00
talyz
a65d7088db
nixos: Use mkDefault to set the default directory permissions
This means we don't have to pass them around as function arguments,
making things a bit cleaner.
2023-04-23 08:15:40 +02:00
Kim Lindberger
6138eb8e73
Merge pull request #114 from mweinelt/persist-nixos-uidgidmap
nixos: Recommend persisting /var/lib/nixos
2023-02-02 18:40:54 +01:00
Kim Lindberger
3792c10037
Merge pull request #115 from Kranzes/master
nixos: Mount binds after the persistent storage path
2023-02-02 18:38:53 +01:00
Ilan Joselevich
ba22f42f53
nixos: Mount binds after the persistent storage path 2023-02-02 19:28:09 +02:00
Martin Weinelt
a0b6d84f54
nixos: Recommend persisting /var/lib/nixos
The `/var/lib/nixos` directory contains the uid and gid map for entities
without a static id. Not persisting them means your user and group ids
could change between reboots, which is likely undesirable.
2023-02-02 17:25:20 +01:00
Kim Lindberger
5df9108b34
Merge pull request #110 from ckiee/gate-verbose
mount-file.bash: be quieter when debugging is off
2022-11-17 08:08:35 +01:00
ckie
32a5793139
mount-file.bash: be quieter when debugging is off 2022-11-17 08:09:12 +02:00
talyz
cd56321db5
home-manager: Add wrappers path for fusermount
Since
886675991b
the path no longer includes the wrappers, since it's reset. To fix
this, add the wrappers to the path.
2022-11-15 18:32:06 +01:00
Kim Lindberger
def994adbd
Merge pull request #100 from plietar/master
Make bash scripts work in cross-compiled environments.
2022-08-31 10:04:31 +02:00
Paul Liétar
e40af4a2a4 Make bash scripts work in cross-compiled environments.
When cross-compiling, `patchShebangs` requires the host platform's bash
to be present in the HOST_PATH environment variable. However, by default
when using `pkgs.runCommand`, only the build platform's bash is
implicitly added to the PATH. The result is that the shebang is not
replaced, and the script fails to run because the activation scripts
don't have `bash` in their environment.

By explicitly adding `pkgs.bash` to the build inputs, this ensures the
HOST_PATH is populated and makes `patchShebangs` work as expected.
2022-08-30 20:27:07 +01:00
Kim Lindberger
2237ad2809
Merge pull request #99 from Misterio77/allow-symlinking-directories
home-manager: adds configurable symlink/bindfs option
2022-08-27 10:56:20 +02:00
Gabriel Fontes
fc9ca99ef8
home-manager: adds configurable symlink/bindfs option 2022-08-22 11:31:31 -03:00
Kim Lindberger
e7c6fbbe90
Merge pull request #83 from devplayer0/qemu-vm-dirs
nixos: Fix bind mounts in VM build
2022-08-22 10:05:43 +02:00