2020-07-02 20:19:08 +02:00
|
|
|
# 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.
|
2021-04-10 13:40:06 +02:00
|
|
|
{ depot, lib, pkgs, ... }@args:
|
2020-07-02 20:19:08 +02:00
|
|
|
|
2020-07-03 06:26:33 +02:00
|
|
|
let
|
|
|
|
inherit (lib) findFirst isAttrs;
|
2021-04-10 13:40:06 +02:00
|
|
|
nixos = import "${depot.third_party.nixpkgsSrc}/nixos";
|
|
|
|
in rec {
|
2020-07-02 20:19:08 +02:00
|
|
|
whitby = import ./whitby/default.nix args;
|
2020-07-03 06:26:33 +02:00
|
|
|
|
|
|
|
# System installation
|
|
|
|
|
|
|
|
allSystems = import ./all-systems.nix args;
|
|
|
|
|
2021-04-02 14:13:08 +02:00
|
|
|
# This provides our standard set of arguments to all NixOS modules.
|
|
|
|
baseModule = { ... }: {
|
|
|
|
_module.args = {
|
|
|
|
inherit (args) depot;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-04-10 13:40:06 +02:00
|
|
|
nixosFor = configuration: (nixos {
|
2021-04-02 14:13:08 +02:00
|
|
|
configuration = { ... }: {
|
2020-11-22 20:35:31 +01:00
|
|
|
imports = [
|
2021-04-02 14:13:08 +02:00
|
|
|
baseModule
|
2020-11-22 20:35:31 +01:00
|
|
|
configuration
|
|
|
|
];
|
|
|
|
};
|
2021-04-02 14:13:08 +02:00
|
|
|
});
|
2020-07-03 06:26:33 +02:00
|
|
|
|
|
|
|
findSystem = hostname:
|
|
|
|
(findFirst
|
|
|
|
(system: system.config.networking.hostName == hostname)
|
|
|
|
(throw "${hostname} is not a known NixOS host")
|
|
|
|
(map nixosFor allSystems));
|
|
|
|
|
|
|
|
rebuild-system = pkgs.writeShellScriptBin "rebuild-system" ''
|
|
|
|
set -ue
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "Oh no! Only root is allowed to rebuild the system!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Rebuilding NixOS for $HOSTNAME"
|
|
|
|
system=$(nix-build -E "((import ${toString depot.depotPath} {}).ops.nixos.findSystem \"$HOSTNAME\").system" --no-out-link --show-trace)
|
|
|
|
|
|
|
|
nix-env -p /nix/var/nix/profiles/system --set $system
|
|
|
|
$system/bin/switch-to-configuration switch
|
|
|
|
'';
|
2020-08-27 00:58:23 +02:00
|
|
|
|
|
|
|
# Systems that should be built in CI
|
|
|
|
#
|
|
|
|
# TODO(tazjin): Refactor the whole systems setup, it's a bit
|
|
|
|
# inconsistent at the moment.
|
2020-08-27 02:05:45 +02:00
|
|
|
whitbySystem = (nixosFor whitby).system;
|
2020-08-31 02:36:03 +02:00
|
|
|
meta.targets = [ "whitbySystem" ];
|
2020-07-02 20:19:08 +02:00
|
|
|
}
|