Skip to content

Commit

Permalink
define nixos module
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Oct 23, 2023
1 parent 6bdc22c commit fb874e7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
mev-rs = pkgs.callPackage ./nix/mev-rs.nix { inherit pkgs; crane = craneLib; };
in
{
devShells.default = import ./shell.nix { inherit pkgs; };
packages = { inherit mev-rs; };
devShells.default = import ./shell.nix { inherit pkgs; };
nixosModules.default = import ./nix/module.nix {
nixpkgs.overlays = self.overlays;
};
});
}
46 changes: 46 additions & 0 deletions nix/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.mev-rs;

mev-rs = pkgs.mev-rs;

name = "mev-${cfg.enable}-rs";

cmd = ''
${mev-rs}/bin/mev \
${cfg.enable} \
${cfg.config-file}
'';
in
{
options.services.mev-rs = {
enable = lib.mkOption {
type = lib.types.enum [ "boost" "build" ];
description = "which subcommand of `mev-rs` to run";
};
config-file = lib.mkOption {
type = lib.types.str;
description = ''
path to a config file suitable for the `mev-rs` toolkit
'';
};
};

config = {
environment.systemPackages = [
mev-rs
];

systemd.services."${name}" = {
description = name;
wantedBy = [ "multi-user.target" ];
after = [ "vc.service" ];
serviceConfig = {
ExecStart = cmd;
Restart = "on-failure";
RestartSec = "10s";
SyslogIdentifier = name;
};
};
};
}

0 comments on commit fb874e7

Please sign in to comment.