Make sure .ssh exists before trying to copy authorized_keys into it
This commit is contained in:
parent
ed11652607
commit
9d5e943468
2 changed files with 16 additions and 4 deletions
|
@ -1,7 +1,10 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
chvp.base.zfs.ensureExists = [ "${config.chvp.dataPrefix}/etc/ssh" ];
|
||||
chvp.base.zfs = {
|
||||
ensureSystemExists = [ "${config.chvp.dataPrefix}/etc/ssh" ];
|
||||
ensureHomeExists = [ ".ssh" ];
|
||||
};
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
passwordAuthentication = false;
|
||||
|
|
|
@ -20,10 +20,14 @@
|
|||
{ path = ".cache/nix-index"; type = "cache"; }
|
||||
];
|
||||
};
|
||||
ensureExists = lib.mkOption {
|
||||
ensureSystemExists = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ "/data/etc/ssh" ];
|
||||
};
|
||||
ensureHomeExists = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ ".ssh" ];
|
||||
};
|
||||
backups = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [{
|
||||
|
@ -87,14 +91,16 @@
|
|||
|
||||
systemd.services =
|
||||
let
|
||||
ensureExistsScript = lib.concatStringsSep "\n" (map (path: "mkdir -p ${path}") config.chvp.base.zfs.ensureExists);
|
||||
makeLinkScript = config: lib.concatStringsSep "\n" (map (location: ''mkdir -p "${location.path}"'') config);
|
||||
ensureSystemExistsScript = lib.concatStringsSep "\n" (map (path: ''mkdir -p "${path}"'') config.chvp.base.zfs.ensureSystemExists);
|
||||
systemLinksScript = makeLinkScript config.chvp.base.zfs.systemLinks;
|
||||
ensureHomeExistsScript = lib.concatStringsSep "\n" (map (path: ''mkdir -p "${path}"'') config.chvp.base.zfs.ensureHomeExists);
|
||||
homeLinksScript = makeLinkScript config.chvp.base.zfs.homeLinks;
|
||||
in
|
||||
{
|
||||
make-system-links-destinations = {
|
||||
script = ''
|
||||
${ensureSystemExistsScript}
|
||||
${systemLinksScript}
|
||||
mkdir -p /home/charlotte
|
||||
chown charlotte:users /home/charlotte
|
||||
|
@ -115,7 +121,10 @@
|
|||
};
|
||||
|
||||
make-home-links-destinations = {
|
||||
script = homeLinksScript;
|
||||
script = ''
|
||||
${ensureHomeExistsScript}
|
||||
${homeLinksScript}
|
||||
'';
|
||||
after = [ "local-fs.target" "make-system-links-destinations.service" ];
|
||||
wants = [ "local-fs.target" "make-system-links-destinations.service" ];
|
||||
before = [ "shutdown.target" "sysinit.target" ];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue