My flake defines 2 packages:
packages = {
android-tools = pkgs.android-tools;
default = pkgs-unstable.rustPlatform.buildRustPackage rec {
# --snip--
};
};
I want to use this flake as a meta-package to install all packages that are required to work on the project (because of many different reasons I specifically need to use nix profile
instead of devShell
).
Problem: When I run nix profile isntall .
only the default package gets installed. The android-tools
is not installed automatically. How can install all of the packages that are defined in my flake? I don’t want to do the following, it is ugly and error-prone.
nix profile instal .#default .#android-tools .#etc
Extra question: How can I avoid declaring packages like this? Can I somehow use inherit
here?
packages = {
android-tools = pkgs.android-tools;
lolcat = pkgs.lolcat;
something = pkgs.something;
etc = pkgs.etc;
};
I tried this, but nix profle install .
still installs only myTool
:
snippet
packages = rec {
default = pkgs.buildEnv {
name = "Default packages";
paths = [
myTool
generalPkgs
];
};
myTool = pkgs-unstable.rustPlatform.buildRustPackage rec {
pname = "myTool";
version = "0.1.0";
cargoLock.lockFile = ./Cargo.lock;
src = ./.;
buildInputs = with pkgs; [
pythonEnv
];
nativeBuildInputs = with pkgs; [
makeWrapper
python
];
postFixup = ''
wrapProgram $out/bin/myTool \
--prefix PATH : ${lib.makeBinPath [ pythonEnv ]}
'';
};
generalPkgs = pkgs.buildEnv {
name = "General packages";
paths = with pkgs; [
android-tools
];
};
};
This also didn’t work:
default = pkgs.buildEnv {
name = "Default packages";
paths = [
myTool
self.packages.${system}.generalPkgs
];
};
synalice:
Extra question: How can I avoid declaring packages like this? Can I somehow use inherit
here?
packages = {
android-tools = pkgs.android-tools;
lolcat = pkgs.lolcat;
something = pkgs.something;
etc = pkgs.etc;
};
packages = {
inherit (pkgs)
android-tools
lolcat
something
etc
;
};
Wait a minute… It did work! I think I’ve either missed something, or solved it by running nix profile remove --all
and reinstalling default
package.
My final solution looks like this — clean and elegant
packages = rec {
default = pkgs.buildEnv {
name = "Default meta-package";
paths = [
myTool
general
];
};
myTool = pkgs-unstable.rustPlatform.buildRustPackage rec {
# --snip--
};
general = pkgs.buildEnv {
name = "General development packages";
paths = with pkgs; [
android-tools
];
};
};