elm: refactor file structure

This commit is contained in:
PedroHLC 2024-03-28 12:57:47 -03:00
parent a5b7a0ff37
commit ae5eab1bf1
No known key found for this signature in database
GPG Key ID: DF4C6898CBDC6DF5
33 changed files with 415 additions and 365 deletions

View File

@ -5,307 +5,52 @@
}:
let
fetchElmDeps = pkgs.callPackage ./fetchElmDeps.nix { };
fetchElmDeps = pkgs.callPackage ./lib/fetchElmDeps.nix { };
# Haskell packages that require ghc 9.6
hs96Pkgs = self: pkgs.haskell.packages.ghc96.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let elmPkgs = rec {
elm = overrideCabal (drv: {
# sadly with parallelism most of the time breaks compilation
enableParallelBuilding = false;
preConfigure = fetchElmDeps {
elmPackages = (import ./packages/elm-srcs.nix);
elmVersion = drv.version;
registryDat = ./registry.dat;
};
buildTools = drv.buildTools or [] ++ [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/elm \
--prefix PATH ':' ${lib.makeBinPath [ nodejs ]}
'';
description = "A delightful language for reliable webapps";
homepage = "https://elm-lang.org/";
license = licenses.bsd3;
maintainers = with maintainers; [ domenkozar turbomack ];
}) (self.callPackage ./packages/elm.nix { });
inherit fetchElmDeps;
elmVersion = elmPkgs.elm.version;
};
in elmPkgs // {
inherit elmPkgs;
ansi-wl-pprint = overrideCabal (drv: {
jailbreak = true;
}) (self.callPackage ./packages/ansi-wl-pprint.nix {});
};
};
hs96Pkgs = import ./packages/ghc9_6 { inherit pkgs lib makeWrapper nodejs fetchElmDeps; };
# Haskell packages that require ghc 8.10
hs810Pkgs = self: pkgs.haskell.packages.ghc810.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let elmPkgs = rec {
elmi-to-json = justStaticExecutables (overrideCabal (drv: {
prePatch = ''
substituteInPlace package.yaml --replace "- -Werror" ""
hpack
'';
jailbreak = true;
description = "Tool that reads .elmi files (Elm interface file) generated by the elm compiler";
homepage = "https://github.com/stoeffel/elmi-to-json";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
}) (self.callPackage ./packages/elmi-to-json.nix {}));
elm-instrument = justStaticExecutables (overrideCabal (drv: {
prePatch = ''
sed "s/desc <-.*/let desc = \"${drv.version}\"/g" Setup.hs --in-place
'';
jailbreak = true;
# Tests are failing because of missing instances for Eq and Show type classes
doCheck = false;
description = "Instrument Elm code as a preprocessing step for elm-coverage";
homepage = "https://github.com/zwilias/elm-instrument";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
}) (self.callPackage ./packages/elm-instrument.nix {}));
};
in elmPkgs // {
inherit elmPkgs;
# We need attoparsec < 0.14 to build elm for now
attoparsec = self.attoparsec_0_13_2_5;
# aeson 2.0.3.0 does not build with attoparsec_0_13_2_5
aeson = doJailbreak self.aeson_1_5_6_0;
# elm-instrument needs this
indents = self.callPackage ./packages/indents.nix {};
# elm-instrument's tests depend on an old version of elm-format, but we set doCheck to false for other reasons above
elm-format = null;
};
};
hs810Pkgs = import ./packages/ghc8_10 { inherit pkgs lib; };
# Haskell packages that require ghc 9.2
hs92Pkgs = self: pkgs.haskell.packages.ghc92.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let elmPkgs = rec {
/*
The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo:
`package/nix/build.sh`
hs92Pkgs = import ./packages/ghc9_2 { inherit pkgs lib; };
# Patched, originally npm-downloaded, packages
patchedNodePkgs = import ./packages/node { inherit pkgs lib nodejs makeWrapper; };
assembleScope = self: basics:
(hs96Pkgs self).elmPkgs // (hs92Pkgs self).elmPkgs // (hs810Pkgs self).elmPkgs // (patchedNodePkgs self) // basics;
in
lib.makeScope pkgs.newScope
(self: assembleScope self
(with self; {
inherit fetchElmDeps nodejs;
/* Node/NPM based dependencies can be upgraded using script `packages/generate-node-packages.sh`.
* Packages which rely on `bin-wrap` will fail by default
and can be patched using `patchBinwrap` function defined in `packages/lib.nix`.
* Packages which depend on npm installation of elm can be patched using
`patchNpmElm` function also defined in `packages/lib.nix`.
*/
elm-format = justStaticExecutables (overrideCabal (drv: {
jailbreak = true;
description = "Formats Elm source code according to a standard set of rules based on the official Elm Style Guide";
homepage = "https://github.com/avh4/elm-format";
license = licenses.bsd3;
maintainers = with maintainers; [ avh4 turbomack ];
}) (self.callPackage ./packages/elm-format.nix {}));
};
in elmPkgs // {
inherit elmPkgs;
# Needed for elm-format
avh4-lib = doJailbreak (self.callPackage ./packages/avh4-lib.nix {});
elm-format-lib = doJailbreak (self.callPackage ./packages/elm-format-lib.nix {});
elm-format-test-lib = self.callPackage ./packages/elm-format-test-lib.nix {};
elm-format-markdown = self.callPackage ./packages/elm-format-markdown.nix {};
# elm-format requires text >= 2.0
text = self.text_2_0_2;
# unorderd-container's tests indirectly depend on text < 2.0
unordered-containers = overrideCabal (drv: { doCheck = false; }) super.unordered-containers;
# relude-1.1.0.0's tests depend on hedgehog < 1.2, which indirectly depends on text < 2.0
relude = overrideCabal (drv: { doCheck = false; }) super.relude;
};
};
nodePkgs = pkgs.callPackage ./packages/node-composition.nix {
inherit pkgs nodejs;
inherit (pkgs.stdenv.hostPlatform) system;
};
in lib.makeScope pkgs.newScope (self: with self; {
inherit fetchElmDeps nodejs;
/* Node/NPM based dependencies can be upgraded using script `packages/generate-node-packages.sh`.
* Packages which rely on `bin-wrap` will fail by default
and can be patched using `patchBinwrap` function defined in `packages/lib.nix`.
* Packages which depend on npm installation of elm can be patched using
`patchNpmElm` function also defined in `packages/lib.nix`.
*/
elmLib = let
hsElmPkgs = (hs810Pkgs self) // (hs96Pkgs self);
in import ./packages/lib.nix {
inherit lib;
inherit (pkgs) writeScriptBin stdenv;
inherit (hsElmPkgs.elmPkgs) elm;
};
elm-json = callPackage ./packages/elm-json.nix { };
elm-test-rs = callPackage ./packages/elm-test-rs.nix { };
elm-test = callPackage ./packages/elm-test.nix { };
} // (hs96Pkgs self).elmPkgs // (hs92Pkgs self).elmPkgs // (hs810Pkgs self).elmPkgs // (with elmLib; with (hs96Pkgs self).elmPkgs; {
elm-verify-examples = let
patched = patchBinwrap [elmi-to-json] nodePkgs.elm-verify-examples // {
meta = with lib; nodePkgs.elm-verify-examples.meta // {
description = "Verify examples in your docs";
homepage = "https://github.com/stoeffel/elm-verify-examples";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
in patched.override (old: {
preRebuild = (old.preRebuild or "") + ''
# This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
# in case of just this package
# TODO: investigate, same as for elm-coverage below
sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
'';
});
elm-coverage = let
patched = patchNpmElm (patchBinwrap [elmi-to-json] nodePkgs.elm-coverage);
in patched.override (old: {
# Symlink Elm instrument binary
preRebuild = (old.preRebuild or "") + ''
# Noop custom installation script
sed 's/\"install\".*/\"install\":\"echo no-op\"/g' --in-place package.json
# This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
# in case of just this package
# TODO: investigate
sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
'';
postInstall = (old.postInstall or "") + ''
mkdir -p unpacked_bin
ln -sf ${elm-instrument}/bin/elm-instrument unpacked_bin/elm-instrument
'';
meta = with lib; nodePkgs.elm-coverage.meta // {
description = "Work in progress - Code coverage tooling for Elm";
homepage = "https://github.com/zwilias/elm-coverage";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
});
create-elm-app = patchNpmElm
nodePkgs.create-elm-app // {
meta = with lib; nodePkgs.create-elm-app.meta // {
description = "Create Elm apps with no build configuration";
homepage = "https://github.com/halfzebra/create-elm-app";
license = licenses.mit;
maintainers = [ maintainers.turbomack ];
};
};
elm-graphql =
nodePkgs."@dillonkearns/elm-graphql" // {
meta = with lib; nodePkgs."@dillonkearns/elm-graphql".meta // {
description = " Autogenerate type-safe GraphQL queries in Elm.";
license = licenses.bsd3;
maintainers = [ maintainers.pedrohlc ];
};
};
elm-review =
nodePkgs.elm-review // {
meta = with lib; nodePkgs.elm-review.meta // {
description = "Analyzes Elm projects, to help find mistakes before your users find them";
homepage = "https://package.elm-lang.org/packages/jfmengels/elm-review/${nodePkgs.elm-review.version}";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
elm-language-server = nodePkgs."@elm-tooling/elm-language-server" // {
meta = with lib; nodePkgs."@elm-tooling/elm-language-server".meta // {
description = "Language server implementation for Elm";
homepage = "https://github.com/elm-tooling/elm-language-server";
license = licenses.mit;
maintainers = [ maintainers.turbomack ];
};
};
elm-spa = nodePkgs."elm-spa".overrideAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
meta = with lib; nodePkgs."elm-spa".meta // {
description = "A tool for building single page apps in Elm";
homepage = "https://www.elm-spa.dev/";
license = licenses.bsd3;
maintainers = [ maintainers.ilyakooo0 ];
};
}
);
elm-optimize-level-2 = nodePkgs."elm-optimize-level-2" // {
meta = with lib; nodePkgs."elm-optimize-level-2".meta // {
description = "A second level of optimization for the Javascript that the Elm Compiler produces";
homepage = "https://github.com/mdgriffith/elm-optimize-level-2";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
elm-pages = nodePkgs."elm-pages".overrideAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
# can't use `patches = [ <patch_file> ]` with a nodePkgs derivation;
# need to patch in one of the build phases instead.
# see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
preFixup = ''
patch $out/lib/node_modules/elm-pages/generator/src/codegen.js ${./packages/elm-pages-fix-read-only.patch}
patch $out/lib/node_modules/elm-pages/generator/src/init.js ${./packages/elm-pages-fix-init-read-only.patch}
'';
postFixup = ''
wrapProgram $out/bin/elm-pages --prefix PATH : ${
with pkgs.elmPackages; lib.makeBinPath [ elm elm-review elm-optimize-level-2 ]
}
'';
meta = with lib; nodePkgs."elm-pages".meta // {
description = "A statically typed site generator for Elm.";
homepage = "https://github.com/dillonkearns/elm-pages";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack maintainers.jali-clarke ];
};
}
);
elm-land =
elmLib =
let
patched = patchNpmElm nodePkgs.elm-land;
hsElmPkgs = (hs810Pkgs self) // (hs96Pkgs self);
in
patched.override (old: {
meta = with lib; nodePkgs."elm-land".meta // {
description = "A production-ready framework for building Elm applications.";
homepage = "https://elm.land/";
license = licenses.bsd3;
maintainers = [ maintainers.zupo ];
};
}
);
import ./lib {
inherit lib;
inherit (pkgs) writeScriptBin stdenv;
inherit (self) elm;
};
lamdera = callPackage ./packages/lamdera.nix {};
elm-json = callPackage ./packages/elm-json { };
elm-doc-preview = nodePkgs."elm-doc-preview".overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ old.nodejs.pkgs.node-gyp-build ];
});
elm-test-rs = callPackage ./packages/elm-test-rs { };
inherit (nodePkgs) elm-live elm-upgrade elm-xref elm-analyse elm-git-install;
elm-test = callPackage ./packages/elm-test { };
lamdera = callPackage ./packages/lamdera { };
})
)

