flake

Francesco Saccone's Nix flake.
git clone https://git.francescosaccone.com/flake
Log | Files | Refs | README | LICENSE

default.nix (1247B)


      1 {
      2   lib,
      3   options,
      4   config,
      5   pkgs,
      6   ...
      7 }:
      8 {
      9   options.modules.monero = {
     10     enable = lib.mkOption {
     11       description = "Whether to enable Monero.";
     12       default = false;
     13       type = lib.types.bool;
     14     };
     15     mining = {
     16       enable = lib.mkOption {
     17         description = "Whether to mine monero.";
     18         default = false;
     19         type = lib.types.bool;
     20       };
     21       address = lib.mkOption {
     22         description = "The address where rewards are sent.";
     23         type = lib.types.uniq lib.types.str;
     24       };
     25     };
     26   };
     27 
     28   config = lib.mkIf config.modules.monero.enable {
     29     users = {
     30       users = {
     31         monero = {
     32           hashedPassword = "!";
     33           isSystemUser = true;
     34           group = "monero";
     35           createHome = true;
     36           home = "/var/lib/monero";
     37         };
     38       };
     39       groups = {
     40         monero = { };
     41       };
     42     };
     43 
     44     environment.systemPackages = [ pkgs.monero-cli ];
     45 
     46     services.monero = {
     47       enable = true;
     48       dataDir = "/var/lib/monero";
     49       rpc = {
     50         user = "monero";
     51         port = 18081;
     52       };
     53       mining = {
     54         inherit (config.modules.monero.mining) enable address;
     55         threads = 0;
     56       };
     57     };
     58 
     59     networking.firewall.allowedTCPPorts = [ 18081 ];
     60   };
     61 }