1
0
Fork 0

Beginn target shenanigans

This commit is contained in:
Malte Brandy 2020-10-12 03:14:05 +02:00
parent 5b06f60c93
commit debd837f8a
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
3 changed files with 31 additions and 7 deletions

View file

@ -9,7 +9,7 @@
i18n.defaultLocale = "en_US.UTF-8";
# For nixos-rebuild
nixpkgs.overlays = import ../../overlays { inherit lib; };
nixpkgs.overlays = [ (_: _: { withSecrets = false; }) ] ++ import ../../overlays { inherit lib; };
time.timeZone = "Europe/Berlin";

15
nixos/target.nix Normal file
View file

@ -0,0 +1,15 @@
{ withSecrets ? false }:
let
sources = import ../nix/sources.nix;
inherit (import sources.nixpkgs { }) lib pkgs;
machines = lib.attrNames (builtins.readDir ./machines);
getConfig = hostname:
args:
import (./machines + "/${hostname}/configuration.nix") (args // {
bla = "fünf";
});
in lib.listToAttrs (map (hostname: {
name = hostname;
value =
(import <nixpkgs/nixos> { configuration = getConfig hostname; }).system;
}) machines)

View file

@ -1,8 +1,14 @@
final: prec: {
withSecrets = let val = builtins.pathExists ../private/submodule-is-checked-out;
in builtins.trace
(if val then "Building _with_ secrets!" else "Building _without_ secrets!")
val;
final: prev:
let
# val = if prev.withSecrets then
# assert builtins.pathExists ../private/submodule-is-checked-out; true
# else
# false;
val = builtins.pathExists ../private/submodule-is-checked-out;
in {
withSecrets = builtins.trace
(if val then "Building _with_ secrets!" else "Building _without_ secrets!")
val;
privatePath = name:
let path = "/etc/nixos/private/${name}";
in if final.withSecrets then
@ -12,5 +18,8 @@ final: prec: {
privateValue = default: name:
if final.withSecrets then import (../private + "/${name}.nix") else default;
privateFile = name:
if final.withSecrets then ../private + "/${name}" else builtins.toFile "missing-secret-file-${name}" "";
if final.withSecrets then
../private + "/${name}"
else
builtins.toFile "missing-secret-file-${name}" "";
}