From 81cd92f3fef484a13fab9aec7e8ccc313372468d Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:09:02 -0500 Subject: [PATCH] add in default nix at repo root that calls flake for build --- default.nix | 10 ++++++++++ flake.lock | 15 +++++++++++++++ flake.nix | 18 ++++++------------ nix/compile-deps.nix | 10 ++++++++++ nix/default.nix | 3 ++- nix/roc-cli.nix | 10 ++++++---- 6 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..71330e4340 --- /dev/null +++ b/default.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix \ No newline at end of file diff --git a/flake.lock b/flake.lock index 37ed04c9a6..bc872cbc49 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,19 @@ { "nodes": { + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -59,6 +73,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixgl": "nixgl", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index ad79775a7b..9fe1922f28 100644 --- a/flake.nix +++ b/flake.nix @@ -18,9 +18,12 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; + + # for non flake backwards compatibility + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; }; - outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl }: + outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs: let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; in flake-utils.lib.eachSystem supportedSystems (system: let @@ -31,7 +34,8 @@ rocBuild = import ./nix { inherit pkgs; }; compile-deps = rocBuild.compile-deps; - inherit (compile-deps) zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath; + inherit (compile-deps) zigPkg llvmPkgs llvmVersion + llvmMajorMinorStr glibcPath libGccSPath darwinInputs; # DevInputs are not necessary to build roc as a user linuxDevInputs = with pkgs; @@ -48,16 +52,6 @@ xorg.libxcb ]; - darwinInputs = with pkgs; - lib.optionals stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; [ - AppKit - CoreFoundation - CoreServices - Foundation - Security - ]); - # DevInputs are not necessary to build roc as a user darwinDevInputs = with pkgs; lib.optionals stdenv.isDarwin diff --git a/nix/compile-deps.nix b/nix/compile-deps.nix index 0bbc56fdf4..59bf6b2086 100644 --- a/nix/compile-deps.nix +++ b/nix/compile-deps.nix @@ -12,4 +12,14 @@ let in { inherit zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath; + + darwinInputs = with pkgs; + lib.optionals stdenv.isDarwin + (with pkgs.darwin.apple_sdk.frameworks; [ + AppKit + CoreFoundation + CoreServices + Foundation + Security + ]); } diff --git a/nix/default.nix b/nix/default.nix index 8676a5472c..15dd93e25a 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -5,11 +5,12 @@ let cargo = rustVersion; rustc = rustVersion; }; - compile-deps = pkgs.callPackage ./compile-deps.nix {}; + compile-deps = pkgs.callPackage ./compile-deps.nix { }; in { inherit rustPlatform compile-deps; rust-shell = (rustVersion.override { extensions = [ "rust-src" "rust-analyzer" ]; }); roc-cli = pkgs.callPackage ./roc-cli.nix { inherit compile-deps rustPlatform; }; + roc-lang-server = {}; } diff --git a/nix/roc-cli.nix b/nix/roc-cli.nix index 6040c51170..af77038363 100644 --- a/nix/roc-cli.nix +++ b/nix/roc-cli.nix @@ -1,4 +1,4 @@ -{ pkgs, rustPlatform, compile-deps }: +{ pkgs, rustPlatform, compile-deps, subPackage ? null }: let inherit (compile-deps) zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath; in @@ -6,10 +6,12 @@ rustPlatform.buildRustPackage { pname = "roc"; version = "0.0.1"; - src = pkgs.nix-gitignore.gitignoreSource [ ] ./.; + buildAndTestSubdir = subPackage; + + src = pkgs.nix-gitignore.gitignoreSource [ ] ../.; cargoLock = { - lockFile = ./Cargo.lock; + lockFile = ../Cargo.lock; outputHashes = { "criterion-0.3.5" = "sha256-+FibPQGiR45g28xCHcM0pMN+C+Q8gO8206Wb5fiTy+k="; "inkwell-0.2.0" = "sha256-VhTapYGonoSQ4hnDoLl4AAgj0BppAhPNA+UPuAJSuAU="; @@ -41,7 +43,7 @@ rustPlatform.buildRustPackage { python3 llvmPkgs.clang llvmPkgs.llvm.dev - llvmPkgs.bintools-unwrapped # contains lld + llvmPkgs.bintools-unwrapped # contains lld zigPkg ]);