Skip to content

Commit

Permalink
Add failing nixoModule
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Oct 17, 2024
1 parent f9e1a0a commit a25b5fd
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nix/nixos-configs.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ repoRoot, inputs }:
{
nixosConfigurations = {
hydra-explorer = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
Expand All @@ -18,6 +17,7 @@
imports = [
"${inputs.nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
inputs.cardano-node.nixosModules.cardano-node
(import (inputs.self + "/nix/nixosModule.nix") { inherit inputs; })
];

networking = {
Expand All @@ -36,11 +36,12 @@
port = 3002;
};

services.hydra-explorer.enable = true;

services.openssh.enable = true;

system.stateVersion = "24.05";
}
];
};
};
}
}
75 changes: 75 additions & 0 deletions nix/nixosModule.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{ inputs, ... }:
{ config, pkgs, lib, ... }:

let cfg = config.services.hydra-explorer;

in

with lib;

{
options = {
services.hydra-explorer = {
enable = mkOption {
default = false;
type = types.bool;
description = ''
Enable hydra-explorer
'';
};
package = mkOption {
type = types.package;
default = inputs.self.packages.x86_64-linux.hydra-explorer;
description = ''
The hydra-explorer package to use.
'';
};
socketPath = mkOption {
type = types.path;
default = config.services.cardano-node.socketPath;
description = ''
The node socket
'';
};
port = mkOption {
type = types.port;
default = 9081;
description = ''
The port to run on
'';
};
user = mkOption {
type = types.str;
default = config.services.cardano-node.user;
description = ''
The user to run the systemd service
'';
};
group = mkOption {
type = types.str;
default = config.services.cardano-node.group;
description = ''
The group to run the systemd service.
'';
};
};
};

config = mkIf cfg.enable {
systemd.services.hydra-explorer = {
after = [ "cardano-node.service" ];
enable = true;
description = "Hydra Explorer";
unitConfig = {
Type = "simple";
};
serviceConfig = {
ExecStart = "${cfg.package}/bin/hydra-explorer --node-socket ${cfg.socketPath} --port ${toString cfg.port}";
Restart = "on-failure";
User = cfg.user;
Group = cfg.group;
};
wantedBy = [ "multi-user.target" ];
};
};
}

0 comments on commit a25b5fd

Please sign in to comment.