Skip to content

Commit

Permalink
chore: workflows to macos, rust-toolchain file
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Jan 6, 2025
1 parent d2999c9 commit 83b33ac
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
Expand Down
200 changes: 99 additions & 101 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,108 +1,106 @@
{ pkgs ? import <nixpkgs> { }
, fenix,
}:
let
{
pkgs ? import <nixpkgs> {},
fenix,
}: let
lib = pkgs.lib;
getLibFolder = pkg: "${pkg}/lib";

toolchain = with fenix.packages.${pkgs.system};
combine [
stable.toolchain
targets.wasm32-unknown-unknown.stable.rust-std
];

toolchain = fenix.packages.${pkgs.system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
};

manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage {
pname = "rust-website";
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;

nativeBuildInputs = with pkgs; [
# LLVM & GCC
gcc
cmake
gnumake
pkg-config
llvmPackages.llvm
llvmPackages.clang
llvmPackages.bintools

# Tailwindcss
tailwindcss

# Rust
rustc
cargo
trunk
clippy
libiconv
toolchain
wasm-pack
pkg-config
rust-analyzer
wasm-bindgen-cli
];

buildInputs = with pkgs; [
openssl
];

buildPhase = ''
# Build the css
tailwindcss -i ./style/input.css -o ./style/output.css
# Wasm-bindgen nigga can't build without storing cache at HOME
export HOME="$(pwd)/home"
mkdir -p $HOME
# Test wasm
wasm-bindgen -V
# Build wasm webiste
trunk build --release --public-url=/
'';

installPhase = ''
# Create out directory
mkdir -p $out/www
# Move all finished content
mv ./dist/* $out/www
'';

# If you wanna get thorny
# RUST_BACKTRACE = 1;
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)}";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.gcc
pkgs.libiconv
pkgs.llvmPackages.llvm
];
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER = "lld";

meta = with lib; {
homepage = manifest.package.homepage;
description = "Website of Rust Uzbekistan community";
license = with lib.licenses; [ gpl3Only ];

platforms = with platforms; linux ++ darwin;

maintainers = [
{
name = "Sokhibjon Orzikulov";
email = "sakhib@orzklv.uz";
handle = "orzklv";
github = "orzklv";
githubId = 54666588;
keys = [
{
fingerprint = "00D2 7BC6 8707 0683 FBB9 137C 3C35 D3AF 0DA1 D6A8";
}
];
}
pkgs.rustPlatform.buildRustPackage {
pname = "rust-website";
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;

nativeBuildInputs = with pkgs; [
# LLVM & GCC
gcc
cmake
gnumake
pkg-config
llvmPackages.llvm
llvmPackages.clang
llvmPackages.bintools

# Tailwindcss
tailwindcss

# Rust
rustc
cargo
trunk
clippy
libiconv
toolchain
wasm-pack
pkg-config
rust-analyzer
wasm-bindgen-cli
];
};
}

buildInputs = with pkgs; [
openssl
];

buildPhase = ''
# Build the css
tailwindcss -i ./style/input.css -o ./style/output.css
# Wasm-bindgen nigga can't build without storing cache at HOME
export HOME="$(pwd)/home"
mkdir -p $HOME
# Test wasm
wasm-bindgen -V
# Build wasm webiste
trunk build --release --public-url=/
'';

installPhase = ''
# Create out directory
mkdir -p $out/www
# Move all finished content
mv ./dist/* $out/www
'';

# If you wanna get thorny
# RUST_BACKTRACE = 1;
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)}";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.gcc
pkgs.libiconv
pkgs.llvmPackages.llvm
];
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER = "lld";

meta = with lib; {
homepage = manifest.package.homepage;
description = "Website of Rust Uzbekistan community";
license = with lib.licenses; [gpl3Only];

platforms = with platforms; linux ++ darwin;

maintainers = [
{
name = "Sokhibjon Orzikulov";
email = "sakhib@orzklv.uz";
handle = "orzklv";
github = "orzklv";
githubId = 54666588;
keys = [
{
fingerprint = "00D2 7BC6 8707 0683 FBB9 137C 3C35 D3AF 0DA1 D6A8";
}
];
}
];
};
}
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
components = ["rust-src", "rustfmt", "rust-analyzer", "rust-std", "clippy"]
targets = ["wasm32-unknown-unknown"]
profile = "complete"
9 changes: 4 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
}: let
getLibFolder = pkg: "${pkg}/lib";

toolchain = with fenix.packages.${pkgs.system};
combine [
stable.toolchain
targets.wasm32-unknown-unknown.stable.rust-std
];
toolchain = fenix.packages.${pkgs.system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
};
in
pkgs.stdenv.mkDerivation {
name = "rust-website";
Expand Down

0 comments on commit 83b33ac

Please sign in to comment.