Files
sydnix/users/crumb/files.nix
Madeleine Sydney 4f5abf4826 feat: ~/scratch
2025-03-11 13:33:12 -06:00

110 lines
3.6 KiB
Nix
Executable File

{ config, lib, pkgs, ... }:
let mutableSymlink = config.lib.file.mkOutOfStoreSymlink;
in lib.mkMerge [
{
# Link private SSH keys to ~/.ssh/id_ed25519 (where SSH will automatically
# find them) and ~/private-keys (where humans will find them). Remember
# that private keys must always be linked with mutable symlinks as to not
# copy them into the world-readable Nix store!!
home.file.".ssh/id_ed25519".source =
mutableSymlink "/persist/private-keys/ssh/crumb-at-nixos-testbed";
home.file."private-keys/ssh/crumb-at-nixos-testbed".source =
mutableSymlink "/persist/private-keys/ssh/crumb-at-nixos-testbed";
# Similarly, public keys are linked where SSH will find them as well as a
# human-friendly ~/public-keys.
home.file.".ssh/id_ed25519.pub".source =
../../public-keys/ssh/crumb-at-nixos-testbed.pub;
home.file."public-keys/ssh/crumb-at-nixos-testbed".source =
../../public-keys/ssh/crumb-at-nixos-testbed.pub;
}
{
### Some basic impermanence setup.
sydnix.impermanence = {
enable = true;
directories = [
"Music"
"Pictures"
"Documents"
"Videos"
"src" # My projects.
"scratch" # My playgrounds.
# Should "org" be declared in emacs.nix? I don't think so. I
# conjecture that my org files are extremely valuable with or without
# Emacs.
"org"
# REVIEW: I think it may be preferable to persist a few individual files
# under ~/.ssh, rather than the whole directory.
".ssh"
{
directory = ".local/share/Steam";
method = "symlink";
}
".passage"
];
};
}
{
# ~/git — other peoples' code
systemd.user.tmpfiles.rules = [
"v ${config.home.homeDirectory}/git 755 ${config.home.username} users - -"
];
sydnix.impermanence.directories = [
"git/doomemacs"
"git/publish-org-roam-ui"
];
}
{
### Syncthing
# TODO: sydnix.syncthing module
sydnix.impermanence.directories =
let xdg-state-dir =
config.home.statehome
or "${config.home.homeDirectory}/.local/state";
in [
# HACK: This relies on behaviour that is not explicitly defined by the
# Syncthing Home-manager module. We have to trust that $XDG_STATE_DIR,
# at the time of syncthing.service's start, does not differ from this
# value defined in Nix. Perhaps a PR to home-manager adding an option
# `services.syncthing.stateDir` would be good.
#
# If Syncthing ever breaks, make sure they didn't start using a different path:
# https://github.com/nix-community/home-manager/blob/master/modules/services/syncthing.nix
#
# Evidence for using this path is found at: (permalink)
# https://github.com/nix-community/home-manager/blob/6d3163aea47fdb1fe19744e91306a2ea4f602292/modules/services/syncthing.nix#L624
# Hack aside, this directory must be persisted to, at least
# 1. Preserve the device ID.
(lib.removePrefix config.home.homeDirectory "${xdg-state-dir}/syncthing")
];
services.syncthing = {
enable = true;
settings = {
overrideDevices = true;
overrideFolders = true;
devices = {
"guix-rebound".id =
"Q5B6LIV-5HQMWWV-XFQL5IT-PHP7PVE-XFWUVHK-F6WJ42C-OPMR4M7-GFNK3AG";
};
folders = {
"org" = {
path = "~/org";
devices = [ "guix-rebound" ];
ignorePerms = true;
};
};
};
};
}
]