From 453af715eebd7102131d2cc6846dd23d49f853ac Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Mon, 13 Nov 2023 06:48:03 +0000 Subject: [PATCH] zephyr: Put modules in a subdirectory so zephyr doesn't get mad --- packages/zephyr/default.nix | 3 ++- packages/zephyr/module.nix | 17 +++++++++++++++++ shells/zephyr/default.nix | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 packages/zephyr/module.nix 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)