nixos-config/nix/default.nix

79 lines
1.9 KiB
Nix
Raw Normal View History

2025-05-18 09:51:46 +02:00
# * Outputs - default.nix
2025-05-18 08:49:34 +02:00
{ inputs, configRootPath }:
let
2025-05-18 10:05:47 +02:00
isDecrypted =
npkgs: system:
let
file = ../private/check-encryption;
resultFile = npkgs.legacyPackages."${system}".runCommandLocal "check-encryption" { src = file; } ''
if [[ "$(< $src)" != "DECRYPTED" ]]; then
echo -n "no" >> $out;
else
echo -n "yes" >> $out;
fi
'';
in
2025-05-18 10:27:43 +02:00
(builtins.readFile resultFile == "yes");
2025-05-18 10:05:47 +02:00
2025-05-18 08:49:34 +02:00
stable = inputs.config-stable;
unstable = inputs.config-unstable;
nixpkgs = stable.nixpkgs;
nixpkgs-unstable = unstable.nixpkgs;
mkkArg = {
inherit stable;
inherit unstable;
inherit configRootPath;
};
in
{
# * NixOS configurations
2025-05-18 10:27:43 +02:00
nixosConfigurations =
let
mkSystem =
hostname:
{
system ? "x86_64-linux",
isStable ? true,
extraArgs ? { },
extraModules ? [ ],
}:
(if isStable then nixpkgs else nixpkgs-unstable).lib.nixosSystem {
system = system;
specialArgs = {
mkkArg =
mkkArg
// {
current = (if isStable then stable else unstable);
}
// {
isDecrypted = (isDecrypted (if isStable then stable else unstable).nixpkgs system);
}
// extraArgs;
};
modules = [
./hosts/${hostname}.nix
(
if
(
(isDecrypted (if isStable then stable else unstable).nixpkgs system)
&& builtins.pathExists ./hosts/${hostname}-private.nix
)
then
./hosts/${hostname}-private.nix
else
{ }
)
./common.nix
./common-os.nix
] ++ extraModules;
};
2025-05-18 08:49:34 +02:00
2025-05-18 10:27:43 +02:00
in
{
# ** materusPC
"materusPC" = mkSystem "materusPC" { };
2025-05-18 09:51:46 +02:00
# * default.nix END
2025-05-18 10:27:43 +02:00
};
2025-05-18 08:49:34 +02:00
}