add homestar

This commit is contained in:
James Walker 2024-02-16 11:50:50 -05:00
parent d8f19c487a
commit c9692d70eb
Signed by: walkah
SSH Key Fingerprint: SHA256:f7Gn4jO4BFHZxWfKTTzEAfWz+cLW51IyGFl9MjDyZGI
5 changed files with 1855 additions and 49 deletions

1796
flake.lock

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,12 @@
inputs.nixpkgs.follows = "nixpkgs";
};
# Fission packages
fission = {
url = "github:fission-codes/nix-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# My stuff
dotfiles = {
url = "github:walkah/dotfiles";
@ -54,7 +60,7 @@
};
};
outputs = { self, nixpkgs, flake-utils, deploy-rs, pre-commit-hooks, workon, ... }@inputs:
outputs = { self, nixpkgs, flake-utils, deploy-rs, pre-commit-hooks, fission, workon, ... }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
@ -71,6 +77,7 @@
// {
hosts = import ./nix/hosts.nix;
overlays.default = nixpkgs.lib.composeManyExtensions [
fission.overlay
workon.overlays.default
];

View File

@ -6,9 +6,10 @@ _:
"homebrew/cask"
"homebrew/cask-fonts"
"homebrew/services"
"fission-codes/fission"
];
brews = [ "code-server" "coreutils" "mosh" ];
brews = [ "code-server" "coreutils" "homestar" "mosh" ];
casks = [
"1password"

View File

@ -19,6 +19,8 @@ in
../../modules/postgresql
../../modules/sops
../../modules/traefik
../../services/homestar.nix
];
boot = {
binfmt.emulatedSystems = [ "aarch64-linux" ];
@ -129,6 +131,15 @@ in
compression = "auto,lzma";
startAt = "daily";
};
homestar = {
enable = true;
settings = {
node.network.rpc = {
port = 9820;
};
};
};
grafana = {
enable = true;
settings = {

85
services/homestar.nix Normal file
View File

@ -0,0 +1,85 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.homestar;
format = pkgs.formats.toml { };
configFile = format.generate "homestar.toml" cfg.settings;
in
{
options.services.homestar = {
enable = mkEnableOption "homestar";
package = mkPackageOption pkgs "homestar" { };
settings = mkOption {
inherit ((pkgs.formats.json { })) type;
default = { };
description = "Homestar settings";
};
user = mkOption {
type = types.str;
default = "homestar";
description = "User under which the Homestar daemon runs";
};
group = mkOption {
type = types.str;
default = "homestar";
description = "Group under which the Homestar daemon runs";
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/homestar";
description = "Homestar data directory";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
networking.firewall = {
allowPing = true;
allowedTCPPorts = [
1337
3030
4000
7001
];
allowedUDPPorts = [
7001
];
};
users.users = mkIf (cfg.user == "homestar") {
homestar = {
inherit (cfg) group;
home = cfg.dataDir;
createHome = true;
isSystemUser = true;
description = "Homestar daemon user";
};
};
users.groups = mkIf (cfg.group == "homestar") {
homestar = { };
};
systemd.services.homestar = {
description = "Homestar daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/homestar start --config ${configFile}";
Restart = "always";
User = cfg.user;
Group = cfg.group;
WorkingDirectory = cfg.dataDir;
};
};
};
}