From 7f5e675bc0baf8640e3f587f7ba241fea5b122bd Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 7 Jan 2026 20:26:30 +0300 Subject: [PATCH 1/2] fix(nix): support flake in a subdir --- default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index a97b910..9142f67 100644 --- a/default.nix +++ b/default.nix @@ -7,13 +7,16 @@ { src, + root ? "/", system ? builtins.currentSystem or "unknown-system", }: let inherit (builtins) mapAttrs; - lockFilePath = src + "/flake.lock"; + root' = "/" + root + "/"; + + lockFilePath = src + root' + "/flake.lock"; lockFile = builtins.fromJSON (builtins.readFile lockFilePath); @@ -167,7 +170,12 @@ let lastModified = 0; lastModifiedDate = formatSecondsSinceEpoch 0; } - // (if src ? outPath then src else tryFetchGit src); + // ( + let + src' = (if src ? outPath then src else tryFetchGit src); + in + src' // { outPath = src'.outPath + root'; } + ); # Format number of seconds in the Unix epoch as %Y%m%d%H%M%S. formatSecondsSinceEpoch = From 02acb08a0aa4b23f28a9552f25d173f4e930fc2d Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sat, 17 Jan 2026 16:53:31 +0300 Subject: [PATCH 2/2] fix(nix): explain the role of 'root' --- default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index 9142f67..956d0b9 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,9 @@ -# Compatibility function to allow flakes to be used by -# non-flake-enabled Nix versions. Given a source tree containing a -# 'flake.nix' and 'flake.lock' file, it fetches the flake inputs and -# calls the flake's 'outputs' function. It then returns an attrset -# containing 'defaultNix' (to be used in 'default.nix'), 'shellNix' -# (to be used in 'shell.nix'). +# Compatibility function to allow flakes to be used by non-flake-enabled Nix +# versions. Given a source tree ('src') containing a 'flake.nix' and +# 'flake.lock' files in '${src}/${root}/', it fetches the flake inputs and calls +# the flake's 'outputs' function. It then returns an attrset containing +# 'defaultNix' (to be used in 'default.nix'), 'shellNix' (to be used in +# 'shell.nix'). { src,