65 lines
1.6 KiB
Nix

{
# Defines a minimal `nixosConfigurations` output and verifies a known
# value from the evaluated system configuration.
description = "A minimal nixosConfigurations example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
demoSystem = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./module.nix
{
boot.loader.grub = {
enable = true;
device = "/dev/null";
};
fileSystems."/" = {
device = "tmpfs";
fsType = "tmpfs";
};
system.stateVersion = "24.11";
playground = {
hostName = "demo-machine";
motd = "hello from nixosConfigurations";
};
}
];
};
in
{
nixosConfigurations.demo = demoSystem;
checks.${system}.configuration =
pkgs.runCommand "nixos-configuration-check"
{
inherit (demoSystem.config.networking) hostName;
motd = demoSystem.config.environment.etc."playground-motd".text;
}
''
if [ "$hostName" != "demo-machine" ]; then
echo "unexpected host name: $hostName" >&2
exit 1
fi
if [ "$motd" != "hello from nixosConfigurations" ]; then
echo "unexpected motd: $motd" >&2
exit 1
fi
echo ok > "$out"
'';
};
}