diff --git a/crates/wasm_interp/src/lib.rs b/crates/wasm_interp/src/lib.rs index 8cc98d3e399..c3add8e6614 100644 --- a/crates/wasm_interp/src/lib.rs +++ b/crates/wasm_interp/src/lib.rs @@ -1,6 +1,5 @@ mod frame; mod instance; -mod tests; mod value_store; pub mod wasi; diff --git a/flake.lock b/flake.lock index e0c185ee013..15d775de42f 100644 --- a/flake.lock +++ b/flake.lock @@ -59,17 +59,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1693140250, - "narHash": "sha256-URyIDETtu1bbxcSl83xp7irEV04dPEgj7O3LjHcD1Sk=", + "lastModified": 1701068326, + "narHash": "sha256-vmMceA+q6hG1yrjb+MP8T0YFDQIrW3bl45e7z24IEts=", "owner": "nixos", "repo": "nixpkgs", - "rev": "676fe5e01b9a41fa14aaa48d87685677664104b1", + "rev": "8cfef6986adfb599ba379ae53c9f5631ecd2fd9c", "type": "github" }, "original": { "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", - "rev": "676fe5e01b9a41fa14aaa48d87685677664104b1", "type": "github" } }, diff --git a/flake.nix b/flake.nix index cfb5b928555..6d58d7f4984 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Roc flake"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?rev=676fe5e01b9a41fa14aaa48d87685677664104b1"; - + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay rust-overlay = { url = "github:oxalica/rust-overlay"; @@ -160,7 +159,7 @@ # You can build this package (the roc CLI) with the `nix build` command. packages = { default = rocBuild.roc-cli; - + # all rust crates in workspace.members of Cargo.toml full = rocBuild.roc-full; # only the CLI crate = executable provided in nightly releases diff --git a/nix/builder.nix b/nix/builder.nix index 4038a1bfbe8..6439bc62b81 100644 --- a/nix/builder.nix +++ b/nix/builder.nix @@ -3,6 +3,8 @@ let inherit (compile-deps) zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath; subPackagePath = if subPackage != null then "crates/${subPackage}" else null; + + filteredSource = pkgs.callPackage ./fileFilter.nix { }; in rustPlatform.buildRustPackage { pname = "roc" + lib.optionalString (subPackage != null) "_${subPackage}"; @@ -10,7 +12,7 @@ rustPlatform.buildRustPackage { buildAndTestSubdir = subPackagePath; - src = pkgs.nix-gitignore.gitignoreSource [ ] ../.; + src = filteredSource; cargoLock = { lockFile = ../Cargo.lock; diff --git a/nix/fileFilter.nix b/nix/fileFilter.nix new file mode 100644 index 00000000000..8f974f85b21 --- /dev/null +++ b/nix/fileFilter.nix @@ -0,0 +1,80 @@ +{ lib, nix-gitignore }: +let + # See https://nix.dev/tutorials/file-sets for a guide on how the file set api works + + fs = lib.fileset; + + fileDoesNotHaveExt = fileExts: file: (!lib.lists.any (ext: file.hasExt ext) fileExts); + + repoRoot = ../.; + + # The file set api does not currently have a way to easily remove folders dynamically. + # The nix build does not run tests, so we try to remove any folders with only tests. + removedTests = + let + dirFilter = pathStr: ( + let dirName = baseNameOf pathStr; in !( + # remove any folder whos name is `tests` or starts with `test_` + dirName == "tests" + ) + ); + removeTestFilter = + path: type: + # only do a "real" check on directory, allow everything else through + (type == "directory" && dirFilter path) + || type != "directory"; + in + lib.sources.cleanSourceWith { src = repoRoot; filter = removeTestFilter; }; + fsBase = fs.fromSource removedTests; + + # fsBase = fs.fromSource repoRoot; + + # only look at files in the crates folder + onlyCratesFolder = fs.intersection ../crates fsBase; + + # the above filter only has the subfolder, put some needed files from the root back in + includeCargoRootFiles = fs.unions [ + ../Cargo.toml + ../Cargo.lock + ../version.txt + onlyCratesFolder + ]; + + # Remove any "simple" files like markdown/pictures since they probably wont be used in the actual code + removedSimpleFiles = + let + extensionsToRemove = [ "md" "svg" "png" ]; + in + fs.intersection + includeCargoRootFiles + (fs.fileFilter (fileDoesNotHaveExt extensionsToRemove) repoRoot); + + # the above filter can make the doc crate sad since it has pictures + docsAddedBack = fs.unions [ + ../crates/docs + removedSimpleFiles + ]; + + # =============================== + # If you are trying to see what is ok to exclude from the "main" builds (cli/lang_server) + # use `cargo tree` https://doc.rust-lang.org/cargo/commands/cargo-tree.html + # + # Ex: `cargo tree -i roc_build` will show all deps of the `roc_build` crate + # if only the package passed with `-i` is shown, nothing depends on it + # =============================== + + # remove www folder from checkmate crate since it's not built with nix + removedWWW = fs.difference docsAddedBack ../crates/compiler/checkmate/www; + + # potential packages/folders that could be removed + # repl_* -> I don't think nix will build those + + filteredSrc = fs.toSource { + root = repoRoot; + # to debug you can switch to + # fileset = fs.traceVal + fileset = removedWWW; + }; + +in +filteredSrc