View File

@ -0,0 +1,41 @@
{ stdenv, lib, fetchurl, registryDat }:
ver: deps:
let
cmds = lib.mapAttrsToList
(name: info:
let
pkg = stdenv.mkDerivation {
name = lib.replaceStrings [ "/" ] [ "-" ] name + "-${info.version}";
src = fetchurl {
url = "https://github.com/${name}/archive/${info.version}.tar.gz";
meta.homepage = "https://github.com/${name}/";
inherit (info) sha256;
};
configurePhase = ''
true
'';
buildPhase = ''
true
'';
installPhase = ''
mkdir -p $out
cp -r * $out
'';
};
in
''
mkdir -p .elm/${ver}/packages/${name}
cp -R ${pkg} .elm/${ver}/packages/${name}/${info.version}
'')
deps;
in
(lib.concatStrings cmds) + ''
mkdir -p .elm/${ver}/packages;
cp ${registryDat} .elm/${ver}/packages/registry.dat;
chmod -R +w .elm
''

View File

@ -1,35 +0,0 @@
{stdenv, lib, fetchurl, registryDat}:
ver: deps:
let cmds = lib.mapAttrsToList (name: info: let
pkg = stdenv.mkDerivation {
name = lib.replaceStrings ["/"] ["-"] name + "-${info.version}";
src = fetchurl {
url = "https://github.com/${name}/archive/${info.version}.tar.gz";
meta.homepage = "https://github.com/${name}/";
inherit (info) sha256;
};
configurePhase = ''
true
'';
buildPhase = ''
true
'';
installPhase = ''
mkdir -p $out
cp -r * $out
'';
};
in ''
mkdir -p .elm/${ver}/packages/${name}
cp -R ${pkg} .elm/${ver}/packages/${name}/${info.version}
'') deps;
in (lib.concatStrings cmds) + ''
mkdir -p .elm/${ver}/packages;
cp ${registryDat} .elm/${ver}/packages/registry.dat;
chmod -R +w .elm
''

