Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion checks/run-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ writeShellApplication {
eval set -- "$args"

system="${stdenv.system}"
nix_args="''${NIX_ARGS:=}"
driver_args=()

while [ $# -gt 0 ]; do
Expand All @@ -64,6 +65,6 @@ writeShellApplication {
shift

# build/run the test driver, passing any remaining arguments
nix run ".#checks.$system.testing-$name.driver" -- "''${driver_args[@]}"
nix run ".#checks.$system.testing-$name.driver" "''${nix_args}" -- "''${driver_args[@]}"
'';
}
2 changes: 1 addition & 1 deletion modules/cardano-node/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{...}: {
{
imports = [
./instance.nix
./relay.nix
Expand Down
21 changes: 12 additions & 9 deletions modules/cardano-node/instance.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@
config,
lib,
pkgs,
inputs,
system,
...
}: let
cardanoTypes = import ./types.nix {inherit lib;};
inherit (builtins) length attrNames;
inherit (lib) types mkOption mapAttrs' nameValuePair flip getBin toGNUCommandLineShell mkIf optional;
inherit (lib) types mkOption mapAttrs' nameValuePair flip getBin toGNUCommandLineShell mkIf;
inherit (types) submodule;
inherit (cardanoTypes) topologyType;
cfg = config.cardanoNix.cardano-node;

# FIXME: move all types to `types.nix`?
# Options shared between "cardanoNix.cardano-node.defaults" "and cardanoNix.cardano-node.instance.$name"
processOptions'.options = {
package = mkOption {
type = types.package;
package = pkgs.cardano-node; # FIXME: would we want to
};
package =
lib.mkPackageOption pkgs
"cardano-node" {
default = inputs.cardano-node.packages.${system}.cardano-node;
};

options = mkOption {
type = types.attrsOf types.str;
Expand Down Expand Up @@ -58,12 +61,12 @@
topologyFile = mkOption {
type = types.either types.str types.path;
internal = true;
literalExample = ''
defaultText = lib.literalExpression ''
# default implementation (for reference purpose)
topologyFile = mkTopologyFile instance.topology;
'';
};
topology = {
topology = mkOption {
type = topologyType;
};
};
Expand Down Expand Up @@ -97,11 +100,11 @@ in {
cardano-node = {};
}
// flip mapAttrs' cfg.instances (name: instance:
nameValuePair "cardano-node-${instance.name}" {
nameValuePair "cardano-node-${name}" {
after = ["network-online.target"];
wants = ["network-online.target"];
wantedBy = ["multi-user.target"];
required = optional instance.useSnapshot "cardano-node-${instance.name}-snapshot.service"; # One shot, which should depends on downloader
# required = optional instance.useSnapshot "cardano-node-${instance.name}-snapshot.service"; # One shot, which should depends on downloader
script = ''
# Show commandline before execution
set -x
Expand Down
23 changes: 12 additions & 11 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
inputs,
...
}: {
flake.nixosModules = let
# Load nixos module, enhancing it's arguments with `self`, `self'`, `inputs` and `system`
getModule = module: {pkgs, ...}: {
imports = [module];
flake.nixosModules = {
inject-args = {
pkgs,
lib,
...
}: {
_module.args = let
inherit (pkgs.stdenv.hostPlatform) system;
in {
inherit self system inputs;
self' = config.perSystem system;
self' = lib.mkForce (config.perSystem system);
};
};
in {
globals = getModule ./globals;
cardano-block-producer = getModule ./cardano-node/producer.nix;
cardano-node-instance = getModule ./cardano-node/instance.nix;
cardano-cli = getModule ./cardano-cli;
packages = getModule ./packages.nix;
globals = ./globals;
cardano-block-producer = ./cardano-node/producer.nix;
cardano-node-instance = ./cardano-node/instance.nix;
cardano-cli = ./cardano-cli;
packages = ./packages.nix;
# the default module imports all modules
default = {
imports = with builtins; attrValues (removeAttrs config.flake.nixosModules ["default"]);
Expand Down
19 changes: 11 additions & 8 deletions tests/block-producer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
writableStore = false;
};
environment.systemPackages = [config.services.cardano-node.cardanoNodePackages.cardano-cli];
cardanoNix.cardano-node.producer = {
enable = true;
relayAddrs = [
{
address = "x.x.x.x";
port = 3000;
}
];
cardanoNix.cardano-node = {
defaults = {};
producer = {
enable = true;
relayAddrs = [
{
address = "x.x.x.x";
port = 3000;
}
];
};
};
};
};
Expand Down