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, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
chvp.base.zfs.ensureExists = [ "${config.chvp.dataPrefix}/etc/ssh" ];
|
chvp.base.zfs = {
|
||||||
|
ensureSystemExists = [ "${config.chvp.dataPrefix}/etc/ssh" ];
|
||||||
|
ensureHomeExists = [ ".ssh" ];
|
||||||
|
};
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
passwordAuthentication = false;
|
passwordAuthentication = false;
|
||||||
|
|
|
@ -20,10 +20,14 @@
|
||||||
{ path = ".cache/nix-index"; type = "cache"; }
|
{ path = ".cache/nix-index"; type = "cache"; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
ensureExists = lib.mkOption {
|
ensureSystemExists = lib.mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
example = [ "/data/etc/ssh" ];
|
example = [ "/data/etc/ssh" ];
|
||||||
};
|
};
|
||||||
|
ensureHomeExists = lib.mkOption {
|
||||||
|
default = [ ];
|
||||||
|
example = [ ".ssh" ];
|
||||||
|
};
|
||||||
backups = lib.mkOption {
|
backups = lib.mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
example = [{
|
example = [{
|
||||||
|
@ -87,14 +91,16 @@
|
||||||
|
|
||||||
systemd.services =
|
systemd.services =
|
||||||
let
|
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);
|
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;
|
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;
|
homeLinksScript = makeLinkScript config.chvp.base.zfs.homeLinks;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
make-system-links-destinations = {
|
make-system-links-destinations = {
|
||||||
script = ''
|
script = ''
|
||||||
|
${ensureSystemExistsScript}
|
||||||
${systemLinksScript}
|
${systemLinksScript}
|
||||||
mkdir -p /home/charlotte
|
mkdir -p /home/charlotte
|
||||||
chown charlotte:users /home/charlotte
|
chown charlotte:users /home/charlotte
|
||||||
|
@ -115,7 +121,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
make-home-links-destinations = {
|
make-home-links-destinations = {
|
||||||
script = homeLinksScript;
|
script = ''
|
||||||
|
${ensureHomeExistsScript}
|
||||||
|
${homeLinksScript}
|
||||||
|
'';
|
||||||
after = [ "local-fs.target" "make-system-links-destinations.service" ];
|
after = [ "local-fs.target" "make-system-links-destinations.service" ];
|
||||||
wants = [ "local-fs.target" "make-system-links-destinations.service" ];
|
wants = [ "local-fs.target" "make-system-links-destinations.service" ];
|
||||||
before = [ "shutdown.target" "sysinit.target" ];
|
before = [ "shutdown.target" "sysinit.target" ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue