Skip to content

Instantly share code, notes, and snippets.

@betaboon
Last active June 19, 2020 11:11
Show Gist options
  • Save betaboon/eb55984df0824e3fa73e8586444febff to your computer and use it in GitHub Desktop.
Save betaboon/eb55984df0824e3fa73e8586444febff to your computer and use it in GitHub Desktop.
{ ... }: {
boot.initrd.postDeviceCommands = ''
for o in $(cat /proc/cmdline); do
case $o in
nfsnixstore=*)
params="''${o#nfsnixstore=}"
nfsnixstore_mount=/nfs-nix-store
nfsnixstore_export=$(echo $params | cut -d, -f1)
nfsnixstore_options=$(echo $params | cut -d, -f2-)
echo "mounting $nfsnixstore_export with $nfsnixstore_options on $nfsnixstore_mount..."
mkdir -p $nfsnixstore_mount
mount -t nfs -o $nfsnixstore_options $nfsnixstore_export $nfsnixstore_mount
;;
esac
done
'';
fileSystems."/" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
};
fileSystems."/nix/.ro-store" = {
device = "../nfs-nix-store";
options = [ "bind" ];
neededForBoot = true;
};
fileSystems."/nix/.rw-store" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};
fileSystems."/nix/store" = {
fsType = "overlay";
device = "overlay";
options = [
"lowerdir=/nix/.ro-store"
"upperdir=/nix/.rw-store/store"
"workdir=/nix/.rw-store/work"
];
};
}
$ systemctl list-dependencies dhcpcd.service
dhcpcd.service
● ├─system.slice
● ├─systemd-udev-settle.service
● ├─network.target
● │ ├─network-local-commands.service
● │ └─network-interfaces.target
● └─sysinit.target
● ├─dev-hugepages.mount
● ├─dev-mqueue.mount
● ├─kmod-static-nodes.service
● ├─sys-fs-fuse-connections.mount
● ├─sys-kernel-config.mount
● ├─sys-kernel-debug.mount
● ├─systemd-ask-password-console.path
● ├─systemd-journal-catalog-update.service
● ├─systemd-journal-flush.service
● ├─systemd-journald.service
● ├─systemd-modules-load.service
● ├─systemd-random-seed.service
● ├─systemd-sysctl.service
● ├─systemd-timesyncd.service
● ├─systemd-tmpfiles-setup.service
● ├─systemd-udev-trigger.service
● ├─systemd-udevd.service
● ├─systemd-update-done.service
● ├─systemd-update-utmp.service
● ├─local-fs.target
● │ ├─-.mount
● │ ├─nix-.ro\x2dstore.mount
● │ ├─nix-.rw\x2dstore.mount
● │ ├─nix-store.mount
● │ └─systemd-remount-fs.service
● └─swap.target
$ systemctl list-dependencies nix-.ro\\x2dstore.mount
nix-.ro\x2dstore.mount
● ├─-.mount
● ├─system.slice
● └─network-online.target
● └─dhcpcd.service
$ systemctl cat nix-.ro\\x2dstore.mount
# /run/systemd/generator/nix-.ro\x2dstore.mount
# Automatically generated by systemd-fstab-generator
[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
Before=local-fs.target
[Mount]
Where=/nix/.ro-store
What=../nfs-nix-store
Options=bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment