|
19 | 19 | inputs.nixpkgs.follows = "nixpkgs"; |
20 | 20 | }; |
21 | 21 | flake-utils.url = "github:numtide/flake-utils"; |
| 22 | + crane.url = "github:ipetkov/crane"; |
22 | 23 |
|
23 | 24 | # This is used to provide a identical development shell at `shell.nix` for users that do not use flakes |
24 | 25 | flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; |
25 | 26 | }; |
26 | 27 |
|
27 | | - outputs = { nixpkgs, rust-overlay, flake-utils, ... }: |
28 | | - flake-utils.lib.eachDefaultSystem (system: |
29 | | - let |
30 | | - overlays = [ (import rust-overlay) ]; |
31 | | - pkgs = import nixpkgs { inherit system overlays; }; |
32 | | - |
33 | | - rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ]; |
34 | | - rust = pkgs.rust-bin.stable.latest.default.override { |
35 | | - targets = [ "wasm32-unknown-unknown" ]; |
36 | | - extensions = rustExtensions; |
37 | | - }; |
38 | | - |
39 | | - # Shared build inputs; libraries that need to be in LD_LIBRARY_PATH |
40 | | - buildInputs = [ |
| 28 | + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: |
| 29 | + let |
| 30 | + info = { |
| 31 | + pname = "graphite"; |
| 32 | + version = "unstable"; |
| 33 | + src = ./..; |
| 34 | + }; |
| 35 | + |
| 36 | + pkgs = import inputs.nixpkgs { |
| 37 | + inherit system; |
| 38 | + overlays = [ (import inputs.rust-overlay) ]; |
| 39 | + }; |
| 40 | + |
| 41 | + deps = { |
| 42 | + rust = import ./deps/rust.nix { inherit pkgs inputs; }; |
| 43 | + crane = import ./deps/crane.nix { inherit pkgs inputs; }; |
| 44 | + cef = import ./deps/cef.nix { inherit pkgs inputs; }; |
| 45 | + rustGPU = import ./deps/rust-gpu.nix { inherit pkgs inputs; }; |
| 46 | + }; |
| 47 | + |
| 48 | + libs = rec { |
| 49 | + desktop = [ |
41 | 50 | pkgs.wayland |
42 | 51 | pkgs.openssl |
43 | 52 | pkgs.vulkan-loader |
44 | 53 | pkgs.libraw |
45 | 54 | pkgs.libGL |
46 | | - |
47 | | - # X11 libraries, not needed on wayland! Remove when x11 is finally dead |
| 55 | + ]; |
| 56 | + desktop-x11 = [ |
48 | 57 | pkgs.libxkbcommon |
49 | 58 | pkgs.xorg.libXcursor |
50 | 59 | pkgs.xorg.libxcb |
51 | 60 | pkgs.xorg.libX11 |
52 | 61 | ]; |
| 62 | + desktop-all = desktop ++ desktop-x11; |
| 63 | + }; |
53 | 64 |
|
54 | | - # Packages needed to build the package |
55 | | - buildTools = [ |
56 | | - rust |
| 65 | + tools = rec { |
| 66 | + desktop = [ |
| 67 | + pkgs.pkg-config |
| 68 | + ]; |
| 69 | + frontend = [ |
| 70 | + pkgs.lld |
57 | 71 | pkgs.nodejs |
58 | 72 | pkgs.nodePackages.npm |
59 | 73 | pkgs.binaryen |
60 | 74 | pkgs.wasm-bindgen-cli_0_2_100 |
61 | 75 | pkgs.wasm-pack |
62 | | - pkgs.pkg-config |
63 | 76 | pkgs.cargo-about |
64 | 77 | ]; |
| 78 | + dev = [ |
| 79 | + pkgs.rustc |
| 80 | + pkgs.cargo |
| 81 | + pkgs.rust-analyzer |
| 82 | + pkgs.clippy |
65 | 83 |
|
66 | | - # Development tools; not needed to build the package |
67 | | - devTools = [ |
68 | 84 | pkgs.git |
69 | 85 |
|
70 | 86 | pkgs.cargo-watch |
|
79 | 95 | pkgs.samply |
80 | 96 | pkgs.cargo-flamegraph |
81 | 97 | ]; |
82 | | - |
83 | | - cefEnv = import ./cef.nix { inherit pkgs; }; |
84 | | - rustGPUEnv = import ./rust-gpu.nix { inherit pkgs; }; |
85 | | - |
86 | | - libPath = "${pkgs.lib.makeLibraryPath buildInputs}:${cefEnv.CEF_PATH}"; |
87 | | - in { |
88 | | - devShells.default = pkgs.mkShell ({ |
89 | | - packages = buildInputs ++ buildTools ++ devTools; |
90 | | - |
91 | | - LD_LIBRARY_PATH = libPath; |
92 | | - XDG_DATA_DIRS = |
93 | | - "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS"; |
94 | | - |
95 | | - shellHook = '' |
96 | | - alias cargo='mold --run cargo' |
97 | | - ''; |
98 | | - } // cefEnv // rustGPUEnv); |
99 | | - |
100 | | - packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: { |
101 | | - pname = "graphite-editor"; |
102 | | - version = "unstable"; |
103 | | - src = pkgs.lib.cleanSource ./..; |
104 | | - |
105 | | - cargoLock = { |
106 | | - lockFile = ../Cargo.lock; |
107 | | - allowBuiltinFetchGit = true; |
108 | | - }; |
109 | | - |
110 | | - # TODO: Remove the need for this hash by using individual package resolutions and hashes from package-lock.json |
111 | | - npmDeps = pkgs.fetchNpmDeps { |
112 | | - inherit (finalAttrs) pname version; |
113 | | - src = "${finalAttrs.src}/frontend"; |
114 | | - hash = "sha256-UWuJpKNYj2Xn34rpMDZ75pzMYUOLQjPeGuJ/QlPbX9A="; |
115 | | - }; |
116 | | - |
117 | | - npmRoot = "frontend"; |
118 | | - npmConfigScript = "setup"; |
119 | | - makeCacheWritable = true; |
120 | | - |
121 | | - buildInputs = buildInputs; |
122 | | - nativeBuildInputs = buildTools ++ [ |
123 | | - pkgs.rustPlatform.cargoSetupHook |
124 | | - pkgs.npmHooks.npmConfigHook |
125 | | - pkgs.makeWrapper |
126 | | - ]; |
127 | | - |
128 | | - env = cefEnv // rustGPUEnv; |
129 | | - |
130 | | - buildPhase = '' |
131 | | - export HOME="$TMPDIR" |
132 | | -
|
133 | | - pushd frontend |
134 | | - npm run build-native |
135 | | - popd |
136 | | - cargo build -r -p graphite-desktop |
137 | | - ''; |
138 | | - |
139 | | - installPhase = '' |
140 | | - mkdir -p $out/bin |
141 | | - cp target/release/graphite-desktop $out/bin/graphite-editor |
142 | | -
|
143 | | - mkdir -p $out/share/applications |
144 | | - cp $src/desktop/assets/*.desktop $out/share/applications/ |
145 | | -
|
146 | | - mkdir -p $out/share/icons/hicolor/scalable/apps |
147 | | - cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/ |
148 | | - ''; |
149 | | - |
150 | | - doCheck = false; |
151 | | - |
152 | | - postFixup = '' |
153 | | - wrapProgram "$out/bin/graphite-editor" \ |
154 | | - --prefix LD_LIBRARY_PATH : "${libPath}" \ |
155 | | - --set CEF_PATH "${cefEnv.CEF_PATH}" |
156 | | - ''; |
157 | | - }); |
158 | | - }); |
| 98 | + all = frontend ++ dev; |
| 99 | + }; |
| 100 | + in |
| 101 | + { |
| 102 | + packages = rec { |
| 103 | + graphiteWithArgs = args: (import ./pkgs/graphite.nix { |
| 104 | + pkgs = pkgs // { inherit graphene-raster-nodes-shaders; }; |
| 105 | + inherit info inputs deps libs tools; |
| 106 | + }) args; |
| 107 | + graphite = graphiteWithArgs { }; |
| 108 | + graphite-dev = graphiteWithArgs { dev = true; }; |
| 109 | + graphite-without-resources = graphiteWithArgs { embeddedResources = false; }; |
| 110 | + graphite-without-resources-dev = graphiteWithArgs { embeddedResources = false; dev = true; }; |
| 111 | + #TODO: graphene-cli = import ./pkgs/graphene-cli.nix { inherit info pkgs inputs deps libs tools; }; |
| 112 | + graphene-raster-nodes-shaders = import ./pkgs/graphene-raster-nodes-shaders.nix { inherit info pkgs inputs deps libs tools; }; |
| 113 | + |
| 114 | + default = graphite; |
| 115 | + }; |
| 116 | + |
| 117 | + devShells.default = import ./dev.nix { inherit pkgs deps libs tools; }; |
| 118 | + } |
| 119 | + ); |
159 | 120 | } |
0 commit comments