View File

@ -1,15 +0,0 @@
{ mkDerivation, base, containers, exceptions, lib, QuickCheck
, template-haskell
}:
mkDerivation {
pname = "bimap";
version = "0.3.3";
sha256 = "73829355c7bcbd3eedba22a382a04a3ab641702b00828790ec082ec2db3a8ad1";
libraryHaskellDepends = [ base containers exceptions ];
testHaskellDepends = [
base containers exceptions QuickCheck template-haskell
];
homepage = "https://github.com/joelwilliamson/bimap";
description = "Bidirectional mapping between two key types";
license = lib.licenses.bsd3;
}

View File

@ -17,12 +17,13 @@ rustPlatform.buildRustPackage rec {
sha256 = "sha256:nlpxlPzWk3wwDgczuMI9T6DFY1YtQpQ1R4BhdPbzZBs=";
};
cargoPatches = [ ./elm-json.patch ];
cargoPatches = [ ./use-system-ssl.patch ];
nativeBuildInputs = [ pkg-config ];
buildInputs = [
curl openssl
curl
openssl
] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
cargoSha256 = "sha256:8SOpL8nfhYen9vza0LYpB/5fgVmBwG7vGMmFOaJskIc=";

View File

@ -0,0 +1,54 @@
{ pkgs, lib }:
self: pkgs.haskell.packages.ghc810.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let
elmPkgs = rec {
elmi-to-json = justStaticExecutables (overrideCabal
(drv: {
prePatch = ''
substituteInPlace package.yaml --replace "- -Werror" ""
hpack
'';
jailbreak = true;
description = "Tool that reads .elmi files (Elm interface file) generated by the elm compiler";
homepage = "https://github.com/stoeffel/elmi-to-json";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
})
(self.callPackage ./elmi-to-json { }));
elm-instrument = justStaticExecutables (overrideCabal
(drv: {
prePatch = ''
sed "s/desc <-.*/let desc = \"${drv.version}\"/g" Setup.hs --in-place
'';
jailbreak = true;
# Tests are failing because of missing instances for Eq and Show type classes
doCheck = false;
description = "Instrument Elm code as a preprocessing step for elm-coverage";
homepage = "https://github.com/zwilias/elm-instrument";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
})
(self.callPackage ./elm-instrument { }));
};
in
elmPkgs // {
inherit elmPkgs;
# We need attoparsec < 0.14 to build elm for now
attoparsec = self.attoparsec_0_13_2_5;
# aeson 2.0.3.0 does not build with attoparsec_0_13_2_5
aeson = doJailbreak self.aeson_1_5_6_0;
# elm-instrument needs this
indents = self.callPackage ./indents { };
# elm-instrument's tests depend on an old version of elm-format, but we set doCheck to false for other reasons above
elm-format = null;
};
}

