chia: migrate to docker #191
17
flake.lock
17
flake.lock
@ -137,22 +137,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs-chia": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1685960109,
|
|
||||||
"narHash": "sha256-uTuKV5ua048dIGdaC+lexSUK/9A/X4la4BEJXODZm9U=",
|
|
||||||
"owner": "lourkeur",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "e2b683787475d344892bddea9ab413dc611b894e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "lourkeur",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "e2b683787475d344892bddea9ab413dc611b894e",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-unstable": {
|
"nixpkgs-unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705316053,
|
"lastModified": 1705316053,
|
||||||
@ -176,7 +160,6 @@
|
|||||||
"home-manager": "home-manager_2",
|
"home-manager": "home-manager_2",
|
||||||
"impermanence": "impermanence",
|
"impermanence": "impermanence",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-chia": "nixpkgs-chia",
|
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable"
|
"nixpkgs-unstable": "nixpkgs-unstable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
||||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-chia.url = "github:lourkeur/nixpkgs?rev=e2b683787475d344892bddea9ab413dc611b894e";
|
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
@ -17,7 +16,7 @@
|
|||||||
|
|
||||||
description = "Hillion Nix flake";
|
description = "Hillion Nix flake";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-chia, flake-utils, agenix, home-manager, impermanence, ... }@inputs: {
|
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, agenix, home-manager, impermanence, ... }@inputs: {
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
let
|
let
|
||||||
fqdns = builtins.attrNames (builtins.readDir ./hosts);
|
fqdns = builtins.attrNames (builtins.readDir ./hosts);
|
||||||
|
@ -183,7 +183,6 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
keyFile = config.age.secrets."chia/farmer.key".path;
|
keyFile = config.age.secrets."chia/farmer.key".path;
|
||||||
targetAddress = "xch1tl87mjd9zpugs7qy2ysc3j4qlftqlyjn037jywq6v2y4kp22g74qahn6sw";
|
|
||||||
plotDirectories = builtins.genList (i: "/mnt/d${toString i}/plots/contract-k32") 7;
|
plotDirectories = builtins.genList (i: "/mnt/d${toString i}/plots/contract-k32") 7;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,43 +26,37 @@
|
|||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
# fileSystems."/mnt/d0" =
|
fileSystems."/mnt/d0" =
|
||||||
# {
|
|
||||||
# device = "/dev/disk/by-uuid/b424c997-4be6-42f3-965a-f5b3573a9cb3";
|
|
||||||
# fsType = "btrfs";
|
|
||||||
# };
|
|
||||||
|
|
||||||
fileSystems."/mnt/d1" =
|
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/9136434d-d883-4118-bd01-903f720e5ce1";
|
device = "/dev/disk/by-uuid/9136434d-d883-4118-bd01-903f720e5ce1";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/mnt/d2" =
|
fileSystems."/mnt/d1" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/a55d164e-b48e-4a4e-b073-d0768662d3d0";
|
device = "/dev/disk/by-uuid/a55d164e-b48e-4a4e-b073-d0768662d3d0";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/mnt/d3" =
|
fileSystems."/mnt/d2" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/82b82c66-e6e6-4b76-a5ef-8adea33dbe18";
|
device = "/dev/disk/by-uuid/82b82c66-e6e6-4b76-a5ef-8adea33dbe18";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/mnt/d4" =
|
fileSystems."/mnt/d3" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/6566588a-9399-4b35-a18c-060de0ee8431";
|
device = "/dev/disk/by-uuid/6566588a-9399-4b35-a18c-060de0ee8431";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/mnt/d5" =
|
fileSystems."/mnt/d4" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/850ce5db-4245-428a-a66d-2647abf62a4c";
|
device = "/dev/disk/by-uuid/850ce5db-4245-428a-a66d-2647abf62a4c";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/mnt/d6" =
|
fileSystems."/mnt/d5" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/78bc5c57-d554-43c5-9a84-14e3dc52b1b3";
|
device = "/dev/disk/by-uuid/78bc5c57-d554-43c5-9a84-14e3dc52b1b3";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
{ config, pkgs, lib, nixpkgs-chia, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.custom.chia;
|
cfg = config.custom.chia;
|
||||||
chia = nixpkgs-chia.legacyPackages.x86_64-linux.chia;
|
|
||||||
|
|
||||||
ctl = pkgs.writeScriptBin "chiactl" ''
|
ctl = pkgs.writeScriptBin "chiactl" ''
|
||||||
#! ${pkgs.runtimeShell}
|
#! ${pkgs.runtimeShell}
|
||||||
sudo=exec
|
set -e
|
||||||
if [[ "$USER" != chia ]]; then
|
sudo ${pkgs.podman}/bin/podman exec chia chia "$@"
|
||||||
sudo='exec /run/wrappers/bin/sudo -u chia'
|
|
||||||
fi
|
|
||||||
|
|
||||||
$sudo ${chia}/bin/chia "$@"
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -26,14 +21,6 @@ in
|
|||||||
type = with lib.types; nullOr str;
|
type = with lib.types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
keyLabel = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "default";
|
|
||||||
};
|
|
||||||
targetAddress = lib.mkOption {
|
|
||||||
type = with lib.types; nullOr str;
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
plotDirectories = lib.mkOption {
|
plotDirectories = lib.mkOption {
|
||||||
type = with lib.types; nullOr (listOf str);
|
type = with lib.types; nullOr (listOf str);
|
||||||
default = null;
|
default = null;
|
||||||
@ -47,52 +34,31 @@ in
|
|||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
environment.systemPackages = [ ctl ];
|
environment.systemPackages = [ ctl ];
|
||||||
|
|
||||||
users.groups.chia = { };
|
users.groups.chia = {
|
||||||
|
gid = config.ids.gids.chia;
|
||||||
|
};
|
||||||
users.users.chia = {
|
users.users.chia = {
|
||||||
home = cfg.path;
|
home = cfg.path;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = "chia";
|
group = "chia";
|
||||||
|
uid = config.ids.uids.chia;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.chia = {
|
virtualisation.oci-containers.containers.chia = {
|
||||||
description = "Chia daemon.";
|
image = "ghcr.io/chia-network/chia:2.1.4";
|
||||||
wantedBy = [ "multi-user.target" ];
|
ports = [ "8444" ];
|
||||||
|
extraOptions = [
|
||||||
preStart = lib.strings.concatStringsSep "\n" ([ "${chia}/bin/chia init" ]
|
"--uidmap=0:${toString config.users.users.chia.uid}:1"
|
||||||
++ (if cfg.keyFile == null then [ ] else [ "${chia}/bin/chia keys add -f ${cfg.keyFile} -l '${cfg.keyLabel}'" ])
|
"--gidmap=0:${toString config.users.groups.chia.gid}:1"
|
||||||
++ (if cfg.targetAddress == null then [ ] else [
|
];
|
||||||
''
|
volumes = [
|
||||||
${pkgs.yq-go}/bin/yq e \
|
"${cfg.keyFile}:/run/keyfile"
|
||||||
'.farmer.xch_target_address = "${cfg.targetAddress}" | .pool.xch_target_address = "${cfg.targetAddress}"' \
|
"${cfg.path}/.chia:/root/.chia"
|
||||||
-i ${cfg.path}/.chia/mainnet/config/config.yaml
|
] ++ lib.lists.imap0 (i: v: "${v}:/plots${toString i}") cfg.plotDirectories;
|
||||||
''
|
environment = {
|
||||||
]) ++ (if cfg.plotDirectories == null then [ ] else [
|
keys = "/run/keyfile";
|
||||||
''
|
plots_dir = lib.strings.concatImapStringsSep ":" (i: v: "/plots${toString i}") cfg.plotDirectories;
|
||||||
${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 = "${chia}/bin/chia start farmer";
|
|
||||||
preStop = "${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;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
ids.uids = {
|
ids.uids = {
|
||||||
## Defined System Users (see https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/ids.nix)
|
## Defined System Users (see https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/ids.nix)
|
||||||
unifi = 183;
|
unifi = 183;
|
||||||
|
chia = 185;
|
||||||
|
|
||||||
## Consistent People
|
## Consistent People
|
||||||
jake = 1000;
|
jake = 1000;
|
||||||
@ -13,6 +14,7 @@
|
|||||||
ids.gids = {
|
ids.gids = {
|
||||||
## Defined System Groups (see https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/ids.nix)
|
## Defined System Groups (see https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/ids.nix)
|
||||||
unifi = 183;
|
unifi = 183;
|
||||||
|
chia = 185;
|
||||||
|
|
||||||
## Consistent Groups
|
## Consistent Groups
|
||||||
mediaaccess = 1200;
|
mediaaccess = 1200;
|
||||||
|
Loading…
Reference in New Issue
Block a user