Flakes: Difference between revisions

imported>Hypnosis2839
Enable unfree software: point to dedicated wiki page
imported>Hypnosis2839
Basic project usage: simplify warning, clarify git-related warning, remove imperative command
Line 56: Line 56:
== Basic project usage ==
== Basic project usage ==


{{warning | All files tracked by the version control system (e.g. git or mercurial) will be copied to the nix store when the flake is evaluated. So be careful when putting secrets in version control (which is not optimal by itself) around a flake.}}
{{warning | Files that are part of the flake will be copied to the world-readable nix store when the flake is evaluated; avoid putting unencrypted secrets in your flake.}}


In your repo, run <code>nix flake init</code> to generate the flake.nix file. Then run <code>git add flake.nix</code> to add it to the git staging area, otherwise nix will not recognize that the file exists.
In your repo, run <code>nix flake init</code> to generate the flake.nix file.
 
If you use <code>git</code>, ensure to <code>git add</code> any project files, because for flakes in git repos, only files in the working tree will be copied to the store.


See also https://www.tweag.io/blog/2020-05-25-flakes/
See also https://www.tweag.io/blog/2020-05-25-flakes/
To install a flake when using nix outside of nixOS, use <code>nix profile install /path/to/flake</code>. The path may also be an URL (e.g.: <code>nix profile install git+https://example.com/my-repo?dir=subdirectory</code>).


== Flake schema ==
== Flake schema ==