2023-11-19 08:20:58 +01:00
|
|
|
# Standalone setup {#sec-flakes-standalone}
|
|
|
|
|
|
|
|
To prepare an initial Home Manager configuration for your logged in
|
|
|
|
user, you can run the Home Manager `init` command directly from its
|
|
|
|
flake.
|
|
|
|
|
|
|
|
For example, if you are using the unstable version of Nixpkgs or NixOS,
|
|
|
|
then to generate and activate a basic configuration run the command
|
|
|
|
|
2023-12-02 01:19:09 +01:00
|
|
|
``` shell
|
2023-11-19 08:20:58 +01:00
|
|
|
$ nix run home-manager/master -- init --switch
|
|
|
|
```
|
|
|
|
|
2023-11-25 14:18:25 +01:00
|
|
|
For Nixpkgs or NixOS version 23.11 run
|
2023-11-19 08:20:58 +01:00
|
|
|
|
2023-12-02 01:19:09 +01:00
|
|
|
``` shell
|
2023-11-25 14:18:25 +01:00
|
|
|
$ nix run home-manager/release-23.11 -- init --switch
|
2023-11-19 08:20:58 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
This will generate a `flake.nix` and a `home.nix` file in
|
|
|
|
`~/.config/home-manager`, creating the directory if it does not exist.
|
|
|
|
|
|
|
|
If you omit the `--switch` option then the activation will not happen.
|
|
|
|
This is useful if you want to inspect and edit the configuration before
|
|
|
|
activating it.
|
|
|
|
|
2023-12-02 01:19:09 +01:00
|
|
|
``` shell
|
2023-11-19 08:20:58 +01:00
|
|
|
$ nix run home-manager/$branch -- init
|
|
|
|
$ # Edit files in ~/.config/home-manager
|
|
|
|
$ nix run home-manager/$branch -- init --switch
|
|
|
|
```
|
|
|
|
|
2023-11-25 14:18:25 +01:00
|
|
|
Where `$branch` is one of `master` or `release-23.11`.
|
2023-11-19 08:20:58 +01:00
|
|
|
|
|
|
|
After the initial activation has completed successfully then building
|
|
|
|
and activating your flake-based configuration is as simple as
|
|
|
|
|
2023-12-02 01:19:09 +01:00
|
|
|
``` shell
|
2023-11-19 08:20:58 +01:00
|
|
|
$ home-manager switch
|
|
|
|
```
|
|
|
|
|
|
|
|
It is possible to override the default configuration directory, if you
|
|
|
|
want. For example,
|
|
|
|
|
2023-12-02 01:19:09 +01:00
|
|
|
``` shell
|
2023-11-19 08:20:58 +01:00
|
|
|
$ nix run home-manager/$branch -- init --switch ~/hmconf
|
|
|
|
$ # And after the initial activation.
|
|
|
|
$ home-manager switch --flake ~/hmconf
|
|
|
|
```
|
|
|
|
|
2023-11-30 15:12:29 +01:00
|
|
|
::: {.note}
|
2023-11-19 08:20:58 +01:00
|
|
|
The flake inputs are not automatically updated by Home Manager. You need
|
|
|
|
to use the standard `nix flake update` command for that.
|
|
|
|
|
|
|
|
If you only want to update a single flake input, then the command
|
|
|
|
`nix flake lock --update-input <input>` can be used.
|
|
|
|
|
|
|
|
You can also pass flake-related options such as `--recreate-lock-file`
|
|
|
|
or `--update-input <input>` to `home-manager` when building or
|
|
|
|
switching, and these options will be forwarded to `nix build`. See the
|
|
|
|
[NixOS Wiki page](https://nixos.wiki/wiki/Flakes) for details.
|
|
|
|
:::
|