hosts/common: cleanup uses of sane-lib.fs.wantedText

This commit is contained in:
Colin 2023-07-13 22:19:18 +00:00
parent a8382fed12
commit 1642734aa3
3 changed files with 14 additions and 14 deletions

View File

@ -1,4 +1,4 @@
{ config, sane-lib, ...}: { config, ...}:
let let
# TODO: should move all of this into `sane.programs` to not ship broken associations # TODO: should move all of this into `sane.programs` to not ship broken associations

View File

@ -1,15 +1,14 @@
# TODO: this should be moved to users/colin.nix # TODO: this should be moved to users/colin.nix
{ config, lib, sane-lib, ... }: { config, lib, ... }:
with lib;
let let
host = config.networking.hostName; host = config.networking.hostName;
user-pubkey-full = config.sane.ssh.pubkeys."colin@${host}" or {}; user-pubkey-full = config.sane.ssh.pubkeys."colin@${host}" or {};
user-pubkey = user-pubkey-full.asUserKey or null; user-pubkey = user-pubkey-full.asUserKey or null;
host-keys = filter (k: k.user == "root") (attrValues config.sane.ssh.pubkeys); host-keys = lib.filter (k: k.user == "root") (lib.attrValues config.sane.ssh.pubkeys);
known-hosts-text = concatStringsSep known-hosts-text = lib.concatStringsSep
"\n" "\n"
(map (k: k.asHostKey) host-keys) (builtins.map (k: k.asHostKey) host-keys)
; ;
in in
{ {
@ -17,13 +16,14 @@ in
sane.user.persist.private = [ sane.user.persist.private = [
{ type = "file"; path = ".ssh/id_ed25519"; } { type = "file"; path = ".ssh/id_ed25519"; }
]; ];
sane.user.fs.".ssh/id_ed25519.pub" = sane.user.fs.".ssh/id_ed25519.pub" = lib.mkIf (user-pubkey != null) {
mkIf (user-pubkey != null) (sane-lib.fs.wantedText user-pubkey); symlink.text = user-pubkey;
sane.user.fs.".ssh/known_hosts" = sane-lib.fs.wantedText known-hosts-text; };
sane.user.fs.".ssh/known_hosts".symlink.text = known-hosts-text;
users.users.colin.openssh.authorizedKeys.keys = users.users.colin.openssh.authorizedKeys.keys =
let let
user-keys = filter (k: k.user == "colin") (attrValues config.sane.ssh.pubkeys); user-keys = lib.filter (k: k.user == "colin") (lib.attrValues config.sane.ssh.pubkeys);
in in
map (k: k.asUserKey) user-keys; builtins.map (k: k.asUserKey) user-keys;
} }

View File

@ -1,9 +1,9 @@
{ lib, sane-lib, ...}: { ... }:
{ {
# XDG defines things like ~/Desktop, ~/Downloads, etc. # XDG defines things like ~/Desktop, ~/Downloads, etc.
# these clutter the home, so i mostly don't use them. # these clutter the home, so i mostly don't use them.
sane.user.fs.".config/user-dirs.dirs" = sane-lib.fs.wantedText '' sane.user.fs.".config/user-dirs.dirs".symlink.text = ''
XDG_DESKTOP_DIR="$HOME/.xdg/Desktop" XDG_DESKTOP_DIR="$HOME/.xdg/Desktop"
XDG_DOCUMENTS_DIR="$HOME/dev" XDG_DOCUMENTS_DIR="$HOME/dev"
XDG_DOWNLOAD_DIR="$HOME/tmp" XDG_DOWNLOAD_DIR="$HOME/tmp"
@ -16,5 +16,5 @@
# prevent `xdg-user-dirs-update` from overriding/updating our config # prevent `xdg-user-dirs-update` from overriding/updating our config
# see <https://manpages.ubuntu.com/manpages/bionic/man5/user-dirs.conf.5.html> # see <https://manpages.ubuntu.com/manpages/bionic/man5/user-dirs.conf.5.html>
sane.user.fs.".config/user-dirs.conf" = sane-lib.fs.wantedText "enabled=False"; sane.user.fs.".config/user-dirs.conf".symlink.text = "enabled=False";
} }