From 544c22bdbf28b61cc019eefb0d8434fdb59f2daa Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Wed, 28 Sep 2022 13:19:18 -0700 Subject: [PATCH 1/5] Fix spelling --- src/subsystems/debian/translators/debian-binary/default.nix | 2 +- src/subsystems/nodejs/translators/npm/default.nix | 2 +- src/subsystems/nodejs/translators/package-json/default.nix | 2 +- src/subsystems/php/translators/composer-json/default.nix | 2 +- src/subsystems/php/translators/packagist/default.nix | 2 +- src/subsystems/rust/translators/cargo-toml/default.nix | 2 +- src/subsystems/rust/translators/crates-io/default.nix | 2 +- src/templates/translators/impure.nix | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/subsystems/debian/translators/debian-binary/default.nix b/src/subsystems/debian/translators/debian-binary/default.nix index 44dc6b56f7..4000219940 100644 --- a/src/subsystems/debian/translators/debian-binary/default.nix +++ b/src/subsystems/debian/translators/debian-binary/default.nix @@ -21,7 +21,7 @@ in { translateBin = { # dream2nix utils utils, - # nixpkgs dependenies + # nixpkgs dependencies bash, coreutils, jq, diff --git a/src/subsystems/nodejs/translators/npm/default.nix b/src/subsystems/nodejs/translators/npm/default.nix index 5cc1af2181..157648c9e6 100644 --- a/src/subsystems/nodejs/translators/npm/default.nix +++ b/src/subsystems/nodejs/translators/npm/default.nix @@ -12,7 +12,7 @@ apps, subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies bash, coreutils, git, diff --git a/src/subsystems/nodejs/translators/package-json/default.nix b/src/subsystems/nodejs/translators/package-json/default.nix index 8c971823c0..ec8cfc3e2a 100644 --- a/src/subsystems/nodejs/translators/package-json/default.nix +++ b/src/subsystems/nodejs/translators/package-json/default.nix @@ -11,7 +11,7 @@ # dream2nix utils subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies bash, coreutils, git, diff --git a/src/subsystems/php/translators/composer-json/default.nix b/src/subsystems/php/translators/composer-json/default.nix index 1bda4dcd38..27fd4b3ff0 100644 --- a/src/subsystems/php/translators/composer-json/default.nix +++ b/src/subsystems/php/translators/composer-json/default.nix @@ -20,7 +20,7 @@ # dream2nix utils subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies bash, coreutils, moreutils, diff --git a/src/subsystems/php/translators/packagist/default.nix b/src/subsystems/php/translators/packagist/default.nix index 64df2e224c..1eabcf318f 100644 --- a/src/subsystems/php/translators/packagist/default.nix +++ b/src/subsystems/php/translators/packagist/default.nix @@ -12,7 +12,7 @@ apps, subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies coreutils, curl, jq, diff --git a/src/subsystems/rust/translators/cargo-toml/default.nix b/src/subsystems/rust/translators/cargo-toml/default.nix index 1b08cbee18..ea358f1343 100644 --- a/src/subsystems/rust/translators/cargo-toml/default.nix +++ b/src/subsystems/rust/translators/cargo-toml/default.nix @@ -11,7 +11,7 @@ # dream2nix utils subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies coreutils, jq, rustPlatform, diff --git a/src/subsystems/rust/translators/crates-io/default.nix b/src/subsystems/rust/translators/crates-io/default.nix index a8ea9f9fc2..c2a0c10377 100644 --- a/src/subsystems/rust/translators/crates-io/default.nix +++ b/src/subsystems/rust/translators/crates-io/default.nix @@ -12,7 +12,7 @@ apps, subsystems, utils, - # nixpkgs dependenies + # nixpkgs dependencies coreutils, curl, gnutar, diff --git a/src/templates/translators/impure.nix b/src/templates/translators/impure.nix index 74edcae73e..6be0e464dd 100644 --- a/src/templates/translators/impure.nix +++ b/src/templates/translators/impure.nix @@ -43,7 +43,7 @@ in { translateBin = { # dream2nix utils utils, - # nixpkgs dependenies + # nixpkgs dependencies bash, coreutils, jq, From 49b299ce80376ee8e1201c1370c2ea602a8ceec3 Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Wed, 28 Sep 2022 13:24:09 -0700 Subject: [PATCH 2/5] nodejs: discoverer read files from tree --- src/subsystems/nodejs/discoverers/default/default.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/subsystems/nodejs/discoverers/default/default.nix b/src/subsystems/nodejs/discoverers/default/default.nix index a2fe5bc90b..805f3d7a05 100644 --- a/src/subsystems/nodejs/discoverers/default/default.nix +++ b/src/subsystems/nodejs/discoverers/default/default.nix @@ -35,9 +35,8 @@ in childrenRemoved; - getTranslatorNames = path: let - nodes = l.readDir path; - packageJson = l.fromJSON (l.readFile "${path}/package.json"); + getTranslatorNames = tree: let + packageJson = tree.files."package.json".jsonContent; translators = # if the package has no dependencies we use the # package-lock translator with `packageLock = null` @@ -47,8 +46,8 @@ && (packageJson.workspaces or [] == []) then ["package-lock"] else - l.optionals (nodes ? "package-lock.json") ["package-lock"] - ++ l.optionals (nodes ? "yarn.lock") ["yarn-lock"] + l.optionals (tree.files ? "package-lock.json") ["package-lock"] + ++ l.optionals (tree.files ? "yarn.lock") ["yarn-lock"] ++ ["package-json"]; in translators; @@ -166,7 +165,7 @@ inherit subsystem; inherit (tree) relPath; name = tree.files."package.json".jsonContent.name or tree.relPath; - translators = getTranslatorNames tree.fullPath; + translators = getTranslatorNames tree; subsystemInfo = l.optionalAttrs (workspaces != []) { workspaces = l.map From 956fb6e8be3f72ba0c4a57f2eb3ffe6c7b020bed Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Wed, 28 Sep 2022 13:52:11 -0700 Subject: [PATCH 3/5] defaultPackage -> packages.default --- .../haskell/builders/simple-haskell/default.nix | 16 +++++++--------- .../nodejs/builders/granular-nodejs/default.nix | 2 -- .../python/builders/simple-python/default.nix | 1 - 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/subsystems/haskell/builders/simple-haskell/default.nix b/src/subsystems/haskell/builders/simple-haskell/default.nix index 2f8a4c84f3..86dfc66e01 100644 --- a/src/subsystems/haskell/builders/simple-haskell/default.nix +++ b/src/subsystems/haskell/builders/simple-haskell/default.nix @@ -64,16 +64,14 @@ in { }) subsystemAttrs.cabalHashes or {}; - # the main package - defaultPackage = allPackages."${defaultPackageName}"."${defaultPackageVersion}"; - # packages to export packages = - lib.mapAttrs - (name: version: { - "${version}" = allPackages.${name}.${version}; - }) - args.packages; + {default = packages.${defaultPackageName};} + // ( + lib.mapAttrs + (name: version: {"${version}" = allPackages.${name}.${version};}) + args.packages + ); # manage packages in attrset to prevent duplicated evaluation allPackages = @@ -173,6 +171,6 @@ in { # apply packageOverrides to current derivation produceDerivation name pkg; in { - inherit defaultPackage packages; + inherit packages; }; } diff --git a/src/subsystems/nodejs/builders/granular-nodejs/default.nix b/src/subsystems/nodejs/builders/granular-nodejs/default.nix index 7dd4ca7d6a..c9a8f4a535 100644 --- a/src/subsystems/nodejs/builders/granular-nodejs/default.nix +++ b/src/subsystems/nodejs/builders/granular-nodejs/default.nix @@ -75,8 +75,6 @@ }) args.packages); - devShell = devShells.default; - devShells = {default = devShells.${defaultPackageName};} // ( diff --git a/src/subsystems/python/builders/simple-python/default.nix b/src/subsystems/python/builders/simple-python/default.nix index 056b5d1af4..fd76c6b328 100644 --- a/src/subsystems/python/builders/simple-python/default.nix +++ b/src/subsystems/python/builders/simple-python/default.nix @@ -80,6 +80,5 @@ in { packages.${defaultPackageName}.${defaultPackageVersion} = package; devShells.${defaultPackageName} = devShell; - inherit devShell; }; } From 6c82d99b79d90c794b499ec1333ac388282aea05 Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Wed, 28 Sep 2022 13:53:45 -0700 Subject: [PATCH 4/5] fix: pure translator template, project is not list --- src/templates/translators/pure.nix | 36 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/templates/translators/pure.nix b/src/templates/translators/pure.nix index 63197fb2f5..0af133a76d 100644 --- a/src/templates/translators/pure.nix +++ b/src/templates/translators/pure.nix @@ -56,26 +56,24 @@ in /* A list of projects returned by `discoverProjects` Example: - [ - { - "dreamLockPath": "packages/optimism/dream-lock.json", - "name": "optimism", - "relPath": "", - "subsystem": "nodejs", - "subsystemInfo": { - "workspaces": [ - "packages/common-ts", - "packages/contracts", - "packages/core-utils", - ] - }, - "translator": "yarn-lock", - "translators": [ - "yarn-lock", - "package-json" + { + "dreamLockPath": "packages/optimism/dream-lock.json", + "name": "optimism", + "relPath": "", + "subsystem": "nodejs", + "subsystemInfo": { + "workspaces": [ + "packages/common-ts", + "packages/contracts", + "packages/core-utils", ] - } - ] + }, + "translator": "yarn-lock", + "translators": [ + "yarn-lock", + "package-json" + ] + } */ project, From d15d931bf9a1a7a3918c05d9f923cfe8f17e4f1c Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Wed, 28 Sep 2022 14:00:22 -0700 Subject: [PATCH 5/5] {utils -> lib.strings}.sanitizeDerivationName --- src/fetchers/combined-fetcher.nix | 6 +++--- src/lib/default.nix | 4 ---- src/subsystems/haskell/builders/simple-haskell/default.nix | 2 +- src/utils/default.nix | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/fetchers/combined-fetcher.nix b/src/fetchers/combined-fetcher.nix index 410b322e00..ef8e0f30f9 100644 --- a/src/fetchers/combined-fetcher.nix +++ b/src/fetchers/combined-fetcher.nix @@ -53,7 +53,7 @@ // { isOriginal = false; outPath = let - sanitizedName = utils.sanitizeDerivationName name; + sanitizedName = l.strings.sanitizeDerivationName name; in "${sanitizedName}/${version}/${fetched.name}"; } # handle already extracted sources @@ -63,7 +63,7 @@ // { isOriginal = true; outPath = let - sanitizedName = utils.sanitizeDerivationName name; + sanitizedName = l.strings.sanitizeDerivationName name; in "${sanitizedName}/${version}/${fetched.original.name}"; } # handle path sources @@ -219,7 +219,7 @@ in { then utils.extractSource { source = "${FODAllSources}/${FODArgsAll."${name}"."${version}".outPath}"; - name = dlib.sanitizeDerivationName name; + name = l.strings.sanitizeDerivationName name; } else "${FODAllSources}/${FODArgsAll."${name}"."${version}".outPath}" else defaultFetched."${name}"."${version}") diff --git a/src/lib/default.nix b/src/lib/default.nix index 16fb7b3437..de5fb9b67b 100644 --- a/src/lib/default.nix +++ b/src/lib/default.nix @@ -26,7 +26,6 @@ recursiveUpdateUntilDepth simpleTranslate2 translators - sanitizeDerivationName sanitizePath sanitizeRelativePath subsystems @@ -280,9 +279,6 @@ recursiveUpdateUntilDepth = depth: lhs: rhs: lib.recursiveUpdateUntil (path: _: _: (l.length path) > depth) lhs rhs; - sanitizeDerivationName = name: - lib.replaceStrings ["@" "/"] ["__at__" "__slash__"] name; - sanitizeRelativePath = path: l.removePrefix "/" (l.toString (l.toPath "/${path}")); diff --git a/src/subsystems/haskell/builders/simple-haskell/default.nix b/src/subsystems/haskell/builders/simple-haskell/default.nix index 86dfc66e01..bb6a8fbf17 100644 --- a/src/subsystems/haskell/builders/simple-haskell/default.nix +++ b/src/subsystems/haskell/builders/simple-haskell/default.nix @@ -117,7 +117,7 @@ in { # Generates a derivation for a specific package name + version makeOnePackage = name: version: let pkg = compiler.mkDerivation (rec { - pname = utils.sanitizeDerivationName name; + pname = l.strings.sanitizeDerivationName name; inherit version; license = null; diff --git a/src/utils/default.nix b/src/utils/default.nix index f06ecd026e..05a0d4be94 100644 --- a/src/utils/default.nix +++ b/src/utils/default.nix @@ -65,7 +65,6 @@ in parseGitUrl readTextFile recursiveUpdateUntilDepth - sanitizeDerivationName traceJ ;