Build a new devshell from scratch
Some checks failed
Monorepo build / build-flake (push) Has been cancelled
Some checks failed
Monorepo build / build-flake (push) Has been cancelled
This commit is contained in:
69
flake.lock
generated
69
flake.lock
generated
@@ -5,11 +5,11 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,39 +20,24 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1768773494,
|
||||
"narHash": "sha256-XsM7GP3jHlephymxhDE+/TKKO1Q16phz/vQiLBGhpF4=",
|
||||
"lastModified": 1769018530,
|
||||
"narHash": "sha256-MJ27Cy2NtBEV5tsK+YraYr2g851f3Fl1LpNHDzDX15c=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "77ef7a29d276c6d8303aece3444d61118ef71ac2",
|
||||
"rev": "88d3861acdd3d2f0e361767018218e51810df8a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-25.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1714906307,
|
||||
"narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"typeshare": "typeshare",
|
||||
"unstable": "unstable"
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
@@ -69,40 +54,6 @@
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"typeshare": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731966246,
|
||||
"narHash": "sha256-e/V7Ffm5wPd9DVzCThnPZ7lFxd43bb64tSk8/oGP4Ag=",
|
||||
"owner": "1Password",
|
||||
"repo": "typeshare",
|
||||
"rev": "e0e5f27ee34d7d4da76a9dc96a11552e98be56da",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "1Password",
|
||||
"repo": "typeshare",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1704722960,
|
||||
"narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
249
flake.nix
249
flake.nix
@@ -1,233 +1,38 @@
|
||||
{
|
||||
description = "Lumenescent Dreams Tools";
|
||||
description = "Luminescent Dreams Monorepo and Applications";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-25.11";
|
||||
unstable.url = "nixpkgs/nixos-unstable";
|
||||
typeshare.url = "github:1Password/typeshare";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
unstable,
|
||||
typeshare,
|
||||
...
|
||||
}:
|
||||
let
|
||||
version = builtins.string 0 8 self.lastModifiedDate;
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
in
|
||||
{
|
||||
devShells."x86_64-linux".default =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
pkgs-unstable = import unstable { system = "x86_64-linux"; };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "ld-tools-devshell";
|
||||
buildInputs = [
|
||||
pkgs.cargo-nextest
|
||||
pkgs.cargo-watch
|
||||
pkgs.clang
|
||||
pkgs.crate2nix
|
||||
pkgs.trunk
|
||||
pkgs.glib
|
||||
pkgs.gst_all_1.gst-plugins-bad
|
||||
pkgs.gst_all_1.gst-plugins-base
|
||||
pkgs.gst_all_1.gst-plugins-good
|
||||
pkgs.gst_all_1.gst-plugins-ugly
|
||||
pkgs.gst_all_1.gstreamer
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.librsvg
|
||||
pkgs.nodejs
|
||||
pkgs.openssl
|
||||
pkgs.pipewire
|
||||
pkgs.pkg-config
|
||||
pkgs.rustup
|
||||
pkgs.sqlite
|
||||
pkgs.cargo-nextest
|
||||
pkgs.wasm-pack
|
||||
pkgs.sqlx-cli
|
||||
pkgs.udev
|
||||
pkgs.wasm-pack
|
||||
pkgs.go-task
|
||||
pkgs.nixfmt
|
||||
typeshare.packages."x86_64-linux".default
|
||||
pkgs.nodePackages_latest.typescript-language-server
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
name = "luminescent-dreams-shell";
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
clang
|
||||
trunk
|
||||
glib
|
||||
gtk4
|
||||
libadwaita
|
||||
librsvg
|
||||
openssl
|
||||
pkg-config
|
||||
sqlite
|
||||
go-task
|
||||
rustup
|
||||
llvmPackages.lld # Add the lld linker
|
||||
];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
ENV = "dev";
|
||||
|
||||
# Install Rust via Rustup
|
||||
shellHook = ''
|
||||
# Use the repository rust-toolchain file when present, otherwise default to 1.92.0
|
||||
if [ -f ./rust-toolchain ]; then
|
||||
# Extract just the channel value from the TOML file (e.g. channel = "1.92.0")
|
||||
TOOLCHAIN=$(grep -E '^[[:space:]]*channel' ./rust-toolchain | sed -E 's/.*"([^"]+)".*/\1/' | head -n1)
|
||||
|
||||
# Parse components and targets arrays (extract quoted strings). Result will be space-separated.
|
||||
COMPONENTS=$(grep -E '^[[:space:]]*components' ./rust-toolchain | sed -E 's/.*\[(.*)\].*/\1/' | grep -oE '"[^"]+"' | tr -d '"' | xargs echo)
|
||||
TARGETS=$(grep -E '^[[:space:]]*targets' ./rust-toolchain | sed -E 's/.*\[(.*)\].*/\1/' | grep -oE '"[^"]+"' | tr -d '"' | xargs echo)
|
||||
|
||||
if [ -z "$TOOLCHAIN" ]; then
|
||||
TOOLCHAIN="1.92.0"
|
||||
fi
|
||||
if [ -z "$COMPONENTS" ]; then
|
||||
COMPONENTS="cargo rustc rustfmt rust-analyzer clippy"
|
||||
fi
|
||||
if [ -z "$TARGETS" ]; then
|
||||
TARGETS="x86_64-unknown-linux-gnu wasm32-unknown-unknown thumbv6m-none-eabi"
|
||||
fi
|
||||
else
|
||||
TOOLCHAIN="1.92.0"
|
||||
COMPONENTS="cargo rustc rustfmt rust-analyzer clippy"
|
||||
TARGETS="x86_64-unknown-linux-gnu wasm32-unknown-unknown thumbv6m-none-eabi"
|
||||
fi
|
||||
|
||||
# Ensure we always include these helpful extras (best-effort); avoid duplicates by appending.
|
||||
EXTRA_COMPONENTS="cargo-nextest cargo-watch"
|
||||
for c in $EXTRA_COMPONENTS; do
|
||||
case " $COMPONENTS " in
|
||||
*" $c "*) : ;; # already present
|
||||
*) COMPONENTS="$COMPONENTS $c" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "[devShell] will ensure rustup toolchain: $TOOLCHAIN"
|
||||
echo "[devShell] will install components: $COMPONENTS"
|
||||
echo "[devShell] will add targets: $TARGETS"
|
||||
|
||||
export RUSTUP_HOME="$HOME/.rustup"
|
||||
export CARGO_HOME="$HOME/.cargo"
|
||||
|
||||
if command -v rustup >/dev/null 2>&1; then
|
||||
# Install the requested toolchain if missing. Ignore errors so shell still opens.
|
||||
rustup toolchain install "$TOOLCHAIN" --no-self-update || true
|
||||
|
||||
# Install components (best-effort; some toolchains may not expose all components)
|
||||
for comp in $COMPONENTS; do
|
||||
# trim possible commas/spaces
|
||||
comp=$(echo "$comp" | tr -d ',')
|
||||
rustup component add "$comp" --toolchain "$TOOLCHAIN" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Install targets
|
||||
for tgt in $TARGETS; do
|
||||
# trim possible commas/spaces
|
||||
tgt=$(echo "$tgt" | tr -d ',')
|
||||
rustup target add "$tgt" --toolchain "$TOOLCHAIN" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Set default toolchain (best-effort)
|
||||
rustup default "$TOOLCHAIN" >/dev/null 2>&1 || true
|
||||
else
|
||||
echo "[devShell] rustup not found in shell; please ensure pkgs.rustup is present"
|
||||
fi
|
||||
rustup target add wasm32-unknown-unknown
|
||||
'';
|
||||
};
|
||||
|
||||
packages."x86_64-linux" =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
gtkNativeInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.wrapGAppsHook4
|
||||
];
|
||||
|
||||
cargoOverrides =
|
||||
pkgs:
|
||||
pkgs.buildRustCrate.override {
|
||||
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
||||
gobject-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gio-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gdk-pixbuf-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
libadwaita-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
|
||||
# Ensure rusqlite build scripts can find sqlite via pkg-config
|
||||
rusqlite =
|
||||
attrs:
|
||||
attrs.overrideAttrs (old: {
|
||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
|
||||
pkgs.pkg-config
|
||||
pkgs.sqlite
|
||||
];
|
||||
});
|
||||
|
||||
# Ensure rusqlite_migration build.rs can read the README and also has sqlite available.
|
||||
# Use overrideAttrs so preBuild runs in the final derivation.
|
||||
rusqlite_migration =
|
||||
attrs:
|
||||
attrs.overrideAttrs (
|
||||
old:
|
||||
let
|
||||
prevNBI = old.nativeBuildInputs or [ ];
|
||||
prevPre = old.preBuild or "";
|
||||
in
|
||||
{
|
||||
nativeBuildInputs = prevNBI ++ [
|
||||
pkgs.pkg-config
|
||||
pkgs.sqlite
|
||||
];
|
||||
|
||||
# Run before build so build.rs can see CARGO_PKG_README.
|
||||
preBuild = ''
|
||||
# If the unpacked crate sources contain README.md, point the build script at it.
|
||||
if [ -n "${attrs.src}" ] && [ -f "${attrs.src}/README.md" ]; then
|
||||
export CARGO_PKG_README="${attrs.src}/README.md"
|
||||
elif [ -f "$PWD/README.md" ]; then
|
||||
# fallback to current working directory (extracted source)
|
||||
export CARGO_PKG_README="$PWD/README.md"
|
||||
fi
|
||||
|
||||
# Preserve any previous preBuild content from the original derivation.
|
||||
${prevPre}
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
# Ensure GTK-based crates get the GTK native inputs
|
||||
dashboard = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
fitnesstrax = import ./fitnesstrax/app/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
simulator = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
otg-gtk = import ./otg/gtk/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
};
|
||||
};
|
||||
|
||||
cargo_nix = pkgs.callPackage ./Cargo.nix {
|
||||
nixpkgs = nixpkgs;
|
||||
buildRustCrateForPkgs = cargoOverrides;
|
||||
};
|
||||
|
||||
in
|
||||
rec {
|
||||
cyberpunk-splash = cargo_nix.workspaceMembers.cyberpunk-splash.build;
|
||||
dashboard = cargo_nix.workspaceMembers.dashboard.build;
|
||||
fitnesstrax = cargo_nix.workspaceMembers.fitnesstrax.build;
|
||||
l10n-db = cargo_nix.workspaceMembers.l10n-db.build;
|
||||
|
||||
# visions-server is provided by crate2nix workspace members
|
||||
visions-server = cargo_nix.workspaceMembers."visions-server".build;
|
||||
|
||||
# visions-server is provided by crate2nix workspace members
|
||||
simulator = cargo_nix.workspaceMembers.simulator.build;
|
||||
|
||||
all = pkgs.symlinkJoin {
|
||||
name = "all";
|
||||
paths = [
|
||||
cyberpunk-splash
|
||||
dashboard
|
||||
fitnesstrax
|
||||
l10n-db
|
||||
visions-server
|
||||
simulator
|
||||
];
|
||||
};
|
||||
|
||||
default = all;
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
233
flake.nix.old
Normal file
233
flake.nix.old
Normal file
@@ -0,0 +1,233 @@
|
||||
{
|
||||
description = "Lumenescent Dreams Tools";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-25.11";
|
||||
unstable.url = "nixpkgs/nixos-unstable";
|
||||
typeshare.url = "github:1Password/typeshare";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
unstable,
|
||||
typeshare,
|
||||
...
|
||||
}:
|
||||
let
|
||||
version = builtins.string 0 8 self.lastModifiedDate;
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
in
|
||||
{
|
||||
devShells."x86_64-linux".default =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
pkgs-unstable = import unstable { system = "x86_64-linux"; };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "ld-tools-devshell";
|
||||
buildInputs = [
|
||||
pkgs.cargo-nextest
|
||||
pkgs.cargo-watch
|
||||
pkgs.clang
|
||||
pkgs.crate2nix
|
||||
pkgs.trunk
|
||||
pkgs.glib
|
||||
pkgs.gst_all_1.gst-plugins-bad
|
||||
pkgs.gst_all_1.gst-plugins-base
|
||||
pkgs.gst_all_1.gst-plugins-good
|
||||
pkgs.gst_all_1.gst-plugins-ugly
|
||||
pkgs.gst_all_1.gstreamer
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.librsvg
|
||||
pkgs.nodejs
|
||||
pkgs.openssl
|
||||
pkgs.pipewire
|
||||
pkgs.pkg-config
|
||||
pkgs.rustup
|
||||
pkgs.sqlite
|
||||
pkgs.cargo-nextest
|
||||
pkgs.wasm-pack
|
||||
pkgs.sqlx-cli
|
||||
pkgs.udev
|
||||
pkgs.wasm-pack
|
||||
pkgs.go-task
|
||||
pkgs.nixfmt
|
||||
typeshare.packages."x86_64-linux".default
|
||||
pkgs.nodePackages_latest.typescript-language-server
|
||||
];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
ENV = "dev";
|
||||
|
||||
shellHook = ''
|
||||
# Use the repository rust-toolchain file when present, otherwise default to 1.92.0
|
||||
if [ -f ./rust-toolchain ]; then
|
||||
# Extract just the channel value from the TOML file (e.g. channel = "1.92.0")
|
||||
TOOLCHAIN=$(grep -E '^[[:space:]]*channel' ./rust-toolchain | sed -E 's/.*"([^"]+)".*/\1/' | head -n1)
|
||||
|
||||
# Parse components and targets arrays (extract quoted strings). Result will be space-separated.
|
||||
COMPONENTS=$(grep -E '^[[:space:]]*components' ./rust-toolchain | sed -E 's/.*\[(.*)\].*/\1/' | grep -oE '"[^"]+"' | tr -d '"' | xargs echo)
|
||||
TARGETS=$(grep -E '^[[:space:]]*targets' ./rust-toolchain | sed -E 's/.*\[(.*)\].*/\1/' | grep -oE '"[^"]+"' | tr -d '"' | xargs echo)
|
||||
|
||||
if [ -z "$TOOLCHAIN" ]; then
|
||||
TOOLCHAIN="1.92.0"
|
||||
fi
|
||||
if [ -z "$COMPONENTS" ]; then
|
||||
COMPONENTS="cargo rustc rustfmt rust-analyzer clippy"
|
||||
fi
|
||||
if [ -z "$TARGETS" ]; then
|
||||
TARGETS="x86_64-unknown-linux-gnu wasm32-unknown-unknown thumbv6m-none-eabi"
|
||||
fi
|
||||
else
|
||||
TOOLCHAIN="1.92.0"
|
||||
COMPONENTS="cargo rustc rustfmt rust-analyzer clippy"
|
||||
TARGETS="x86_64-unknown-linux-gnu wasm32-unknown-unknown thumbv6m-none-eabi"
|
||||
fi
|
||||
|
||||
# Ensure we always include these helpful extras (best-effort); avoid duplicates by appending.
|
||||
EXTRA_COMPONENTS="cargo-nextest cargo-watch"
|
||||
for c in $EXTRA_COMPONENTS; do
|
||||
case " $COMPONENTS " in
|
||||
*" $c "*) : ;; # already present
|
||||
*) COMPONENTS="$COMPONENTS $c" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "[devShell] will ensure rustup toolchain: $TOOLCHAIN"
|
||||
echo "[devShell] will install components: $COMPONENTS"
|
||||
echo "[devShell] will add targets: $TARGETS"
|
||||
|
||||
export RUSTUP_HOME="$HOME/.rustup"
|
||||
export CARGO_HOME="$HOME/.cargo"
|
||||
|
||||
if command -v rustup >/dev/null 2>&1; then
|
||||
# Install the requested toolchain if missing. Ignore errors so shell still opens.
|
||||
rustup toolchain install "$TOOLCHAIN" --no-self-update || true
|
||||
|
||||
# Install components (best-effort; some toolchains may not expose all components)
|
||||
for comp in $COMPONENTS; do
|
||||
# trim possible commas/spaces
|
||||
comp=$(echo "$comp" | tr -d ',')
|
||||
rustup component add "$comp" --toolchain "$TOOLCHAIN" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Install targets
|
||||
for tgt in $TARGETS; do
|
||||
# trim possible commas/spaces
|
||||
tgt=$(echo "$tgt" | tr -d ',')
|
||||
rustup target add "$tgt" --toolchain "$TOOLCHAIN" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Set default toolchain (best-effort)
|
||||
rustup default "$TOOLCHAIN" >/dev/null 2>&1 || true
|
||||
else
|
||||
echo "[devShell] rustup not found in shell; please ensure pkgs.rustup is present"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
packages."x86_64-linux" =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
gtkNativeInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.wrapGAppsHook4
|
||||
];
|
||||
|
||||
cargoOverrides =
|
||||
pkgs:
|
||||
pkgs.buildRustCrate.override {
|
||||
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
||||
gobject-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gio-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gdk-pixbuf-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
libadwaita-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
|
||||
# Ensure rusqlite build scripts can find sqlite via pkg-config
|
||||
rusqlite =
|
||||
attrs:
|
||||
attrs.overrideAttrs (old: {
|
||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
|
||||
pkgs.pkg-config
|
||||
pkgs.sqlite
|
||||
];
|
||||
});
|
||||
|
||||
# Ensure rusqlite_migration build.rs can read the README and also has sqlite available.
|
||||
# Use overrideAttrs so preBuild runs in the final derivation.
|
||||
rusqlite_migration =
|
||||
attrs:
|
||||
attrs.overrideAttrs (
|
||||
old:
|
||||
let
|
||||
prevNBI = old.nativeBuildInputs or [ ];
|
||||
prevPre = old.preBuild or "";
|
||||
in
|
||||
{
|
||||
nativeBuildInputs = prevNBI ++ [
|
||||
pkgs.pkg-config
|
||||
pkgs.sqlite
|
||||
];
|
||||
|
||||
# Run before build so build.rs can see CARGO_PKG_README.
|
||||
preBuild = ''
|
||||
# If the unpacked crate sources contain README.md, point the build script at it.
|
||||
if [ -n "${attrs.src}" ] && [ -f "${attrs.src}/README.md" ]; then
|
||||
export CARGO_PKG_README="${attrs.src}/README.md"
|
||||
elif [ -f "$PWD/README.md" ]; then
|
||||
# fallback to current working directory (extracted source)
|
||||
export CARGO_PKG_README="$PWD/README.md"
|
||||
fi
|
||||
|
||||
# Preserve any previous preBuild content from the original derivation.
|
||||
${prevPre}
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
# Ensure GTK-based crates get the GTK native inputs
|
||||
dashboard = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
fitnesstrax = import ./fitnesstrax/app/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
simulator = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
otg-gtk = import ./otg/gtk/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
};
|
||||
};
|
||||
|
||||
cargo_nix = pkgs.callPackage ./Cargo.nix {
|
||||
nixpkgs = nixpkgs;
|
||||
buildRustCrateForPkgs = cargoOverrides;
|
||||
};
|
||||
|
||||
in
|
||||
rec {
|
||||
cyberpunk-splash = cargo_nix.workspaceMembers.cyberpunk-splash.build;
|
||||
dashboard = cargo_nix.workspaceMembers.dashboard.build;
|
||||
fitnesstrax = cargo_nix.workspaceMembers.fitnesstrax.build;
|
||||
l10n-db = cargo_nix.workspaceMembers.l10n-db.build;
|
||||
|
||||
# visions-server is provided by crate2nix workspace members
|
||||
visions-server = cargo_nix.workspaceMembers."visions-server".build;
|
||||
|
||||
# visions-server is provided by crate2nix workspace members
|
||||
simulator = cargo_nix.workspaceMembers.simulator.build;
|
||||
|
||||
all = pkgs.symlinkJoin {
|
||||
name = "all";
|
||||
paths = [
|
||||
cyberpunk-splash
|
||||
dashboard
|
||||
fitnesstrax
|
||||
l10n-db
|
||||
visions-server
|
||||
simulator
|
||||
];
|
||||
};
|
||||
|
||||
default = all;
|
||||
};
|
||||
};
|
||||
}
|
||||
63
plan.md
63
plan.md
@@ -1,5 +1,27 @@
|
||||
Goal: Create a new flake.nix file which provides a shell for Rust development and build instructions for multiple Rust applications.
|
||||
|
||||
Instructions:
|
||||
- Create a new flake.nix file to contain the new work.
|
||||
- Define a developer shell which installs Rust, extra Rust tools, and the dependencies needed for building the project. A list of dependencies is given below in the section titled "The Shell".
|
||||
- Define a derivation for each of the installable applications. A list of applications and their dependencies is given below in the section titled "Applications".
|
||||
|
||||
Parameters:
|
||||
- I have backed up the existing flake.nix as flake.nix.old. You may disregard it, but I will use it for reference if we encounter an issue that I have seen before. Ignore the Cargo.nix file. Use the fitnesstrax/app/override.nix file for guidance on postInstall and preFixup instructions that may still be valuable for the gtk applications.
|
||||
- Any application should be built as its own derivation.
|
||||
- Use Crane for build and dependency management. Ensure that dependencies for each application are built into a derivation separate from the final application.
|
||||
- The flake.nix should use flake-utils to implement the instructions for Linux x86_64 and ARM for Raspberry Pi platforms, and for MacOS. Other platforms will be disregarded at this time.
|
||||
- The Rust toolchain and corresponding Rust utilities can be installed through any mechanism available, with these restrictions:
|
||||
- The devshell and the application derivations use identical rust shells.
|
||||
|
||||
Known Issues:
|
||||
- The rusqlite_migration crate requires that the environment variable CARGO_PKG_README be set to the path to the README.md file at the root fo the rusqlite_migration source tree.
|
||||
|
||||
Supported host platforms:
|
||||
|
||||
- x86_64-unknown-linux-gnu
|
||||
- aarch64-apple-darwin
|
||||
- aarch64-unknown-linux-gnu
|
||||
|
||||
# The Shell
|
||||
|
||||
The shell is an interactive environment containing all of the tools commonly used for Rust development. These tools are:
|
||||
@@ -16,33 +38,32 @@ The shell is an interactive environment containing all of the tools commonly use
|
||||
- sqlite
|
||||
- go-task
|
||||
|
||||
# The Rust toolchain
|
||||
The devshell should include these Rust components:
|
||||
- cargo, rustc, rustfmt, rust-analyzer, clippy, cargo-nextest, and cargo-watch
|
||||
|
||||
The shell environment specifies that we will install rustup. I want to control Rust versions through the `rust-toolchain` file. The file should
|
||||
- use channel 1.92.0
|
||||
- include the targets x86_64-unknown-linux-gnu, wasm32-unknown-unknown, and thumbv6m-none-eabi
|
||||
- install the components cargo, rustc, rustfmt, rust-analyzer, clippy, cargo-nextest, and cargo-watch
|
||||
Rust in the devshell should be able to build executables for these targets:
|
||||
- the host platform
|
||||
- wasm32-unknown-unknown
|
||||
|
||||
# Build and distribution instructions
|
||||
|
||||
The following packages should, by default, be built for the host platform. There should also be a parameter which allows the user to specify any other platform supported by Rust and Nix.
|
||||
# Applications
|
||||
|
||||
- bike-lights/simulator
|
||||
- visions__build/bike-lights/simulator/Cargo.toml
|
||||
- dependencies: pkg-config, gtk4, libadwaita
|
||||
- Cargo.toml file: visions__build/bike-lights/simulator/Cargo.toml
|
||||
- native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
|
||||
- cyberpunk-splash
|
||||
- visions__build/cyberpunk-splash/Cargo.toml
|
||||
- dependencies: pkg-config, gtk4, libadwaita
|
||||
- Cargo.toml file: visions__build/cyberpunk-splash/Cargo.toml
|
||||
- native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
|
||||
- dashboard
|
||||
- visions__build/dashboard/Cargo.toml
|
||||
- dependencies: pkg-config, gtk4, libadwaita, openssl
|
||||
- Cargo.toml file: visions__build/dashboard/Cargo.toml
|
||||
- native dependencies: pkg-config, gtk4, libadwaita, openssl, wrapGAppsHook4
|
||||
- fitnesstrax
|
||||
- visions__build/fitnesstrax/app/Cargo.toml
|
||||
- dependencies: pkg-config, gtk4, libadwaita
|
||||
- additional files: resources/fitnesstrax.desktop, resources/com.luminescent-dreams.fitnesstrax.gschema.xml
|
||||
- The fitnesstrax installation should install the desktop and gschema.xml files to their correct locations. It should include a launcher script that sets up paths for a GTK application.
|
||||
- Cargo.toml file: visions__build/fitnesstrax/app/Cargo.toml
|
||||
- native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
|
||||
- additional files: resources/fitnesstrax.desktop, resources/com.luminescent-dreams.fitnesstrax.gschema.xml. The postInstall script in fitnesstrax/app/override.nix installs the files to their correct locations in the installation directory. The preFixup script uses gappsWrapperArgs, paired with the wrapGAppsHook4 native dependency, to generate the launcher script.
|
||||
- visions-server
|
||||
- visions__build/visions/server/Cargo.toml
|
||||
- dependencies: openssl, sqlite
|
||||
- Cargo.toml file: visions__build/visions/server/Cargo.toml
|
||||
- native dependencies: openssl, sqlite
|
||||
|
||||
The following package should always be cross-compiled for wasm32-unknown-unknown: visions-ui. This package will never be installed through Nix. The Cargo.toml for this project is visions__build/visions/ui/Cargo.toml.
|
||||
The following package should always be cross-compiled for wasm32-unknown-unknown, no matter the source platform:
|
||||
- visions-ui.
|
||||
- This package will built, but not installed, through Nix. The Cargo.toml for this project is visions__build/visions/ui/Cargo.toml.
|
||||
|
||||
Reference in New Issue
Block a user