Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #315

Merged
merged 5 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fetchers/combined-fetcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down
4 changes: 0 additions & 4 deletions src/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
recursiveUpdateUntilDepth
simpleTranslate2
translators
sanitizeDerivationName
sanitizePath
sanitizeRelativePath
subsystems
Expand Down Expand Up @@ -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}"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in {
translateBin = {
# dream2nix utils
utils,
# nixpkgs dependenies
# nixpkgs dependencies
bash,
coreutils,
jq,
Expand Down
18 changes: 8 additions & 10 deletions src/subsystems/haskell/builders/simple-haskell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -119,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;

Expand Down Expand Up @@ -173,6 +171,6 @@ in {
# apply packageOverrides to current derivation
produceDerivation name pkg;
in {
inherit defaultPackage packages;
inherit packages;
};
}
2 changes: 0 additions & 2 deletions src/subsystems/nodejs/builders/granular-nodejs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
})
args.packages);

devShell = devShells.default;

devShells =
{default = devShells.${defaultPackageName};}
// (
Expand Down
11 changes: 5 additions & 6 deletions src/subsystems/nodejs/discoverers/default/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/nodejs/translators/npm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
apps,
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
bash,
coreutils,
git,
Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/nodejs/translators/package-json/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# dream2nix utils
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
bash,
coreutils,
git,
Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/php/translators/composer-json/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# dream2nix utils
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
bash,
coreutils,
moreutils,
Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/php/translators/packagist/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
apps,
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
coreutils,
curl,
jq,
Expand Down
1 change: 0 additions & 1 deletion src/subsystems/python/builders/simple-python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,5 @@
in {
packages.${defaultPackageName}.${defaultPackageVersion} = package;
devShells.${defaultPackageName} = devShell;
inherit devShell;
};
}
2 changes: 1 addition & 1 deletion src/subsystems/rust/translators/cargo-toml/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# dream2nix utils
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
coreutils,
jq,
rustPlatform,
Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/rust/translators/crates-io/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
apps,
subsystems,
utils,
# nixpkgs dependenies
# nixpkgs dependencies
coreutils,
curl,
gnutar,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/translators/impure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ in {
translateBin = {
# dream2nix utils
utils,
# nixpkgs dependenies
# nixpkgs dependencies
bash,
coreutils,
jq,
Expand Down
36 changes: 17 additions & 19 deletions src/templates/translators/pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
1 change: 0 additions & 1 deletion src/utils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ in
parseGitUrl
readTextFile
recursiveUpdateUntilDepth
sanitizeDerivationName
traceJ
;

Expand Down