mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-06 22:07:33 +08:00
52 lines
1.2 KiB
Text
52 lines
1.2 KiB
Text
= Running programs directly (without installing them)
|
|
|
|
== Run a top level package from the Nixpkgs/NixOS repo
|
|
|
|
....
|
|
$ nix run nixpkgs#cowsay "Moo!"
|
|
....
|
|
|
|
[#flakeref]
|
|
== Run a flake
|
|
|
|
=== Run a flake defined in a local file
|
|
|
|
....
|
|
$ nix run ~/codeberg/hello-flake
|
|
....
|
|
|
|
=== Run a flake defined in a remote git repo
|
|
|
|
....
|
|
$ nix run git+https://codeberg.org/mhwombat/hello-flake
|
|
....
|
|
|
|
To use a package from GitHub, GitLab, or any other public platform,
|
|
modify the URL accordingly.
|
|
To run a specific branch, use the command below.
|
|
|
|
....
|
|
nix run git+https://codeberg.org/mhwombat/hello-flake?ref=main
|
|
....
|
|
|
|
To run a specific branch and revision, use the command below.
|
|
|
|
....
|
|
nix run git+https://codeberg.org/mhwombat/hello-flake?ref=main&rev=d44728bce88a6f9d1d37dbf4720ece455e997606
|
|
....
|
|
|
|
=== Run a flake defined in a zip archive
|
|
|
|
....
|
|
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.zip
|
|
....
|
|
|
|
=== Run a flake defined in a compressed tar archive
|
|
|
|
....
|
|
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.tar.gz
|
|
....
|
|
|
|
=== Run other types of flake references
|
|
|
|
See https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-flake#flake-reference-attributes.
|