Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Feb 7, 2023
1 parent a014298 commit a74cbb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
14 changes: 10 additions & 4 deletions nixos/modules/services/misc/nix-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ let

remoteBuilder = import ./remote-builder.nix;

renderRemoteBuilder = machine: (lib.evalModules {
modules = [ ../modules/services/misc/remote-builder.nix machine ] ;
}).config.rendered;

makeNixBuildUser = nr: {
name = "nixbld${toString nr}";
value = {
Expand Down Expand Up @@ -221,7 +225,9 @@ in
};

buildMachines = mkOption {
type = types.listOf remoteBuilder.machineSubmodule;
#
# remoteBuilder.machineSubmodule;
type = types.listOf types.attrs;
default = [ ];
description = lib.mdDoc ''
This option lists the machines to be used if distributed builds are
Expand Down Expand Up @@ -560,9 +566,9 @@ in
# List of machines for distributed Nix builds in the format
# expected by build-remote.pl.
environment.etc."nix/machines" = mkIf (cfg.buildMachines != [ ]) {
text =
concatStringsSep "\n"
cfg.buildMachines.rendered
text = map
# TODO eval here
concatMapStringsSep "\n" renderRemoteBuilder cfg.buildMachines
;
};

Expand Down
19 changes: 12 additions & 7 deletions nixos/modules/services/misc/remote-builder.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }:

with lib;

let
mkRemoteBuilderDesc = machine:

mkRemoteBuilderDesc = config:
concatStringsSep " " ([
"${optionalString (machine.sshUser != null) "${machine.sshUser}@"}${machine.hostName}"
(if machine.system != null then machine.system else if machine.systems != [ ] then concatStringsSep "," machine.systems else "-")
Expand All @@ -12,7 +16,8 @@ let
]
++ optional (isNixAtLeast "2.4pre") (if machine.publicHostKey != null then machine.publicHostKey else "-"));

machineSubmodule = types.submodule {
# TODO rename into module one
machineSubmodule = {
options = {
hostName = mkOption {
type = types.str;
Expand Down Expand Up @@ -118,11 +123,11 @@ let
'';
};
rendered = mkOption {
internal = true; type = types.str;
apply = mkRemoteBuilderDesc;
internal = true;
type = types.str;
apply = mkRemoteBuilderDesc config;
};
};
};
in {
inherit mkRemoteBuilderDesc machineSubmodule;
}
in
machineSubmodule

0 comments on commit a74cbb7

Please sign in to comment.