From 97ab70a4d45bc6938f888ee1ebc77dbc16713c98 Mon Sep 17 00:00:00 2001 From: comonad Date: Sun, 19 Apr 2026 02:30:21 +0900 Subject: [PATCH] docs: note for inputs.self.submodules --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 467597e..bc879db 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,32 @@ Afterwards, create a `default.nix` file containing the following: ) { src = ./.; }).defaultNix ``` +NOTE: Flake fetcher is aware of Git submodules when `inputs.self.submodules` is set to `true` in `flake.nix`. +For compatibility in stable Nix, paste the following content in `default.nix` instead: + +```nix +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + + fetchFromLockFile = + nodeName: + fetchTarball { + url = + lock.nodes.${nodeName}.locked.url + or "https://github.com/${lock.nodes.${nodeName}.locked.owner}/${lock.nodes.${nodeName}.locked.repo}/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz"; + sha256 = lock.nodes.${nodeName}.locked.narHash; + }; + + lib = (import (fetchFromLockFile lock.nodes.root.inputs.nixpkgs) { }).lib; +in +(import (fetchFromLockFile lock.nodes.root.inputs.flake-compat) { + src = lib.fileset.toSource { + root = ./.; + fileset = (lib.fileset.gitTrackedWith { recurseSubmodules = true; }) ./.; + }; +}).defaultNix +``` + If you would like a `shell.nix` file, create one containing the above, replacing `defaultNix` with `shellNix`. You can access any flake output via the `outputs` attribute returned by `flake-compat`, e.g.