Since in Autonomic we want granuralize the cache by solution, I trying to build in my extended makes a main.nix file that allow me from a main derivation collect multiple lazy derivations
- Get all .lobster files from my repo (pathsMatching)
- Create the lazy makeDerivations
- Collect all created lazy makeDerivations
So I made this based on some builtins
{ makeDerivation
, path
, inputs
, makeSearchPaths
, pathsMatching
, ...
}:
let
## Get lobster solutions
solutionNames = pathsMatching {
regex = ".*\\.lobster";
target = "/code";
};
lib = inputs.nixpkgs.lib;
## Build a single solution file
makeSolution = name: { src }: {
name = "/solution/lobster/${name}";
value = makeDerivation {
env = {
envTargets = path src;
};
name = "build-solutions-lobster-${name}";
searchPaths = {
bin = [
inputs.nixpkgs.lobster
];
};
builder = ./entrypoint.sh;
};
};
## Lazy functions
solutions = builtins.map
(solutionName: {
name = "/solution/dirOfSolution/lobster/${solutionName}";
value = (makeSolution solutionName {
src = "${solutionName}";
}).value;
})
solutionNames;
in
## Collect lazy functions
makeDerivation {
env = {
envSolutions = lib.attrsets.catAttrs "value" solutions;
};
builder = "echo $envSolutions > $out";
name = "solution-dir-of-solutions-for-lobster";
}
Initially, I thought that since a single derivation was created for each file these derivations will be cached, however, seems it wasn't like that, I made the following:
I run this test once to build all derivations, after that, I modified only the file code-codeabbey-002-alejotru3012.lobster and I run again my test, but, I notice that all derivations were re-built and not only the derivation for the file that I modified
I got this output
these derivations will be built:
/nix/store/0llv41qzl5qm5l1c3hax7hj1431w25nv-build-solutions-lobster--code-codeabbey-002-alejotru3012.lobster.drv
/nix/store/0ym4c8hk55c8c9add8hlsq0as8jrjfxv-build-solutions-lobster--code-codeabbey-100-alejotru3012.lobster.drv
/nix/store/572hjp4iiysfn4h1rk7bnhhphsv6nxah-build-solutions-lobster--code-codeabbey-120-alejotru3012.lobster.drv
/nix/store/7ygd265h0xsvpp8rdhbqq7kqphrbrrik-build-solutions-lobster--code-codeabbey-023-alejotru3012.lobster.drv
/nix/store/9nyr7y4zg44nqhwwn0d6f31qvqi0zvyg-build-solutions-lobster--code-codeabbey-102-alejotru3012.lobster.drv
/nix/store/b9sin6417g6636y50ig1fnx93cd97797-build-solutions-lobster--code-codeabbey-015-alejotru3012.lobster.drv
/nix/store/bldsbih8kzq9ajnwpbm2jz2nrv6gsjca-build-solutions-lobster--code-codeabbey-101-alejotru3012.lobster.drv
/nix/store/czvgd8awqgqjblb1100cm1rw00aq1kq7-build-solutions-lobster--code-codeabbey-044-alejotru3012.lobster.drv
/nix/store/dhm16pcffyy6czi6bd6ldvzh0kxavm95-build-solutions-lobster--code-codeabbey-038-alejotru3012.lobster.drv
/nix/store/djyhj53xdpz0lfclwdbk2isz3p42iwnq-build-solutions-lobster--code-codeabbey-006-alejotru3012.lobster.drv
/nix/store/gj1pabpzykpr6lh58cmhwj5ppv8vzw5p-build-solutions-lobster--code-codeabbey-043-alejotru3012.lobster.drv
/nix/store/ikfjj6y6g0437sw4wak0qzz0a317yw9a-build-solutions-lobster--code-codeabbey-011-alejotru3012.lobster.drv
/nix/store/kqpcl2bci0wam75fhf2g92qjz0gig7kz-build-solutions-lobster--code-codeabbey-003-alejotru3012.lobster.drv
/nix/store/n4aznc7h9alz4h33k302i7j6xxiibyzz-build-solutions-lobster--code-codeabbey-085-alejotru3012.lobster.drv
/nix/store/rjh21wsa8dqy5aw9pbrq97nnxcj6lf7k-build-solutions-lobster--code-codeabbey-016-alejotru3012.lobster.drv
/nix/store/s52lmcb28akfh6i82vq1h0nfrhxnxfad-build-solutions-lobster--code-codeabbey-031-alejotru3012.lobster.drv
/nix/store/v2f98dc5m3n33nkyvfkjf9q3njvqqidj-build-solutions-lobster--code-codeabbey-080-alejotru3012.lobster.drv
/nix/store/ynpww3cy6kzppmlwyx2hwq1kxq0cbr2x-build-solutions-lobster--code-codeabbey-053-alejotru3012.lobster.drv
/nix/store/p60pkp1g1wzvhs6c8xm7h2vdzvzpq9mh-solution-dir-of-solutions-for-lobster.drv
building '/nix/store/0llv41qzl5qm5l1c3hax7hj1431w25nv-build-solutions-lobster--code-codeabbey-002-alejotru3012.lobster.drv'...
building '/nix/store/kqpcl2bci0wam75fhf2g92qjz0gig7kz-build-solutions-lobster--code-codeabbey-003-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/002/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/003/alejotru3012.lobster
building '/nix/store/djyhj53xdpz0lfclwdbk2isz3p42iwnq-build-solutions-lobster--code-codeabbey-006-alejotru3012.lobster.drv'...
building '/nix/store/ikfjj6y6g0437sw4wak0qzz0a317yw9a-build-solutions-lobster--code-codeabbey-011-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/006/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/011/alejotru3012.lobster
building '/nix/store/b9sin6417g6636y50ig1fnx93cd97797-build-solutions-lobster--code-codeabbey-015-alejotru3012.lobster.drv'...
building '/nix/store/rjh21wsa8dqy5aw9pbrq97nnxcj6lf7k-build-solutions-lobster--code-codeabbey-016-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/015/alejotru3012.lobster
building '/nix/store/7ygd265h0xsvpp8rdhbqq7kqphrbrrik-build-solutions-lobster--code-codeabbey-023-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/016/alejotru3012.lobster
building '/nix/store/s52lmcb28akfh6i82vq1h0nfrhxnxfad-build-solutions-lobster--code-codeabbey-031-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/023/alejotru3012.lobster
building '/nix/store/dhm16pcffyy6czi6bd6ldvzh0kxavm95-build-solutions-lobster--code-codeabbey-038-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/031/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/038/alejotru3012.lobster
building '/nix/store/gj1pabpzykpr6lh58cmhwj5ppv8vzw5p-build-solutions-lobster--code-codeabbey-043-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/043/alejotru3012.lobster
building '/nix/store/czvgd8awqgqjblb1100cm1rw00aq1kq7-build-solutions-lobster--code-codeabbey-044-alejotru3012.lobster.drv'...
building '/nix/store/ynpww3cy6kzppmlwyx2hwq1kxq0cbr2x-build-solutions-lobster--code-codeabbey-053-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/044/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/053/alejotru3012.lobster
building '/nix/store/v2f98dc5m3n33nkyvfkjf9q3njvqqidj-build-solutions-lobster--code-codeabbey-080-alejotru3012.lobster.drv'...
building '/nix/store/n4aznc7h9alz4h33k302i7j6xxiibyzz-build-solutions-lobster--code-codeabbey-085-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/080/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/085/alejotru3012.lobster
building '/nix/store/0ym4c8hk55c8c9add8hlsq0as8jrjfxv-build-solutions-lobster--code-codeabbey-100-alejotru3012.lobster.drv'...
building '/nix/store/bldsbih8kzq9ajnwpbm2jz2nrv6gsjca-build-solutions-lobster--code-codeabbey-101-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/101/alejotru3012.lobster
building '/nix/store/9nyr7y4zg44nqhwwn0d6f31qvqi0zvyg-build-solutions-lobster--code-codeabbey-102-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/100/alejotru3012.lobster
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/102/alejotru3012.lobster
building '/nix/store/572hjp4iiysfn4h1rk7bnhhphsv6nxah-build-solutions-lobster--code-codeabbey-120-alejotru3012.lobster.drv'...
I'm building for this file /nix/store/y4bhzlcjidzd0id5gg3lcsrv0sy784ks-head/code/codeabbey/120/alejotru3012.lobster
building '/nix/store/p60pkp1g1wzvhs6c8xm7h2vdzvzpq9mh-solution-dir-of-solutions-for-lobster.drv'...
/nix/store/bxsjkisbd3bf70j9z6vpwmnyl9caxwvn-solution-dir-of-solutions-for-lobster
so I have these questions
Is this the expected behavior? maybe I'm misunderstanding the cache? or am I forgetting something to get a solution for my problem?.
Is it possible to have a granular cache using the approach that I propose?
Finally, I know that I can use an approach like /lintWithLizard to get a single derivation by solution, so at this moment, I'm looking for a method to call all that individuals outputs /lintWithLizard/ at the same time.