Skip to content

Commit 2fcc892

Browse files
committed
Eval before deployment
1 parent 826c32e commit 2fcc892

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

flake.nix

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@
4141
let
4242
pkgs = nixpkgs.legacyPackages.${system};
4343

44+
evalServerScript = pkgs.writeShellApplication {
45+
name = "eval-server";
46+
runtimeInputs = [ pkgs.nix ];
47+
text = ''
48+
set -euo pipefail
49+
50+
echo "▶ Evaluating NixOS configuration for '.#server'..."
51+
nix eval .#nixosConfigurations.server.config.system.build.toplevel > /dev/null
52+
echo "✅ Evaluation succeeded — configuration is valid."
53+
'';
54+
};
55+
4456
deployServerScript = pkgs.writeShellApplication {
4557
name = "deploy-server";
46-
runtimeInputs = [
47-
pkgs.nix
48-
pkgs.openssh
58+
runtimeInputs = with pkgs; [
59+
nix
60+
openssh
4961
];
5062
text = ''
63+
set -euo pipefail
64+
65+
"${evalServerScript}/bin/eval-server"
66+
5167
nix run nixpkgs#nixos-rebuild-ng -- \
5268
--flake .#server \
5369
--target-host [email protected] \
@@ -58,6 +74,11 @@
5874
};
5975
in
6076
{
77+
eval-server = {
78+
type = "app";
79+
program = "${evalServerScript}/bin/eval-server";
80+
};
81+
6182
deploy-server = {
6283
type = "app";
6384
program = "${deployServerScript}/bin/deploy-server";

0 commit comments

Comments
 (0)