Seems to be building with trunk

This commit is contained in:
Jeremy Wall 2022-02-25 19:10:55 -05:00
parent 7ea672a8fd
commit 3da9f135be
9 changed files with 118 additions and 28 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ target/
.clj-kondo/
web/dist/
webdist/
nix/*/result

View File

@ -1,23 +1,45 @@
{
description = "kitchen";
# Pin nixpkgs
inputs.nixpkgs.url = "github:NixOS/nixpkgs/adf7f03d3bfceaba64788e1e846191025283b60d";
inputs.gitignore = { url = "github:hercules-ci/gitignore.nix"; flake = false; };
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/adf7f03d3bfceaba64788e1e846191025283b60d";
gitignore = { url = "github:hercules-ci/gitignore.nix"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {self, nixpkgs, flake-utils, gitignore}:
let
kitchenGen = import ./kitchen.nix;
kitchenGen = (import ./nix/default.nix);
trunkGen = (import ./nix/trunk/default.nix);
kitchenWasmGen = (import ./nix/kitchenWasm/default.nix);
cargoVendorGen = (import ./nix/cargoVendorDeps/default.nix);
version = "0.2.1";
in
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; }; in
let
pkgs = import nixpkgs { inherit system; };
trunk = trunkGen { inherit pkgs; };
cargoVendorDeps = cargoVendorGen {
inherit pkgs version;
lockFile = ./Cargo.lock;
};
kitchenWasm = kitchenWasmGen {
inherit pkgs cargoVendorDeps trunk version;
};
#kitchen = (kitchenGen {
# inherit pkgs cargoDeps version kitchenWasm;
## gitignoreSrc = nixpkgs.callPackage gitignore { };
#});
in
{
defaultPackage = (kitchenGen {
nixpkgs = pkgs;
gitignoreSrc = pkgs.callPackage gitignore { };
});
packages = {
inherit trunk
cargoVendorDeps
kitchenWasm
# kitchen
;
};
defaultPackage = cargoVendorDeps;
}
);
}

View File

@ -1,16 +0,0 @@
{nixpkgs, gitignoreSrc}:
with nixpkgs;
nixpkgs.stdenv.mkDerivation rec {
name = "kitchen";
src = fetchurl {
url = "https://github.com/zaphar/kitchen/releases/download/v0.2.0-nix/kitchen-linux";
sha256 = "1f1lxw893r6afgkhizvhm4pg20qfw3kwf9kbzmkbcw0d21qsd9z2";
};
phases = ["installPhase" "patchPhase"];
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/kitchen
chmod u+x $out/bin/kitchen
'';
}

View File

@ -1,3 +1,5 @@
cargo-features = ["edition2021"]
[package]
name = "kitchen"
version = "0.2.1"

View File

@ -0,0 +1,21 @@
{pkgs ? (import <nixpkgs>) {},
lockFile ? ./../../Cargo.lock,
version ? "0.2.1"}:
let
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile; });
recipes = ./../../recipes;
in
with pkgs;
stdenv.mkDerivation {
name = "cargo-vendor-deps";
version = "0.0.0";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out
cp -r ${cargoDeps}/* $out/
cp -r ${cargoDeps}/.cargo $out/
cp -r ${recipes} $out/recipes-${version}
ls -al $out/
'';
}

View File

@ -0,0 +1,36 @@
{pkgs? (import <nixpkgs>) {},
version ? "0.2.1",
cargoVendorDeps ? (import ./../cargoVendorDeps/default.nix {inherit pkgs version; }),
trunk ? (import ./../trunk/default.nix {inherit pkgs;}),
}:
with pkgs;
let
pname = "kitchen-wasm";
src = ./../../web;
in
stdenv.mkDerivation {
inherit src pname;
version = version;
buildInputs = [ trunk ];
phases = [ "postUnpackPhase" "buildPhase" "installPhase" ];
postUnpackPhase = ''
ln -s ${cargoVendorDeps} ./cargo-vendor-dir
cp -r ./cargo-vendor-dir/.cargo ./
cp -r $src/* ./
'';
# NOTE(jwall): For some reason trunk is trying to do something with staging that
# nix doesn't like. We suppress the message for now but I'd like to
# know why trunk can't create those directories.
buildPhase = ''
trunk build --release --public-url /ui/ --dist ./dist || echo ignoring staging errors for now;
pwd
ls -al .
'';
installPhase = ''
pwd
ls -al .
mkdir -p $out
echo cp -r ./dist $out/
cp -r ./dist $out/
'';
}

20
nix/trunk/default.nix Normal file
View File

@ -0,0 +1,20 @@
{pkgs ? (import <nixpkgs>) {}}:
with pkgs;
rustPlatform.buildRustPackage rec {
pname = "trunk";
version = "v0.14.0";
src = fetchFromGitHub {
owner = "thedodd";
repo = pname;
rev = version;
sha256 = "sha256-69MQDIF79pSuaOgZEIqb/ESPQzL7MUiQaJaxPccGxo8=";
};
cargoSha256 = "sha256-RPE2wMggD8nXpuUkRsvG5wxIWCHifD4RLLLPkq8HOEQ=";
# Trunk uses the network in it's test which is lame. We'll work around
# by disabling here for now.
doCheck = false;
meta = {
description = "Trunk rust web assembly bundler";
};
}

View File

@ -1,3 +1,5 @@
cargo-features = ["edition2021"]
[package]
name = "recipes"
version = "0.2.1"

View File

@ -1,3 +1,5 @@
cargo-features = ["edition2021"]
[package]
name = "kitchen-wasm"
version = "0.2.1"