Skip to content

build: add a nix flake to build and run DanXi on NixOS#676

Open
sseu-buhzzi wants to merge 12 commits into
DanXi-Dev:mainfrom
sseu-buhzzi:38203017/build-nix-flake
Open

build: add a nix flake to build and run DanXi on NixOS#676
sseu-buhzzi wants to merge 12 commits into
DanXi-Dev:mainfrom
sseu-buhzzi:38203017/build-nix-flake

Conversation

@sseu-buhzzi
Copy link
Copy Markdown
Contributor

No description provided.

@sseu-buhzzi sseu-buhzzi changed the title feat: add a nix flake to build and run DanXi on NixOS build: add a nix flake to build and run DanXi on NixOS May 9, 2026
@w568w
Copy link
Copy Markdown
Member

w568w commented May 9, 2026

Sorry for the delay. I would review it tomorrow asap.

@w568w w568w requested review from Copilot and w568w May 10, 2026 12:45
@w568w w568w added enhancement New feature or request compliance to comply with regulations and requirements internal The request is from our team and not widely applicable. labels May 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Nix support for DanXi by introducing a flake-based build/dev environment (Linux desktop build + Android dev tooling), along with README documentation and a small Gradle change to allow locating Flutter via an environment variable.

Changes:

  • Add flake.nix/flake.lock and Nix expressions for building the Linux desktop app and providing a devShell with Android/Chrome tooling.
  • Update Android Gradle settings to allow using FLUTTER_ROOT (useful for Nix dev shells / shims).
  • Document NixOS/Nix flake usage in both Chinese and English READMEs and ignore Nix build outputs.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
README.md Adds NixOS usage instructions and flake build commands (CN).
README_EN.md Adds NixOS usage instructions and flake build commands (EN).
nix/util/hex-to-base36.nix Adds a Nix helper wrapper for hex→base36 conversion via Python.
nix/util/hex_to_base36.py Adds the Python implementation of hex→base36 conversion.
nix/packages/default.nix Defines the flake package build for the Flutter Linux desktop app.
nix/devShells/default.nix Defines the devShell (Android SDK, Chrome, JDK) and shell hooks.
flake.nix Main flake wiring: inputs, overlays, Android SDK composition, packages/devShells outputs.
flake.lock Pins flake inputs.
default.nix Adds a non-flake Nix build expression for the Linux desktop app.
android/settings.gradle Allows resolving Flutter SDK from FLUTTER_ROOT env var.
.gitignore Ignores Nix build result* outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nix/util/hex_to_base36.py Outdated
Comment on lines +35 to +41
local_prop_path='android/local.properties'
if [ -f "$local_prop_path" ]; then
sed -i '/^\s*flutter\./d' "$local_prop_path"
fi
cat >>"$local_prop_path" <<-EOF
flutter.sdk=$FLUTTER_ROOT
EOF
Comment thread packaging/nix/flake.nix
Comment on lines +146 to +157
gradle_prop_path="$gradle_home/gradle.properties"
if [ -f "$gradle_prop_path" ]; then
args=(
-i
'/^\s*android\.aapt2FromMavenOverride\s*=/d'
"$gradle_prop_path"
)
sed "''${args[@]}"
fi
cat >>"$gradle_prop_path" <<-EOF
android.aapt2FromMavenOverride=$ANDROID_HOME/build-tools/${androidBuildToolsVersion}/aapt2
EOF
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gnused does use \s to match whitespace.

nix shell nixpkgs#gnused -c sed 's/\s*/-/g' <<<'1   2 3'
# -1-2-3-

Comment thread android/settings.gradle
Comment thread default.nix Outdated
Comment thread default.nix Outdated
Comment thread default.nix Outdated
Comment thread default.nix Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move nix/*, *.nix, flake.lock to packaging/ subdir? It might be better to keep the project root less complicated, given that it has been already very bloaty now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For /nix/* we can move them into a subdir. By the way flake.nix and flake.lock must be in the same directory.

When flake.nix and flake.lock are in a subdir such as /packaging/nix/, it would require nix build github:DanXi-Dev/DanXi?dir=packaging/nix to build.

Copy link
Copy Markdown
Member

@w568w w568w May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When flake.nix and flake.lock are in a subdir such as /packaging/nix/, it would require nix build github:DanXi-Dev/DanXi?dir=packaging/nix to build.

I think this is acceptable. From what I recall, packaging scripts like this are typically kept in a separate repo (as is the case with Arch and Gentoo) rather than sharing the same repository as the software itself.

Since we are adopting a monorepo approach, placing it in a subdirectory might be semantically more appropriate.

(Alternatively, we could also create an independent repository, like DanXi-Dev/DanXi.nix?) Let me know what you think.

Comment thread nix/util/hex-to-base36.nix Outdated
@w568w
Copy link
Copy Markdown
Member

w568w commented May 10, 2026

Please also check GitHub Copilot's suggestions. Most of them look valid to me.

@w568w w568w mentioned this pull request May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compliance to comply with regulations and requirements enhancement New feature or request internal The request is from our team and not widely applicable.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants