commands

Commands #

env #

OLD NEW pacman 解释
nix-env -iA nixpkgs.gcc nix profile install nixpkgs#gcc pacman -S gcc 安装
nix-env -i gcc-3.3.3 nix profile install nixpkgs/<hash branch>#gcc pacman -U /path/to/cache
nix-env -f ~/foo.nix -i ‘.*’ - makepkg -i foo/PKGBUILD 本地 build
nix-env -f ‘nixpkgs.hello’ -A hello –dry-run - - If you create –dry-run, you can see where it will be installed in /nix/store.
nix-env -uA nix profile upgrade ‘.*’ pacman -Syu Upgrade all packages
nix-env -u gcc-3.2.2 –always - pacman -U /path/to/lower-version Downgrade to a specific version.
nix-env -e gcc/nix-env -e nix profile remove <position attribute path store path
nix-env –set-flag (true/false) - Writing/removing pacman.conf to NoUpgrade Pin/Unpin versions of specific packages
nix-env -q nix profile list pacman -Qem List of installed packages (only those installed with nix-env are listed)

nix-env –list-generations | - | - | generation list nix-env –delete-generations (3 4 5 | +5 | d | 30d |) | nix profile wipe-history –older-than 100d | paccache -r | Delete from left (specific generation | all but the latest 5 | all before current generation | all before 30 generations) nix-env -G 42 | nix profile rollback to 42 | - | Switch to specific generation nix-env –rollback | nix profile rollback | - | Switch to previous generation

nix-env -qas for status

nix-env -qa | nix search nixpkgs | pacman -Slq | Display all installable packages. nix-env -qas | nix search nixpkgs | pacman -Slq | Display all installable packages with status (installed or not, etc.). nix-env -qa ‘.zip.’ | nix search nixpkgs#zip | pacman -Ss ‘*zip’ | Search for a specific package (regular expressions can also be used) nix search will show all packages containing that name if you don’t include the #.

cache #

nix-collect-garbage => nix store gc

OLD NEW Arch 解釋
nix-collect-garbage -d nix store gc pacman -Sc Delete all but the current generation
nix-collect-garbage –max-freed $((100 1024 1024)) nix store gc –max 1G paccache -ruk3 Delete until specified capacity is reached

build #

OLD NEW Arch EXPLAIN
nix-build ‘’ -A (firefox openssl.all openssl.man) nix build nixpkgs#hello
nix-build nix build Simply run it and it will build default.nix in the directory (nix build is the package set to default in flake.nix)
nix-build –dry-run nix build –print-out-paths Get only the store path
nix-build –no-out-link nix build –no-link Do not create a link to ./result

env #

COMMAND EXPLAIN
nix-shell Isolated environment with dependencies written in default.nix.
nix develop nix-shell in flake. An environment containing dependencies written in .mkShell { buildInputs = [ any pkgs ]; }. To check the build procedure.
nix shell This will enter an environment where the path is to the package built with the contents written in stdenv.mkDerivation. For checking products and creating an isolated environment.
nix run Executing the binary. Just build and run.
OLD NEW EXPLAIN
nix-shell nix develop Enter the interactive environment where the path is passed to the dependencies listed in default.nix (nix develop is flake.nix). nix develop configurePhasecan run predefined commands such as (nix-shell is also possible)
nix-shell ‘’ -A bash –run “command” nix shell nixpkgs#bash -c “command” Build the package and run commands in a non-interactive environment
  •                                           | nix develop (--unpack|--configure|...|--(eachPhase)     | Executes the specified Phase.
    

project management #

COMMAND EXPLAIN
nix flake check Build check. You can check only the build of the target package with nixpkgs#bash or .#foo.
nix flake check –no-build Evaluation of only nix expressions
nix flake clone Clone a repository containing flake
nix flake info Repository description
nix flake init -t template#full Create a flake repository according to the template. There is no need to specify a template
nix flake new -t template#full /path/to/output Create a flake repository in the specified directory
nix flake show Output of packages in repository
nix flake update Update flake.lock

nixos #

command explain
nixos-rebuild switch -p profilename –flake .#target After building and passing through the target nix expression, enter the updated environment. Updates that require a reboot will not be reflected. -p allows you to specify a profile name (displayed at boot time).
nixos-rebuild boot … It even builds using the nix expression for target. You can enter that environment by selecting it the next time you boot.
nixos-rebuild test … A version that is not registered in the nix-rebuild switch bootloader.
nixos-rebuild dry-build … just build
nixos-rebuild build-vm … Build an environment on the VM.

home manager #

command explain
home-manager build –flake .#target Building the user environment
home-manager switch … User environment switch
home-manager generations … User environment generation list
home-manager remove-generations ID Delete specific generation