Something went wrong. Try again.
flake for building a declarative fusesoc dev environment
Something went wrong. Try again.
3.5 kB · 121 lines
Nix
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122{ fetchProvider, formats, lib, mkRunners, parseVlnv, readYAML, resolveDeps, stdenvNoCC, stripCond,}:lib.extendMkDerivation { constructDrv = stdenvNoCC.mkDerivation; excludeDrvArgNames = [ ]; extendDrvArgs = finalAttrs: { coreRoot, coreName, core ? (readYAML "${coreRoot}/${coreName}"), patches ? [ ], providerHash ? "", preservePaths ? [ ], tools ? [ ], dependencies ? [ ], passthru ? { }, }: let parsed = parseVlnv finalAttrs.passthru.core.name; coreFileset = (builtins.concatLists ( lib.mapAttrsToList ( n: v: map ( entry: stripCond (if builtins.isAttrs entry then (builtins.head (builtins.attrNames entry)) else entry) ) (v.files or [ ]) ) (finalAttrs.passthru.core.filesets or { }) )) ++ finalAttrs.passthru.preservePaths; useProvider = let inherit (finalAttrs.passthru) core; in (builtins.hasAttr "provider" core) && (core.provider.name != "local"); in { pname = let opt = str: lib.optional (str != "") str; mapOpts = strs: builtins.concatLists (map opt strs); in with parsed; lib.concatStringsSep "_" (mapOpts [ vendor library name ]); inherit (finalAttrs.passthru.parsed) version; passthru = passthru // { withTools = toolList: finalAttrs.finalPackage.overrideAttrs ( final: prev: { passthru = prev.passthru // { tools = prev.passthru.tools ++ toolList; }; } ); linkWith = coreSet: finalAttrs.finalPackage.overrideAttrs ( final: prev: { passthru = prev.passthru // { dependencies = resolveDeps finalAttrs.finalPackage coreSet; }; } ); list = builtins.sort (p: q: lib.versionOlder q.version p.version) ( lib.mapAttrsToList (_: v: v) ( lib.filterAttrs (n: _: !(isNull (builtins.match "^[[:digit:]]+.*$" n))) ( { ${finalAttrs.passthru.parsed.version} = finalAttrs.finalPackage; } // finalAttrs.passthru ) ) ); inherit dependencies parsed preservePaths tools core ; run = mkRunners { inherit (finalAttrs.passthru) core tools; dependencies = finalAttrs.passthru.dependencies ++ [ finalAttrs.finalPackage ]; }; }; phases = [ "unpackPhase" "patchPhase" "installPhase" ]; patches = patches ++ (map (patch: "${coreRoot}/${patch}") (finalAttrs.passthru.core.provider.patches or [ ])); src = if useProvider then fetchProvider finalAttrs.passthru.core providerHash else coreRoot; installPhase = let patchedCore = removeAttrs finalAttrs.passthru.core [ "provider" ]; in '' mkdir -p $out/ ${lib.concatStringsSep "\n" ( map (file: '' mkdir -p $out/${dirOf file} cp ${file} $out/${file} '') coreFileset )} cp ${(formats.yaml_1_2 { }).generate coreName patchedCore} $out/${coreName} ''; };}