View File

@ -1,13 +1,13 @@
{ mkDerivation, fetchpatch, ansi-terminal, ansi-wl-pprint, base, binary
{ mkDerivation, ansi-terminal, ansi-wl-pprint, base, binary
, bytestring, Cabal, cmark, containers, directory, elm-format
, fetchgit, filepath, free, HUnit, indents, json, mtl
, fetchgit, filepath, free, HUnit, indents, json, lib, mtl
, optparse-applicative, parsec, process, QuickCheck, quickcheck-io
, split, lib, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
, text
, split, tasty, tasty-golden, tasty-hunit, tasty-quickcheck, text
, fetchpatch
}:
mkDerivation {
pname = "elm-instrument";
version = "0.0.7";
version = "unstable-2020-03-16";
src = fetchgit {
url = "https://github.com/zwilias/elm-instrument";
sha256 = "167d7l2547zxdj7i60r6vazznd9ichwc0bqckh3vrh46glkz06jv";

View File

@ -1,15 +1,15 @@
{ mkDerivation, aeson, base, binary, bytestring, containers
, directory, fetchgit, filepath, ghc-prim, hpack
, optparse-applicative, lib, text, unliftio
, unordered-containers
, directory, fetchgit, filepath, ghc-prim, hpack, lib
, optparse-applicative, text, unliftio, unordered-containers
}:
mkDerivation {
pname = "elmi-to-json";
version = "1.3.0";
version = "unstable-2021-07-19";
src = fetchgit {
url = "https://github.com/stoeffel/elmi-to-json";
hash = "sha256-9fScXRSyTkqzeXwh/Jjza6mnENCThlU6KI366CLFcgY=";
rev = "bd18efb59d247439b362272b480e67a16a4e424e";
sha256 = "sha256-9fScXRSyTkqzeXwh/Jjza6mnENCThlU6KI366CLFcgY=";
fetchSubmodules = true;
};
isLibrary = true;
isExecutable = true;
@ -23,4 +23,5 @@ mkDerivation {
prePatch = "hpack";
homepage = "https://github.com/stoeffel/elmi-to-json#readme";
license = lib.licenses.bsd3;
mainProgram = "elmi-to-json";
}

View File

@ -0,0 +1,39 @@
{ pkgs, lib }:
self: pkgs.haskell.packages.ghc92.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let
elmPkgs = rec {
/*
The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo:
`package/nix/build.sh`
*/
elm-format = justStaticExecutables (overrideCabal
(drv: {
jailbreak = true;
description = "Formats Elm source code according to a standard set of rules based on the official Elm Style Guide";
homepage = "https://github.com/avh4/elm-format";
license = licenses.bsd3;
maintainers = with maintainers; [ avh4 turbomack ];
})
(self.callPackage ./elm-format/elm-format.nix { }));
};
in
elmPkgs // {
inherit elmPkgs;
# Needed for elm-format
avh4-lib = doJailbreak (self.callPackage ./elm-format/avh4-lib.nix { });
elm-format-lib = doJailbreak (self.callPackage ./elm-format/elm-format-lib.nix { });
elm-format-test-lib = self.callPackage ./elm-format/elm-format-test-lib.nix { };
elm-format-markdown = self.callPackage ./elm-format/elm-format-markdown.nix { };
# elm-format requires text >= 2.0
text = self.text_2_0_2;
# unorderd-container's tests indirectly depend on text < 2.0
unordered-containers = overrideCabal (drv: { doCheck = false; }) super.unordered-containers;
# relude-1.1.0.0's tests depend on hedgehog < 1.2, which indirectly depends on text < 2.0
relude = overrideCabal (drv: { doCheck = false; }) super.relude;
};
}

View File

@ -12,7 +12,6 @@ mkDerivation {
fetchSubmodules = true;
};
postUnpack = "sourceRoot+=/avh4-lib; echo source root reset to $sourceRoot";
configureFlags = [ "--ghc-option=-Wno-error=unused-packages" ];
libraryHaskellDepends = [
array base bytestring directory filepath mtl pooled-io process
relude text
@ -22,7 +21,10 @@ mkDerivation {
relude tasty tasty-hspec tasty-hunit text
];
testToolDepends = [ tasty-discover ];
doHaddock = false;
description = "Common code for haskell projects";
license = lib.licenses.bsd3;
# Added manually
configureFlags = [ "--ghc-option=-Wno-error=unused-packages" ];
doHaddock = false;
}

View File

@ -24,7 +24,9 @@ mkDerivation {
text
];
testToolDepends = [ tasty-discover ];
doHaddock = false;
description = "Common code used by elm-format and elm-refactor";
license = lib.licenses.bsd3;
# Added manually
doHaddock = false;
}

View File

@ -10,7 +10,9 @@ mkDerivation {
};
postUnpack = "sourceRoot+=/elm-format-markdown; echo source root reset to $sourceRoot";
libraryHaskellDepends = [ base containers mtl text ];
doHaddock = false;
description = "Markdown parsing for Elm documentation comments";
license = lib.licenses.bsd3;
# Added manually
doHaddock = false;
}

