mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 02:11:35 +01:00
Eval before deployment
This commit is contained in:
27
flake.nix
27
flake.nix
@@ -41,13 +41,29 @@
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
evalServerScript = pkgs.writeShellApplication {
|
||||
name = "eval-server";
|
||||
runtimeInputs = [ pkgs.nix ];
|
||||
text = ''
|
||||
set -euo pipefail
|
||||
|
||||
echo "▶ Evaluating NixOS configuration for '.#server'..."
|
||||
nix eval .#nixosConfigurations.server.config.system.build.toplevel > /dev/null
|
||||
echo "✅ Evaluation succeeded — configuration is valid."
|
||||
'';
|
||||
};
|
||||
|
||||
deployServerScript = pkgs.writeShellApplication {
|
||||
name = "deploy-server";
|
||||
runtimeInputs = [
|
||||
pkgs.nix
|
||||
pkgs.openssh
|
||||
runtimeInputs = with pkgs; [
|
||||
nix
|
||||
openssh
|
||||
];
|
||||
text = ''
|
||||
set -euo pipefail
|
||||
|
||||
"${evalServerScript}/bin/eval-server"
|
||||
|
||||
nix run nixpkgs#nixos-rebuild-ng -- \
|
||||
--flake .#server \
|
||||
--target-host thohlt@91.98.171.83 \
|
||||
@@ -58,6 +74,11 @@
|
||||
};
|
||||
in
|
||||
{
|
||||
eval-server = {
|
||||
type = "app";
|
||||
program = "${evalServerScript}/bin/eval-server";
|
||||
};
|
||||
|
||||
deploy-server = {
|
||||
type = "app";
|
||||
program = "${deployServerScript}/bin/deploy-server";
|
||||
|
||||
Reference in New Issue
Block a user