chia: create service and start syncing
This commit is contained in:
parent
562ed2f53f
commit
1c7d449c6f
@ -56,5 +56,19 @@
|
||||
};
|
||||
in
|
||||
builtins.map (mkFolder) folderNames;
|
||||
|
||||
## Chia
|
||||
age.secrets."chia/farmer.key" = {
|
||||
file = ../../secrets/chia/farmer.key.age;
|
||||
owner = "chia";
|
||||
group = "chia";
|
||||
};
|
||||
custom.chia = {
|
||||
enable = true;
|
||||
path = "/data/chia";
|
||||
keyFile = config.age.secrets."chia/farmer.key".path;
|
||||
targetAddress = "xch1tl87mjd9zpugs7qy2ysc3j4qlftqlyjn037jywq6v2y4kp22g74qahn6sw";
|
||||
plotDirectories = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
81
modules/chia.nix
Normal file
81
modules/chia.nix
Normal file
@ -0,0 +1,81 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.custom.chia;
|
||||
in
|
||||
{
|
||||
options.custom.chia = {
|
||||
enable = lib.mkEnableOption "chia";
|
||||
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/lib/chia";
|
||||
};
|
||||
keyFile = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
targetAddress = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
plotDirectories = lib.mkOption {
|
||||
type = with lib.types; nullOr (listOf str);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [ chia ];
|
||||
|
||||
users.groups.chia = { };
|
||||
users.users.chia = {
|
||||
home = cfg.path;
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
group = "chia";
|
||||
};
|
||||
|
||||
systemd.services.chia = {
|
||||
description = "Chia daemon.";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
preStart = with pkgs; lib.strings.concatStringsSep "\n" ([ "${pkgs.chia}/bin/chia init" ]
|
||||
++ (if cfg.keyFile == null then [ ] else [ "${pkgs.chia}/bin/chia keys add -f ${cfg.keyFile}" ])
|
||||
++ (if cfg.targetAddress == null then [ ] else [
|
||||
''
|
||||
${pkgs.yq-go}/bin/yq e \
|
||||
'.farmer.xch_target_address = "${cfg.targetAddress}" | .pool.xch_target_address = "${cfg.targetAddress}"' \
|
||||
-i ${cfg.path}/.chia/mainnet/config/config.yaml
|
||||
''
|
||||
]) ++ (if cfg.plotDirectories == null then [ ] else [
|
||||
''
|
||||
${pkgs.yq-go}/bin/yq e \
|
||||
'.harvester.plot_directories = [${lib.strings.concatMapStringsSep "," (x: "\"" + x + "\"") cfg.plotDirectories}]' \
|
||||
-i ${cfg.path}/.chia/mainnet/config/config.yaml
|
||||
''
|
||||
]));
|
||||
script = with pkgs; "${pkgs.chia}/bin/chia start farmer";
|
||||
preStop = with pkgs; "${pkgs.chia}/bin/chia stop -d farmer";
|
||||
|
||||
serviceConfig = {
|
||||
Type = "forking";
|
||||
|
||||
User = "chia";
|
||||
Group = "chia";
|
||||
|
||||
WorkingDirectory = cfg.path;
|
||||
|
||||
Restart = "always";
|
||||
RestartSec = 10;
|
||||
TimeoutStopSec = 120;
|
||||
OOMScoreAdjust = 1000;
|
||||
|
||||
Nice = 2;
|
||||
IOSchedulingClass = "best-effort";
|
||||
IOSchedulingPriority = 7;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
{
|
||||
imports = [
|
||||
./backups/default.nix
|
||||
./chia.nix
|
||||
./desktop/awesome/default.nix
|
||||
./locations.nix
|
||||
./resilio.nix
|
||||
|
BIN
secrets/chia/farmer.key.age
Normal file
BIN
secrets/chia/farmer.key.age
Normal file
Binary file not shown.
@ -77,4 +77,7 @@ in
|
||||
"mastodon/social.hillion.co.uk/secret_key_base.age".publicKeys = jake_users ++ [ ts.strangervm.vm ];
|
||||
"mastodon/social.hillion.co.uk/vapid_private_key.age".publicKeys = jake_users ++ [ ts.strangervm.vm ];
|
||||
"mastodon/social.hillion.co.uk/mastodon_at_social.hillion.co.uk.age".publicKeys = jake_users ++ [ ts.strangervm.vm ];
|
||||
|
||||
# Chia Secrets
|
||||
"chia/farmer.key.age".publicKeys = jake_users ++ [ ts.storage.tywin ];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user