-
-
Notifications
You must be signed in to change notification settings - Fork 172
Add cross-platform Nix flake support #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sachk
wants to merge
1
commit into
webosbrew:main
Choose a base branch
from
sachk:nix-flake-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| { | ||
| description = "webOS Dev Manager"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
| nixpkgs-x86-darwin.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin"; | ||
| }; | ||
|
|
||
| outputs = | ||
| { | ||
| nixpkgs, | ||
| nixpkgs-x86-darwin, | ||
| ... | ||
| }: | ||
| let | ||
| supportedSystems = [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| "x86_64-darwin" | ||
| "aarch64-darwin" | ||
| ]; | ||
| forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
| nixpkgsFor = | ||
| system: if system == "x86_64-darwin" then nixpkgs-x86-darwin else nixpkgs; | ||
| mkBuildInputs = | ||
| pkgs: | ||
| with pkgs; | ||
| [ | ||
| openssl | ||
| ] | ||
| ++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
| glib-networking | ||
| gsettings-desktop-schemas | ||
| gtk3 | ||
| shared-mime-info | ||
| webkitgtk_4_1 | ||
|
|
||
| gst_all_1.gstreamer | ||
| gst_all_1.gst-plugins-base | ||
| gst_all_1.gst-plugins-good | ||
| ]; | ||
| packageFor = | ||
| system: | ||
| let | ||
| pkgs = import (nixpkgsFor system) { inherit system; }; | ||
| packageJson = builtins.fromJSON (builtins.readFile ./package.json); | ||
| in | ||
| pkgs.rustPlatform.buildRustPackage { | ||
| pname = "webos-dev-manager"; | ||
| inherit (packageJson) version; | ||
|
|
||
| src = pkgs.lib.cleanSourceWith { | ||
| src = ./.; | ||
| filter = | ||
| path: type: | ||
| let | ||
| name = baseNameOf path; | ||
| in | ||
| !builtins.elem name [ | ||
| ".git" | ||
| "dist" | ||
| "flake.lock" | ||
| "flake.nix" | ||
| "node_modules" | ||
| "target" | ||
| "tmp" | ||
| ]; | ||
| }; | ||
|
|
||
| cargoLock = { | ||
| lockFile = ./Cargo.lock; | ||
| outputHashes = { | ||
| "r2d2-0.8.10" = "sha256-7bWbepxcaLbN0909s46ftHmtDUKrp4RCCKMZG0EiFG4="; | ||
| }; | ||
| }; | ||
|
|
||
| npmDeps = pkgs.importNpmLock { npmRoot = ./.; }; | ||
|
|
||
| nativeBuildInputs = | ||
| with pkgs; | ||
| [ | ||
| nodejs_24 | ||
| pkg-config | ||
| importNpmLock.npmConfigHook | ||
| ] | ||
| ++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
| wrapGAppsHook3 | ||
| ]; | ||
|
|
||
| buildInputs = mkBuildInputs pkgs; | ||
|
|
||
| preBuild = '' | ||
| npm run ng build | ||
| ''; | ||
|
|
||
| cargoBuildFlags = [ | ||
| "--package" | ||
| "devman" | ||
| ]; | ||
|
|
||
| cargoTestFlags = [ | ||
| "--package" | ||
| "devman" | ||
| "--lib" | ||
| ]; | ||
| # These tests need Docker SSH fixtures or host networking semantics | ||
| # that are unavailable in a pure Nix build sandbox. | ||
| checkFlags = [ | ||
| "--skip" | ||
| "conn_pool::cmd::test" | ||
| ]; | ||
|
|
||
| preFixup = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' | ||
| gappsWrapperArgs+=( | ||
| --prefix XDG_DATA_DIRS : "${pkgs.shared-mime-info}/share" | ||
| --set WEBKIT_DISABLE_DMABUF_RENDERER 1 | ||
| --set GDK_BACKEND x11 | ||
| ) | ||
| ''; | ||
|
|
||
| meta = { | ||
| description = packageJson.description; | ||
| homepage = packageJson.homepage; | ||
| license = pkgs.lib.licenses.asl20; | ||
| mainProgram = "webos-dev-manager"; | ||
| platforms = supportedSystems; | ||
| }; | ||
| }; | ||
| in | ||
| { | ||
| packages = forAllSystems ( | ||
| system: | ||
| let | ||
| package = packageFor system; | ||
| in | ||
| { | ||
| default = package; | ||
| webos-dev-manager = package; | ||
| } | ||
| ); | ||
|
|
||
| apps = forAllSystems ( | ||
| system: | ||
| let | ||
| package = packageFor system; | ||
| in | ||
| { | ||
| default = { | ||
| type = "app"; | ||
| program = "${package}/bin/webos-dev-manager"; | ||
| meta = package.meta; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| devShells = forAllSystems ( | ||
| system: | ||
| let | ||
| pkgs = import (nixpkgsFor system) { inherit system; }; | ||
| in | ||
| { | ||
| default = pkgs.mkShell ( | ||
| { | ||
| packages = with pkgs; [ | ||
| cargo | ||
| clippy | ||
| nodejs_24 | ||
| rustc | ||
| rustfmt | ||
| ]; | ||
|
|
||
| nativeBuildInputs = with pkgs; [ | ||
| pkg-config | ||
| ]; | ||
|
|
||
| buildInputs = mkBuildInputs pkgs; | ||
| } | ||
| // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { | ||
| # WebKitGTK needs the relocated Nix GSettings schemas at runtime. | ||
| shellHook = '' | ||
| export XDG_DATA_DIRS="${pkgs.shared-mime-info}/share:$GSETTINGS_SCHEMAS_PATH''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" | ||
| ''; | ||
|
|
||
| # Avoid WebKit's GBM/DMABUF path, which is unreliable on some | ||
| # NixOS graphics stacks, and use the X11 backend as this app does. | ||
| WEBKIT_DISABLE_DMABUF_RENDERER = "1"; | ||
| GDK_BACKEND = "x11"; | ||
| GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules"; | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.