diff --git a/packages/zephyr/default.nix b/packages/zephyr/default.nix index 76987a6..3a1b32c 100644 --- a/packages/zephyr/default.nix +++ b/packages/zephyr/default.nix @@ -2,6 +2,7 @@ let assets = lib.importJSON ./assets.json; modules = lib.importJSON ./modules.json; + buildModule = module: callPackage ./module.nix { inherit module; }; in { host-tools = callPackage ./host-tools.nix { inherit (assets) version hosts; @@ -20,5 +21,5 @@ in { }; src = fetchFromGitHub modules.zephyr; - modules = lib.mapAttrs (_: fetchFromGitHub) modules.modules; + modules = lib.mapAttrs (_: buildModule) modules.modules; } diff --git a/packages/zephyr/module.nix b/packages/zephyr/module.nix new file mode 100644 index 0000000..fd5a2f2 --- /dev/null +++ b/packages/zephyr/module.nix @@ -0,0 +1,17 @@ +{ stdenvNoCC, fetchFromGitHub, version ? null, module }: +let src = fetchFromGitHub module; +in stdenvNoCC.mkDerivation (finalAttrs: { + name = if version != null then + "${module.name}-wrapped-${version}" + else + "${module.name}-wrapped"; + + passthru.modulePath = "${finalAttrs.finalPackage.out}/${module.name}"; + + passAsFile = [ "buildCommand" ]; + buildCommand = '' + mkdir -p $out + ln -s "${src}" "$out/${module.name}" + ''; +}) + diff --git a/shells/zephyr/default.nix b/shells/zephyr/default.nix index 91cd3c6..9f6aac4 100644 --- a/shells/zephyr/default.nix +++ b/shells/zephyr/default.nix @@ -29,5 +29,6 @@ in mkShell ({ PATH="${zephyrSrc}/scripts:$PATH" ''; } // lib.optionalAttrs (modules != [ ]) { - ZEPHYR_MODULES = lib.concatStringsSep ";" (map (pkg: pkg.out) modules); + ZEPHYR_MODULES = + lib.concatStringsSep ";" (map (pkg: pkg.passthru.modulePath) modules); } // extraAttrs)