diff --git a/homeManagerModules/restic/flake.nix b/homeManagerModules/restic/flake.nix new file mode 100644 index 0000000..c35bfe1 --- /dev/null +++ b/homeManagerModules/restic/flake.nix @@ -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; + }; + }; +} diff --git a/homeManagerModules/restic/resticprofile.nix b/homeManagerModules/restic/resticprofile.nix new file mode 100644 index 0000000..0163483 --- /dev/null +++ b/homeManagerModules/restic/resticprofile.nix @@ -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; + }; +} diff --git a/homeManagerModules/ssh.nix b/homeManagerModules/ssh.nix index a99c5fb..3db4590 100644 --- a/homeManagerModules/ssh.nix +++ b/homeManagerModules/ssh.nix @@ -8,6 +8,14 @@ ''; matchBlocks = lib.mkMerge [ (lib.mkIf (config.profile == "personal") { + "ad-nix" = { + hostname = "192.168.1.201"; + user = "appdaemon"; + }; + "docs" = { + hostname = "192.168.1.110"; + user = "root"; + }; "panoptes" = { hostname = "192.168.1.107"; user = "panoptes";