Flakes: Difference between revisions
imported>Samuelludwig m →Input schema: Correct passes -> passed gramatical error |
imported>DieracDelta add information on how to get repl |
||
| Line 351: | Line 351: | ||
should make a package accessible through <syntaxHighlight>pkgs.unstable.package</syntaxHighlight> | should make a package accessible through <syntaxHighlight>pkgs.unstable.package</syntaxHighlight> | ||
Same can be done with the NURs, as it already has an ''overlay'' attribute in the flake.nix of the project, you can just add <syntaxHighlight>nixpkgs.overlays = [ nur.overlay ];</syntaxHighlight> | Same can be done with the NURs, as it already has an ''overlay'' attribute in the flake.nix of the project, you can just add <syntaxHighlight>nixpkgs.overlays = [ nur.overlay ];</syntaxHighlight> | ||
== Getting *Instant* System Flakes Repl == | |||
How to get a nix repl out of your current flake: | |||
<syntaxHighlight> | |||
# nix repl | |||
>> flake = builtins.getFlake (toString /etc/nixos) | |||
</syntaxHighlight> | |||
However, this won't be instant upon evaluation. Instead, if one puts: | |||
<syntaxHighlight>nix.nixPath = let path = toString ./.; in [ "repl=${path}/repl.nix" "nixpkgs=${inputs.nixpkgs}" ];</syntaxHighlight> | |||
In their system `flake.nix` configuration file, and includes the following flake in their root directory flake as `repl.nix`: | |||
<syntaxHighlight lang=nix> | |||
let | |||
flake = builtins.getFlake (toString ./.); | |||
nixpkgs = import <nixpkgs> { }; | |||
in | |||
{ inherit flake; } | |||
// flake | |||
// nixpkgs | |||
// nixpkgs.lib | |||
// flake.nixosConfigurations | |||
</syntaxHighlight> | |||
Then add the `repl.nix` file to git and rebuild the system flake. Then if one runs (or binds a bash alias): | |||
<syntaxHighlight> | |||
export __NIXOS_SET_ENVIRONMENT_DONE='' && nix repl $(source /etc/profile && echo $NIX_PATH | perl -pe 's|.*(/nix/store/.*-source/repl.nix).*|\\1|') | |||
</syntaxHighlight> | |||
This will launch a repl with access to `nixpkgs`, `lib`, and the `flake` options instantly. | |||
== Enable unfree software == | == Enable unfree software == | ||