diff --git a/README.md b/README.md index b7ea0f876..0f618bf21 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Twitter][]. [`//ops/pipelines`](https://cs.tvl.fyi/depot/-/tree/ops/pipelines). All services that we host are deployed on NixOS machines that we manage. Their -configuration is tracked in `//ops/nixos`. +configuration is tracked in `//ops/{modules,machines}`. ## Nix diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 80481d88d..7c9d034a9 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -60,7 +60,7 @@ And `scope` should refer to some kind of logical grouping inside of the project. It does not make sense to include the full path unless it aids in disambiguating. For example, when changing the configuration of the host -`camden` at `//ops/nixos/camden` it is enough to write `feat(camden): ...`. +`whitby` at `//ops/machines/whitby` it is enough to write `feat(whitby): ...`. Please take a look at the existing commit log for examples. diff --git a/ops/nixos/all-systems.nix b/ops/machines/all-systems.nix similarity index 86% rename from ops/nixos/all-systems.nix rename to ops/machines/all-systems.nix index 05a89e05a..493d39e06 100644 --- a/ops/nixos/all-systems.nix +++ b/ops/machines/all-systems.nix @@ -1,6 +1,6 @@ { depot, ... }: -(with depot.ops.nixos; [ +(with depot.ops.machines; [ whitby ]) ++ diff --git a/ops/nixos/whitby/OWNERS b/ops/machines/whitby/OWNERS similarity index 100% rename from ops/nixos/whitby/OWNERS rename to ops/machines/whitby/OWNERS diff --git a/ops/nixos/whitby/README.md b/ops/machines/whitby/README.md similarity index 100% rename from ops/nixos/whitby/README.md rename to ops/machines/whitby/README.md diff --git a/ops/nixos/whitby/default.nix b/ops/machines/whitby/default.nix similarity index 89% rename from ops/nixos/whitby/default.nix rename to ops/machines/whitby/default.nix index 394b79c21..eb5ee4ed6 100644 --- a/ops/nixos/whitby/default.nix +++ b/ops/machines/whitby/default.nix @@ -1,30 +1,31 @@ -{ depot, lib, pkgs, ... }: +{ depot, lib, pkgs, ... }: # readTree options +config: # passed by module system let inherit (builtins) listToAttrs; inherit (lib) range; in lib.fix(self: { imports = [ - "${depot.depotPath}/ops/nixos/clbot.nix" - "${depot.depotPath}/ops/nixos/irccat.nix" - "${depot.depotPath}/ops/nixos/monorepo-gerrit.nix" - "${depot.depotPath}/ops/nixos/panettone.nix" - "${depot.depotPath}/ops/nixos/paroxysm.nix" - "${depot.depotPath}/ops/nixos/smtprelay.nix" - "${depot.depotPath}/ops/nixos/sourcegraph.nix" - "${depot.depotPath}/ops/nixos/tvl-buildkite.nix" - "${depot.depotPath}/ops/nixos/tvl-slapd/default.nix" - "${depot.depotPath}/ops/nixos/tvl-sso/default.nix" - "${depot.depotPath}/ops/nixos/www/b.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/cache.tvl.su.nix" - "${depot.depotPath}/ops/nixos/www/cl.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/code.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/cs.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/login.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/tazj.in.nix" - "${depot.depotPath}/ops/nixos/www/todo.tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/tvl.fyi.nix" - "${depot.depotPath}/ops/nixos/www/wigglydonke.rs.nix" + "${depot.depotPath}/ops/modules/clbot.nix" + "${depot.depotPath}/ops/modules/irccat.nix" + "${depot.depotPath}/ops/modules/monorepo-gerrit.nix" + "${depot.depotPath}/ops/modules/panettone.nix" + "${depot.depotPath}/ops/modules/paroxysm.nix" + "${depot.depotPath}/ops/modules/smtprelay.nix" + "${depot.depotPath}/ops/modules/sourcegraph.nix" + "${depot.depotPath}/ops/modules/tvl-buildkite.nix" + "${depot.depotPath}/ops/modules/tvl-slapd/default.nix" + "${depot.depotPath}/ops/modules/tvl-sso/default.nix" + "${depot.depotPath}/ops/modules/www/b.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/cache.tvl.su.nix" + "${depot.depotPath}/ops/modules/www/cl.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/code.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/cs.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/login.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/tazj.in.nix" + "${depot.depotPath}/ops/modules/www/todo.tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/tvl.fyi.nix" + "${depot.depotPath}/ops/modules/www/wigglydonke.rs.nix" "${pkgs.path}/nixos/modules/services/web-apps/gerrit.nix" ]; diff --git a/ops/nixos/.skip-subtree b/ops/modules/.skip-subtree similarity index 100% rename from ops/nixos/.skip-subtree rename to ops/modules/.skip-subtree diff --git a/ops/nixos/README.md b/ops/modules/README.md similarity index 100% rename from ops/nixos/README.md rename to ops/modules/README.md diff --git a/ops/nixos/clbot.nix b/ops/modules/clbot.nix similarity index 100% rename from ops/nixos/clbot.nix rename to ops/modules/clbot.nix diff --git a/ops/modules/default.nix b/ops/modules/default.nix new file mode 100644 index 000000000..8bdfecdf4 --- /dev/null +++ b/ops/modules/default.nix @@ -0,0 +1,2 @@ +# Make readTree happy at this level. +_: {} diff --git a/ops/nixos/irccat.nix b/ops/modules/irccat.nix similarity index 100% rename from ops/nixos/irccat.nix rename to ops/modules/irccat.nix diff --git a/ops/nixos/monorepo-gerrit.nix b/ops/modules/monorepo-gerrit.nix similarity index 100% rename from ops/nixos/monorepo-gerrit.nix rename to ops/modules/monorepo-gerrit.nix diff --git a/ops/nixos/panettone.nix b/ops/modules/panettone.nix similarity index 100% rename from ops/nixos/panettone.nix rename to ops/modules/panettone.nix diff --git a/ops/nixos/paroxysm.nix b/ops/modules/paroxysm.nix similarity index 100% rename from ops/nixos/paroxysm.nix rename to ops/modules/paroxysm.nix diff --git a/ops/nixos/quassel.nix b/ops/modules/quassel.nix similarity index 100% rename from ops/nixos/quassel.nix rename to ops/modules/quassel.nix diff --git a/ops/nixos/smtprelay.nix b/ops/modules/smtprelay.nix similarity index 100% rename from ops/nixos/smtprelay.nix rename to ops/modules/smtprelay.nix diff --git a/ops/nixos/sourcegraph.nix b/ops/modules/sourcegraph.nix similarity index 100% rename from ops/nixos/sourcegraph.nix rename to ops/modules/sourcegraph.nix diff --git a/ops/nixos/tvl-buildkite.nix b/ops/modules/tvl-buildkite.nix similarity index 100% rename from ops/nixos/tvl-buildkite.nix rename to ops/modules/tvl-buildkite.nix diff --git a/ops/nixos/tvl-slapd/default.nix b/ops/modules/tvl-slapd/default.nix similarity index 100% rename from ops/nixos/tvl-slapd/default.nix rename to ops/modules/tvl-slapd/default.nix diff --git a/ops/nixos/tvl-sso/default.nix b/ops/modules/tvl-sso/default.nix similarity index 100% rename from ops/nixos/tvl-sso/default.nix rename to ops/modules/tvl-sso/default.nix diff --git a/ops/nixos/v4l2loopback.nix b/ops/modules/v4l2loopback.nix similarity index 100% rename from ops/nixos/v4l2loopback.nix rename to ops/modules/v4l2loopback.nix diff --git a/ops/nixos/www/b.tvl.fyi.nix b/ops/modules/www/b.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/b.tvl.fyi.nix rename to ops/modules/www/b.tvl.fyi.nix diff --git a/ops/nixos/www/base.nix b/ops/modules/www/base.nix similarity index 100% rename from ops/nixos/www/base.nix rename to ops/modules/www/base.nix diff --git a/ops/nixos/www/cache.tvl.su.nix b/ops/modules/www/cache.tvl.su.nix similarity index 100% rename from ops/nixos/www/cache.tvl.su.nix rename to ops/modules/www/cache.tvl.su.nix diff --git a/ops/nixos/www/cl.tvl.fyi.nix b/ops/modules/www/cl.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/cl.tvl.fyi.nix rename to ops/modules/www/cl.tvl.fyi.nix diff --git a/ops/nixos/www/code.tvl.fyi.nix b/ops/modules/www/code.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/code.tvl.fyi.nix rename to ops/modules/www/code.tvl.fyi.nix diff --git a/ops/nixos/www/cs.tvl.fyi.nix b/ops/modules/www/cs.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/cs.tvl.fyi.nix rename to ops/modules/www/cs.tvl.fyi.nix diff --git a/ops/nixos/www/login.tvl.fyi.nix b/ops/modules/www/login.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/login.tvl.fyi.nix rename to ops/modules/www/login.tvl.fyi.nix diff --git a/ops/nixos/www/tazj.in.nix b/ops/modules/www/tazj.in.nix similarity index 100% rename from ops/nixos/www/tazj.in.nix rename to ops/modules/www/tazj.in.nix diff --git a/ops/nixos/www/todo.tvl.fyi.nix b/ops/modules/www/todo.tvl.fyi.nix similarity index 100% rename from ops/nixos/www/todo.tvl.fyi.nix rename to ops/modules/www/todo.tvl.fyi.nix diff --git a/ops/nixos/www/tvl.fyi.nix b/ops/modules/www/tvl.fyi.nix similarity index 100% rename from ops/nixos/www/tvl.fyi.nix rename to ops/modules/www/tvl.fyi.nix diff --git a/ops/nixos/www/wigglydonke.rs.nix b/ops/modules/www/wigglydonke.rs.nix similarity index 100% rename from ops/nixos/www/wigglydonke.rs.nix rename to ops/modules/www/wigglydonke.rs.nix diff --git a/ops/nixos/default.nix b/ops/nixos.nix similarity index 66% rename from ops/nixos/default.nix rename to ops/nixos.nix index 8be700b10..465a2eed3 100644 --- a/ops/nixos/default.nix +++ b/ops/nixos.nix @@ -1,21 +1,8 @@ -# Most of the Nix expressions in this folder are NixOS modules, which -# are not readTree compatible. -# -# Some things (such as system configurations) are, and we import them -# here manually. -# -# TODO(tazjin): Find a more elegant solution for the whole module -# situation. +# Helper functions for instantiating depot-compatible NixOS machines. { depot, lib, pkgs, ... }@args: let inherit (lib) findFirst isAttrs; in rec { - whitby = import ./whitby/default.nix args; - - # System installation - - allSystems = import ./all-systems.nix args; - # This provides our standard set of arguments to all NixOS modules. baseModule = { ... }: { _module.args = { @@ -36,7 +23,7 @@ in rec { (findFirst (system: system.config.networking.hostName == hostname) (throw "${hostname} is not a known NixOS host") - (map nixosFor allSystems)); + (map nixosFor depot.ops.machines.all-systems)); rebuild-system = pkgs.writeShellScriptBin "rebuild-system" '' set -ue @@ -53,9 +40,6 @@ in rec { ''; # Systems that should be built in CI - # - # TODO(tazjin): Refactor the whole systems setup, it's a bit - # inconsistent at the moment. - whitbySystem = (nixosFor whitby).system; + whitbySystem = (nixosFor depot.ops.machines.whitby).system; meta.targets = [ "whitbySystem" ]; } diff --git a/ops/nixos/.gitignore b/ops/nixos/.gitignore deleted file mode 100644 index 773fa1667..000000000 --- a/ops/nixos/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -hardware-configuration.nix -local-configuration.nix -result diff --git a/users/glittershark/system/system/machines/chupacabra.nix b/users/glittershark/system/system/machines/chupacabra.nix index 4f7f39ee5..974e3c34e 100644 --- a/users/glittershark/system/system/machines/chupacabra.nix +++ b/users/glittershark/system/system/machines/chupacabra.nix @@ -7,7 +7,7 @@ ../modules/tvl.nix ../modules/fcitx.nix ../modules/rtlsdr.nix - ../../../../../ops/nixos/v4l2loopback.nix + ../../../../../ops/modules/v4l2loopback.nix ../modules/desktop.nix ../modules/development.nix ]; diff --git a/users/tazjin/nixos/README.md b/users/tazjin/nixos/README.md index 0093f4ac6..662f2a36a 100644 --- a/users/tazjin/nixos/README.md +++ b/users/tazjin/nixos/README.md @@ -1,20 +1,17 @@ NixOS configuration =================== -My NixOS configuration! It configures most of the packages I require +My NixOS configurations! It configures most of the packages I require on my systems, sets up Emacs the way I need and does a bunch of other interesting things. -System configuration lives in folders for each machine and a custom -fixed point evaluation (similar to standard NixOS module -configuration) is used to combine configuration together. +System configuration lives in folders, and some of the modules stem +from `//ops/modules`. -Building `ops.nixos.rebuilder` yields a script that will automatically -build and activate the newest configuration based on the current -hostname. +Machines are deployed with the script at `ops.nixos.rebuild-system`. ## Configured hosts: -* `frog` - weapon of mass computation at home -* `camden` - NUC serving tazj.in, tvl.fyi & co -* ~~`urdhva` - T470s~~ (currently with edef) +* `tverskoy` - X13 AMD that's travelling around with me +* `frog` - weapon of mass computation (in storage in London) +* `camden` - NUC formerly serving tazj.in (in storage in London) diff --git a/users/tazjin/nixos/camden/default.nix b/users/tazjin/nixos/camden/default.nix index f334320b3..2659db5e9 100644 --- a/users/tazjin/nixos/camden/default.nix +++ b/users/tazjin/nixos/camden/default.nix @@ -25,8 +25,8 @@ in lib.fix(self: { sha256 = "157c64220lf825ll4c0cxsdwg7cxqdx4z559fdp7kpz0g6p8fhhr"; }; in [ - "${depot.depotPath}/ops/nixos/quassel.nix" - "${depot.depotPath}/ops/nixos/smtprelay.nix" + "${depot.depotPath}/ops/modules/quassel.nix" + "${depot.depotPath}/ops/modules/smtprelay.nix" "${oldChannel}/nixos/modules/security/acme.nix" ]; diff --git a/users/tazjin/nixos/frog/default.nix b/users/tazjin/nixos/frog/default.nix index 7f709da7e..1394f9cf4 100644 --- a/users/tazjin/nixos/frog/default.nix +++ b/users/tazjin/nixos/frog/default.nix @@ -16,7 +16,7 @@ config: let }; in lib.fix(self: { imports = [ - "${depot.depotPath}/ops/nixos/v4l2loopback.nix" + "${depot.depotPath}/ops/modules/v4l2loopback.nix" ]; boot = {