resticprofile build works
This commit is contained in:
48
homeManagerModules/restic/flake.nix
Normal file
48
homeManagerModules/restic/flake.nix
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
description = "Flake packaging resticprofile with a Home Manager module for programs.resticprofile";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-unstable"; # Use latest Nixpkgs for Go package build
|
||||||
|
home-manager.url = "github:nix-community/home-manager";
|
||||||
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, home-manager }:
|
||||||
|
let
|
||||||
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
|
# Define a function to build the resticprofile package for a given system:
|
||||||
|
resticprofilePkg = { pkgs, lib, ... }:
|
||||||
|
pkgs.buildGoModule rec {
|
||||||
|
pname = "resticprofile";
|
||||||
|
version = "0.31.0";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "creativeprojects";
|
||||||
|
repo = "resticprofile";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "sha256-ezelvyroQG1EW3SU63OVHJ/T4qjN5DRllvPIXnei1Z4="; # source tarball hash
|
||||||
|
};
|
||||||
|
vendorHash = "sha256-M9S6F/Csz7HnOq8PSWjpENKm1704kVx9zDts1ieraTE="; # Correct vendor hash
|
||||||
|
goPackagePath = "github.com/creativeprojects/resticprofile";
|
||||||
|
# (Optional) Include restic in checkInputs if tests require it:
|
||||||
|
# checkInputs = [ pkgs.restic ];
|
||||||
|
doCheck = false; # Disable tests due to sandboxed build environment
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Configuration profiles manager and scheduler for restic backup";
|
||||||
|
homepage = "https://creativeprojects.github.io/resticprofile/";
|
||||||
|
license = licenses.gpl3Only;
|
||||||
|
maintainers = [ ]; # (Add yourself or skip)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
# Provide the package for all supported systems:
|
||||||
|
packages = nixpkgs.lib.genAttrs systems (system:
|
||||||
|
let pkgs = import nixpkgs { inherit system; };
|
||||||
|
in { resticprofile = resticprofilePkg { inherit pkgs; lib = pkgs.lib; }; }
|
||||||
|
);
|
||||||
|
|
||||||
|
# Provide the Home Manager module
|
||||||
|
homeManagerModules = {
|
||||||
|
resticprofile = import ./resticprofile.nix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
46
homeManagerModules/restic/resticprofile.nix
Normal file
46
homeManagerModules/restic/resticprofile.nix
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkOption mkPackageOption mkIf types;
|
||||||
|
cfg = config.programs.resticprofile;
|
||||||
|
|
||||||
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
|
in {
|
||||||
|
options.programs.resticprofile = {
|
||||||
|
enable = mkEnableOption "Enable resticprofile (Restic backup profile manager)";
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "resticprofile" { };
|
||||||
|
|
||||||
|
# Config structured as an attrset that maps to resticprofile's YAML format
|
||||||
|
config = mkOption {
|
||||||
|
type = yamlFormat.type;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Configuration for resticprofile, which will be written as YAML to
|
||||||
|
`$XDG_CONFIG_HOME/resticprofile/profiles.yaml`.
|
||||||
|
'';
|
||||||
|
example = {
|
||||||
|
repository = "local:/backup";
|
||||||
|
passwordFile = "password.txt";
|
||||||
|
backup = {
|
||||||
|
source = [ "/home/user/Documents" ];
|
||||||
|
schedule = "12:30";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
configFile = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "profiles.yaml";
|
||||||
|
description = "The configuration file name under $XDG_CONFIG_HOME/resticprofile/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
xdg.configFile."resticprofile/${cfg.configFile}".source =
|
||||||
|
yamlFormat.generate "resticprofile-config" cfg.config;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -8,6 +8,14 @@
|
|||||||
'';
|
'';
|
||||||
matchBlocks = lib.mkMerge [
|
matchBlocks = lib.mkMerge [
|
||||||
(lib.mkIf (config.profile == "personal") {
|
(lib.mkIf (config.profile == "personal") {
|
||||||
|
"ad-nix" = {
|
||||||
|
hostname = "192.168.1.201";
|
||||||
|
user = "appdaemon";
|
||||||
|
};
|
||||||
|
"docs" = {
|
||||||
|
hostname = "192.168.1.110";
|
||||||
|
user = "root";
|
||||||
|
};
|
||||||
"panoptes" = {
|
"panoptes" = {
|
||||||
hostname = "192.168.1.107";
|
hostname = "192.168.1.107";
|
||||||
user = "panoptes";
|
user = "panoptes";
|
||||||
|
|||||||
Reference in New Issue
Block a user