Commit graph

161 commits

Author SHA1 Message Date
Bernardo Meurer
df5038f20c
Merge pull request #43 from RiscadoA/master
Added home manager module to flake.nix
2021-12-08 08:44:21 -08:00
Kim Lindberger
0616c64b0e
Merge pull request #55 from nix-community/hm-create-target-directories-for-files
home-manager: Create missing target directories for files
2021-11-19 00:30:00 +01:00
Bernardo Meurer
b74f468e4e
Merge pull request #44 from nix-community/systemd-service-files
nixos: Manage files using systemd services
2021-11-18 11:36:07 -08:00
talyz
96fc5494dc
nixos: Manage files using systemd services
Manage files by creating a systemd oneshot service for each file. The
service links or bind mounts the file as appropriate on start and
removes the link or unmounts it when stopped. Whether a symlink or
bind mount is used is determined by if the target exists - if it does,
it's bind mounted, otherwise symlinked. To make sure files are
available early enough, also run the start portion in the activation
script.

This lifts the restriction on files being placed in `/etc` and should
finally close #1.
2021-11-17 09:12:36 +01:00
Bernardo Meurer
26d69654e7
Merge pull request #56 from adisbladis/bash-exec
home-manager: Use bash exec when calling bindfs
2021-11-15 20:12:14 -08:00
adisbladis
4b4bf5026a
home-manager: Use bash exec when calling bindexec
Right now the shell script wrapper doesn't exit which results in a lot of unnecessary bash processes.
2021-11-15 23:10:59 +00:00
talyz
6b474b097a
home-manager: Create missing target directories for files
Create missing parent directories for nonexistent files in persistent
storage.

Reported in #53.
2021-11-14 19:19:17 +01:00
Kim Lindberger
00df1e57bb
Merge pull request #54 from nix-community/fix-ci
ci: Use nix-shell instead of nix run
2021-11-13 15:13:35 +01:00
talyz
4269cf2fbb
ci: Use nix-shell instead of nix run
Since the release of Nix 2.4, the ci pipeline is broken, as the syntax
and behavior of nix run changed. The command is also considered
experimental. Switch to using nix-shell instead.
2021-11-13 14:37:18 +01:00
talyz
ce77ed9bd0
README: Add note about using home-manager as a NixOS module
Fixes #52.
2021-10-29 16:20:58 +02:00
RiscadoA
80fc82343a
Added home manager module to flake 2021-09-01 16:48:14 +01:00
talyz
58558845bc
home-manager: Create the mount point in the systemd service
This is purely for convenience when fiddling with the services
manually, since the directory is created by the activation script
already.
2021-01-27 12:39:08 +01:00
talyz
48b5d5291c
home-manager: Simplify the directory creation
The checks should be unnecessary, since `mkdir -p` is idempotent.
2021-01-27 12:37:08 +01:00
talyz
4d655d7842
home-manager: Add allowOther option to let other users read bind mounts
NixOS defaults to not letting fuse mounts be allowed to let other
users read their contents. `bindfs` wants to give other users access
and is therefore normally run with `--no-allow-other` to not throw an
error.

Giving other users, mainly `root`, access to the bind mounts is,
however, useful and works fine when

programs.fuse.userAllowOther = true;

is declared in `configuration.nix`. This adds an option to choose
whether to give other users access or not. It also prompts the user to
set the `allowOther` attribute with a link to the documentation.
2021-01-27 12:35:27 +01:00
talyz
48f3a3018e
home-manager: Fix the fix
`let` variables have priority over `with` imports, argh
2021-01-27 12:34:21 +01:00
talyz
a1dfdfa1aa
home-manager: Fix bindfs options
No flag should be passed when the option list is empty.
2021-01-26 22:31:17 +01:00
talyz
77302d9381
home-manager: Document options, update readme 2021-01-25 00:15:36 +01:00
talyz
43095936d4
home-manager: Use the fsname option of the latest bindfs release
This makes changing bindfs target directories more reliable when their
paths contain spaces or commas. See
https://github.com/mpartel/bindfs/issues/94 for details.
2021-01-24 23:26:22 +01:00
talyz
e6d15a7cbb
home-manager: Don't remount when bindfs is found instead of target
Due to what is likely a bug in bindfs or fuse, the target path is
sometimes missing from the mount entry. This causes false positives
for the target directory having changed, leading to unnecessary
remounts. Luckily, it seems that when this happens, the line instead
contains the string `bindfs`, which it doesn't normally, so we can at
least circumvent this issue to some degree.
2021-01-24 11:57:21 +01:00
talyz
47147e71ff
home-manager: Fix unmounts in the activation script for recent HM
Find the correct name of the activation script entry responsible for
reloading systemd user services. The name was initially
`reloadSystemD` but has been changed to `reloadSystemd`, causing
failures due to the unmounts being done after the systemd services are
reloaded.
2021-01-24 11:56:48 +01:00
talyz
41bddc6661
nixos: Fix No such file or directory errors on fresh installs
If there were multiple levels of directories which hadn't yet been
created in persistent storage, the `create-directories.bash` script
would error out when running `realpath` on the path. To allow this,
`realpath` has to be run with `-m`.
2021-01-23 16:20:04 +01:00
talyz
2cda5cd30b
nixos: Create directories of files in persistent storage 2020-12-14 17:33:30 +01:00
talyz
3cea211006
nixos: Extract the createDirectories script out into its own file 2020-12-14 17:33:24 +01:00
talyz
74de76031f
nixos: Add description and examples 2020-12-14 17:10:34 +01:00
Cole Helbling
4c7871a86a flake: remove unused nixpkgs input
Packages are retrieved from the `pkgs` module argument, rather than
Nixpkgs itself.
2020-11-29 07:49:21 -08:00
Kim Lindberger
a7169e575a
Merge pull request #16 from danieldk/flake
Make impermanence a flake
2020-11-26 22:18:17 +01:00
Daniël de Kok
62aa75cb60
Make impermanence a flake 2020-11-26 12:48:48 -08:00
Kim Lindberger
86231d3ae8
Merge pull request #23 from linyinfeng/fix-argument-list-too-long
nixos: Fix "Argument list too long" error
2020-11-18 08:13:46 +01:00
Lin Yinfeng
b9342b5e44
nixos: Write the directories creation script into store
When user writes a long list of directories, the original code
generates a very long activation script, which can cause an "Argument
list too long" error.

This try to fix the issue by writing the directories creation script
into nix store as an executable instead of repeating it multiple
times.
2020-11-18 12:49:14 +08:00
Kim Lindberger
16bc81cd32
Merge pull request #24 from nix-community/ci-update
ci: update install-nix-action to v12
2020-11-17 22:45:17 +01:00
Bernardo Meurer
e6a4988a06
ci: update install-nix-action to v12 2020-11-17 09:09:14 -08:00
talyz
4b3000b9be
home-manager: Remove unnecessary PartOf in systemd unit
Fixes #20
2020-10-17 23:45:30 +02:00
talyz
ecb89af129
home-manager: Abbreviate commands using nix- and env variables 2020-10-03 09:40:36 +02:00
talyz
b6181bd997
home-manager: Make quoting and grepping more robust
Try to more properly escape paths using `escapeShellArg` and use
`grep -F` to avoid accidental regexes.
2020-10-03 09:39:34 +02:00
Kim Lindberger
2c5aded3c2
Merge pull request #11 from nix-community/home-manager-bind-mount
home-manager: Bind mount directories instead of symlinking them
2020-09-05 14:16:00 +02:00
talyz
619b089f58
README, home-manager: Note that the mounts are visible in /etc/mtab 2020-07-24 13:41:27 +02:00
talyz
4d2cfadbc1
home-manager: Make unmounts more robust
Try to unmount normally a few times, and if that fails, unmount lazily
to at least clean up the mount point before the fuse process is killed.
2020-07-24 13:41:21 +02:00
talyz
5b3345400c
home-manager: Bind mount directories instead of symlinking them
Use bindfs to create bind mounts for directories instead of symlinking
them. This should be less problematic for many applications, since
bind mounts are much more transparent.

This sets up the bind mounts in the activation script, before any
writes are done by home-manager, then tears them down again
afterwards. The bind mounts are then handled by individual systemd
services, since they're long-running fuse processes and need to be
managed as such. This also means we leverage home-manager's mechanism
for deciding which user services should be active after a switch to a
new generation, and don't have to bother with cleaning up old leftover
fuse processes.

NOTE: All unmounts done in the activation script are put into a
function which is run either on error, or right before home-manager
starts / reloads systemd units. This will conflict with other attempts
to add traps on ERR, but this isn't currently done upstream.
2020-07-24 13:00:13 +02:00
talyz
8fc761e8c3
nixos: Only check file systems for neededForBoot
Only assert that persistent paths are marked neededForBoot if they're
file system roots.

Fixes #12
2020-07-18 21:51:16 +02:00
Bernardo Meurer
a45918b80c
Merge pull request #3 from nix-community/fix-perms
nixos: bind mount with correct permissions
2020-06-15 14:11:39 -07:00
Bernardo Meurer
c601a2d839
nixos: correctly replicate permissions in bind mounts 2020-06-15 14:09:06 -07:00
Cole Helbling
ff77093186 README: add links to further reading 2020-06-09 23:08:50 -07:00
Elis Hirwing
f87dc9cb76
Merge pull request #5 from nix-community/comments-and-assert
nixos: Add comments and neededForBoot assert
2020-06-08 22:03:53 +02:00
Bernardo Meurer
8f53357e38
Merge pull request #6 from nix-community/license
LICENSE: init
2020-06-08 12:56:35 -07:00
Bernardo Meurer
38d02f471c
LICENSE: init 2020-06-08 12:56:02 -07:00
talyz
ddbbb2af58
nixos: Add comments 2020-06-08 18:40:46 +02:00
Elis Hirwing
ea476db66e
nixos: Add neededForBoot assertion 2020-06-08 18:40:45 +02:00
talyz
def13ddc2e
home-manager: Fix types - string -> str, since string is deprecated 2020-06-07 10:14:06 +02:00
talyz
2472286e92
nixos, home-manager: Handle whitespace in persistentStoragePaths 2020-06-07 10:14:00 +02:00
Bernardo Meurer
13ff4509fc
impermanence: move development to next branch 2020-06-07 00:26:08 -07:00