depot/ops/nixos/default.nix

24 lines
842 B
Nix

{ depot, lib, pkgs, ... }@args:
let
inherit (builtins) foldl' mapAttrs;
systemFor = config:
(depot.third_party.nixos {
configuration = config;
}).system;
systems = [ "porcorosso" "ixvm-fra01" "marukuru" ];
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}") (args // { rebuilder = rebuilder name; }));
mapAttrValues = (f: set: mapAttrs (name: f) set);
systemDrvs = mapAttrValues (systemCfg: systemFor systemCfg) systemCfgs;
in systemDrvs