43 lines
1 KiB
Nix
43 lines
1 KiB
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
targetHosts = [ "helix-texta" "elysia-clarki" ];
|
|
|
|
remote = "https://git.sr.ht/~megamanmalte/nixos";
|
|
|
|
buildForHost = host:
|
|
with pkgs; ''
|
|
nixos-rebuild build --flake .#${host} || exit 1
|
|
'';
|
|
|
|
build = with pkgs;
|
|
writeScriptBin "build" ''
|
|
#!${stdenv.shell}
|
|
|
|
rm -rf nixos
|
|
git clone ${remote} || exit 2
|
|
cd nixos
|
|
${builtins.concatStringsSep "\n" (map buildForHost targetHosts)}
|
|
rm result
|
|
'';
|
|
|
|
in {
|
|
systemd.services.local-build-service = {
|
|
unitConfig = {
|
|
Description = ''
|
|
Regularly pull and build various configuration to populate the local store
|
|
'';
|
|
After = [ "network.target" ];
|
|
};
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = [ "${build}/bin/build" ];
|
|
RuntimeDirectory = "local-build-service";
|
|
CacheDirectory = "local-build-service";
|
|
CacheDirectoryMode = "0777";
|
|
Environment = with pkgs;
|
|
"PATH=${git}/bin:${coreutils}/bin:${nixos-rebuild}/bin";
|
|
};
|
|
};
|
|
}
|