diff --git a/spaghetto/.gitignore b/spaghetto/.gitignore index 1243a4692..973093bbe 100644 --- a/spaghetto/.gitignore +++ b/spaghetto/.gitignore @@ -12,3 +12,4 @@ /bin/bundle.js .direnv *.node +result \ No newline at end of file diff --git a/spaghetto/flake.lock b/spaghetto/flake.lock index 035c32f8c..1ffa37664 100644 --- a/spaghetto/flake.lock +++ b/spaghetto/flake.lock @@ -1,5 +1,39 @@ { "nodes": { + "all-cabal-json": { + "flake": false, + "locked": { + "lastModified": 1665552503, + "narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=", + "owner": "nix-community", + "repo": "all-cabal-json", + "rev": "d7c0434eebffb305071404edcf9d5cd99703878e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "hackage", + "repo": "all-cabal-json", + "type": "github" + } + }, + "crane": { + "flake": false, + "locked": { + "lastModified": 1681175776, + "narHash": "sha256-7SsUy9114fryHAZ8p1L6G6YSu7jjz55FddEwa2U8XZc=", + "owner": "ipetkov", + "repo": "crane", + "rev": "445a3d222947632b5593112bb817850e8a9cf737", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "ref": "v0.12.1", + "repo": "crane", + "type": "github" + } + }, "devshell": { "inputs": { "nixpkgs": [ @@ -21,6 +55,87 @@ "type": "github" } }, + "devshell_2": { + "flake": false, + "locked": { + "lastModified": 1663445644, + "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", + "owner": "numtide", + "repo": "devshell", + "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dream2nix": { + "inputs": { + "all-cabal-json": "all-cabal-json", + "crane": "crane", + "devshell": "devshell_2", + "drv-parts": "drv-parts", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "flake-utils-pre-commit": "flake-utils-pre-commit", + "ghc-utils": "ghc-utils", + "gomod2nix": "gomod2nix", + "mach-nix": "mach-nix", + "nix-pypi-fetcher": "nix-pypi-fetcher", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgsV1": "nixpkgsV1", + "poetry2nix": "poetry2nix", + "pre-commit-hooks": "pre-commit-hooks", + "pruned-racket-catalog": "pruned-racket-catalog" + }, + "locked": { + "lastModified": 1690660611, + "narHash": "sha256-nfDb1koAB/bD2pzENgVe+q4lwi9tgwR772dZgaGR4Io=", + "owner": "nix-community", + "repo": "dream2nix", + "rev": "ce7b3975b63062b9e440e48a75a5c12253231af5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "legacy", + "repo": "dream2nix", + "type": "github" + } + }, + "drv-parts": { + "inputs": { + "flake-compat": [ + "dream2nix", + "flake-compat" + ], + "flake-parts": [ + "dream2nix", + "flake-parts" + ], + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1680698112, + "narHash": "sha256-FgnobN/DvCjEsc0UAZEAdPLkL4IZi2ZMnu2K2bUaElc=", + "owner": "davhau", + "repo": "drv-parts", + "rev": "e8c2ec1157dc1edb002989669a0dbd935f430201", + "type": "github" + }, + "original": { + "owner": "davhau", + "repo": "drv-parts", + "type": "github" + } + }, "easy-purescript-nix": { "inputs": { "flake-utils": [ @@ -57,6 +172,43 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "dream2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675933616, + "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "47478a4a003e745402acf63be7f9a092d51b83d7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems_2" @@ -75,6 +227,21 @@ "type": "github" } }, + "flake-utils-pre-commit": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flake-utils_2": { "locked": { "lastModified": 1653893745, @@ -90,6 +257,69 @@ "type": "github" } }, + "ghc-utils": { + "flake": false, + "locked": { + "lastModified": 1662774800, + "narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=", + "ref": "refs/heads/master", + "rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea", + "revCount": 1072, + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + }, + "original": { + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + } + }, + "gomod2nix": { + "flake": false, + "locked": { + "lastModified": 1627572165, + "narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "gomod2nix", + "type": "github" + } + }, + "mach-nix": { + "flake": false, + "locked": { + "lastModified": 1634711045, + "narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d", + "type": "github" + }, + "original": { + "id": "mach-nix", + "type": "indirect" + } + }, + "nix-pypi-fetcher": { + "flake": false, + "locked": { + "lastModified": 1669065297, + "narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=", + "owner": "DavHau", + "repo": "nix-pypi-fetcher", + "rev": "a9885ac6a091576b5195d547ac743d45a2a615ac", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "nix-pypi-fetcher", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1688492144, @@ -106,6 +336,21 @@ "type": "github" } }, + "nixpkgsV1": { + "locked": { + "lastModified": 1686501370, + "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1679679161, @@ -137,6 +382,65 @@ "type": "github" } }, + "poetry2nix": { + "flake": false, + "locked": { + "lastModified": 1666918719, + "narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "289efb187123656a116b915206e66852f038720e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "1.36.0", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "dream2nix", + "flake-utils-pre-commit" + ], + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1646153636, + "narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pruned-racket-catalog": { + "flake": false, + "locked": { + "lastModified": 1672537287, + "narHash": "sha256-SuOvXVcLfakw18oJB/PuRMyvGyGG1+CQD3R+TGHIv44=", + "owner": "nix-community", + "repo": "pruned-racket-catalog", + "rev": "c8b89557fb53b36efa2ee48a769c7364df0f6262", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "catalog", + "repo": "pruned-racket-catalog", + "type": "github" + } + }, "purenix": { "inputs": { "flake-utils": "flake-utils_2", @@ -164,15 +468,15 @@ "slimlock": "slimlock" }, "locked": { - "lastModified": 1690481124, - "narHash": "sha256-BiDhpIzTkOKaUYomRHFFkAsqBQ6NKa9LTGuqYI+7yoY=", - "owner": "deemp", + "lastModified": 1690938891, + "narHash": "sha256-GHLvi3J0mp0hArCKjDr1+TzecVjbbWIfphwvnfn30Sc=", + "owner": "thomashoneyman", "repo": "purescript-overlay", - "rev": "17bc34ed939590b977493f494b8be0aa1c32b535", + "rev": "339dc45f5f883644ce59bd95d23753c93845093e", "type": "github" }, "original": { - "owner": "deemp", + "owner": "thomashoneyman", "repo": "purescript-overlay", "type": "github" } @@ -236,8 +540,9 @@ "root": { "inputs": { "devshell": "devshell", + "dream2nix": "dream2nix", "easy-purescript-nix": "easy-purescript-nix", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "purescript-overlay": "purescript-overlay", diff --git a/spaghetto/flake.nix b/spaghetto/flake.nix index 3a23a5079..973094411 100644 --- a/spaghetto/flake.nix +++ b/spaghetto/flake.nix @@ -5,14 +5,16 @@ flake-utils.url = "github:numtide/flake-utils"; + dream2nix.url = "github:nix-community/dream2nix/legacy"; + dream2nix.inputs.nixpkgs.follows = "nixpkgs"; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - # TODO switch to thomashoneyman/purescript-overlay after https://github.com/thomashoneyman/purescript-overlay/pull/40 is merged purescript-overlay = { - url = "github:deemp/purescript-overlay"; + url = "github:thomashoneyman/purescript-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -47,9 +49,35 @@ purs = pkgs.purs-bin.purs-0_15_10; spago = pkgs.spago-unstable; purs-tidy = pkgs.purs-tidy-unstable; + nodejs = pkgs.nodejs_18; app = pkgs.purifix { src = ./.; }; + js = (inputs.dream2nix.lib.makeFlakeOutputs { + systems = [ system ]; + config.projectRoot = ./.; + source = ./.; + # autoProjects = true; + projects = { + spago = { + name = "spago"; + relPath = ""; + subsystem = "nodejs"; + translator = "package-lock"; + subsystemInfo = { + nodejs = 18; + }; + }; + }; + }); + + js-modules = js.packages.${system}.spago.overrideAttrs (x: { + installPhase = '' + mkdir $out + cp -r node_modules/* $out + ''; + }); + packages = { # TODO fix # Fails due to @@ -60,6 +88,43 @@ app = true; }; + inherit js; + + spago = pkgs.stdenv.mkDerivation { + name = "spago"; + + phases = [ "buildPhase" ]; + + nativeBuildInputs = [ spago pkgs.git purs pkgs.esbuild nodejs ]; + + src = ./.; + + # https://github.com/NixOS/nixpkgs/issues/210223#issuecomment-1383979488 + buildPhase = '' + cp -r $src $out + + cd $out + + export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt + export SYSTEM_CERTIFICATE_PATH="$SSL_CERT_FILE" + export GIT_SSL_CAINFO="$SSL_CERT_FILE" + + mkdir $out/node_modules + cp -r ${js-modules} $out/node_modules + # spago bundle -p spago-bin + + # find . ! -name 'bundle.js' -type f -exec rm -f {} + + # mv bin/bundle.js $CUR/spaghetto + # cd $CUR + + # mv spaghetto $out + ''; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = ""; + }; + inherit app; inherit pkgs; @@ -70,7 +135,7 @@ purs spago purs-tidy - pkgs.nodejs_18 + nodejs pkgs.esbuild ]; commands = map (x: { package = x; category = "tools"; }) packages;