forked from fediversity/fediversity
Compare commits
1 commit
90d9988d88
...
ca5d7f1909
| Author | SHA1 | Date | |
|---|---|---|---|
| ca5d7f1909 |
8 changed files with 69 additions and 37 deletions
|
|
@ -3,10 +3,7 @@
|
|||
"hello"
|
||||
"cowsay"
|
||||
];
|
||||
pathToRoot = builtins.path {
|
||||
path = ../../..;
|
||||
name = "root";
|
||||
};
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = "/deployment/check/data-model-ssh";
|
||||
useFlake = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@
|
|||
"peertube"
|
||||
"pixelfed"
|
||||
];
|
||||
pathToRoot = builtins.path {
|
||||
path = ../../..;
|
||||
name = "root";
|
||||
};
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = "/deployment/check/data-model-ssh";
|
||||
enableAcme = true;
|
||||
useFlake = true;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
}@args:
|
||||
|
||||
let
|
||||
# self = ./data-model.nix;
|
||||
self = "deployment/check/common/data-model.nix";
|
||||
# args = { inherit config system inputs sources; };
|
||||
# self args
|
||||
inherit (sources) nixpkgs;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (pkgs) lib;
|
||||
|
|
@ -142,6 +145,7 @@ let
|
|||
};
|
||||
module = self;
|
||||
inherit args deployment-name root-path;
|
||||
# deployment-name = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@
|
|||
targetMachines = [
|
||||
"nixops4"
|
||||
];
|
||||
pathToRoot = builtins.path {
|
||||
path = ../../..;
|
||||
name = "root";
|
||||
};
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = "/deployment/check/data-model-ssh";
|
||||
enableAcme = true;
|
||||
useFlake = true;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,7 @@
|
|||
targetMachines = [
|
||||
"ssh"
|
||||
];
|
||||
# stablize path, as just the path would yield distinct paths when applied multiple times
|
||||
pathToRoot = builtins.path {
|
||||
path = ../../..;
|
||||
name = "root";
|
||||
};
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = "/deployment/check/data-model-ssh";
|
||||
enableAcme = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@
|
|||
"peertube"
|
||||
"pixelfed"
|
||||
];
|
||||
pathToRoot = builtins.path {
|
||||
path = ../../..;
|
||||
name = "root";
|
||||
};
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = "/deployment/check/data-model-ssh";
|
||||
enableAcme = true;
|
||||
useFlake = true;
|
||||
|
|
|
|||
|
|
@ -92,10 +92,12 @@ let
|
|||
type = types.path;
|
||||
};
|
||||
run = mkOption {
|
||||
# type = types.path;
|
||||
type = types.str;
|
||||
# readOnly = true;
|
||||
default =
|
||||
let
|
||||
# inherit (ssh-host.config) ssh nixos-configuration;
|
||||
inherit (ssh-host.config)
|
||||
ssh
|
||||
module
|
||||
|
|
@ -103,37 +105,69 @@ let
|
|||
deployment-name
|
||||
root-path
|
||||
;
|
||||
# inherit (ssh-host.config) ssh module args;
|
||||
inherit (ssh) host username key-file;
|
||||
# inherit (import ./nixos.nix {
|
||||
# # inherit system;
|
||||
# system = pkgs.system; # XXX recheck this is the right one
|
||||
# configuration = nixos-configuration;
|
||||
# # commandFn = outPath: '''';
|
||||
# }) drv_path;
|
||||
# command
|
||||
environment = {
|
||||
# inherit (ssh-host) host username key-file;
|
||||
# inherit host username drv_path;
|
||||
key_file = key-file;
|
||||
deployment_name = deployment-name;
|
||||
root_path = root-path;
|
||||
system = pkgs.system; # XXX recheck this is the right one
|
||||
# config_nix = nixos-configuration;
|
||||
# config_tf = {};
|
||||
# inherit host username;
|
||||
inherit
|
||||
host
|
||||
username
|
||||
module
|
||||
args
|
||||
# root_path
|
||||
;
|
||||
deployment_type = "ssh-host";
|
||||
# module = ;
|
||||
# args = ;
|
||||
# deployment_name = ;
|
||||
# deployment_type = ;
|
||||
# root_path = builtins.toString ./..;
|
||||
# root_path = ;
|
||||
};
|
||||
in
|
||||
''
|
||||
# error: cannot coerce a function to a string: «lambda mkNixosConfiguration @ /nix/store/ifj5ykvb5hv05m9qcr4r1aah4s4f9pdi-source/deployment/check/common/data-model.nix:106:15»
|
||||
# ''
|
||||
# env ${toString (lib.mapAttrsToList (k: v: lib.trace (if k == "config_nix" then v {} else k) "${k}='${v}'") environment)} ${./run/ssh-single-host/run.sh}";
|
||||
# '';
|
||||
# ''
|
||||
# env ${toString (lib.mapAttrsToList (k: v: lib.trace k "${k}=${lib.strings.toJSON v}") environment)} ${./run/ssh-single-host/run.sh}";
|
||||
# '';
|
||||
# if v == null then toString v else
|
||||
# lib.traceVal
|
||||
# ''
|
||||
# env ${toString (lib.mapAttrsToList (k: v: lib.trace k "${k}='${v}'") (lib.filterAttrs (_: v: v != null) environment))} ${./run/ssh-single-host/run.sh}
|
||||
# '';
|
||||
lib.traceVal ''
|
||||
env ${
|
||||
toString (
|
||||
lib.mapAttrsToList (
|
||||
k: v:
|
||||
"${k}=\"${
|
||||
lib.trace k "${k}=\"${
|
||||
lib.replaceStrings [ "\"" ] [ "\\\\\"" ] (
|
||||
if lib.isPath v || builtins.isNull v then
|
||||
toString v
|
||||
else if lib.isString v then
|
||||
v
|
||||
else
|
||||
if lib.isAttrs v then
|
||||
lib.strings.toJSON v
|
||||
else if lib.isPath v then
|
||||
toString v
|
||||
else
|
||||
v
|
||||
)
|
||||
}\""
|
||||
) environment
|
||||
) (lib.filterAttrs (_: v: v != null) environment)
|
||||
)
|
||||
} bash ./deployment/run/ssh-single-host/run.sh
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -1,26 +1,35 @@
|
|||
#! /usr/bin/env bash
|
||||
set -xeuo pipefail
|
||||
declare username host system module args deployment_name deployment_type args key_file root_path
|
||||
declare username host system module args deployment_name deployment_type args #key_file root_path
|
||||
|
||||
# DEPLOY
|
||||
sshOpts=(
|
||||
-o BatchMode=yes
|
||||
-o StrictHostKeyChecking=no
|
||||
# TODO set key for production
|
||||
# ${if key-file == null then "" else "-i ${key-file}"}
|
||||
# NOTE the below options are for tests
|
||||
-o ConnectTimeout=1
|
||||
-o ServerAliveInterval=1
|
||||
)
|
||||
if [[ -n "$key_file" ]]; then
|
||||
sshOpts+=(
|
||||
-i "$key_file"
|
||||
)
|
||||
fi
|
||||
destination="$username@$host"
|
||||
|
||||
# echo "$cwd/deployment"
|
||||
# ls "$cwd/deployment"
|
||||
|
||||
# echo "$args"
|
||||
root=$(echo "$args" | jq -r '.config.pathToRoot')
|
||||
# echo "$root/deployment/nixos.nix"
|
||||
# ls "$root/deployment/nixos.nix"
|
||||
|
||||
# FIXME: ensure [[ $root_path == $root ]] so i could just rely on stuff from /deployment/data-model.nix
|
||||
# cwd=$root_path
|
||||
cwd=$root
|
||||
|
||||
command=(nix-instantiate --show-trace --expr "
|
||||
import $root_path/deployment/nixos.nix {
|
||||
import $cwd/deployment/nixos.nix {
|
||||
system = \"$system\";
|
||||
configuration = (import \"$root_path/$module\" (builtins.fromJSON ''$args'')).$deployment_name.$deployment_type.nixos-configuration;
|
||||
configuration = (import \"$cwd/$module\" (builtins.fromJSON ''$args'')).$deployment_name.$deployment_type.nixos-configuration;
|
||||
}
|
||||
")
|
||||
|
||||
|
|
@ -29,6 +38,7 @@ command=(nix-instantiate --show-trace --expr "
|
|||
"${command[@]}" -A out_path
|
||||
|
||||
# get the realized derivation to deploy
|
||||
# "${command[@]}" --show-trace --eval --strict --json | jq -r '.command')"
|
||||
outPath=$(nix-store --realize "$("${command[@]}" --show-trace --eval --strict --json | jq -r '.drv_path')")
|
||||
# deploy the config by nix-copy-closure
|
||||
NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$destination" "$outPath" --gzip --use-substitutes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue