NAME
flox-build-import-nixpkgs - Import package definition from nixpkgs
SYNOPSIS
flox [<general-options>] build import-nixpkgs
[-d=<path>]
[--force]
[--stability <stability>]
<installable>
DESCRIPTION
Import a package definition from nixpkgs for use in the environment.
This command copies the source code of a package from nixpkgs into the
environment's .flox/pkgs/ directory, allowing you to modify and build
the package locally.
The package definition is imported as a Nix expression file at
.flox/pkgs/<package>/default.nix, where <package> is the attribute
path of the package (e.g., hello for nixpkgs#hello).
This is useful when you need to:
- Modify a package's build process
- Apply patches or customizations
- Debug package issues
- Create variants of existing packages
Installable format
The <installable> parameter can be specified in one of the following formats:
- Attribute path only:
hello(defaults tonixpkgs#hello) - Flake reference with attribute:
nixpkgs#hello - Full flake reference:
github:nixos/nixpkgs#hello
When using --stability, the installable must be a bare
attribute path or the nixpkgs# prefix form.
An explicit flake reference (e.g. github:nixos/nixpkgs#hello) cannot be
combined with the flag.
OPTIONS
<installable>
The package to import from nixpkgs.
Can be specified as an attribute path (e.g., hello) or as a flake
reference with attribute path (e.g., nixpkgs#hello).
--force
Overwrite existing package file if it already exists.
Without this flag, the command will fail if the package file
already exists in the environment.
--stability <stability>
Import using a base package set of the given stability as tracked by
the catalog server.
A stability (e.g., "stable" or "unstable") identifies a curated
nixpkgs revision managed by the catalog server.
When omitted, the default nixpkgs channel is used.
Cannot be combined with an explicit flake reference in <installable>.
Environment Options
If no environment is specified for an environment command, the environment in the current directory or the active environment that was last activated is used.
-d, --dir
Path containing a .flox/ directory.
General Options
-h, --help
Prints help information.
The following options can be passed when running any flox subcommand but must
be specified before the subcommand.
-v, --verbose
Increase logging verbosity.
Invoke multiple times for increasing detail.
-q, --quiet
Silence logs except for errors.
EXAMPLES
Import a simple package
Import the hello package from nixpkgs:
flox build import-nixpkgs hello
This creates .flox/pkgs/hello/default.nix with the package definition.
Import using a specific stability
Import samba from the unstable channel as tracked by the catalog:
flox build import-nixpkgs samba --stability unstable
Import from a specific nixpkgs revision
Import a package from a specific nixpkgs revision:
flox build import-nixpkgs github:nixos/nixpkgs/nixos-23.11#hello
Overwrite an existing package
Force import a package, overwriting any existing definition:
flox build import-nixpkgs --force hello
Import a complex package
Import a package with a nested attribute path:
flox build import-nixpkgs python310Packages.requests
This creates .flox/pkgs/python310Packages/requests/default.nix.
NOTES
- This command only works with local environments (not managed or remote environments)
- The imported package definition is a snapshot of the source code at the time of import
- You can modify the imported package definition and build it using
flox build - The package will be available in the environment's build context