Add nix package (#1829)
* .editorconfig: force spaces and 2 space indent_size * nix: package init at 0.1.7 * gitignore: ignore result symlinks created by nix build * nix/devShell: obtain toolchain used by package recipe to build the package * nix: the toolchain should never be installed globally as encouraged by fenix * nix: format nix code and add nixfmt-tree formatter * nix: add overlay to flake outputs * zeroclaw-web: fix unknow name loading building with Nix * nix: package zeroclaw-web at 0.1.0 * zeroclaw: use build zeroclaw-web artifacts direclty * nix: remove reference to the Rust toolchain from the runtime dependencies
This commit is contained in:
parent
6106c2547e
commit
035b19ffba
@ -23,3 +23,7 @@ indent_size = 2
|
||||
|
||||
[Dockerfile]
|
||||
indent_size = 4
|
||||
|
||||
[*.nix]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -33,3 +33,6 @@ venv/
|
||||
*.pem
|
||||
credentials.json
|
||||
.worktrees/
|
||||
|
||||
# Nix
|
||||
result
|
||||
|
||||
70
flake.nix
70
flake.nix
@ -8,54 +8,44 @@
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { flake-utils, fenix, nixpkgs, ... }:
|
||||
let
|
||||
nixosModule = { pkgs, ... }: {
|
||||
nixpkgs.overlays = [ fenix.overlays.default ];
|
||||
environment.systemPackages = [
|
||||
(pkgs.fenix.stable.withComponents [
|
||||
"cargo"
|
||||
"clippy"
|
||||
"rust-src"
|
||||
"rustc"
|
||||
"rustfmt"
|
||||
])
|
||||
pkgs.rust-analyzer
|
||||
];
|
||||
};
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
flake-utils,
|
||||
fenix,
|
||||
nixpkgs,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ fenix.overlays.default ];
|
||||
overlays = [
|
||||
fenix.overlays.default
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
};
|
||||
rustToolchain = pkgs.fenix.stable.withComponents [
|
||||
"cargo"
|
||||
"clippy"
|
||||
"rust-src"
|
||||
"rustc"
|
||||
"rustfmt"
|
||||
];
|
||||
in {
|
||||
packages.default = fenix.packages.${system}.stable.toolchain;
|
||||
in
|
||||
{
|
||||
formatter = pkgs.nixfmt-tree;
|
||||
|
||||
packages = {
|
||||
default = self.packages.${system}.zeroclaw;
|
||||
inherit (pkgs)
|
||||
zeroclaw
|
||||
zeroclaw-web
|
||||
;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inputsFrom = [ pkgs.zeroclaw ];
|
||||
packages = [
|
||||
rustToolchain
|
||||
pkgs.rust-analyzer
|
||||
];
|
||||
};
|
||||
}) // {
|
||||
nixosConfigurations = {
|
||||
nixos = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [ nixosModule ];
|
||||
};
|
||||
|
||||
nixos-aarch64 = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
modules = [ nixosModule ];
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
// {
|
||||
overlays.default = import ./overlay.nix;
|
||||
};
|
||||
}
|
||||
|
||||
13
overlay.nix
Normal file
13
overlay.nix
Normal file
@ -0,0 +1,13 @@
|
||||
final: prev: {
|
||||
zeroclaw-web = final.callPackage ./web/package.nix { };
|
||||
|
||||
zeroclaw = final.callPackage ./package.nix {
|
||||
rustToolchain = final.fenix.stable.withComponents [
|
||||
"cargo"
|
||||
"clippy"
|
||||
"rust-src"
|
||||
"rustc"
|
||||
"rustfmt"
|
||||
];
|
||||
};
|
||||
}
|
||||
58
package.nix
Normal file
58
package.nix
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
makeRustPlatform,
|
||||
rustToolchain,
|
||||
lib,
|
||||
zeroclaw-web,
|
||||
removeReferencesTo,
|
||||
}:
|
||||
let
|
||||
rustPlatform = makeRustPlatform {
|
||||
cargo = rustToolchain;
|
||||
rustc = rustToolchain;
|
||||
};
|
||||
in
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "zeroclaw";
|
||||
version = "0.1.7";
|
||||
|
||||
src =
|
||||
let
|
||||
fs = lib.fileset;
|
||||
in
|
||||
fs.toSource {
|
||||
root = ./.;
|
||||
fileset = fs.unions (
|
||||
[
|
||||
./src
|
||||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
./crates
|
||||
./benches
|
||||
]
|
||||
++ (lib.optionals finalAttrs.doCheck [
|
||||
./tests
|
||||
./test_helpers
|
||||
])
|
||||
);
|
||||
};
|
||||
prePatch = ''
|
||||
mkdir web
|
||||
ln -s ${zeroclaw-web} web/dist
|
||||
'';
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = [
|
||||
removeReferencesTo
|
||||
];
|
||||
|
||||
# Since tests run in the official pipeline, no need to run them in the Nix sandbox.
|
||||
# Can be changed by consumers using `overrideAttrs` on this package.
|
||||
doCheck = false;
|
||||
|
||||
# Some dependency causes Nix to detect the Rust toolchain to be a runtime dependency
|
||||
# of zeroclaw. This manually removes any reference to the toolchain.
|
||||
postFixup = ''
|
||||
find "$out" -type f -exec remove-references-to -t ${rustToolchain} '{}' +
|
||||
'';
|
||||
})
|
||||
31
web/package.nix
Normal file
31
web/package.nix
Normal file
@ -0,0 +1,31 @@
|
||||
{ buildNpmPackage, lib }:
|
||||
buildNpmPackage {
|
||||
pname = "zeroclaw-web";
|
||||
version = "0.1.0";
|
||||
|
||||
src =
|
||||
let
|
||||
fs = lib.fileset;
|
||||
in
|
||||
fs.toSource {
|
||||
root = ./.;
|
||||
fileset = fs.unions [
|
||||
./src
|
||||
./index.html
|
||||
./package.json
|
||||
./package-lock.json
|
||||
./tsconfig.json
|
||||
./tsconfig.app.json
|
||||
./tsconfig.node.json
|
||||
./vite.config.ts
|
||||
];
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-H3extDaq4DgNYTUcw57gqwVWc3aPCWjIJEVYRMzdFdM=";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
cp -r dist $out
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
@ -80,7 +80,7 @@ function PairingDialog({ onPair }: { onPair: (code: string) => Promise<void> })
|
||||
}
|
||||
|
||||
function AppContent() {
|
||||
const { isAuthenticated, pair, logout } = useAuth();
|
||||
const { isAuthenticated, loading, pair, logout } = useAuth();
|
||||
const [locale, setLocaleState] = useState<Locale>('tr');
|
||||
|
||||
const setAppLocale = (newLocale: Locale) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user