View File

@ -21,7 +21,9 @@ mkDerivation {
split tasty tasty-hspec tasty-hunit text
];
testToolDepends = [ tasty-discover ];
doHaddock = false;
description = "Test helpers used by elm-format-tests and elm-refactor-tests";
license = lib.licenses.bsd3;
# Added manually
doHaddock = false;
}

View File

@ -24,16 +24,17 @@ mkDerivation rec {
quickcheck-io relude tasty tasty-hspec tasty-hunit tasty-quickcheck
text
];
doHaddock = false;
homepage = "https://elm-lang.org";
description = "A source code formatter for Elm";
license = lib.licenses.bsd3;
mainProgram = "elm-format";
# Added manually (and "rec" above)
doHaddock = false;
postPatch = ''
mkdir -p ./generated
cat <<EOHS > ./generated/Build_elm_format.hs
module Build_elm_format where
gitDescribe :: String
gitDescribe = "${version}"
EOHS

View File

@ -0,0 +1,42 @@
{ pkgs, lib, makeWrapper, nodejs, fetchElmDeps }:
self: pkgs.haskell.packages.ghc96.override {
overrides = self: super: with pkgs.haskell.lib.compose; with lib;
let
elmPkgs = rec {
elm = overrideCabal
(drv: {
# sadly with parallelism most of the time breaks compilation
enableParallelBuilding = false;
preConfigure = fetchElmDeps {
elmPackages = (import ../elm-srcs.nix);
elmVersion = drv.version;
registryDat = ../../registry.dat;
};
buildTools = drv.buildTools or [ ] ++ [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/elm \
--prefix PATH ':' ${lib.makeBinPath [ nodejs ]}
'';
description = "A delightful language for reliable webapps";
homepage = "https://elm-lang.org/";
license = licenses.bsd3;
maintainers = with maintainers; [ domenkozar turbomack ];
})
(self.callPackage ./elm { });
inherit fetchElmDeps;
elmVersion = elmPkgs.elm.version;
};
in
elmPkgs // {
inherit elmPkgs;
ansi-wl-pprint = overrideCabal
(drv: {
jailbreak = true;
})
(self.callPackage ./ansi-wl-pprint { });
};
}

