forked from adisbladis/west2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.nix
45 lines (43 loc) · 1.06 KB
/
hook.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ lib
, makeSetupHook
, gitMinimal
, fetchgit
}:
{ manifest
}:
let
manifest' =
if builtins.isPath manifest then (lib.importTOML manifest)
else manifest;
in
makeSetupHook
{
name = "west2nix-project-hook.sh";
substitutions = {
# West only considers proper git repos when discovering projects.
# Hack around this by:
# - Copying the project into place
# - Instantiate a git repo
git = lib.getExe gitMinimal;
# Copy projects into the workspace
copyProjects = lib.concatStringsSep "\n" (
map
(project:
let
path = project.path or project.name;
src = fetchgit {
inherit (project) url;
inherit (project.nix) hash;
fetchSubmodules = project.submodules or false;
rev = project.revision;
};
in
''
__west2nix_copyProject ${src} ${path}
'')
manifest'.manifest.projects
);
# Project path for `west init -l ...`
path = manifest'.manifest.self.path or ".";
};
} ./project-hook.sh