Help with Zrepl

Hi all, someone can help me to set zrepl? I’m using this with arch, Gentoo and feeebsd. I puted package and service.zrepl.enable on my configuration.nix but I didn’t understand how create its configuration file

The config file is created by its corresponding settings option.
https://search.nixos.org/options?channel=unstable&show=services.zrepl.settings&from=0&size=50&sort=relevance&type=packages&query=services.zrepl.settings

I’m using this model

but when I launch nixos-rebuild test I have a few errors, e.g. an error near jobs :

This afternoon I post correct error

There are errors:

[11:41:42] zar_marco :: nixgram  ➜  ~ » sudo nixos-rebuild test 
error:
       … while evaluating the attribute 'config'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: syntax error, unexpected '='

       at /etc/nixos/zrepl.nix:8:10:

            7|  jobs = [
            8|     name = "snapjob";
             |          ^
            9|     type = "snap";
building Nix...
error:
       … while evaluating the attribute 'config'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: syntax error, unexpected '='

       at /etc/nixos/zrepl.nix:8:10:

            7|  jobs = [
            8|     name = "snapjob";
             |          ^
            9|     type = "snap";
building the system configuration...
error:
       … while evaluating the attribute 'config.system.build.toplevel'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: syntax error, unexpected '='

       at /etc/nixos/zrepl.nix:8:10:

            7|  jobs = [
            8|     name = "snapjob";
             |          ^
            9|     type = "snap";

and this is my zrepl.nix file
`[11:44:43] zar_marco :: nixgram ➜ ~ » cat /etc/nixos/zrepl.nix
{ config, pkgs, lib, … }:

{

services.zrepl.settings = {

jobs = [
name = “snapjob”;
type = “snap”;
filesystems: {
“rpool/root/nixos”: true,
“rpool/data/nixos-home”: true,
“rpool/data/condivise”: true,
}
snapshotting:
type: periodic
interval: 30m
prefix: zrepl_snapjob_
pruning:
keep:
- type: last_n
count: 20
]
};
}
``

The linked snippet seems to be no valid nix.
You could peek on my config. nix-configuration/machines/tank/configuration.nix at 6f155193b2f261e22e0ae162e2d0a9a26d900484 · Shawn8901/nix-configuration · GitHub

The nix code will be translated to yaml by the module

1 Like

Thanks so much, I generated setting correctly. Now I must understand how enable systemd service

Sorry, I’ve this error that I don’t know

[17:25:32] zar_marco :: nixgram  ➜  ~ » systemctl status zrepl.service                 
○ zrepl.service - zrepl daemon
     Loaded: loaded (/etc/systemd/system/zrepl.service; enabled; preset: enabled)
    Drop-In: /nix/store/p1mpzax6sjblibiv7gpi5iskkc4vl2wg-system-units/zrepl.service.d
             └─overrides.conf
     Active: inactive (dead) since Mon 2024-04-01 17:20:34 CEST; 5min ago
       Docs: https://zrepl.github.io
    Process: 4860 ExecStartPre=/nix/store/hnwbdspbqacr1b84c2q0ziss93k21mvs-zrepl-0.6.1/bin/zrepl --config /etc/zrepl/zrepl.yml configcheck (co>
         IP: 0B in, 0B out
        CPU: 30ms

apr 01 17:20:34 nixgram systemd[1]: zrepl.service: Scheduled restart job, restart counter is at 5.
apr 01 17:20:34 nixgram systemd[1]: zrepl.service: Start request repeated too quickly.
apr 01 17:20:34 nixgram systemd[1]: zrepl.service: Failed with result 'exit-code'.
apr 01 17:20:34 nixgram systemd[1]: Failed to start zrepl daemon.
[17:25:47] zar_marco :: nixgram  ➜  ~ »                           

can I fixed this?

Now I must understand how enable systemd service

The module already enables the systems service, there should not be any need of manual intervention. Just activate the config switch switch or test, or enable it with boot and reboot.

Sorry, I’ve this error that I don’t know

Posting an actual error could be helpful. You now have postet “sorry I can not start, there is something wrong with config” (pre check fails)

It would be also interesting what systems override you have applied

Ok this is the error:

[18:13:49] zar_marco :: nixgram  ➜  ~ » systemctl status zrepl.service                                                                                                                                                                                                                                                  3 ↵
× zrepl.service - zrepl daemon
     Loaded: loaded (/etc/systemd/system/zrepl.service; enabled; preset: enabled)
    Drop-In: /nix/store/p1mpzax6sjblibiv7gpi5iskkc4vl2wg-system-units/zrepl.service.d
             └─overrides.conf
     Active: failed (Result: exit-code) since Mon 2024-04-01 18:08:31 CEST; 5min ago
       Docs: https://zrepl.github.io
    Process: 1730 ExecStartPre=/nix/store/hnwbdspbqacr1b84c2q0ziss93k21mvs-zrepl-0.6.1/bin/zrepl --config /etc/zrepl/zrepl.yml configcheck (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 17ms

apr 01 18:08:31 nixgram systemd[1]: zrepl.service: Scheduled restart job, restart counter is at 5.
apr 01 18:08:31 nixgram systemd[1]: zrepl.service: Start request repeated too quickly.
apr 01 18:08:31 nixgram systemd[1]: zrepl.service: Failed with result 'exit-code'.
apr 01 18:08:31 nixgram systemd[1]: Failed to start zrepl daemon.

there are my configuration for nixos:
configuration.nix

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./users.nix
      ./desktop.nix 
      ./package.nix
      ./tlp.nix
      ./zrepl.nix
    ];
  boot.loader.grub = {
    enable = true;
    zfsSupport = true;
    efiSupport = true;
    efiInstallAsRemovable = true;
    mirroredBoots = [
      { devices = [ "nodev"]; path = "/boot/efi"; }
    ];
  };
  networking.hostId = "00bab10c";
 boot.zfs.extraPools = [ "rpool" ];
  # Use the systemd-boot EFI boot loader.
  #boot.loader.systemd-boot.enable = true;
  #boot.loader.efi.canTouchEfiVariables = true;
 
  hardware.bluetooth.enable = true; # enables support for Bluetooth
  hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
  services.blueman.enable = true;
  
  hardware.bluetooth.settings = {
	General = {
		Experimental = true;
	};
   };
   
   networking.hostName = "nixgram"; # Define your hostname.
  # Pick only one of the below networking options.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
  # networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.

  nixpkgs.config.allowUnfree = true; #needed for nvidia drivers  
 
  # tlp service
  services.tlp.enable = true;

  services.power-profiles-daemon.enable = false;
  
  services.zrepl.enable = true;
  services.zrepl.package = pkgs.zrepl;
  
  services.flatpak.enable = true;
  services.packagekit.enable = true;  

  # thunderbolt
  services.hardware.bolt.enable = true;
 
 # Set your time zone.
  time.timeZone = "Europe/Rome";

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  networking.networkmanager.enable = true;

  # Select internationalisation properties.
   i18n.defaultLocale = "it_IT.UTF-8";
   console = {
     font = "Lat2-Terminus16";
    # keyMap = "it";
     useXkbConfig = true; # use xkbOptions in tty.
   };

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  

  # Configure keymap in X11
 #  services.xserver.layout = "it";
  # services.xserver.xkbOptions = {
  #   "eurosign:e";
  #   "caps:escape" # map caps to escape.
  # };

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
   sound.enable = true;
   hardware.pulseaudio.enable = true;

  # Enable touchpad support (enabled default in most desktopManager).
  services.xserver.libinput.enable = true;
programs.zsh.enable = true;
 users.extraUsers.root = {
      shell = pkgs.zsh;
    };
 

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  # environment.systemPackages = with pkgs; [
  #   vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #   wget
  # ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Copy the NixOS configuration file and link it from the resulting system
  # (/run/current-system/configuration.nix). This is useful in case you
  # accidentally delete configuration.nix.
  # system.copySystemConfiguration = true;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.11"; # Did you read the comment?

}


and this zrepl.nix:

{ config, pkgs, lib,  ... }:


{
services.zrepl.settings = {

 jobs = [
  { 
    name = "snapjob";
    type = "snap";
    filesystems = {
     "rpool/root/nixos"= true;
     "rpool/data/nixos-home"= true;
     "rpool/data/condivise"= true;
  };
  snapshotting = [
   {
    type = "periodic";
    interval= "30m";
    prefix= "zrepl_snapjob_";
  pruning=
   { 
   keep = [
   { 
        type= "last_n";
        count= "20";
}
];
};
}
];
}
];
};
}

and there are my dataset:

[18:13:51] zar_marco :: nixgram  ➜  ~ » zfs list                                                                                                                                                                                                                                                                        3 ↵
NAME                       USED  AVAIL  REFER  MOUNTPOINT
rpool                      268G   631G    96K  none
rpool/data                 167G   631G    96K  none
rpool/data/arch-home-old  18.7G   631G  16.9G  legacy
rpool/data/condivise       122G   631G   122G  legacy
rpool/data/gentoo-home    2.55G   631G  1.93G  legacy
rpool/data/gentooD-home   11.1G   631G  10.5G  legacy
rpool/data/gentoorc-home  1.84G   631G  1.32G  legacy
rpool/data/nixos-home     1.00G   631G  1.00G  legacy
rpool/data/void-home      10.3G   631G  8.44G  legacy
rpool/root                 101G   631G    96K  none
rpool/root/arch-old       23.5G   631G  16.5G  /
rpool/root/gentooD        32.8G   631G  32.3G  /
rpool/root/gentoorc       11.6G   631G  10.7G  /
rpool/root/nixos          17.0G   631G  17.0G  /
rpool/root/void           16.1G   631G  11.5G  /