View File

@ -0,0 +1,139 @@
{ pkgs, lib, nodejs, makeWrapper }: self:
let
# Untouched npm-downloaded packages
nodePkgs = pkgs.callPackage ./node-composition.nix {
inherit pkgs nodejs;
inherit (pkgs.stdenv.hostPlatform) system;
};
in
with self; with elmLib; {
inherit (nodePkgs) elm-live elm-upgrade elm-xref elm-analyse elm-git-install;
elm-verify-examples =
let
patched = patchBinwrap [ elmi-to-json ] nodePkgs.elm-verify-examples // {
meta = with lib; nodePkgs.elm-verify-examples.meta // {
description = "Verify examples in your docs";
homepage = "https://github.com/stoeffel/elm-verify-examples";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
in
patched.override (old: {
preRebuild = (old.preRebuild or "") + ''
# This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
# in case of just this package
# TODO: investigate, same as for elm-coverage below
sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
'';
});
elm-coverage =
let
patched = patchNpmElm (patchBinwrap [ elmi-to-json ] nodePkgs.elm-coverage);
in
patched.override (old: {
# Symlink Elm instrument binary
preRebuild = (old.preRebuild or "") + ''
# Noop custom installation script
sed 's/\"install\".*/\"install\":\"echo no-op\"/g' --in-place package.json
# This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
# in case of just this package
# TODO: investigate
sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
'';
postInstall = (old.postInstall or "") + ''
mkdir -p unpacked_bin
ln -sf ${elm-instrument}/bin/elm-instrument unpacked_bin/elm-instrument
'';
meta = with lib; nodePkgs.elm-coverage.meta // {
description = "Work in progress - Code coverage tooling for Elm";
homepage = "https://github.com/zwilias/elm-coverage";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
});
create-elm-app = patchNpmElm
nodePkgs.create-elm-app // {
meta = with lib; nodePkgs.create-elm-app.meta // {
description = "Create Elm apps with no build configuration";
homepage = "https://github.com/halfzebra/create-elm-app";
license = licenses.mit;
maintainers = [ maintainers.turbomack ];
};
};
elm-graphql =
nodePkgs."@dillonkearns/elm-graphql" // {
meta = with lib; nodePkgs."@dillonkearns/elm-graphql".meta // {
description = " Autogenerate type-safe GraphQL queries in Elm.";
license = licenses.bsd3;
maintainers = [ maintainers.pedrohlc ];
};
};
elm-review =
nodePkgs.elm-review // {
meta = with lib; nodePkgs.elm-review.meta // {
description = "Analyzes Elm projects, to help find mistakes before your users find them";
homepage = "https://package.elm-lang.org/packages/jfmengels/elm-review/${nodePkgs.elm-review.version}";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
elm-language-server = nodePkgs."@elm-tooling/elm-language-server" // {
meta = with lib; nodePkgs."@elm-tooling/elm-language-server".meta // {
description = "Language server implementation for Elm";
homepage = "https://github.com/elm-tooling/elm-language-server";
license = licenses.mit;
maintainers = [ maintainers.turbomack ];
};
};
elm-spa = nodePkgs."elm-spa".overrideAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
meta = with lib; nodePkgs."elm-spa".meta // {
description = "A tool for building single page apps in Elm";
homepage = "https://www.elm-spa.dev/";
license = licenses.bsd3;
maintainers = [ maintainers.ilyakooo0 ];
};
}
);
elm-optimize-level-2 = nodePkgs."elm-optimize-level-2" // {
meta = with lib; nodePkgs."elm-optimize-level-2".meta // {
description = "A second level of optimization for the Javascript that the Elm Compiler produces";
homepage = "https://github.com/mdgriffith/elm-optimize-level-2";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack ];
};
};
elm-pages = import ./elm-pages { inherit nodePkgs pkgs lib makeWrapper; };
elm-land =
let
patched = patchNpmElm nodePkgs.elm-land;
in
patched.override (old: {
meta = with lib; nodePkgs."elm-land".meta // {
description = "A production-ready framework for building Elm applications.";
homepage = "https://elm.land/";
license = licenses.bsd3;
maintainers = [ maintainers.zupo ];
};
}
);
elm-doc-preview = nodePkgs."elm-doc-preview".overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ old.nodejs.pkgs.node-gyp-build ];
});
}

