From 43fa7fdd9fd6b0807c0181bac89cf117437af584 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 22 Nov 2022 02:33:47 +0000 Subject: [PATCH] rename `machines` -> `hosts` - shorter. - congruent with `nixos-rebuild .` choosing what to build based on `hostname`. - more widely used within other nix repos i've seen. - more accurate in the case that i migrate a host to a different machine (which i plan to do with servo). --- flake.nix | 28 +++++++++---------- {machines => hosts}/desko/default.nix | 0 {machines => hosts}/desko/fs.nix | 0 {machines => hosts}/instantiate.nix | 2 +- {machines => hosts}/lappy/default.nix | 0 {machines => hosts}/lappy/fs.nix | 0 {machines => hosts}/moby/default.nix | 0 {machines => hosts}/moby/firmware.nix | 0 {machines => hosts}/moby/fs.nix | 0 {machines => hosts}/moby/kernel.nix | 0 .../moby/ucm2/PinePhone/HiFi.conf | 0 .../moby/ucm2/PinePhone/PinePhone.conf | 0 .../moby/ucm2/PinePhone/VoiceCall.conf | 0 {machines => hosts}/moby/ucm2/ucm.conf | 0 {machines => hosts}/rescue/default.nix | 0 {machines => hosts}/rescue/fs.nix | 0 {machines => hosts}/servo/default.nix | 0 {machines => hosts}/servo/fs.nix | 0 {machines => hosts}/servo/hardware.nix | 0 {machines => hosts}/servo/net.nix | 0 .../servo/services/ddns-he.nix | 0 .../servo/services/default.nix | 0 .../servo/services/ejabberd.nix | 0 .../servo/services/freshrss.nix | 0 {machines => hosts}/servo/services/gitea.nix | 0 .../servo/services/goaccess.nix | 0 {machines => hosts}/servo/services/ipfs.nix | 0 .../servo/services/jackett.nix | 0 .../servo/services/jellyfin.nix | 0 .../servo/services/matrix/default.nix | 0 .../servo/services/matrix/discord-puppet.nix | 0 .../servo/services/matrix/irc.nix | 0 .../services/matrix/synapse-log_level.yaml | 0 .../servo/services/navidrome.nix | 0 {machines => hosts}/servo/services/nginx.nix | 0 .../servo/services/pleroma.nix | 0 .../servo/services/postfix.nix | 0 .../servo/services/postgres.nix | 0 .../servo/services/prosody.nix | 0 .../servo/services/transmission.nix | 0 {machines => hosts}/servo/users.nix | 0 modules/universal/allocations.nix | 8 +++--- modules/universal/pubkeys.nix | 4 +-- modules/universal/secrets.nix | 2 +- readme.md | 6 ++++ 45 files changed, 28 insertions(+), 22 deletions(-) rename {machines => hosts}/desko/default.nix (100%) rename {machines => hosts}/desko/fs.nix (100%) rename {machines => hosts}/instantiate.nix (56%) rename {machines => hosts}/lappy/default.nix (100%) rename {machines => hosts}/lappy/fs.nix (100%) rename {machines => hosts}/moby/default.nix (100%) rename {machines => hosts}/moby/firmware.nix (100%) rename {machines => hosts}/moby/fs.nix (100%) rename {machines => hosts}/moby/kernel.nix (100%) rename {machines => hosts}/moby/ucm2/PinePhone/HiFi.conf (100%) rename {machines => hosts}/moby/ucm2/PinePhone/PinePhone.conf (100%) rename {machines => hosts}/moby/ucm2/PinePhone/VoiceCall.conf (100%) rename {machines => hosts}/moby/ucm2/ucm.conf (100%) rename {machines => hosts}/rescue/default.nix (100%) rename {machines => hosts}/rescue/fs.nix (100%) rename {machines => hosts}/servo/default.nix (100%) rename {machines => hosts}/servo/fs.nix (100%) rename {machines => hosts}/servo/hardware.nix (100%) rename {machines => hosts}/servo/net.nix (100%) rename {machines => hosts}/servo/services/ddns-he.nix (100%) rename {machines => hosts}/servo/services/default.nix (100%) rename {machines => hosts}/servo/services/ejabberd.nix (100%) rename {machines => hosts}/servo/services/freshrss.nix (100%) rename {machines => hosts}/servo/services/gitea.nix (100%) rename {machines => hosts}/servo/services/goaccess.nix (100%) rename {machines => hosts}/servo/services/ipfs.nix (100%) rename {machines => hosts}/servo/services/jackett.nix (100%) rename {machines => hosts}/servo/services/jellyfin.nix (100%) rename {machines => hosts}/servo/services/matrix/default.nix (100%) rename {machines => hosts}/servo/services/matrix/discord-puppet.nix (100%) rename {machines => hosts}/servo/services/matrix/irc.nix (100%) rename {machines => hosts}/servo/services/matrix/synapse-log_level.yaml (100%) rename {machines => hosts}/servo/services/navidrome.nix (100%) rename {machines => hosts}/servo/services/nginx.nix (100%) rename {machines => hosts}/servo/services/pleroma.nix (100%) rename {machines => hosts}/servo/services/postfix.nix (100%) rename {machines => hosts}/servo/services/postgres.nix (100%) rename {machines => hosts}/servo/services/prosody.nix (100%) rename {machines => hosts}/servo/services/transmission.nix (100%) rename {machines => hosts}/servo/users.nix (100%) diff --git a/flake.nix b/flake.nix index a27f84d3..6b5924e2 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ nixpkgsFor = local: target: import (patchedPkgs target) { crossSystem = target; localSystem = local; }; # evaluate ONLY our overlay, for the provided system customPackagesFor = local: target: import ./pkgs/overlay.nix (nixpkgsFor local target) (nixpkgsFor local target); - decl-machine = { name, local, target }: + decl-host = { name, local, target }: let nixosSystem = import ((patchedPkgs target) + "/nixos/lib/eval-config.nix"); in (nixosSystem { @@ -54,7 +54,7 @@ specialArgs = { inherit mobile-nixos home-manager impermanence; }; modules = [ ./modules - (import ./machines/instantiate.nix name) + (import ./hosts/instantiate.nix name) home-manager.nixosModule impermanence.nixosModule sops-nix.nixosModules.sops @@ -77,8 +77,8 @@ ]; }); - decl-bootable-machine = { name, local, target }: rec { - nixosConfiguration = decl-machine { inherit name local target; }; + decl-bootable-host = { name, local, target }: rec { + nixosConfiguration = decl-host { inherit name local target; }; # this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition). # after building this: # - flash it to a bootable medium (SD card, flash drive, HDD) @@ -91,23 +91,23 @@ # - boot # - if fs wasn't resized automatically, then `sudo btrfs filesystem resize max /` # - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS. - # - `nixos-rebuild --flake './#' switch` + # - `nixos-rebuild --flake './#' switch` img = nixosConfiguration.config.system.build.img; }; - machines.servo = decl-bootable-machine { name = "servo"; local = "aarch64-linux"; target = "aarch64-linux"; }; - machines.desko = decl-bootable-machine { name = "desko"; local = "x86_64-linux"; target = "x86_64-linux"; }; - machines.lappy = decl-bootable-machine { name = "lappy"; local = "x86_64-linux"; target = "x86_64-linux"; }; - machines.moby = decl-bootable-machine { name = "moby"; local = "aarch64-linux"; target = "aarch64-linux"; }; + hosts.servo = decl-bootable-host { name = "servo"; local = "aarch64-linux"; target = "aarch64-linux"; }; + hosts.desko = decl-bootable-host { name = "desko"; local = "x86_64-linux"; target = "x86_64-linux"; }; + hosts.lappy = decl-bootable-host { name = "lappy"; local = "x86_64-linux"; target = "x86_64-linux"; }; + hosts.moby = decl-bootable-host { name = "moby"; local = "aarch64-linux"; target = "aarch64-linux"; }; # special cross-compiled variant, to speed up deploys from an x86 box to the arm target # note that these *do* produce different store paths, because the closure for the tools used to cross compile # v.s. emulate differ. # so deploying foo-cross and then foo incurs some rebuilding. - machines.servo-cross = decl-bootable-machine { name = "servo"; local = "x86_64-linux"; target = "aarch64-linux"; }; - machines.moby-cross = decl-bootable-machine { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; }; - machines.rescue = decl-bootable-machine { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; }; + hosts.servo-cross = decl-bootable-host { name = "servo"; local = "x86_64-linux"; target = "aarch64-linux"; }; + hosts.moby-cross = decl-bootable-host { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; }; + hosts.rescue = decl-bootable-host { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; }; in { - nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) machines; - imgs = builtins.mapAttrs (name: value: value.img) machines; + nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) hosts; + imgs = builtins.mapAttrs (name: value: value.img) hosts; packages = let allPkgsFor = sys: (customPackagesFor sys sys) // { nixpkgs = nixpkgsFor sys sys; diff --git a/machines/desko/default.nix b/hosts/desko/default.nix similarity index 100% rename from machines/desko/default.nix rename to hosts/desko/default.nix diff --git a/machines/desko/fs.nix b/hosts/desko/fs.nix similarity index 100% rename from machines/desko/fs.nix rename to hosts/desko/fs.nix diff --git a/machines/instantiate.nix b/hosts/instantiate.nix similarity index 56% rename from machines/instantiate.nix rename to hosts/instantiate.nix index d9f521ff..bfd70402 100644 --- a/machines/instantiate.nix +++ b/hosts/instantiate.nix @@ -1,4 +1,4 @@ -# trampoline from flake.nix into the specific machine definition, while doing a tiny bit of common setup +# trampoline from flake.nix into the specific host definition, while doing a tiny bit of common setup hostName: { ... }: { imports = [ diff --git a/machines/lappy/default.nix b/hosts/lappy/default.nix similarity index 100% rename from machines/lappy/default.nix rename to hosts/lappy/default.nix diff --git a/machines/lappy/fs.nix b/hosts/lappy/fs.nix similarity index 100% rename from machines/lappy/fs.nix rename to hosts/lappy/fs.nix diff --git a/machines/moby/default.nix b/hosts/moby/default.nix similarity index 100% rename from machines/moby/default.nix rename to hosts/moby/default.nix diff --git a/machines/moby/firmware.nix b/hosts/moby/firmware.nix similarity index 100% rename from machines/moby/firmware.nix rename to hosts/moby/firmware.nix diff --git a/machines/moby/fs.nix b/hosts/moby/fs.nix similarity index 100% rename from machines/moby/fs.nix rename to hosts/moby/fs.nix diff --git a/machines/moby/kernel.nix b/hosts/moby/kernel.nix similarity index 100% rename from machines/moby/kernel.nix rename to hosts/moby/kernel.nix diff --git a/machines/moby/ucm2/PinePhone/HiFi.conf b/hosts/moby/ucm2/PinePhone/HiFi.conf similarity index 100% rename from machines/moby/ucm2/PinePhone/HiFi.conf rename to hosts/moby/ucm2/PinePhone/HiFi.conf diff --git a/machines/moby/ucm2/PinePhone/PinePhone.conf b/hosts/moby/ucm2/PinePhone/PinePhone.conf similarity index 100% rename from machines/moby/ucm2/PinePhone/PinePhone.conf rename to hosts/moby/ucm2/PinePhone/PinePhone.conf diff --git a/machines/moby/ucm2/PinePhone/VoiceCall.conf b/hosts/moby/ucm2/PinePhone/VoiceCall.conf similarity index 100% rename from machines/moby/ucm2/PinePhone/VoiceCall.conf rename to hosts/moby/ucm2/PinePhone/VoiceCall.conf diff --git a/machines/moby/ucm2/ucm.conf b/hosts/moby/ucm2/ucm.conf similarity index 100% rename from machines/moby/ucm2/ucm.conf rename to hosts/moby/ucm2/ucm.conf diff --git a/machines/rescue/default.nix b/hosts/rescue/default.nix similarity index 100% rename from machines/rescue/default.nix rename to hosts/rescue/default.nix diff --git a/machines/rescue/fs.nix b/hosts/rescue/fs.nix similarity index 100% rename from machines/rescue/fs.nix rename to hosts/rescue/fs.nix diff --git a/machines/servo/default.nix b/hosts/servo/default.nix similarity index 100% rename from machines/servo/default.nix rename to hosts/servo/default.nix diff --git a/machines/servo/fs.nix b/hosts/servo/fs.nix similarity index 100% rename from machines/servo/fs.nix rename to hosts/servo/fs.nix diff --git a/machines/servo/hardware.nix b/hosts/servo/hardware.nix similarity index 100% rename from machines/servo/hardware.nix rename to hosts/servo/hardware.nix diff --git a/machines/servo/net.nix b/hosts/servo/net.nix similarity index 100% rename from machines/servo/net.nix rename to hosts/servo/net.nix diff --git a/machines/servo/services/ddns-he.nix b/hosts/servo/services/ddns-he.nix similarity index 100% rename from machines/servo/services/ddns-he.nix rename to hosts/servo/services/ddns-he.nix diff --git a/machines/servo/services/default.nix b/hosts/servo/services/default.nix similarity index 100% rename from machines/servo/services/default.nix rename to hosts/servo/services/default.nix diff --git a/machines/servo/services/ejabberd.nix b/hosts/servo/services/ejabberd.nix similarity index 100% rename from machines/servo/services/ejabberd.nix rename to hosts/servo/services/ejabberd.nix diff --git a/machines/servo/services/freshrss.nix b/hosts/servo/services/freshrss.nix similarity index 100% rename from machines/servo/services/freshrss.nix rename to hosts/servo/services/freshrss.nix diff --git a/machines/servo/services/gitea.nix b/hosts/servo/services/gitea.nix similarity index 100% rename from machines/servo/services/gitea.nix rename to hosts/servo/services/gitea.nix diff --git a/machines/servo/services/goaccess.nix b/hosts/servo/services/goaccess.nix similarity index 100% rename from machines/servo/services/goaccess.nix rename to hosts/servo/services/goaccess.nix diff --git a/machines/servo/services/ipfs.nix b/hosts/servo/services/ipfs.nix similarity index 100% rename from machines/servo/services/ipfs.nix rename to hosts/servo/services/ipfs.nix diff --git a/machines/servo/services/jackett.nix b/hosts/servo/services/jackett.nix similarity index 100% rename from machines/servo/services/jackett.nix rename to hosts/servo/services/jackett.nix diff --git a/machines/servo/services/jellyfin.nix b/hosts/servo/services/jellyfin.nix similarity index 100% rename from machines/servo/services/jellyfin.nix rename to hosts/servo/services/jellyfin.nix diff --git a/machines/servo/services/matrix/default.nix b/hosts/servo/services/matrix/default.nix similarity index 100% rename from machines/servo/services/matrix/default.nix rename to hosts/servo/services/matrix/default.nix diff --git a/machines/servo/services/matrix/discord-puppet.nix b/hosts/servo/services/matrix/discord-puppet.nix similarity index 100% rename from machines/servo/services/matrix/discord-puppet.nix rename to hosts/servo/services/matrix/discord-puppet.nix diff --git a/machines/servo/services/matrix/irc.nix b/hosts/servo/services/matrix/irc.nix similarity index 100% rename from machines/servo/services/matrix/irc.nix rename to hosts/servo/services/matrix/irc.nix diff --git a/machines/servo/services/matrix/synapse-log_level.yaml b/hosts/servo/services/matrix/synapse-log_level.yaml similarity index 100% rename from machines/servo/services/matrix/synapse-log_level.yaml rename to hosts/servo/services/matrix/synapse-log_level.yaml diff --git a/machines/servo/services/navidrome.nix b/hosts/servo/services/navidrome.nix similarity index 100% rename from machines/servo/services/navidrome.nix rename to hosts/servo/services/navidrome.nix diff --git a/machines/servo/services/nginx.nix b/hosts/servo/services/nginx.nix similarity index 100% rename from machines/servo/services/nginx.nix rename to hosts/servo/services/nginx.nix diff --git a/machines/servo/services/pleroma.nix b/hosts/servo/services/pleroma.nix similarity index 100% rename from machines/servo/services/pleroma.nix rename to hosts/servo/services/pleroma.nix diff --git a/machines/servo/services/postfix.nix b/hosts/servo/services/postfix.nix similarity index 100% rename from machines/servo/services/postfix.nix rename to hosts/servo/services/postfix.nix diff --git a/machines/servo/services/postgres.nix b/hosts/servo/services/postgres.nix similarity index 100% rename from machines/servo/services/postgres.nix rename to hosts/servo/services/postgres.nix diff --git a/machines/servo/services/prosody.nix b/hosts/servo/services/prosody.nix similarity index 100% rename from machines/servo/services/prosody.nix rename to hosts/servo/services/prosody.nix diff --git a/machines/servo/services/transmission.nix b/hosts/servo/services/transmission.nix similarity index 100% rename from machines/servo/services/transmission.nix rename to hosts/servo/services/transmission.nix diff --git a/machines/servo/users.nix b/hosts/servo/users.nix similarity index 100% rename from machines/servo/users.nix rename to hosts/servo/users.nix diff --git a/modules/universal/allocations.nix b/modules/universal/allocations.nix index 4a51afcc..544fb7a5 100644 --- a/modules/universal/allocations.nix +++ b/modules/universal/allocations.nix @@ -29,7 +29,7 @@ in sane.allocations.colin-uid = mkId 1000; sane.allocations.guest-uid = mkId 1100; - # found on all machines + # found on all hosts sane.allocations.sshd-uid = mkId 2001; # 997 sane.allocations.sshd-gid = mkId 2001; # 997 sane.allocations.polkituser-gid = mkId 2002; # 998 @@ -39,15 +39,15 @@ in sane.allocations.systemd-oom-uid = mkId 2005; sane.allocations.systemd-oom-gid = mkId 2005; - # found on graphical machines + # found on graphical hosts sane.allocations.nm-iodine-uid = mkId 2101; # desko/moby/lappy - # found on desko machine + # found on desko host sane.allocations.usbmux-uid = mkId 2204; sane.allocations.usbmux-gid = mkId 2204; - # originally found on moby machine + # originally found on moby host sane.allocations.avahi-uid = mkId 2304; sane.allocations.avahi-gid = mkId 2304; sane.allocations.colord-uid = mkId 2305; diff --git a/modules/universal/pubkeys.nix b/modules/universal/pubkeys.nix index 3e10735f..59f3decf 100644 --- a/modules/universal/pubkeys.nix +++ b/modules/universal/pubkeys.nix @@ -27,8 +27,8 @@ let }; in { # map hostname -> something suitable for known_keys - hosts = builtins.mapAttrs (machine: keys: withHost machine keys.host) keys; + hosts = builtins.mapAttrs (host: keys: withHost host keys.host) keys; # map hostname -> something suitable for authorized_keys to allow access to colin@ - users = builtins.mapAttrs (machine: keys: withUser "colin@${machine}" keys.users.colin) keys; + users = builtins.mapAttrs (host: keys: withUser "colin@${host}" keys.users.colin) keys; } diff --git a/modules/universal/secrets.nix b/modules/universal/secrets.nix index 306deabe..a95cb626 100644 --- a/modules/universal/secrets.nix +++ b/modules/universal/secrets.nix @@ -16,7 +16,7 @@ # add the result to .sops.yaml # since we specify ssh pubkeys in the nix config, you can just grep for `ssh-ed25519` here and use those instead # - # for each machine you want to decrypt secrets: + # for each host you want to decrypt secrets: # $ cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age # add the result to .sops.yaml # $ sops updatekeys secrets/example.yaml diff --git a/readme.md b/readme.md index 38a47685..378bef7a 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,12 @@ to deploy: nixos-rebuild --flake "./#servo" {build,switch} ``` +if the target is the same as the host, nix will grab the hostname automatically: + +```sh +nixos-rebuild --flake . {build,switch} +``` + more options (like building packages defined in this repo): ```sh