I’m trying to convert this to an overlay: PKGBUILD - aur.git - AUR Package Repositories
It is a bash client to update dynamic DNS at freedns.afraid.org
Here is what I have, ~/.config/nixpkgs/overlays/extrapkgs.nix
:
self: super:
{
petrified = super.stdenv.mkDerivation rec {
name = "petrified-${version}";
version = "2.0.3";
src = super.fetchurl {
url = "https://gitlab.com/troyengel/petrified/-/archive/v${version}/petrified-v${version}.tar.gz";
sha256 = "bb01029abc7796d2dd824f88beb2da05fb8da10ceb3ec7a0c1682631d670fc27";
};
buildInputs = with self; [ iproute curl ];
installFlags = [ "DESTDIR=$(out)" ];
};
systemd.user.services.petrified = {
description = "Run petrified as user";
after = [ "network-online.target" ];
requires = [ "network-online.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${self.pkgs.petrified}/bin/petrified -c ''\"%h/.petrifiedrc''\"";
};
startAt = [ "0/6:00:00" ];
};
}
I install it with nix-env -f '<nixpkgs>' -iA petrified
It installs OK, but if I do systemctl --user list-timers
(or without --user) I don’t see the timer. What am I doing wrong?
1 Like
NobbZ
October 4, 2020, 4:51pm
2
You can not set options through an overlay.
You need to manually create those, or provide a function from your overlay that would return a module setting up the timer.
1 Like
Thanks a lot, I will look into it
To conclude, this is how I solved it with help on IRC from Ke, sphalerite, monty, V and dutchie.
Instead of an overlay, I put everything in configuration.nix. I used makeWrapper’s wrapProgram to pass locations of binaries like curl to the script. I was informed that there is an open PR for adding a tool called “resholved”, which would solve these path annoyances.
There are other ways of tackling this, for example Ke said he uses systemd.services.<name>.script
instead of ExecStart with
script = "${setPath} ${pkgs.bash}/bin/bash ${exec} ${mkConfig name params}";
setPath = "PATH=${pkgs.btrfsProgs}/bin:$PATH";
or
PATH=$PATH:${lib.makeBinPath (with pkgs; [hdparm bash])}
I also found a typoed variable in the script and submitted a merge request for fixing it
systemd.services.petrified = let petrifiedPkg = pkgs.stdenv.mkDerivation rec {
name = "petrified-${version}";
version = "2.0.3";
src = pkgs.fetchurl {
url = "https://gitlab.com/troyengel/petrified/-/archive/v${version}/petrified-v${version}.tar.gz";
sha256 = "bb01029abc7796d2dd824f88beb2da05fb8da10ceb3ec7a0c1682631d670fc27";
};
buildInputs = with pkgs; [ iproute curl makeWrapper ];
installFlags = [ "PREFIX=$(out)" "ETCPREFIX=$(NIX_BUILD_TOP)" "VARPREFIX=$(out)/var" ];
postInstall = ''
wrapProgram "$out/bin/petrified" --prefix PATH : "${pkgs.curl}/bin:${pkgs.utillinux}/bin:${pkgs.iproute}/bin"
}; in {
description = "Run petrified in system mode";
after = [ "network-online.target" ];
requires = [ "network-online.target" ];
serviceConfig = {
Type = "simple";
CacheDirectory = "petrified";
ExecStart = "${petrifiedPkg}/bin/petrified -c /etc/petrified.conf";
};
startAt = [ "0/6:00:00" ];
};
systemd.timers."petrified".timerConfig.Persistent = true;
2 Likes