Automatically set machine hostname

This commit is contained in:
Zuckerberg 2023-04-24 20:52:17 -06:00
parent 832894edfc
commit b5dd983ba3
6 changed files with 11 additions and 16 deletions

View File

@ -55,7 +55,7 @@
{ {
nixosConfigurations = nixosConfigurations =
let let
modules = system: with inputs; [ modules = system: hostname: with inputs; [
./common ./common
simple-nixos-mailserver.nixosModule simple-nixos-mailserver.nixosModule
agenix.nixosModules.default agenix.nixosModules.default
@ -63,19 +63,23 @@
archivebox.nixosModule archivebox.nixosModule
nix-index-database.nixosModules.nix-index nix-index-database.nixosModules.nix-index
({ lib, ... }: { ({ lib, ... }: {
config.environment.systemPackages = [ config = {
environment.systemPackages = [
agenix.packages.${system}.agenix agenix.packages.${system}.agenix
]; ];
networking.hostName = hostname;
};
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way # because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
options.inputs = lib.mkOption { default = inputs; }; options.inputs = lib.mkOption { default = inputs; };
options.currentSystem = lib.mkOption { default = system; }; options.currentSystem = lib.mkOption { default = system; };
}) })
]; ];
mkSystem = system: nixpkgs: path: mkSystem = system: nixpkgs: path: hostname:
let let
allModules = modules system; allModules = modules system hostname;
# allow patching nixpkgs, remove this hack once this is solved: https://github.com/NixOS/nix/issues/3920 # allow patching nixpkgs, remove this hack once this is solved: https://github.com/NixOS/nix/issues/3920
patchedNixpkgsSrc = nixpkgs.legacyPackages.${system}.applyPatches { patchedNixpkgsSrc = nixpkgs.legacyPackages.${system}.applyPatches {
@ -99,7 +103,7 @@
in in
nixpkgs.lib.mapAttrs nixpkgs.lib.mapAttrs
(hostname: cfg: (hostname: cfg:
mkSystem cfg.arch nixpkgs cfg.configurationPath) mkSystem cfg.arch nixpkgs cfg.configurationPath hostname)
machines; machines;
packages = packages =

View File

@ -5,7 +5,6 @@
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
networking.hostName = "phil";
services.gitea-runner = { services.gitea-runner = {
enable = true; enable = true;
instanceUrl = "https://git.neet.dev"; instanceUrl = "https://git.neet.dev";

View File

@ -5,8 +5,6 @@
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
networking.hostName = "ponyo";
system.autoUpgrade.enable = true; system.autoUpgrade.enable = true;
# p2p mesh network # p2p mesh network

View File

@ -5,8 +5,6 @@
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
networking.hostName = "ray";
# for luks onlock over tor # for luks onlock over tor
services.tor.enable = true; services.tor.enable = true;
services.tor.client.enable = true; services.tor.client.enable = true;

View File

@ -11,8 +11,6 @@
# https://github.com/skogsbrus/os/blob/master/sys/router.nix # https://github.com/skogsbrus/os/blob/master/sys/router.nix
# http://trac.gateworks.com/wiki/wireless/wifi # http://trac.gateworks.com/wiki/wireless/wifi
networking.hostName = "router";
system.autoUpgrade.enable = true; system.autoUpgrade.enable = true;
services.tailscale.exitNode = true; services.tailscale.exitNode = true;

View File

@ -5,8 +5,6 @@
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
networking.hostName = "s0";
system.autoUpgrade.enable = true; system.autoUpgrade.enable = true;
services.iperf3.enable = true; services.iperf3.enable = true;