Give a proper type to the sourceFileset option
Some checks failed
/ check-pre-commit (pull_request) Successful in 11s
/ check-peertube (pull_request) Has been cancelled
/ check-panel (pull_request) Has been cancelled
/ check-deployment-basic (pull_request) Has been cancelled
/ check-deployment-cli (pull_request) Has been cancelled
/ check-deployment-panel (pull_request) Has been cancelled
/ check-data-model (pull_request) Has been cancelled

This commit is contained in:
Nicolas Jeannerod 2025-07-09 12:02:53 +02:00
parent 59ded28863
commit 128ddc60b3
Signed by: Niols
GPG key ID: 35DB9EC8886E1CB8
3 changed files with 32 additions and 26 deletions

View file

@ -16,7 +16,7 @@ in
name = "deployment-cli"; name = "deployment-cli";
extraSourceFileset = lib.fileset.unions [ sourceFileset = lib.fileset.unions [
# REVIEW: I would like to be able to grab all of `/deployment` minus # REVIEW: I would like to be able to grab all of `/deployment` minus
# `/deployment/check`, but I can't because there is a bunch of other files # `/deployment/check`, but I can't because there is a bunch of other files
# in `/deployment`. Maybe we can think of a reorg making things more robust # in `/deployment`. Maybe we can think of a reorg making things more robust

View file

@ -13,6 +13,7 @@ let
toJSON toJSON
; ;
inherit (lib) inherit (lib)
types
fileset fileset
mkOption mkOption
genAttrs genAttrs
@ -27,23 +28,6 @@ let
forConcat = xs: f: concatStringsSep "\n" (map f xs); forConcat = xs: f: concatStringsSep "\n" (map f xs);
## A subset of the repository that is necessary for this test. It will be
## copied inside the test. The smaller this set, the faster our CI, because we
## won't need to re-run when things change outside of it.
src = fileset.toSource {
root = ../../..;
fileset = fileset.unions [
# NOTE: not the flake itself; it will be overridden.
../../../mkFlake.nix
../../../flake.lock
../../../npins
./.
config.pathToCwd
config.extraSourceFileset
];
};
## We will need to override some inputs by the empty flake, so we make one. ## We will need to override some inputs by the empty flake, so we make one.
emptyFlake = runCommandNoCC "empty-flake" { } '' emptyFlake = runCommandNoCC "empty-flake" { } ''
mkdir $out mkdir $out
@ -63,21 +47,35 @@ in
## `mkOrder` to put this module's string before something else. ## `mkOrder` to put this module's string before something else.
extraTestScript = mkOption { }; extraTestScript = mkOption { };
extraSourceFileset = mkOption { sourceFileset = mkOption {
## FIXME: type? what is the type of a fileset? cf ## REVIEW: Upstream to nixpkgs?
## https://moduscreate.slack.com/archives/C0T4L4QPR/p1752048299160429 type = types.mkOptionType {
name = "fileset";
description = "fileset";
descriptionClass = "noun";
check = (x: (builtins.tryEval (fileset.unions [ x ])).success);
merge = (_: defs: fileset.unions (map (x: x.value) defs));
};
description = '' description = ''
A fileset that will be copied to the deployer node in the current A fileset that will be copied to the deployer node in the current
working directory. This should contain all the files that are working directory. This should contain all the files that are
necessary to run that particular test, such as the NixOS necessary to run that particular test, such as the NixOS
modules necessary to evaluate a deployment. The common architecture modules necessary to evaluate a deployment.
of the tests is already included.
''; '';
default = (fileset.unions [ ]); # the empty file set
}; };
}; };
config = { config = {
sourceFileset = fileset.unions [
# NOTE: not the flake itself; it will be overridden.
../../../mkFlake.nix
../../../flake.lock
../../../npins
./.
config.pathToCwd
];
acmeNodeIP = config.nodes.acme.networking.primaryIPAddress; acmeNodeIP = config.nodes.acme.networking.primaryIPAddress;
nodes = nodes =
@ -125,8 +123,16 @@ in
${n}.wait_for_unit("multi-user.target") ${n}.wait_for_unit("multi-user.target")
'')} '')}
## A subset of the repository that is necessary for this test. It will be
## copied inside the test. The smaller this set, the faster our CI, because we
## won't need to re-run when things change outside of it.
with subtest("Unpacking"): with subtest("Unpacking"):
deployer.succeed("cp -r --no-preserve=mode ${src}/* .") deployer.succeed("cp -r --no-preserve=mode ${
fileset.toSource {
root = ../../..;
fileset = config.sourceFileset;
}
}/* .")
with subtest("Configure the network"): with subtest("Configure the network"):
${forConcat config.targetMachines ( ${forConcat config.targetMachines (

View file

@ -125,7 +125,7 @@ in
name = "deployment-panel"; name = "deployment-panel";
extraSourceFileset = lib.fileset.unions [ sourceFileset = lib.fileset.unions [
# REVIEW: I would like to be able to grab all of `/deployment` minus # REVIEW: I would like to be able to grab all of `/deployment` minus
# `/deployment/check`, but I can't because there is a bunch of other files # `/deployment/check`, but I can't because there is a bunch of other files
# in `/deployment`. Maybe we can think of a reorg making things more robust # in `/deployment`. Maybe we can think of a reorg making things more robust