Add 'my packages'
This commit is contained in:
parent
fca664b887
commit
f96ed50dfa
8 changed files with 209 additions and 101 deletions
17
flake.nix
17
flake.nix
|
@ -134,6 +134,7 @@
|
|||
inherit inputs;
|
||||
# Import overlays for building nixosconfig with them.
|
||||
overlays = import ./nixos/overlays {inherit inputs;};
|
||||
|
||||
# generate a base nixos configuration with the specified overlays, hardware modules, and any AerModules applied
|
||||
mkNixosConfig = {
|
||||
hostname,
|
||||
|
@ -162,12 +163,7 @@
|
|||
}
|
||||
],
|
||||
profileModules ? [],
|
||||
}:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system lib;
|
||||
modules = baseModules ++ hardwareModules ++ profileModules;
|
||||
specialArgs = {inherit self inputs nixpkgs;};
|
||||
# Add our overlays
|
||||
}: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = builtins.attrValues overlays;
|
||||
|
@ -176,6 +172,15 @@
|
|||
allowUnfreePredicate = _: true;
|
||||
};
|
||||
};
|
||||
in
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system lib;
|
||||
modules = baseModules ++ hardwareModules ++ profileModules;
|
||||
specialArgs = {
|
||||
inherit self inputs nixpkgs;
|
||||
myPkgs = lib.myLib.mkMyPkgs pkgs;
|
||||
};
|
||||
inherit pkgs;
|
||||
};
|
||||
in {
|
||||
"shadowfax" = mkNixosConfig {
|
||||
|
|
10
nixos/hosts/shadowfax/config/borgmatic/default.nix
Normal file
10
nixos/hosts/shadowfax/config/borgmatic/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
dir = ./.;
|
||||
files = lib.filterAttrs (name: type:
|
||||
type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name
|
||||
) (builtins.readDir dir);
|
||||
imports = map (name: "${dir}/${name}") (builtins.attrNames files);
|
||||
in {
|
||||
imports = imports;
|
||||
}
|
34
nixos/hosts/shadowfax/config/borgmatic/plex.nix
Normal file
34
nixos/hosts/shadowfax/config/borgmatic/plex.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
services.borgmatic = {
|
||||
enable = true;
|
||||
configurations.plex = {
|
||||
source_directories = [
|
||||
"/mnt/restic_nightly_backup/nahar/containers/volumes/plex/Library/"
|
||||
];
|
||||
|
||||
repositories = [
|
||||
{
|
||||
label = "local";
|
||||
path = "/eru/borg/plex";
|
||||
}
|
||||
];
|
||||
|
||||
storage.encryption_passcommand = ''${pkgs.coreutils-full}/bin/cat ${config.sops.secrets."borgmatic/encryption_passphrase".path}'';
|
||||
|
||||
# Retention settings
|
||||
retention.keep_daily = 7;
|
||||
retention.keep_weekly = 4;
|
||||
retention.keep_monthly = 6;
|
||||
zfs = {
|
||||
zfs_command = "${pkgs.zfs}/bin/zfs";
|
||||
mount_command = "${pkgs.util-linux}/bin/mount";
|
||||
umount_command = "${pkgs.util-linux}/bin/umount";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{ ... }:
|
||||
{
|
||||
{...}: {
|
||||
secrets = {
|
||||
# Minio
|
||||
"minio" = {
|
||||
|
@ -206,5 +205,10 @@
|
|||
mode = "400";
|
||||
restartUnits = ["unpackerr.service"];
|
||||
};
|
||||
"borgmatic/encryption_passphrase" = {
|
||||
sopsFile = ../secrets.sops.yaml;
|
||||
mode = "400";
|
||||
restartUnits = ["borgmatic.service"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ in {
|
|||
(import ../../profiles/disko-nixos.nix {
|
||||
disks = ["/dev/sda|/dev/disk/by-id/nvme-Samsung_SSD_970_EVO_Plus_500GB_S58SNM0W406409E"];
|
||||
})
|
||||
./config/borgmatic
|
||||
inputs.nix-minecraft.nixosModules.minecraft-servers
|
||||
];
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ postgres:
|
|||
port: ENC[AES256_GCM,data:Z0fHNA==,iv:otbEsYxhJ6/YR+A5oRx3Dwrqk6T6BL9OGka5yu1H+HA=,tag:T+KW8DaRJ8NN7k1mIMn6QA==,type:int]
|
||||
pushover:
|
||||
userKey: ENC[AES256_GCM,data:RYn9OCGaEgu/41kMolmqjYtr8FRmyEOvNStk+7Uz1A==,iv:L4pJJxGPhrmGSJdRDIP/OONibHvIP8KUdXwED29kTJ8=,tag:6TxYaUA6QA1NroBXhQHRlQ==,type:str]
|
||||
borgmatic:
|
||||
encryption_passphrase: ENC[AES256_GCM,data:Rzmb+tNo0IG6Ub3Z5pB+XahW7gtZOPs5Cjvrzw4m47q0D7bErACTzQx7VdrSJcm8+g==,iv:cQsm3MfrY4KCTvByUcQe0n51UVm/kNtTUGORx0r+wjg=,tag:j/n/4TI193ec3/mOJeB1Lg==,type:str]
|
||||
arr:
|
||||
prowlarr:
|
||||
apiKey: ENC[AES256_GCM,data:qxm2yp8ReuMgQ0155mKBAWickKusOaa/FeoIopj9l1Z3,iv:pAeDxK6CGap4fKU5xQ5hZR9It6/1uo27dKZBi5Bl3rc=,tag:HZl914AfFU4D5J7cDS3I1g==,type:str]
|
||||
|
@ -133,8 +135,8 @@ sops:
|
|||
aVlOSHhFb2I5UnYwVytyQzlWTXBDYUUKdQKilmfJ1F7UYKtQV9zV95FcRIK17p4M
|
||||
vGvu/pGJ32tH8xI7cNs9I5Hmg9c5wOam21W1FDk+VlJ/ClXqQzS0MA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2025-02-10T19:15:54Z"
|
||||
mac: ENC[AES256_GCM,data:KyP1lzKD/iV6SgHbsEYvVRwgrFy/PqHGMVEjeTAcLFCFrIyn9/Gd5ravTOj+37phVARnHI3h2vetqzOBO7/tE4jz0nsEGawOfVMOTKR1Y7+35TKJaC4FTO3/hfczjzolvoLk8011J9aoeC44yx+UT8Ijehc3mkd4x8zVvOK/OG4=,iv:e6FudQPXESAw/CNVqJWGZG+/8j/J88Z8InjM++GJ9lM=,tag:KaQkmLGSU+jJF3f6YBKhmQ==,type:str]
|
||||
lastmodified: "2025-02-24T21:27:42Z"
|
||||
mac: ENC[AES256_GCM,data:5E9adS+q+Vb45MtKDuI65GaKxb/yksqSN73ZFHYhdL+w6Lk4/WPd9n7qTENKfFkYN2qIRP3S4IQUBwobep4wiEQt4v8XdNN7gR7cgI/2u4y/iKptyv/YWyj+YYfFaZjJ6lqxod3MAq92L4xYq+91aKoWEW/ErpDy8N3xOe7GI6U=,iv:WGWCD9pfu7ijiDXhcV26j7XpFl5dVglWZeMVQFyFUSA=,tag:PP4yI+iLaaPLG0YoI19zTQ==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.9.4
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
{lib, ...}:
|
||||
with lib; rec {
|
||||
firstOrDefault = first: default:
|
||||
if first != null
|
||||
then first
|
||||
else default;
|
||||
existsOrDefault = x: set: default:
|
||||
if builtins.hasAttr x set
|
||||
then builtins.getAttr x set
|
||||
else default;
|
||||
|
||||
with lib;
|
||||
rec {
|
||||
|
||||
firstOrDefault = first: default: if first != null then first else default;
|
||||
existsOrDefault =
|
||||
x: set: default:
|
||||
if builtins.hasAttr x set then builtins.getAttr x set else default;
|
||||
# Create custom package set
|
||||
mkMyPkgs = pkgs: {
|
||||
borgmatic = pkgs.callPackage ../../nixos/packages/borgmatic {};
|
||||
};
|
||||
|
||||
# main service builder
|
||||
mkService =
|
||||
options:
|
||||
(
|
||||
mkService = options: (
|
||||
let
|
||||
user = existsOrDefault "user" options "568";
|
||||
group = existsOrDefault "group" options "568";
|
||||
|
@ -37,14 +41,15 @@ rec {
|
|||
++ lib.optionals (lib.attrsets.attrByPath ["container" "caps" "dropAll"] false options) [
|
||||
"--cap-drop=ALL"
|
||||
];
|
||||
in
|
||||
{
|
||||
in {
|
||||
virtualisation.oci-containers.containers.${options.app} = mkIf options.container.enable {
|
||||
image = "${options.container.image}";
|
||||
user = "${user}:${group}";
|
||||
environment = {
|
||||
environment =
|
||||
{
|
||||
TZ = options.timeZone;
|
||||
} // options.container.env;
|
||||
}
|
||||
// options.container.env;
|
||||
environmentFiles = lib.attrsets.attrByPath ["container" "envFiles"] [] options;
|
||||
volumes =
|
||||
["/etc/localtime:/etc/localtime:ro"]
|
||||
|
@ -57,7 +62,8 @@ rec {
|
|||
systemd.tmpfiles.rules = lib.optionals (lib.attrsets.hasAttrByPath [
|
||||
"persistence"
|
||||
"folder"
|
||||
] options) [ "d ${options.persistence.folder} 0750 ${user} ${group} -" ];
|
||||
]
|
||||
options) ["d ${options.persistence.folder} 0750 ${user} ${group} -"];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
46
nixos/packages/borgmatic/default.nix
Normal file
46
nixos/packages/borgmatic/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
lib,
|
||||
python3,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
python3.pkgs.buildPythonApplication rec {
|
||||
pname = "borgmatic";
|
||||
version = "1.9.12";
|
||||
pyproject = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "borgmatic-collective";
|
||||
repo = "borgmatic";
|
||||
rev = version;
|
||||
hash = "sha256-tTnk2xO5F5AoQICZGVnEj8v6kNA7Wkd8kzvm4i3r0kU=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
python3.pkgs.setuptools
|
||||
];
|
||||
|
||||
dependencies = with python3.pkgs; [
|
||||
jsonschema
|
||||
packaging
|
||||
requests
|
||||
ruamel-yaml
|
||||
];
|
||||
|
||||
optional-dependencies = with python3.pkgs; {
|
||||
Apprise = [
|
||||
apprise
|
||||
];
|
||||
};
|
||||
|
||||
pythonImportsCheck = [
|
||||
"borgmatic"
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "Simple, configuration-driven backup software for servers and workstations";
|
||||
homepage = "https://github.com/borgmatic-collective/borgmatic/";
|
||||
changelog = "https://github.com/borgmatic-collective/borgmatic/blob/${src.rev}/NEWS";
|
||||
license = lib.licenses.gpl3Only;
|
||||
mainProgram = "borgmatic";
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue