Nix(OS) Cheatsheet
- Resources
- Using nix profile to install packages
- Using nix shell to create a temporary shell
- Development environment using nix develop
Contents
Resources #
Using nix profile
to install packages #
nix profile install nixpkgs#<package name>
nix profile install nixpkgs/nixos-unstable#<package name> # install an unstable package
nix profile upgrade '.*' # upgrade all installed packages
nix profile list # lists installed packages along with indicies
nix profile remove <package name>
Using nix shell
to create a temporary shell #
nix shell nixpkgs#<package name>
nix shell install nixpkgs/nixos-unstable#<package name>
Development environment using nix develop
#
A basic cross-platform development Flake, can look like:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
# packages needed at build time
];
buildInputs = with pkgs; [
# libraries to link against
];
};
}
);
}
Now, you can enter the development environment by running:
nix develop # uses bash by default
nix develop --command "fish" # use your favourite shell