-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
86 lines (72 loc) · 2.43 KB
/
Copy pathflake.nix
File metadata and controls
86 lines (72 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
description = "Daffa Karyudi - Portfolio (Rust + WASM / Dioxus)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
nixConfig = {
extra-substituters = [ "https://porto.cachix.org" ];
extra-trusted-public-keys = [ "porto.cachix.org-1:+LLDAFA3ZLtOWuVBRn5V/hNjbDKW1ZYqhxQShPQBTPc=" ];
};
outputs = { self, nixpkgs, rust-overlay, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = pkgs.lib.cleanSource ./.;
cargoVendorDir = craneLib.vendorCargoDeps { inherit src; };
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "web-porto";
version = "0.1.0";
inherit src;
nativeBuildInputs = [
rustToolchain
pkgs.dioxus-cli
pkgs.wasm-bindgen-cli
pkgs.binaryen
];
configurePhase = ''
export HOME=$TMPDIR
export CARGO_HOME=$TMPDIR/.cargo
mkdir -p .cargo
cp ${cargoVendorDir}/config.toml .cargo/config.toml
'';
buildPhase = ''
dx bundle --package porto-app --release
'';
installPhase = ''
mkdir -p $out
cp -r target/dx/porto-app/release/web/public/* $out/
# Photos, paper PDFs, the embedding model and the favicon are
# referenced by absolute URL and are not part of the dx bundle, so
# they have to be copied in for $out to be a complete site root.
cp -r public/. $out/
'';
};
devShells.default = pkgs.mkShell {
buildInputs = [
rustToolchain
pkgs.dioxus-cli
pkgs.wasm-bindgen-cli
pkgs.binaryen
pkgs.cargo-watch
pkgs.simple-http-server
];
};
}
) // {
nixosModules.default = import ./nix/module.nix self;
};
}