Skip to content

Commit

Permalink
codex32 offline website service (currently broken with some strange w…
Browse files Browse the repository at this point in the history
…asm error).
  • Loading branch information
VzxPLnHqr committed May 15, 2024
1 parent c5cf8f5 commit 425ca34
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 36 deletions.
11 changes: 11 additions & 0 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@

# web browser (for viewing static sites offline)
firefox

# misc
python3
];

# program-specific settings
Expand Down Expand Up @@ -138,4 +141,12 @@

system.stateVersion = "24.05";

virtualisation.vmVariant = {
# following configuration is added only when building VM with build-vm
virtualisation = {
memorySize = 4096; # Use 4096MiB memory.
cores = 3;
};
};

}
133 changes: 129 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};

codex32-website.url = "github:vzxplnhqr/volvelle-website?ref=nix-flake";
};

outputs = inputs@{ self, nixpkgs, nixos-generators }: {
outputs = inputs@{ self, nixpkgs, nixos-generators, codex32-website }: {


nixosModules.nixos-airgapped = {pkgs, config, ...}: {
nixosModules.nixos-airgapped = {pkgs, config, codex32-website, ...}: {

imports = [ ./configuration.nix ];

Expand All @@ -25,14 +27,16 @@
# build a vm by running `nixos-rebuild build-vm --flake .#nixos-airgapped`
# the vm can be started by running `./result/bin/run-...`
nixosConfigurations.nixos-airgapped = nixpkgs.lib.nixosSystem {
specialArgs = inputs;
system = "x86_64-linux";
modules = [ self.nixosModules.nixos-airgapped ];
modules = [ ./configuration.nix ];
};

# build the iso by running `nix build .#nixos-airgapped-iso`
packages.x86_64-linux.nixos-airgapped-iso = nixos-generators.nixosGenerate {
specialArgs = inputs;
system = "x86_64-linux";
modules = [ self.nixosModules.nixos-airgapped ];
modules = [ ./configuration.nix ];

# see different formats here: https://github.com/nix-community/nixos-generators
# for nixos bootable installer ISO change to "install-iso"
Expand Down
42 changes: 14 additions & 28 deletions modules/codex32.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
{ lib, pkgs, config, ... }:
let
codex32-website = pkgs.rustPlatform.buildRustPackage rec {
name = "codex32-website";
src = pkgs.fetchFromGitHub {
owner = "apoelstra";
repo = "volvelle-website";
rev = "main";
hash = "sha256-ZkIFqSE/blcOfqiehY/Wt6HCc2dcLrOTDH7hM72M/n8=";
};
sourceRoot = "source/volvelle-wasm";
cargoSha256 = "beUS0vVAH3nKlQll7cn51U+m8QLKiZcWgh56tC1BDKw=";
nativeBuildInputs = with pkgs; [
git rustc cargo gcc llvmPackages.bintools wasm-pack
];
buildPhase = ''
echo "STARTING BUILD"
# mkdir -p target/pkg
# wasm-pack build --out-dir target/pkg --target no-modules
# cargo test
wasm-pack build --target no-modules
echo "FINISHED BUILD"
'';
};
in {
{ lib, pkgs, config, codex32-website, ... }: {

# host the codex32 website offline
# THIS IS BROKEN
# for some strange reason, nginx does not serve the site up properly
# however, manually running the following *does* seem to work:
#
# cd /nix/store/18aakaqqgi2a4dam0zq80v6gkmb1r41k-codex32-website-1.0.0/www
# python3 webserver.py
# # now the site is accessible at http://localhost:9000
#
# but why does the below simple nginx site serving out of the same directory
# not work? WHY!!!?

# host the bip39 tool offline
services.nginx = {
enable = true;
virtualHosts."codex32.offline" = {
root = "${codex32-website}";
root = "${codex32-website}/www";
};
};

networking.extraHosts = "127.0.0.1 codex32.offline";


}

0 comments on commit 425ca34

Please sign in to comment.