depot/ops/nixos/default.nix

30 lines
984 B
Nix
Raw Normal View History

{ depot, lib, pkgs, ... }@args:
let
inherit (builtins) foldl' mapAttrs;
baseModule = name: { ... }: {
_module.args = args // {
rebuilder = rebuilder name;
};
};
systemFor = systemName: config:
(depot.third_party.nixeval {
system = builtins.currentSystem;
modules = [ (baseModule systemName) (args: { imports = [ lib/common.nix config ]; }) ];
}).config.system.build.toplevel;
2020-05-05 23:28:23 +00:00
systems = [ "porcorosso" "ixvm-fra01" "marukuru" "clouvider-fra01" ];
rebuilder = system:
pkgs.writeShellScriptBin "rebuilder" ''
set -ue
if [[ $EUID -ne 0 ]]; then
exec sudo "$0" "$@"
fi
system="$(nix-build -E '(import <depot> {}).ops.nixos.${system}' --no-out-link)"
nix-env -p /nix/var/nix/profiles/system --set "$system"
"$system/bin/switch-to-configuration" switch
'';
systemCfgs = lib.genAttrs systems
(name: import (./. + "/${name}"));
systemDrvs = mapAttrs systemFor systemCfgs;
in systemDrvs