Get the nix store path of an executable built as a derivation inside a NixOS module? (gitlab-rails)

Hello there,

I would like to create a systemd service that runs the gitlab-rails executable, but the package is built as a derivation inside the gitlab NixOS module, and I don’t know how to get its nix store’s path. I cannot use pkgs like usually: ${pkgs.gitlab-rails}/bin/gitlab-rails.

Currently I have to statically use the path /run/current-system/sw/bin/gitlab-rails.

The goal is to have a timer that automatically postpone user tokens expiration, here is my config (which works):

{
  systemd.timers."gitlab-postpone-token-expiration" = {
    wantedBy = [ "timers.target" ];
      timerConfig = {
        OnCalendar = "weekly";
        Persistent = true; 
        Unit = "gitlab-postpone-token-expiration.service";
      };
  };

  systemd.services."gitlab-postpone-token-expiration" = {
    script = ''
      /run/current-system/sw/bin/gitlab-rails runner "PersonalAccessToken.where(revoked: false, user_id: User.active).where(last_used_at: 3.months.ago...).update_all(expires_at: Time.now + 3.months, expire_notification_delivered: false)"
    '';
    serviceConfig = {
      Type = "oneshot";
      User = config.services.gitlab.user;
    };
  };

}

Is there a better solution than using this static path?

Thanks for the help

The maintainer should have provided a pkgs.gitlab.gitlab-rails or some such. I’d suggest you email them. As far as I know, there’s not a way around this.

2 Likes

Thank you, I created an issue for this.

Opened a PR to add those to services.gitlab.packages. Would that help you out?

2 Likes

Many thanks, unfortunately I get the same error as the pipeline, I tried to fix it but can’t find any solution for the moment.

mkOption needs defaultText passed to it, if you provide a default value that depends on config or pkgs or so on.

1 Like

tested and working, thank you <3