View File

@ -0,0 +1,28 @@
{ nodePkgs, pkgs, lib, makeWrapper }:
nodePkgs."elm-pages".overrideAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
# can't use `patches = [ <patch_file> ]` with a nodePkgs derivation;
# need to patch in one of the build phases instead.
# see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
preFixup = ''
patch $out/lib/node_modules/elm-pages/generator/src/codegen.js ${./fix-read-only.patch}
patch $out/lib/node_modules/elm-pages/generator/src/init.js ${./fix-init-read-only.patch}
'';
postFixup = ''
wrapProgram $out/bin/elm-pages --prefix PATH : ${
with pkgs.elmPackages; lib.makeBinPath [ elm elm-review elm-optimize-level-2 ]
}
'';
meta = with lib; nodePkgs."elm-pages".meta // {
description = "A statically typed site generator for Elm.";
homepage = "https://github.com/dillonkearns/elm-pages";
license = licenses.bsd3;
maintainers = [ maintainers.turbomack maintainers.jali-clarke ];
};
}
)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../../..)"
ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../../../..)"
set -eu -o pipefail
@ -9,4 +9,4 @@ $(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
-i node-packages.json \
-o node-packages.nix \
-c node-composition.nix \
--no-copy-node-env -e ../../../node-packages/node-env.nix
--no-copy-node-env -e ../../../../node-packages/node-env.nix

View File

@ -5,7 +5,7 @@
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_18"}:
let
nodeEnv = import ../../../node-packages/node-env.nix {
nodeEnv = import ../../../../node-packages/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;

View File

@ -1,13 +1,13 @@
#!/usr/bin/env nix-shell
#!nix-shell -p cabal2nix elm2nix -i bash ../../..
cabal2nix https://github.com/ekmett/ansi-wl-pprint --revision d16e2f6896d76b87b72af7220c2e93ba15c53280 > packages/ansi-wl-pprint.nix
cabal2nix https://github.com/ekmett/ansi-wl-pprint --revision d16e2f6896d76b87b72af7220c2e93ba15c53280 > packages/ghc9_6/ansi-wl-pprint/default.nix
# We're building binaries from commit that npm installer is using since
# November 1st release called 0.19.1-6 in npm registry.
# These binaries are built with newer ghc version and also support Aarch64 for Linux and Darwin.
# Upstream git tag for 0.19.1 is still pointing to original commit from 2019.
cabal2nix https://github.com/elm/compiler --revision 2f6dd29258e880dbb7effd57a829a0470d8da48b > packages/elm.nix
cabal2nix https://github.com/elm/compiler --revision 2f6dd29258e880dbb7effd57a829a0470d8da48b > packages/ghc9_6/elm/default.nix
echo "need to manually copy registry.dat from an existing elm project"
#elm2nix snapshot > registry.dat