main
1# Generate the small set of host files Nagoya needs outside Home Manager.
2# Debian continues to manage packages, services, and networking.
3{
4 pkgs,
5 globals,
6 libx,
7 ...
8}:
9let
10 hostsEntries = libx.hostConfigs globals.machines;
11 hosts = pkgs.writeText "hosts" ''
12 127.0.0.1 localhost nagoya
13 ::1 localhost
14 ${pkgs.lib.concatStringsSep "\n" (
15 pkgs.lib.mapAttrsToList (ip: names: "${ip} ${pkgs.lib.concatStringsSep " " names}") hostsEntries
16 )}
17 '';
18
19 nixCustomConf = pkgs.writeText "nix.custom.conf" ''
20 trusted-users = root vincent
21 connect-timeout = 5
22 download-attempts = 2
23 builders-use-substitutes = true
24 '';
25
26 deploy = pkgs.writeShellScript "deploy-nagoya-configs" ''
27 set -euo pipefail
28 install -m 0644 ${hosts} /etc/hosts
29 install -d -m 0755 /etc/nix
30 install -m 0644 ${nixCustomConf} /etc/nix/nix.custom.conf
31 '';
32in
33pkgs.runCommand "nagoya-configs" { } ''
34 mkdir -p "$out/etc/nix"
35 cp ${hosts} "$out/etc/hosts"
36 cp ${nixCustomConf} "$out/etc/nix/nix.custom.conf"
37 cp ${deploy} "$out/deploy"
38''