mirror of
https://github.com/roc-lang/roc.git
synced 2024-08-16 06:10:44 +03:00
format all Nix source files with nixfmt
This commit is contained in:
parent
201ccd6a23
commit
2cc0f39273
55
default.nix
55
default.nix
@ -1,30 +1,28 @@
|
||||
{ rev ? "541a3ca27c9a8220b46f4feb7dd8e94336a77f42", # nixpkgs master
|
||||
nixpkgsSource ? builtins.fetchTarball {
|
||||
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
|
||||
sha256 = "sha256:1mxv0zigm98pawf05kd4s8ipvk1pvvdsn1yh978c5an97kz0ck5w";
|
||||
},
|
||||
pkgs ? import nixpkgsSource { },
|
||||
cargoSha256 ? "sha256-treL2sWPcZ1NBwdab3FOb2FI2wT/Vt9tD4XRfJ8rYWA=",
|
||||
}:
|
||||
nixpkgsSource ? builtins.fetchTarball {
|
||||
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
|
||||
sha256 = "sha256:1mxv0zigm98pawf05kd4s8ipvk1pvvdsn1yh978c5an97kz0ck5w";
|
||||
}, pkgs ? import nixpkgsSource { }
|
||||
, cargoSha256 ? "sha256-treL2sWPcZ1NBwdab3FOb2FI2wT/Vt9tD4XRfJ8rYWA=", }:
|
||||
# we only this file to release a nix package, use flake.nix for development
|
||||
let
|
||||
rustPlatform = pkgs.rustPlatform;
|
||||
llvmPkgs = pkgs.llvmPackages_13;
|
||||
# nix does not store libs in /usr/lib or /lib
|
||||
nixGlibcPath = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
in rustPlatform.buildRustPackage {
|
||||
pname = "roc";
|
||||
version = "0.0.1";
|
||||
|
||||
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
|
||||
inherit cargoSha256;
|
||||
|
||||
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
|
||||
|
||||
# required for zig
|
||||
XDG_CACHE_HOME = "xdg_cache"; # prevents zig AccessDenied error github.com/ziglang/zig/issues/6810
|
||||
XDG_CACHE_HOME =
|
||||
"xdg_cache"; # prevents zig AccessDenied error github.com/ziglang/zig/issues/6810
|
||||
# want to see backtrace in case of failure
|
||||
RUST_BACKTRACE = 1;
|
||||
|
||||
@ -45,17 +43,17 @@ rustPlatform.buildRustPackage {
|
||||
rust-bindgen
|
||||
]);
|
||||
|
||||
buildInputs = (with pkgs; [
|
||||
libffi
|
||||
libiconv
|
||||
libxkbcommon
|
||||
libxml2
|
||||
ncurses
|
||||
zlib
|
||||
cargo
|
||||
makeWrapper # necessary for postBuild wrapProgram
|
||||
]
|
||||
++ lib.optionals pkgs.stdenv.isLinux [
|
||||
buildInputs = (with pkgs;
|
||||
[
|
||||
libffi
|
||||
libiconv
|
||||
libxkbcommon
|
||||
libxml2
|
||||
ncurses
|
||||
zlib
|
||||
cargo
|
||||
makeWrapper # necessary for postBuild wrapProgram
|
||||
] ++ lib.optionals pkgs.stdenv.isLinux [
|
||||
alsa-lib
|
||||
valgrind
|
||||
vulkan-headers
|
||||
@ -67,8 +65,7 @@ rustPlatform.buildRustPackage {
|
||||
xorg.libXi
|
||||
xorg.libXrandr
|
||||
xorg.libxcb
|
||||
]
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
] ++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.darwin.apple_sdk.frameworks.AppKit
|
||||
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
|
||||
pkgs.darwin.apple_sdk.frameworks.CoreServices
|
||||
@ -76,15 +73,19 @@ rustPlatform.buildRustPackage {
|
||||
pkgs.darwin.apple_sdk.frameworks.Foundation
|
||||
pkgs.darwin.apple_sdk.frameworks.Metal
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
]);
|
||||
]);
|
||||
|
||||
# cp: to copy str.zig,list.zig...
|
||||
# wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs
|
||||
postInstall = if pkgs.stdenv.isLinux then ''
|
||||
cp -r target/x86_64-unknown-linux-gnu/release/lib/. $out/lib
|
||||
wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${nixGlibcPath} --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]}
|
||||
wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${nixGlibcPath} --prefix PATH : ${
|
||||
pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]
|
||||
}
|
||||
'' else ''
|
||||
cp -r target/aarch64-apple-darwin/release/lib/. $out/lib
|
||||
wrapProgram $out/bin/roc --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]}
|
||||
wrapProgram $out/bin/roc --prefix PATH : ${
|
||||
pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
@ -8,10 +8,8 @@
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = { self, roc, flake-utils }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
in flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let
|
||||
pkgs = import roc.inputs.nixpkgs {
|
||||
inherit system;
|
||||
@ -19,28 +17,19 @@
|
||||
};
|
||||
|
||||
rocShell = roc.devShell.${system};
|
||||
in
|
||||
{
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
packages =
|
||||
let
|
||||
devInputs = (with pkgs; [
|
||||
less
|
||||
gdb
|
||||
]);
|
||||
vscodeWithExtensions = pkgs.vscode-with-extensions.override {
|
||||
vscodeExtensions = with pkgs.vscode-extensions; [
|
||||
matklad.rust-analyzer
|
||||
eamodio.gitlens
|
||||
bbenoist.nix
|
||||
vadimcn.vscode-lldb
|
||||
];
|
||||
};
|
||||
in
|
||||
[
|
||||
vscodeWithExtensions
|
||||
devInputs
|
||||
];
|
||||
packages = let
|
||||
devInputs = (with pkgs; [ less gdb ]);
|
||||
vscodeWithExtensions = pkgs.vscode-with-extensions.override {
|
||||
vscodeExtensions = with pkgs.vscode-extensions; [
|
||||
matklad.rust-analyzer
|
||||
eamodio.gitlens
|
||||
bbenoist.nix
|
||||
vadimcn.vscode-lldb
|
||||
];
|
||||
};
|
||||
in [ vscodeWithExtensions devInputs ];
|
||||
|
||||
inputsFrom = [ rocShell ];
|
||||
|
||||
|
40
flake.nix
40
flake.nix
@ -24,20 +24,18 @@
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, zig, flake-utils, nixgl }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
in flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ] ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else []);
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
overlays = [ (import rust-overlay) ]
|
||||
++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]);
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
llvmPkgs = pkgs.llvmPackages_13;
|
||||
|
||||
# get current working directory
|
||||
cwd = builtins.toString ./.;
|
||||
rust = pkgs.rust-bin.fromRustupToolchainFile "${cwd}/rust-toolchain.toml";
|
||||
rust =
|
||||
pkgs.rust-bin.fromRustupToolchainFile "${cwd}/rust-toolchain.toml";
|
||||
|
||||
linuxInputs = with pkgs;
|
||||
lib.optionals stdenv.isLinux [
|
||||
@ -55,7 +53,8 @@
|
||||
];
|
||||
|
||||
darwinInputs = with pkgs;
|
||||
lib.optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
|
||||
lib.optionals stdenv.isDarwin
|
||||
(with pkgs.darwin.apple_sdk.frameworks; [
|
||||
AppKit
|
||||
CoreFoundation
|
||||
CoreServices
|
||||
@ -114,22 +113,27 @@
|
||||
rust
|
||||
rust-bindgen
|
||||
]);
|
||||
in
|
||||
{
|
||||
in {
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs ++ (if system == "x86_64-linux" then [ pkgs.nixgl.nixVulkanIntel ] else []);
|
||||
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs
|
||||
++ (if system == "x86_64-linux" then
|
||||
[ pkgs.nixgl.nixVulkanIntel ]
|
||||
else
|
||||
[ ]);
|
||||
|
||||
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
|
||||
# nix does not store libs in /usr/lib or /lib
|
||||
NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
|
||||
NIX_GLIBC_PATH =
|
||||
if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
|
||||
LD_LIBRARY_PATH = with pkgs;
|
||||
lib.makeLibraryPath
|
||||
([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib] ++ linuxInputs);
|
||||
NIXPKGS_ALLOW_UNFREE = 1; # to run the editor with NVIDIA's closed source drivers
|
||||
([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ]
|
||||
++ linuxInputs);
|
||||
NIXPKGS_ALLOW_UNFREE =
|
||||
1; # to run the editor with NVIDIA's closed source drivers
|
||||
};
|
||||
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user