summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-03-17 04:45:07 -0400
committerLLLL Colonq <llll@colonq>2025-03-17 04:45:07 -0400
commit4943071802296b234402a879a8be67ade1e1e4a1 (patch)
treee266b6ec89a7470b16c46c9ed2fe8218d9f80ff4 /flake.nix
parent66a4f9ea42217367d61293e2f62c746aed984b05 (diff)
Update flake.nix
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix159
1 files changed, 18 insertions, 141 deletions
diff --git a/flake.nix b/flake.nix
index d7bcefc..d425697 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,151 +1,28 @@
{
inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- crane = {
- url = "github:ipetkov/crane";
- };
- flake-utils.url = "github:numtide/flake-utils";
- rust-overlay = {
- url = "github:oxalica/rust-overlay";
- inputs = {
- nixpkgs.follows = "nixpkgs";
- };
- };
+ teleia.url = "github:lcolonq/teleia";
+ nixpkgs.follows = "teleia/nixpkgs";
st = {
url = "github:lcolonq/st";
inputs.nixpkgs.follows = "nixpkgs";
};
};
- outputs = { self, nixpkgs, ... }@inputs:
- inputs.flake-utils.lib.eachDefaultSystem (system:
- let
- pkgs = import nixpkgs {
- inherit system;
- overlays = [ (import inputs.rust-overlay) ];
- };
- inherit (pkgs) lib;
-
- native = rec {
- rustToolchain = pkgs.rust-bin.stable.latest.default.override {
- targets = [ "x86_64-unknown-linux-gnu" ];
- };
- craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
- src = lib.cleanSourceWith {
- src = ./.;
- filter = path: type:
- (lib.hasSuffix "\.html" path) ||
- (lib.hasSuffix "\.js" path) ||
- (lib.hasSuffix "\.css" path) ||
- (lib.hasInfix "/assets/" path) ||
- (craneLib.filterCargoSources path type)
- ;
- };
- nativeBuildInputs = [
- pkgs.pkg-config
- ];
- buildInputs = [
- pkgs.openssl.dev
- pkgs.glfw
- pkgs.xorg.libX11
- pkgs.xorg.libXcursor
- pkgs.xorg.libXi
- pkgs.xorg.libXrandr
- pkgs.xorg.libXinerama
- pkgs.libxkbcommon
- pkgs.xorg.libxcb
- pkgs.libglvnd
- pkgs.alsa-lib
- ];
- commonArgs = {
- inherit src nativeBuildInputs buildInputs;
- strictDeps = true;
- CARGO_BUILD_TARGET = "x86_64-unknown-linux-gnu";
- inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
- };
- cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
- doCheck = false;
- });
- renderer = craneLib.buildPackage (commonArgs // {
- inherit cargoArtifacts;
- cargoExtraArgs = "-p renderer";
- });
- };
-
- wasm = rec {
- rustToolchain = pkgs.rust-bin.stable.latest.default.override {
- targets = [ "wasm32-unknown-unknown" ];
- };
- craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
- src = lib.cleanSourceWith {
- src = ./.;
- filter = path: type:
- (lib.hasSuffix "\.html" path) ||
- (lib.hasSuffix "\.js" path) ||
- (lib.hasSuffix "\.css" path) ||
- (lib.hasInfix "/assets/" path) ||
- (craneLib.filterCargoSources path type)
- ;
- };
- commonArgs = {
- inherit src;
- strictDeps = true;
- CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
- buildInputs = [];
- inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
- wasm-bindgen-cli = pkgs.buildWasmBindgenCli rec {
- src = pkgs.fetchCrate {
- pname = "wasm-bindgen-cli";
- version = "0.2.100";
- hash = "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog=";
- };
- cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
- inherit src;
- inherit (src) pname version;
- hash = "sha256-qsO12332HSjWCVKtf1cUePWWb9IdYUmT+8OPj/XP2WE=";
- };
- };
- };
- throwshade = craneLib.buildTrunkPackage (commonArgs // rec {
- pname = "throwshade";
- cargoExtraArgs = "-p throwshade";
- cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
- inherit cargoExtraArgs;
- doCheck = false;
- });
- preBuild = ''
- cd ./crates/throwshade
- '';
- postBuild = ''
- mv ./dist ../..
- cd ../..
- '';
- });
- };
- in
- {
- packages = {
- inherit native wasm;
- st = inputs.st.packages.x86_64-linux.st;
- };
+ outputs = inputs@{ self, nixpkgs, ... }:
+ let
+ system = "x86_64-linux";
+ native = {
+ renderer = inputs.teleia.native.build ./. "renderer";
+ };
+ wasm = {
+ throwshade = inputs.teleia.wasm.build ./. "throwshade";
+ };
+ in {
+ packages.${system} = {
+ inherit native wasm;
+ st = inputs.st.packages.x86_64-linux.st;
+ };
- devShells.default = native.craneLib.devShell {
- packages = native.nativeBuildInputs ++ native.buildInputs ++ [
- pkgs.trunk
- pkgs.rust-analyzer
- pkgs.glxinfo
- pkgs.cmake
- ];
- LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${
- pkgs.lib.makeLibraryPath [
- pkgs.xorg.libX11
- pkgs.xorg.libXcursor
- pkgs.xorg.libXi
- pkgs.libxkbcommon
- pkgs.xorg.libxcb
- pkgs.libglvnd
- ]
- }";
- };
- });
+ devShells.${system}.default = inputs.teleia.shell;
+ };
}