refactor: separated rustypaste client and server modules and moved client to home-manager
This commit is contained in:
parent
83e97c1c8d
commit
11a8a5514f
7 changed files with 47 additions and 35 deletions
|
|
@ -43,6 +43,7 @@ in {
|
||||||
|
|
||||||
tools = {
|
tools = {
|
||||||
presenterm = enabled;
|
presenterm = enabled;
|
||||||
|
rustypaste = enabled;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ in {
|
||||||
|
|
||||||
tools = {
|
tools = {
|
||||||
presenterm = enabled;
|
presenterm = enabled;
|
||||||
|
rustypaste = enabled;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,6 @@ in {
|
||||||
".config/sops/age/keys.txt".source =
|
".config/sops/age/keys.txt".source =
|
||||||
"${crypt}/age/${host}/keys.txt"
|
"${crypt}/age/${host}/keys.txt"
|
||||||
|> config.lib.file.mkOutOfStoreSymlink;
|
|> config.lib.file.mkOutOfStoreSymlink;
|
||||||
".config/rustypaste/config.toml".source =
|
|
||||||
"${crypt}/rustypaste/client.toml"
|
|
||||||
|> config.lib.file.mkOutOfStoreSymlink;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
activation.ensureUserDirs = {
|
activation.ensureUserDirs = {
|
||||||
|
|
|
||||||
32
modules/home/cli/tools/rustypaste/default.nix
Normal file
32
modules/home/cli/tools/rustypaste/default.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
namespace,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkIf mkEnableOption;
|
||||||
|
inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace;
|
||||||
|
base = "${namespace}.cli.tools.rustypaste";
|
||||||
|
cfg = getAttrByNamespace config base;
|
||||||
|
in {
|
||||||
|
options = mkOptionsWithNamespace base {
|
||||||
|
enable = mkEnableOption "rustypaste";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home = {
|
||||||
|
packages = with pkgs; [
|
||||||
|
rustypaste-cli
|
||||||
|
];
|
||||||
|
|
||||||
|
file = let
|
||||||
|
crypt = "${config.snowfallorg.user.home.directory}/dotfiles/secrets/crypt";
|
||||||
|
in {
|
||||||
|
".config/rustypaste/config.toml".source =
|
||||||
|
"${crypt}/rustypaste/client.toml"
|
||||||
|
|> config.lib.file.mkOutOfStoreSymlink;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -6,30 +6,19 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf mkEnableOption;
|
inherit (lib) mkIf;
|
||||||
inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace hostHasService resolveServicePort;
|
inherit (lib.${namespace}) getAttrByNamespace hostHasService resolveServicePort;
|
||||||
inherit (config.users) users groups;
|
inherit (config.users) users groups;
|
||||||
inherit (config.sops) secrets;
|
inherit (config.sops) secrets;
|
||||||
inherit (config.networking) hostName;
|
inherit (config.networking) hostName;
|
||||||
|
|
||||||
base = "${namespace}.services.apps.rustypaste";
|
|
||||||
cfg = getAttrByNamespace config base;
|
|
||||||
|
|
||||||
networkCfg = getAttrByNamespace config "${namespace}.services.networking";
|
networkCfg = getAttrByNamespace config "${namespace}.services.networking";
|
||||||
|
|
||||||
isEnabled = hostHasService networkCfg.network-services hostName "paste";
|
isEnabled = hostHasService networkCfg.network-services hostName "paste";
|
||||||
port = resolveServicePort networkCfg.network-services "paste" 5100;
|
port = resolveServicePort networkCfg.network-services "paste" 5100;
|
||||||
in {
|
in {
|
||||||
options = mkOptionsWithNamespace base {
|
config = mkIf isEnabled {
|
||||||
client = {
|
systemd.services.rustypaste = {
|
||||||
enable = mkEnableOption "rustypaste client";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
environment.systemPackages = mkIf cfg.client.enable (with pkgs; [rustypaste-cli]);
|
|
||||||
|
|
||||||
systemd.services.rustypaste = mkIf isEnabled {
|
|
||||||
description = "rustypaste";
|
description = "rustypaste";
|
||||||
|
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
|
|
@ -53,15 +42,15 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
users = {
|
users = {
|
||||||
users.rustypaste = mkIf isEnabled {
|
users.rustypaste = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = "rustypaste";
|
group = "rustypaste";
|
||||||
};
|
};
|
||||||
|
|
||||||
groups.rustypaste = mkIf (isEnabled || cfg.client.enable) {};
|
groups.rustypaste = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."rustypaste/rustypaste.toml" = mkIf isEnabled {
|
environment.etc."rustypaste/rustypaste.toml" = {
|
||||||
source = let
|
source = let
|
||||||
crypt = "${inputs.self}/secrets/crypt/";
|
crypt = "${inputs.self}/secrets/crypt/";
|
||||||
in "${crypt}/rustypaste/server.toml";
|
in "${crypt}/rustypaste/server.toml";
|
||||||
|
|
@ -69,25 +58,25 @@ in {
|
||||||
mode = "0755";
|
mode = "0755";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.tmpfiles.rules = mkIf isEnabled [
|
systemd.tmpfiles.rules = [
|
||||||
"d /var/lib/rustypaste 2750 ${users.rustypaste.name} ${users.rustypaste.group} -"
|
"d /var/lib/rustypaste 2750 ${users.rustypaste.name} ${users.rustypaste.group} -"
|
||||||
];
|
];
|
||||||
|
|
||||||
sops.secrets = mkIf (isEnabled || cfg.client.enable) {
|
sops.secrets = {
|
||||||
"rustypaste/auth" = {
|
"rustypaste/auth" = {
|
||||||
owner = mkIf isEnabled users.rustypaste.name;
|
owner = users.rustypaste.name;
|
||||||
group = groups.rustypaste.name;
|
group = groups.rustypaste.name;
|
||||||
mode = "0440";
|
mode = "0440";
|
||||||
};
|
};
|
||||||
"rustypaste/delete" = {
|
"rustypaste/delete" = {
|
||||||
owner = mkIf isEnabled users.rustypaste.name;
|
owner = users.rustypaste.name;
|
||||||
group = groups.rustypaste.name;
|
group = groups.rustypaste.name;
|
||||||
mode = "0440";
|
mode = "0440";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = mkIf isEnabled [port];
|
networking.firewall.allowedTCPPorts = [port];
|
||||||
|
|
||||||
${namespace}.services.storage.impermanence.folders = mkIf isEnabled ["/var/lib/rustypaste"];
|
${namespace}.services.storage.impermanence.folders = ["/var/lib/rustypaste"];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
apps = {
|
|
||||||
rustypaste.client = enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
ci = {
|
ci = {
|
||||||
gitea-runner = {
|
gitea-runner = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
apps = {
|
|
||||||
rustypaste.client = enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
storage = {
|
storage = {
|
||||||
samba.mounts = {
|
samba.mounts = {
|
||||||
shared = {
|
shared = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue