mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Replace npm build script with new cargo run tool (#3832)
* move nix flake to root * cargo run tool * use thiserror in third-party-licenses tool * prefere panic over exit * Add automatic dependency check to cargo run tool * Skip dependecies that are not needed for the current task * Fixup * Fixup * fix windows * Fixup * improve usage text * Fix linux bundle * add graphen-cli * fix build profile * fix * release profile should not include debug infos * Review * remove profiling profile was redundent with release * rename to cargo-run tool * improve consistency * rename deps to requirements * fix * return success when showing usage
This commit is contained in:
81
.nix/default.nix
Normal file
81
.nix/default.nix
Normal file
@@ -0,0 +1,81 @@
|
||||
inputs:
|
||||
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems (system: f system);
|
||||
args =
|
||||
system:
|
||||
(
|
||||
let
|
||||
lib = inputs.nixpkgs.lib // {
|
||||
call = p: import p args;
|
||||
};
|
||||
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
info = {
|
||||
pname = "graphite";
|
||||
version = "unstable";
|
||||
src = inputs.nixpkgs.lib.cleanSourceWith {
|
||||
src = ./..;
|
||||
filter = path: type: !(type == "directory" && builtins.baseNameOf path == ".nix");
|
||||
};
|
||||
cargoVendored = deps.crane.lib.vendorCargoDeps { inherit (info) src; };
|
||||
};
|
||||
|
||||
deps = {
|
||||
crane = lib.call ./deps/crane.nix;
|
||||
cef = lib.call ./deps/cef.nix;
|
||||
rustGPU = lib.call ./deps/rust-gpu.nix;
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit system;
|
||||
inherit (inputs) self;
|
||||
inherit inputs;
|
||||
inherit pkgs;
|
||||
inherit lib;
|
||||
inherit info;
|
||||
inherit deps;
|
||||
}
|
||||
// inputs;
|
||||
in
|
||||
args
|
||||
);
|
||||
withArgs = f: forAllSystems (system: f (args system));
|
||||
in
|
||||
{
|
||||
packages = withArgs (
|
||||
{ lib, ... }:
|
||||
rec {
|
||||
default = graphite;
|
||||
graphite = (lib.call ./pkgs/graphite.nix) { };
|
||||
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
||||
graphite-raster-nodes-shaders = lib.call ./pkgs/graphite-raster-nodes-shaders.nix;
|
||||
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
||||
graphite-bundle = lib.call ./pkgs/graphite-bundle.nix;
|
||||
graphite-flatpak-manifest = lib.call ./pkgs/graphite-flatpak-manifest.nix;
|
||||
|
||||
# TODO: graphene-cli = lib.call ./pkgs/graphene-cli.nix;
|
||||
|
||||
tools = {
|
||||
third-party-licenses = lib.call ./pkgs/tools/third-party-licenses.nix;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = withArgs (
|
||||
{ lib, ... }:
|
||||
{
|
||||
default = lib.call ./dev.nix;
|
||||
}
|
||||
);
|
||||
|
||||
formatter = withArgs ({ pkgs, ... }: pkgs.nixfmt-tree);
|
||||
}
|
||||
79
.nix/flake.lock
generated
79
.nix/flake.lock
generated
@@ -1,79 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1770169865,
|
||||
"narHash": "sha256-iPiy13xzDQ9GjpOez+NNIjh/qjl7i4RDf9dF2x5mF9I=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "8254ccf3b5b5131890ee073776f2e61c6d1e55d4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"revCount": 69,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1770197578,
|
||||
"narHash": "sha256-AYqlWrX09+HvGs8zM6ebZ1pwUqjkfpnv8mewYwAo+iM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "00c21e4c93d963c50d4c0c89bfa84ed6e0694df2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1770347142,
|
||||
"narHash": "sha256-uz+ZSqXpXEPtdRPYwvgsum/CfNq7AUQ/0gZHqTigiPM=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "2859683cd9ef7858d324c5399b0d8d6652bf4044",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
110
.nix/flake.nix
110
.nix/flake.nix
@@ -1,110 +0,0 @@
|
||||
# This is a helper file for people using NixOS as their operating system.
|
||||
# If you don't know what this file does, you can safely ignore it.
|
||||
# This file defines the reproducible development environment for the project.
|
||||
#
|
||||
# Development Environment:
|
||||
# - Provides all necessary tools for Rust/Wasm development
|
||||
# - Includes dependencies for desktop app development
|
||||
# - Sets up profiling and debugging tools
|
||||
# - Configures mold as the default linker for faster builds
|
||||
#
|
||||
# Usage:
|
||||
# - Development shell: `nix develop .nix` from the project root
|
||||
# - Run in dev shell with direnv: add `use flake` to .envrc
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
|
||||
# This is used to provide a identical development shell at `shell.nix` for users that do not use flakes
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs:
|
||||
(
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems (system: f system);
|
||||
args =
|
||||
system:
|
||||
(
|
||||
let
|
||||
lib = inputs.nixpkgs.lib // {
|
||||
call = p: import p args;
|
||||
};
|
||||
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
info = {
|
||||
pname = "graphite";
|
||||
version = "unstable";
|
||||
src = inputs.nixpkgs.lib.cleanSourceWith {
|
||||
src = ./..;
|
||||
filter = path: type: !(type == "directory" && builtins.baseNameOf path == ".nix");
|
||||
};
|
||||
cargoVendored = deps.crane.lib.vendorCargoDeps { inherit (info) src; };
|
||||
};
|
||||
|
||||
deps = {
|
||||
crane = lib.call ./deps/crane.nix;
|
||||
cef = lib.call ./deps/cef.nix;
|
||||
rustGPU = lib.call ./deps/rust-gpu.nix;
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit system;
|
||||
inherit (inputs) self;
|
||||
inherit inputs;
|
||||
inherit pkgs;
|
||||
inherit lib;
|
||||
inherit info;
|
||||
inherit deps;
|
||||
}
|
||||
// inputs;
|
||||
in
|
||||
args
|
||||
);
|
||||
withArgs = f: forAllSystems (system: f (args system));
|
||||
in
|
||||
{
|
||||
packages = withArgs (
|
||||
{ lib, ... }:
|
||||
rec {
|
||||
default = graphite;
|
||||
graphite = (lib.call ./pkgs/graphite.nix) { };
|
||||
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
||||
graphite-raster-nodes-shaders = lib.call ./pkgs/graphite-raster-nodes-shaders.nix;
|
||||
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
||||
graphite-bundle = lib.call ./pkgs/graphite-bundle.nix;
|
||||
graphite-flatpak-manifest = lib.call ./pkgs/graphite-flatpak-manifest.nix;
|
||||
|
||||
# TODO: graphene-cli = lib.call ./pkgs/graphene-cli.nix;
|
||||
|
||||
tools = {
|
||||
third-party-licenses = lib.call ./pkgs/tools/third-party-licenses.nix;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = withArgs (
|
||||
{ lib, ... }:
|
||||
{
|
||||
default = lib.call ./dev.nix;
|
||||
}
|
||||
);
|
||||
|
||||
formatter = withArgs ({ pkgs, ... }: pkgs.nixfmt-tree);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
# This is a helper file for people using NixOS as their operating system.
|
||||
# If you don't know what this file does, you can safely ignore it.
|
||||
|
||||
# If you are using Nix as your package manager, you can run 'nix-shell .nix'
|
||||
# in the root directory of the project and Nix will open a bash shell
|
||||
# with all the packages needed to build and run Graphite installed.
|
||||
# A shell.nix file is used in the Nix ecosystem to define a development
|
||||
# environment with specific dependencies. When you enter a Nix shell using
|
||||
# this file, it ensures that all the specified tools and libraries are
|
||||
# available regardless of the host system's configuration. This provides
|
||||
# a reproducible development environment across different machines and developers.
|
||||
|
||||
# You can enter the Nix shell and run Graphite like normal with:
|
||||
# > npm start
|
||||
# Or you can run it like this without needing to first enter the Nix shell:
|
||||
# > nix-shell .nix --command "npm start"
|
||||
|
||||
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||
in
|
||||
fetchTarball {
|
||||
url = lock.nodes.${nodeName}.locked.url;
|
||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||
}
|
||||
) { src = ./.; }).shellNix
|
||||
Reference in New Issue
Block a user