mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-11 20:28:07 +03:00
05167f7e6f
* feat: add translate and shell commands * feat: add indexer modules * feat(nodejs): add a basic npm indexer * feat: add an index app for indexing using an indexer * feat(rust): add crates-io indexer * refactor: use configFile in more places * feat: implement translate-index app * refactor: move indexers out of subsystems since they aren't subsystem specific * fix: discard string context for config text * docs: add a preliminary document for indexers * docs: add examples for crates-io and npm indexer inputs * feat: add support for setting sourceRoot in dream-lock, fix translate source patching * fix: don't discard context from config passed as text * fix: remove duplicate resolves * fix: shell command * refactor: remove useless nix calls, improve the apps * feat: improve cli apps UX, implement runNixCmdInSrc, remove shell * docs: more comments * feat: add generatePackagesFromLocksTree util * fix: pass args to generatePackagesFromDreamLocks correctly * Update indexers.md * chore: remove license from crates-io indexer * fix: pass config loaded from env vars to loadConfig * refactor: don't expose dream2nix internally * feat: add makeOutputsForIndexes utility * refactor: make make(Flake)OutputsForIndexes interface consistent with make(Flake)Outputs * fix: allow passing pkgs to makeFlakeOutputsForIndexes * fix: remove unused code * fix: rename var to expected name * refactor(utils/index): improve and fix overrideOutputs arg * fix(utils/index): actually pass prev outputs to overrideOutputs * refactor: patch all sources instead of using a seperate field in dream lock * fix(utils/index): use .program to access the program * fix: correct jq command in translate app * refactor: improve translate app performance * feat: add crates-io-simple indexer * fix(apps/translate): only set dir if relPath is set * fix(apps/callNixWithD2N): pin nixpkgs * fix: unloaded config passed to dlib * refactor: rewrite root source patching in nix * tests: add a unit test for replace root sources Co-authored-by: DavHau <hsngrmpf+github@gmail.com>
57 lines
1.1 KiB
Python
57 lines
1.1 KiB
Python
import pytest
|
|
import nix_ffi
|
|
|
|
exampleDreamLock = dict(
|
|
_generic = dict(
|
|
defaultPackage="example",
|
|
packages=dict(
|
|
example="1.2.3",
|
|
),
|
|
subsystem = "nodejs",
|
|
_subsystemAttrs = {},
|
|
),
|
|
dependencies = {},
|
|
cyclicDependencies = {},
|
|
sources = dict(
|
|
example = {
|
|
"1.2.3": dict(
|
|
type = "path",
|
|
rootName = None,
|
|
rootVersion = None,
|
|
relPath = "a/b/c",
|
|
),
|
|
},
|
|
),
|
|
)
|
|
|
|
def test_dream_lock_inject():
|
|
result = nix_ffi.callNixFunction(
|
|
'utils.dreamLock.injectDependencies',
|
|
dreamLock=exampleDreamLock,
|
|
inject=dict(
|
|
example={
|
|
"1.2.3": [
|
|
[ "injected-package", "1.0.0" ]
|
|
]
|
|
}
|
|
),
|
|
)
|
|
assert result['dependencies']['example']['1.2.3'] == [dict(
|
|
name="injected-package",
|
|
version="1.0.0",
|
|
)]
|
|
|
|
def test_dream_lock_replace_root_sources():
|
|
result = nix_ffi.callNixFunction(
|
|
'utils.dreamLock.replaceRootSources',
|
|
dreamLock=exampleDreamLock,
|
|
newSourceRoot=dict(
|
|
type = "http",
|
|
url = "something",
|
|
),
|
|
)
|
|
assert result['sources']['example']['1.2.3'] == dict(
|
|
type = "http",
|
|
url = "something",
|
|
dir = "a/b/c",
|
|
) |