I looked through some documentation including the wiki page, but I can’t figure out how to install flake packages like nix-flatpak. After trying to copy the “getting started” section I got the error undefined variable 'nix-flatpak'
under modules = [.
I also get the error The option \
services.flatpak.packages’ does not exist. With this in my
configuration.nix`:
services.flatpak.enable = true;
services.flatpak.packages = [
"app.zen_browser.zen"
];
My flake.nix
is below. I don’t know if either the documentation is too scatted, I’m too impatient / lazy to look through enough of it, or both.
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
};
outputs = { self, nixpkgs, ... }@inputs: {
nixosConfigurations.NixOS-MBP = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
nix-flatpak.nixosModules.nix-flatpak
./configuration.nix
];
};
};
}
You’ve just overlooked a word:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
};
outputs = { self, nixpkgs, nix-flatpak, ... }@inputs: {
nixosConfigurations.NixOS-MBP = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
nix-flatpak.nixosModules.nix-flatpak
./configuration.nix
];
};
};
}
Personally, I would recommend doing this, however; it keeps your flake.nix
neater and makes the module system do what the module system is supposed to do:
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
};
outputs = { self, nixpkgs, ... }@inputs: {
nixosConfigurations.NixOS-MBP = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs.flake-inputs = inputs;
modules = [
./configuration.nix
];
};
};
}
# configuration.nix
{ flake-inputs, ... }: {
imports = [
flake-inputs.nix-flatpak.nixosModules.nix-flatpak
];
}
I’ve also quoted your URLs for you.
1 Like
flake-inputs.nix-flatpak.nixosModules.nix-flatpak
How would I know what to write for other flakes?
You look at the name in your inputs
:
For nixpkgs
, for example, it would be flake-inputs.nixpkgs.<whateveryouwanttoaccess>
. For your system nixpkgs this isn’t very useful, but if you had a second nixpkgs (e.g. to get unstable) you could grab packages from it that way.
As for the bit after the input name (e.g. .nixosModules.nix-flatpak
), there are a number of standardized outputs (most notably for NixOS users, packages
, nixosModules
, legacyPackages
and lib
, but there’s also e.g. devShells
), and you need to check the documentation of the flake you depend on for the specific name of its module/package/whatever.
See the docs for more details on how flakes work: nix flake - Nix 2.28.1 Reference Manual
1 Like