Fetch package from Git with default.nix in subdir

I’m trying to install a package : GitHub - Aylur/ags: A customizable and extensible shell which has it’s default.nix file in a subdirectory. It seems it’s causing some issues because nix cannot find it when I rebuild my system.

opening file /nix/store/***/default.nix : No such file or directory

Here is how I fetch the repo :

{ config, pkgs, ... }:
let aylur-gtk-shell = import (builtins.fetchGit {
  url = "https://github.com/Aylur/ags.git"
  ref = "main"
});
in {
  environment.systemPackages = [
    aylur-gtk-shell
  ];
}

Is it possible to specify where default.nix file is in the repo (it is in nix folder) ?

You need to use the correct path. Nix can’t guess what you want. Try

"${builtins.fetchGit {
  url = "https://github.com/Aylur/ags.git"
  ref = "main"
}}/nix"

And I thought you need to callPackage.

I get this error

error: A definition for option `environment.systemPackages."[definition 1-entry 1]"' is not of type `package'. Definition values:
       - In `/etc/nixos/ags.nix': <function, args: {buildNpmPackage, extraPackages?, fetchFromGitLab, gjs, glib-networking, gnome, gobject-introspection, gtk-layer-shell, gtk3, gvfs, lib, libdbusmenu-gtk3, libpulseaudio, meson, networkmanager, ninja, nodePackages, pkg-config, python3, stdenv, upower, wrapGAppsHook}>

I’m fairly new to nix, so how do I use callPackage in my case ? I’m still very unsure on how everything works together.

Yes. As you can see:

is not of type `package’

<function, ...

It’s a function and you need to use callPackage to make it a package.

pkgs.callPackage "${builtins.fetchGit {
  url = "https://github.com/Aylur/ags.git"
  ref = "main"
}}/nix" { };

Thank you, it did work ! Unfortunately, the build failed, but those are compile errors.