fix(nix): get nix devshell working (#4883)
* fix: update flake lock and properly pass zlib to pkgconfig * chore: install nixfmt formatter * chore: add startup script * fix: ignore files in the nix store * docs: change required node version to v24 * chore: upgrade to node v24 * fix: specify XDG_DATA_DIRS to fix webkitgtk issues * fix: add required config to get android emulator working - Add a `postInit` script for the android shell to auto-configure an Android emulator - Required compile-time dependencies - Required compilation targets for app to successfully build and run. * fix: silence warning by using stdenv.hostPlatform.system instead of system * chore: remove android-studio
This commit is contained in:
+2
-2
@@ -20,8 +20,8 @@ Basically you need to install or update the following development tools:
|
|||||||
- **Rust** and **Cargo** for Tauri development
|
- **Rust** and **Cargo** for Tauri development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nvm install v22
|
nvm install v24
|
||||||
nvm use v22
|
nvm use v24
|
||||||
npm install -g pnpm
|
npm install -g pnpm
|
||||||
rustup update
|
rustup update
|
||||||
```
|
```
|
||||||
|
|||||||
+2
-1
@@ -40,7 +40,8 @@
|
|||||||
"!**/*.mjs",
|
"!**/*.mjs",
|
||||||
"!**/*.cjs",
|
"!**/*.cjs",
|
||||||
"!**/*.mts",
|
"!**/*.mts",
|
||||||
"!pnpm-lock.yaml"
|
"!pnpm-lock.yaml",
|
||||||
|
"!**/nix/store/**"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"assist": { "enabled": false },
|
"assist": { "enabled": false },
|
||||||
|
|||||||
Generated
+24
-24
@@ -7,11 +7,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737231446,
|
"lastModified": 1782941279,
|
||||||
"narHash": "sha256-5lwp4VeKe0/rZzz7tew6egj1f80cY6xQtqf929iscyU=",
|
"narHash": "sha256-ayqk9KFIFa1TacPfQxLFpbFWiqEhL811Jx/+/gjHKVA=",
|
||||||
"owner": "tadfisher",
|
"owner": "tadfisher",
|
||||||
"repo": "android-nixpkgs",
|
"repo": "android-nixpkgs",
|
||||||
"rev": "11344fbb813770ff8f8b8de5e4d512c0c4910a78",
|
"rev": "9d13340524e2df1448d3b3599ee6b9159a0f8f87",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -29,11 +29,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735644329,
|
"lastModified": 1768818222,
|
||||||
"narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=",
|
"narHash": "sha256-460jc0+CZfyaO8+w8JNtlClB2n4ui1RbHfPTLkpwhU8=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "f7795ede5b02664b57035b3b757876703e2c3eac",
|
"rev": "255a2b1725a20d060f566e4755dbf571bbbb5f76",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -47,11 +47,11 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735644329,
|
"lastModified": 1768818222,
|
||||||
"narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=",
|
"narHash": "sha256-460jc0+CZfyaO8+w8JNtlClB2n4ui1RbHfPTLkpwhU8=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "f7795ede5b02664b57035b3b757876703e2c3eac",
|
"rev": "255a2b1725a20d060f566e4755dbf571bbbb5f76",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -68,11 +68,11 @@
|
|||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1765003156,
|
"lastModified": 1782900513,
|
||||||
"narHash": "sha256-k4YrPUhRj7Ciq385vREU57RHiDFycY5RaJwdCOmsLhU=",
|
"narHash": "sha256-GHrsl1+ysDFgmDQtQSqWS7TiYD2Q58VlwLvnf1+crJM=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "e8361cc010853d17740a63aae00385061ac9de51",
|
"rev": "16810aa8f4ad89ca480b1513774e8b6f485fe368",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -119,11 +119,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737062831,
|
"lastModified": 1782723713,
|
||||||
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
|
"narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
|
"rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -135,11 +135,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722073938,
|
"lastModified": 1762156382,
|
||||||
"narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
|
"narHash": "sha256-Yg7Ag7ov5+36jEFC1DaZh/12SEXo6OO3/8rqADRxiqs=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
|
"rev": "7241bcbb4f099a66aafca120d37c65e8dda32717",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -151,11 +151,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737062831,
|
"lastModified": 1782723713,
|
||||||
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
|
"narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
|
"rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -177,11 +177,11 @@
|
|||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1764925941,
|
"lastModified": 1782864348,
|
||||||
"narHash": "sha256-zldc1SrUIhGMdQp+0woSqvBS51Mi8PW6JukONBQXZBY=",
|
"narHash": "sha256-NVYhLbaefeIUftPlo3kS6qr0xd8eFJRodEiaHrvFKR4=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "2cbf3587d36dfc7b701ebb744d3dd5064355d04f",
|
"rev": "0d381ca097a8e0375a19387874d952c0a230ac4f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
+80
-21
@@ -17,7 +17,7 @@
|
|||||||
outputs = { self, nixpkgs, flake-utils, android, devshell, fenix }:
|
outputs = { self, nixpkgs, flake-utils, android, devshell, fenix }:
|
||||||
{
|
{
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
inherit (self.packages.${final.system}) android-sdk android-studio;
|
inherit (self.packages.${final.stdenv.hostPlatform.system}) android-sdk;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -36,22 +36,15 @@
|
|||||||
self.overlay
|
self.overlay
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
# android-studio is not available in aarch64-darwin
|
|
||||||
androidConditionalPackages = if pkgs.system != "aarch64-darwin" then [ pkgs.android-studio ] else [ ];
|
|
||||||
commonPackages = with pkgs; [
|
commonPackages = with pkgs; [
|
||||||
pnpm
|
pnpm
|
||||||
nodejs_22
|
nodejs_24
|
||||||
clang
|
clang
|
||||||
pkg-config
|
pkg-config
|
||||||
(pkgs.fenix.complete.withComponents [
|
|
||||||
"cargo"
|
|
||||||
"clippy"
|
|
||||||
"rust-src"
|
|
||||||
"rustc"
|
|
||||||
"rustfmt"
|
|
||||||
])
|
|
||||||
pkgs.rust-analyzer-nightly
|
pkgs.rust-analyzer-nightly
|
||||||
xdg-utils
|
xdg-utils
|
||||||
|
self.formatter.${pkgs.stdenv.hostPlatform.system}
|
||||||
];
|
];
|
||||||
|
|
||||||
systemDeps = with pkgs; [
|
systemDeps = with pkgs; [
|
||||||
@@ -79,12 +72,26 @@
|
|||||||
getDev = pkg: if pkg ? dev then pkg.dev else pkg;
|
getDev = pkg: if pkg ? dev then pkg.dev else pkg;
|
||||||
getLib = pkg: if pkg ? lib then pkg.lib else pkg;
|
getLib = pkg: if pkg ? lib then pkg.lib else pkg;
|
||||||
|
|
||||||
pkgConfigPath = lib.makeSearchPath "lib/pkgconfig" (map getDev systemDeps);
|
# zlib stores zlib.pc in share/pkgconfig while everything else is stored in lib/pkgconfig
|
||||||
|
pkgConfigPath = lib.concatStringsSep ":" [
|
||||||
|
(lib.makeSearchPath "lib/pkgconfig" (map getDev systemDeps))
|
||||||
|
(lib.makeSearchPath "share/pkgconfig" (map getDev systemDeps))
|
||||||
|
];
|
||||||
|
|
||||||
|
xdgPath = "${
|
||||||
|
lib.makeSearchPath "share/gsettings-schemas" [
|
||||||
|
pkgs.gsettings-desktop-schemas
|
||||||
|
pkgs.gtk3
|
||||||
|
]
|
||||||
|
}:$XDG_DATA_DIRS";
|
||||||
|
|
||||||
libPath = lib.makeLibraryPath (map getLib systemDeps);
|
libPath = lib.makeLibraryPath (map getLib systemDeps);
|
||||||
|
|
||||||
mkCommonShell =
|
mkCommonShell =
|
||||||
{ name
|
{ name
|
||||||
|
, postInit ? ""
|
||||||
, extraPackages ? [ ]
|
, extraPackages ? [ ]
|
||||||
|
, extraTargets ? [ ]
|
||||||
, extraEnv ? [
|
, extraEnv ? [
|
||||||
{
|
{
|
||||||
name = "PKG_CONFIG_PATH";
|
name = "PKG_CONFIG_PATH";
|
||||||
@@ -98,7 +105,12 @@
|
|||||||
name = "LIBRARY_PATH";
|
name = "LIBRARY_PATH";
|
||||||
value = libPath;
|
value = libPath;
|
||||||
}
|
}
|
||||||
] ++ (optionals isDarwin [
|
{
|
||||||
|
name = "XDG_DATA_DIRS";
|
||||||
|
eval = xdgPath;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ (optionals isDarwin [
|
||||||
{
|
{
|
||||||
name = "RUSTFLAGS";
|
name = "RUSTFLAGS";
|
||||||
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
|
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
|
||||||
@@ -122,18 +134,42 @@
|
|||||||
}:
|
}:
|
||||||
pkgs.devshell.mkShell {
|
pkgs.devshell.mkShell {
|
||||||
inherit name;
|
inherit name;
|
||||||
packages = commonPackages ++ extraPackages;
|
packages =
|
||||||
|
commonPackages
|
||||||
|
++ extraPackages
|
||||||
|
++ [
|
||||||
|
(
|
||||||
|
with pkgs.fenix;
|
||||||
|
pkgs.fenix.combine [
|
||||||
|
complete.cargo
|
||||||
|
complete.clippy
|
||||||
|
complete.rust-src
|
||||||
|
complete.rustc
|
||||||
|
complete.rustfmt
|
||||||
|
extraTargets
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
env = extraEnv;
|
env = extraEnv;
|
||||||
|
devshell.startup.init_project.text = ''
|
||||||
|
git submodule update --init --recursive
|
||||||
|
pnpm install
|
||||||
|
pnpm --filter @readest/readest-app setup-vendors
|
||||||
|
'' + postInit;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [
|
android-sdk = android.sdk.${pkgs.stdenv.hostPlatform.system} (sdkPkgs: with sdkPkgs; [
|
||||||
# Useful packages for building and testing.
|
# Useful packages for building and testing.
|
||||||
|
build-tools-36-0-0
|
||||||
|
build-tools-35-0-0
|
||||||
build-tools-34-0-0
|
build-tools-34-0-0
|
||||||
cmdline-tools-latest
|
cmdline-tools-latest
|
||||||
emulator
|
emulator
|
||||||
platform-tools
|
platform-tools
|
||||||
|
platforms-android-36
|
||||||
|
platforms-android-35
|
||||||
platforms-android-34
|
platforms-android-34
|
||||||
ndk-26-1-10909125
|
ndk-26-1-10909125
|
||||||
]
|
]
|
||||||
@@ -145,9 +181,6 @@
|
|||||||
system-images-android-34-google-apis-x86-64
|
system-images-android-34-google-apis-x86-64
|
||||||
system-images-android-34-google-apis-playstore-x86-64
|
system-images-android-34-google-apis-playstore-x86-64
|
||||||
]);
|
]);
|
||||||
} // lib.optionalAttrs (system == "x86_64-linux") {
|
|
||||||
# Android Studio in nixpkgs is currently packaged for x86_64-linux only.
|
|
||||||
android-studio = pkgs.androidStudioPackages.stable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = {
|
devShells = {
|
||||||
@@ -160,13 +193,33 @@
|
|||||||
extraPackages = [ pkgs.cocoapods ];
|
extraPackages = [ pkgs.cocoapods ];
|
||||||
};
|
};
|
||||||
|
|
||||||
android = mkCommonShell {
|
android = mkCommonShell rec {
|
||||||
name = "readest-android";
|
name = "readest-android";
|
||||||
|
postInit = ''
|
||||||
|
rm -rf apps/readest-app/src-tauri/gen/android
|
||||||
|
pnpm tauri android init
|
||||||
|
git checkout apps/readest-app/src-tauri/gen/android
|
||||||
|
pnpm tauri icon ../../data/icons/readest-book.png
|
||||||
|
|
||||||
|
if [ ! -d "$ANDROID_AVD_HOME/${name}.avd" ]; then
|
||||||
|
avdmanager create avd \
|
||||||
|
-n ${name} \
|
||||||
|
-k "system-images;android-34;google_apis;x86_64" \
|
||||||
|
-d "pixel" \
|
||||||
|
--force
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
extraTargets = with pkgs.fenix.targets; [
|
||||||
|
aarch64-linux-android.latest.rust-std
|
||||||
|
armv7-linux-androideabi.latest.rust-std
|
||||||
|
i686-linux-android.latest.rust-std
|
||||||
|
x86_64-linux-android.latest.rust-std
|
||||||
|
];
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
pkgs.android-sdk
|
pkgs.android-sdk
|
||||||
pkgs.gradle
|
pkgs.gradle
|
||||||
pkgs.jdk
|
pkgs.jdk
|
||||||
] ++ androidConditionalPackages;
|
];
|
||||||
extraEnv = [
|
extraEnv = [
|
||||||
{
|
{
|
||||||
name = "ANDROID_HOME";
|
name = "ANDROID_HOME";
|
||||||
@@ -184,10 +237,16 @@
|
|||||||
name = "JAVA_HOME";
|
name = "JAVA_HOME";
|
||||||
value = pkgs.jdk.home;
|
value = pkgs.jdk.home;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "ANDROID_AVD_HOME";
|
||||||
|
eval = "$XDG_CONFIG_HOME/.android/avd";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
default = self.devShells.${system}.web;
|
default = self.devShells.${pkgs.stdenv.hostPlatform.system}.web;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatter = pkgs.nixfmt;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user