Project import generated by Copybara.

GitOrigin-RevId: 781d25b315def05cd7ede3765226c54216f0b1fe
This commit is contained in:
Default email 2021-12-02 21:30:34 -08:00
parent ce641f4048
commit b9675abb90
98 changed files with 1695 additions and 731 deletions

View file

@ -113,6 +113,9 @@
/modules/programs/lazygit.nix @kalhauge /modules/programs/lazygit.nix @kalhauge
/modules/programs/less.nix @pamplemousse
/tests/modules/programs/less @pamplemousse
/modules/programs/lesspipe.nix @rycee /modules/programs/lesspipe.nix @rycee
/modules/programs/lf.nix @owm111 /modules/programs/lf.nix @owm111
@ -353,6 +356,8 @@
/modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans /modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans
/tests/modules/services/window-managers/sway @sumnerevans /tests/modules/services/window-managers/sway @sumnerevans
/modules/services/window-managers/i3-sway/swaynag.nix @polykernel
/modules/services/wlsunset.nix @matrss /modules/services/wlsunset.nix @matrss
/tests/modules/services/wlsunset @matrss /tests/modules/services/wlsunset @matrss
@ -376,4 +381,7 @@
/modules/services/volnoti.nix @IvanMalison /modules/services/volnoti.nix @IvanMalison
/modules/targets/darwin @midchildan
/tests/modules/targets-darwin @midchildan
Makefile @thiagokokada Makefile @thiagokokada

View file

@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: cachix/install-nix-action@v14 - uses: cachix/install-nix-action@v16
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10 - uses: cachix/cachix-action@v10

View file

@ -12,13 +12,18 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: cachix/install-nix-action@v14.1 - uses: cachix/install-nix-action@v16
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10 - uses: cachix/cachix-action@v10
with: with:
name: nix-community name: nix-community
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: |
if grep -R --exclude stdlib-extended.nix literalExample modules ; then
echo "Error: literalExample should be replaced by literalExpression" > /dev/stderr
exit 1
fi
- run: ./format -c - run: ./format -c
- run: nix-shell . -A install - run: nix-shell . -A install
- run: nix-shell --arg enableBig false --pure tests -A run.all - run: nix-shell --arg enableBig false --pure tests -A run.all

View file

@ -1 +1 @@
21.11 22.05

View file

@ -32,7 +32,7 @@ will write to your dconf store and cannot tell whether a configuration
that it is about to be overwritten was from a previous Home Manager that it is about to be overwritten was from a previous Home Manager
generation or from manual configuration. generation or from manual configuration.
Home Manager targets [NixOS][] unstable and NixOS version 21.05 (the Home Manager targets [NixOS][] unstable and NixOS version 21.11 (the
current stable version), it may or may not work on other Linux current stable version), it may or may not work on other Linux
distributions and NixOS versions. distributions and NixOS versions.
@ -53,270 +53,25 @@ You can chat with us on IRC in the channel [#home-manager][] on
Installation Installation
------------ ------------
Currently the easiest way to install Home Manager is as follows: Home Manager can be used in three primary ways:
1. Make sure you have a working Nix installation. Specifically, make 1. Using the standalone `home-manager` tool. For platforms other than
sure that your user is able to build and install Nix packages. For NixOS and Darwin, this is the only available choice. It is also
example, you should be able to successfully run a command like recommended for people on NixOS or Darwin that want to manage their
`nix-instantiate '<nixpkgs>' -A hello` without having to switch to home directory independently of the system as a whole. See
the root user. For a multi-user install of Nix this means that [Standalone installation][manual standalone install] in the manual
your user must be covered by the for instructions on how to perform this installation.
[`allowed-users`][nixAllowedUsers] Nix option. On NixOS you can
control this option using the 2. As a module within a NixOS system configuration. This allows the
[`nix.allowedUsers`][nixosAllowedUsers] system option. user profiles to be built together with the system when running
`nixos-rebuild`. See [NixOS module installation][manual nixos
Note that Nix 2.4 (`nixUnstable`) is not yet supported. install] in the manual for a description of this setup.
2. Add the appropriate Home Manager channel. If you are following 3. As a module within a [nix-darwin][] system configuration. This
Nixpkgs master or an unstable channel you can run allows the user profiles to be built together with the system when
running `darwin-rebuild`. See [nix-darwin module
```shell installation][manual nix-darwin install] in the manual for a
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager description of this setup.
nix-channel --update
```
and if you follow a Nixpkgs version 21.05 channel you can run
```shell
nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager
nix-channel --update
```
On NixOS you may need to log out and back in for the channel to
become available. On non-NixOS you may have to add
```shell
export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
```
to your shell (see [nix#2033](https://github.com/NixOS/nix/issues/2033)).
3. Install Home Manager and create the first Home Manager generation:
```shell
nix-shell '<home-manager>' -A install
```
Once finished, Home Manager should be active and available in your
user environment.
3. If you do not plan on having Home Manager manage your shell
configuration then you must source the
```shell
$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
```
file in your shell configuration. This file can be sourced
directly by POSIX.2-like shells such as [Bash][] or [Z shell][].
[Fish][] users can use utilities such as [foreign-env][] or
[babelfish][].
For example, if you use Bash then add
```bash
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
```
or this when managing home configuration together with system
configuration
```bash
. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh"
```
to your `~/.profile` file.
If instead of using channels you want to run Home Manager from a Git
checkout of the repository then you can use the
`programs.home-manager.path` option to specify the absolute path to
the repository.
Usage
-----
Home Manager is typically managed through the `home-manager` tool.
This tool can, for example, apply configurations to your home
directory, list user packages installed by the tool, and list the
configuration generations.
As an example, let us expand the initial configuration file from the
installation above to install the htop and fortune packages, install
Emacs with a few extra packages enabled, install Firefox with
smooth scrolling disabled, and enable the user gpg-agent service.
To satisfy the above setup we should elaborate the
`~/.config/nixpkgs/home.nix` file as follows:
```nix
{ pkgs, ... }:
{
home.packages = [
pkgs.htop
pkgs.fortune
];
programs.emacs = {
enable = true;
extraPackages = epkgs: [
epkgs.nix-mode
epkgs.magit
];
};
programs.firefox = {
enable = true;
profiles = {
myprofile = {
settings = {
"general.smoothScroll" = false;
};
};
};
};
services.gpg-agent = {
enable = true;
defaultCacheTtl = 1800;
enableSshSupport = true;
};
programs.home-manager = {
enable = true;
path = "…";
};
}
```
To activate this configuration you can then run
```shell
home-manager switch
```
or if you are not feeling so lucky,
```shell
home-manager build
```
which will create a `result` link to a directory containing an
activation script and the generated home directory files.
Documentation of available configuration options, including
descriptions and usage examples, is available in the [Home Manager
manual][configuration options] or offline by running
```shell
man home-configuration.nix
```
Rollbacks
---------
While the `home-manager` tool does not explicitly support rollbacks at
the moment it is relatively easy to perform one manually. The steps to
do so are
1. Run `home-manager generations` to determine which generation you
wish to rollback to:
```console
$ home-manager generations
2018-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation
2018-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation
2018-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
2017-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation
2017-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation
```
2. Copy the Nix store path of the generation you chose, e.g.,
/nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
for generation 763.
3. Run the `activate` script inside the copied store path:
```console
$ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate
Starting home manager activation
```
Keeping your ~ safe from harm
-----------------------------
To configure programs and services Home Manager must write various
things to your home directory. To prevent overwriting any existing
files when switching to a new generation, Home Manager will attempt to
detect collisions between existing files and generated files. If any
such collision is detected the activation will terminate before
changing anything on your computer.
For example, suppose you have a wonderful, painstakingly created
`~/.config/git/config` and add
```nix
{
# …
programs.git = {
enable = true;
userName = "Jane Doe";
userEmail = "jane.doe@example.org";
};
# …
}
```
to your configuration. Attempting to switch to the generation will
then result in
```console
$ home-manager switch
Activating checkLinkTargets
Existing file '/home/jdoe/.config/git/config' is in the way
Please move the above files and try again
```
Graphical services
------------------
Home Manager includes a number of services intended to run in a
graphical session, for example `xscreensaver` and `dunst`.
Unfortunately, such services will not be started automatically unless
you let Home Manager start your X session. That is, you have something
like
```nix
{
# …
services.xserver.enable = true;
# …
}
```
in your system configuration and
```nix
{
# …
xsession.enable = true;
xsession.windowManager.command = "…";
# …
}
```
in your Home Manager configuration.
Nix Flakes Nix Flakes
---------- ----------
@ -345,6 +100,9 @@ as follows:
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.jdoe = import ./home.nix; home-manager.users.jdoe = import ./home.nix;
# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
} }
]; ];
}; };
@ -353,6 +111,33 @@ as follows:
} }
``` ```
If you are not using NixOS you can place the following flake in
`~/.config/nixpkgs/flake.nix` to load your standard Home Manager
configuration:
```nix
{
description = "A Home Manager flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs: {
homeConfigurations = {
jdoe = inputs.home-manager.lib.homeManagerConfiguration {
system = "x86_64-linux";
homeDirectory = "/home/jdoe";
username = "jdoe";
configuration.imports = [ ./home.nix ];
};
};
};
}
```
Note, the Home Manager library is exported by the flake under Note, the Home Manager library is exported by the flake under
`lib.hm`. `lib.hm`.
@ -367,24 +152,26 @@ Home Manager is developed against `nixpkgs-unstable` branch, which
often causes it to contain tweaks for changes/packages not yet often causes it to contain tweaks for changes/packages not yet
released in stable NixOS. To avoid breaking users' configurations, released in stable NixOS. To avoid breaking users' configurations,
Home Manager is released in branches corresponding to NixOS releases Home Manager is released in branches corresponding to NixOS releases
(e.g. `release-21.05`). These branches get fixes, but usually not new (e.g. `release-21.11`). These branches get fixes, but usually not new
modules. If you need a module to be backported, then feel free to open modules. If you need a module to be backported, then feel free to open
an issue. an issue.
[Bash]: https://www.gnu.org/software/bash/ License
-------
This project is licensed under the terms of the [MIT license](LICENSE).
[Nix]: https://nixos.org/nix/ [Nix]: https://nixos.org/nix/
[NixOS]: https://nixos.org/ [NixOS]: https://nixos.org/
[Nixpkgs]: https://nixos.org/nixpkgs/ [Nixpkgs]: https://nixos.org/nixpkgs/
[nixAllowedUsers]: https://nixos.org/nix/manual/#conf-allowed-users
[nixosAllowedUsers]: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers
[Z shell]: http://zsh.sourceforge.net/
[manual]: https://nix-community.github.io/home-manager/ [manual]: https://nix-community.github.io/home-manager/
[manual usage]: https://nix-community.github.io/home-manager/#ch-usage
[configuration options]: https://nix-community.github.io/home-manager/options.html [configuration options]: https://nix-community.github.io/home-manager/options.html
[#home-manager]: https://webchat.oftc.net/?channels=home-manager [#home-manager]: https://webchat.oftc.net/?channels=home-manager
[OFTC]: https://oftc.net/ [OFTC]: https://oftc.net/
[samueldr]: https://github.com/samueldr/
[Nix Pills]: https://nixos.org/nixos/nix-pills/ [Nix Pills]: https://nixos.org/nixos/nix-pills/
[Nix Flakes]: https://nixos.wiki/wiki/Flakes [Nix Flakes]: https://nixos.wiki/wiki/Flakes
[Fish]: https://fishshell.com [nix-darwin]: https://github.com/LnL7/nix-darwin/
[foreign-env]: https://github.com/oh-my-fish/plugin-foreign-env [manual standalone install]: https://nix-community.github.io/home-manager/index.html#sec-install-standalone
[babelfish]: https://github.com/bouk/babelfish [manual nixos install]: https://nix-community.github.io/home-manager/index.html#sec-install-nixos-module
[manual nix-darwin install]: https://nix-community.github.io/home-manager/index.html#sec-install-nix-darwin-module

View file

@ -9,8 +9,8 @@ let
name = "nmd"; name = "nmd";
owner = "rycee"; owner = "rycee";
repo = "nmd"; repo = "nmd";
rev = "12bc57594e12525d2e4422fa7034b2d54e9ea09a"; rev = "527245ff605bde88c2dd2ddae21c6479bb7cf8aa";
sha256 = "0fpankfx2c99x4n1mhdy730yxy2b03qcw4zvjxyk4b1v60h8057n"; sha256 = "1zi0f9y3wq4bpslx1py3sfgrgd9av41ahpandvs6rvkpisfsqqlp";
}; };
nmd = import nmdSrc { inherit lib pkgs; }; nmd = import nmdSrc { inherit lib pkgs; };

View file

@ -8,7 +8,7 @@ Home Manager can be used in three primary ways:
1. Using the standalone `home-manager` tool. For platforms other than 1. Using the standalone `home-manager` tool. For platforms other than
NixOS and Darwin, this is the only available choice. It is also NixOS and Darwin, this is the only available choice. It is also
recommended for people on NixOS or Darwin that want to manage their recommended for people on NixOS or Darwin that want to manage their
home directory independent of the system as a whole. See home directory independently of the system as a whole. See
<<sec-install-standalone>> for instructions on how to perform this <<sec-install-standalone>> for instructions on how to perform this
installation. installation.
@ -27,6 +27,11 @@ for a description of this setup.
:nix-allowed-users: https://nixos.org/nix/manual/#conf-allowed-users :nix-allowed-users: https://nixos.org/nix/manual/#conf-allowed-users
:nixos-allowed-users: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers :nixos-allowed-users: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers
:bash: https://www.gnu.org/software/bash/
:zsh: http://zsh.sourceforge.net/
:fish: https://fishshell.com
:plugin-foreign-env: https://github.com/oh-my-fish/plugin-foreign-env
:babelfish: https://github.com/bouk/babelfish
1. Make sure you have a working Nix installation. Specifically, make 1. Make sure you have a working Nix installation. Specifically, make
sure that your user is able to build and install Nix packages. For sure that your user is able to build and install Nix packages. For
@ -36,10 +41,12 @@ root user. For a multi-user install of Nix this means that your user
must be covered by the {nix-allowed-users}[`allowed-users`] Nix must be covered by the {nix-allowed-users}[`allowed-users`] Nix
option. On NixOS you can control this option using the option. On NixOS you can control this option using the
{nixos-allowed-users}[`nix.allowedUsers`] system option. {nixos-allowed-users}[`nix.allowedUsers`] system option.
+
Note that Nix 2.4 is not yet fully supported. Most significantly, Home
Manager is incompatible with the new `nix profile`.
2. Add the Home Manager channel that you wish to follow. If you are 2. Add the appropriate Home Manager channel. If you are following
following Nixpkgs master or an unstable channel then this is done by Nixpkgs master or an unstable channel you can run
running
+ +
[source,console] [source,console]
---- ----
@ -47,11 +54,11 @@ $ nix-channel --add https://github.com/nix-community/home-manager/archive/master
$ nix-channel --update $ nix-channel --update
---- ----
+ +
and if you follow a Nixpkgs version 21.05 channel, you can run and if you follow a Nixpkgs version 21.11 channel you can run
+ +
[source,console] [source,console]
---- ----
$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager $ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
$ nix-channel --update $ nix-channel --update
---- ----
+ +
@ -87,11 +94,8 @@ file in your shell configuration. Alternatively source
when managing home configuration together with system configuration. when managing home configuration together with system configuration.
+ +
This file can be sourced directly by POSIX.2-like shells such as This file can be sourced directly by POSIX.2-like shells such as
https://www.gnu.org/software/bash/[Bash] or {bash}[Bash] or {zsh}[Z shell]. {fish}[Fish] users can use utilities
http://zsh.sourceforge.net/[Z shell]. https://fishshell.com[Fish] such as {plugin-foreign-env}[foreign-env] or {babelfish}[babelfish].
users can use utilities such as
https://github.com/oh-my-fish/plugin-foreign-env[foreign-env] or
https://github.com/bouk/babelfish[babelfish].
+ +
For example, if you use Bash then add For example, if you use Bash then add
+ +
@ -107,6 +111,9 @@ checkout of the repository then you can use the
<<opt-programs.home-manager.path>> option to specify the absolute path <<opt-programs.home-manager.path>> option to specify the absolute path
to the repository. to the repository.
Once installed you can see <<ch-usage>> for a more detailed
description of Home Manager and how to use it.
[[sec-install-nixos-module]] [[sec-install-nixos-module]]
=== NixOS module === NixOS module
@ -128,11 +135,11 @@ or an unstable channel, you can run
# nix-channel --update # nix-channel --update
---- ----
and if you follow a Nixpkgs version 21.05 channel, you can run and if you follow a Nixpkgs version 21.11 channel, you can run
[source,console] [source,console]
---- ----
# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager # nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
# nix-channel --update # nix-channel --update
---- ----
@ -159,6 +166,27 @@ home-manager.users.eve = { pkgs, ... }: {
and after a `nixos-rebuild switch` the user eve's environment should and after a `nixos-rebuild switch` the user eve's environment should
include a basic Bash configuration and the packages atool and httpie. include a basic Bash configuration and the packages atool and httpie.
If you do not plan on having Home Manager manage your shell
configuration then you must add either
[source,bash]
----
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
----
or
[source,bash]
----
. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh"
----
to your shell configuration, depending on whether
<<nixos-opt-home-manager.useUserPackages>> is enabled. This file can
be sourced directly by POSIX.2-like shells such as {bash}[Bash] or
{zsh}[Z shell]. {fish}[Fish] users can use utilities such as
{plugin-foreign-env}[foreign-env] or {babelfish}[babelfish].
[NOTE] [NOTE]
==== ====
By default packages will be installed to `$HOME/.nix-profile` but they By default packages will be installed to `$HOME/.nix-profile` but they
@ -187,6 +215,9 @@ the dependency on `NIX_PATH`, which is otherwise used for importing
Nixpkgs. Nixpkgs.
==== ====
Once installed you can see <<ch-usage>> for a more detailed
description of Home Manager and how to use it.
[[sec-install-nix-darwin-module]] [[sec-install-nix-darwin-module]]
=== nix-darwin module === nix-darwin module
@ -206,11 +237,11 @@ or an unstable channel, you can run
# nix-channel --update # nix-channel --update
---- ----
and if you follow a Nixpkgs version 21.05 channel, you can run and if you follow a Nixpkgs version 21.11 channel, you can run
[source,console] [source,console]
---- ----
# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager # nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
# nix-channel --update # nix-channel --update
---- ----
@ -241,6 +272,27 @@ and after a `darwin-rebuild switch` the user eve's environment
should include a basic Bash configuration and the packages atool and should include a basic Bash configuration and the packages atool and
httpie. httpie.
If you do not plan on having Home Manager manage your shell
configuration then you must add either
[source,bash]
----
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
----
or
[source,bash]
----
. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh"
----
to your shell configuration, depending on whether
<<nix-darwin-opt-home-manager.useUserPackages>> is enabled. This file
can be sourced directly by POSIX.2-like shells such as {bash}[Bash] or
{zsh}[Z shell]. {fish}[Fish] users can use utilities such as
{plugin-foreign-env}[foreign-env] or {babelfish}[babelfish].
[NOTE] [NOTE]
==== ====
By default user packages will not be ignored in favor of By default user packages will not be ignored in favor of
@ -268,3 +320,6 @@ This saves an extra Nixpkgs evaluation, adds consistency, and removes
the dependency on `NIX_PATH`, which is otherwise used for importing the dependency on `NIX_PATH`, which is otherwise used for importing
Nixpkgs. Nixpkgs.
==== ====
Once installed you can see <<ch-usage>> for a more detailed
description of Home Manager and how to use it.

View file

@ -29,6 +29,7 @@
</note> </note>
</preface> </preface>
<xi:include href="installation.xml" /> <xi:include href="installation.xml" />
<xi:include href="usage.xml" />
<xi:include href="writing-modules.xml" /> <xi:include href="writing-modules.xml" />
<xi:include href="contributing.xml" /> <xi:include href="contributing.xml" />
<xi:include href="faq.xml" /> <xi:include href="faq.xml" />

View file

@ -6,6 +6,8 @@ This section lists the release notes for stable versions of Home Manager and the
:leveloffset: 1 :leveloffset: 1
include::rl-2205.adoc[]
include::rl-2111.adoc[] include::rl-2111.adoc[]
include::rl-2105.adoc[] include::rl-2105.adoc[]

View file

@ -1,8 +1,7 @@
[[sec-release-21.11]] [[sec-release-21.11]]
== Release 21.11 == Release 21.11
This is the current unstable branch and the information in this The 21.11 release branch became the stable branch in November, 2021.
section is therefore not final.
[[sec-release-21.11-highlights]] [[sec-release-21.11-highlights]]
=== Highlights === Highlights
@ -37,6 +36,10 @@ https://github.com/nix-community/home-manager/issues/1906[issue #1906].
+ +
You can replicate your old configuration by moving those options to <<opt-programs.rofi.theme>>. Keep in mind that the syntax is different so you may need to do some changes. You can replicate your old configuration by moving those options to <<opt-programs.rofi.theme>>. Keep in mind that the syntax is different so you may need to do some changes.
* Taskwarrior version 2.6.0 respects XDG Specification for the config file now.
Option <<opt-programs.taskwarrior.config>> and friends now generate the config file at
`$XDG_CONFIG_HOME/task/taskrc` instead of `~/.taskrc`.
[[sec-release-21.11-state-version-changes]] [[sec-release-21.11-state-version-changes]]
=== State Version Changes === State Version Changes
@ -45,3 +48,26 @@ changes are only active if the `home.stateVersion` option is set to
"21.11" or later. "21.11" or later.
* The <<opt-home.keyboard>> option now defaults to `null`, meaning that Home Manager won't do any keyboard layout management. For example, `setxkbmap` won't be run in X sessions. * The <<opt-home.keyboard>> option now defaults to `null`, meaning that Home Manager won't do any keyboard layout management. For example, `setxkbmap` won't be run in X sessions.
* The <<opt-programs.pet.settings>> option no longer place its value inside a `General` attribute.
For example,
+
[source,nix]
programs.pet.settings.editor = "nvim";
+
becomes
+
[source,nix]
programs.pet.settings.General.editor = "nvim";
* The <<opt-programs.waybar.settings>> option now allows defining modules directly under <<opt-programs.waybar.settings>>.
For example,
+
[source,nix]
programs.waybar.settings.modules."custom/my-module" = { };
+
becomes
+
[source,nix]
programs.waybar.settings."custom/my-module" = { };

View file

@ -0,0 +1,31 @@
[[sec-release-22.05]]
== Release 22.05
This is the current unstable branch and the information in this section is therefore not final.
[[sec-release-22.05-highlights]]
=== Highlights
This release has the following notable changes:
* The `programs.waybar.settings.modules` option was removed.
Waybar modules should now be declared directly under `programs.waybar.settings`.
[[sec-release-22.05-state-version-changes]]
=== State Version Changes
The state version in this release includes the changes below.
These changes are only active if the `home.stateVersion` option is set to "22.05" or later.
* The <<opt-programs.waybar.settings>> option now allows defining modules directly under <<opt-programs.waybar.settings>>.
Defining modules under `programs.waybar.settings.modules` will now be an error.
For example,
+
[source,nix]
programs.waybar.settings.modules."custom/my-module" = { };
+
becomes
+
[source,nix]
programs.waybar.settings."custom/my-module" = { };

226
third_party/home-manager/docs/usage.adoc vendored Normal file
View file

@ -0,0 +1,226 @@
[[ch-usage]]
== Using Home Manager
Your use of Home Manager is centered around the configuration file, which is typically found at `~/.config/nixpkgs/home.nix`.
This configuration file can be _built_ and _activated_.
Building a configuration produces a directory in the Nix store that contains all files and programs that should be available in your home directory and Nix user profile, respectively. The build step also checks that the configuration is valid and it will fail with an error if you, for example, assign a value to an option that does not exist or assign a value of the wrong type. Some modules also have custom assertions that perform more detailed, module specific, checks.
Concretely, if your configuration contains
[source,nix]
programs.emacs.enable = "yes";
then building it, for example using `home-manager build`, will result in an error message saying something like
[source,console]
----
$ home-manager build
error: A definition for option `programs.emacs.enable' is not of type `boolean'. Definition values:
- In `/home/jdoe/.config/nixpkgs/home.nix': "yes"
(use '--show-trace' to show detailed location information)
----
The message indicates that you must provide a Boolean value for this option, that is, either `true` or `false`. The documentation of each option will state the expected type, for <<opt-programs.emacs.enable>> you will see ``Type: boolean''. You there also find information about the default value and a description of the option. You can find the complete option documentation in <<ch-options>> or directly in the terminal by running
[source,console]
man home-configuration.nix
Once a configuration is successfully built, it can be activated. The activation performs the steps necessary to make the files, programs, and services available in your user environment. The `home-manager switch` command performs a combined build and activation.
=== Configuration Example
A fresh install of Home Manager will generate a minimal `~/.config/nixpkgs/home.nix` file containing something like
[source,nix]
----
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "jdoe";
home.homeDirectory = "/home/jdoe";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.05";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}
----
You can use this as a base for your further configurations.
[NOTE]
If you are not very familiar with the Nix language and NixOS modules then it is encouraged to start with small and simple changes. As you learn you can gradually grow the configuration with confidence.
As an example, let us expand the initial configuration file to also install the htop and fortune packages, install Emacs with a few extra packages available, and enable the user gpg-agent service.
To satisfy the above setup we should elaborate the `home.nix` file as follows:
[source,nix]
----
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "jdoe";
home.homeDirectory = "/home/jdoe";
# Packages that should be installed to the user profile.
home.packages = [ <1>
pkgs.htop
pkgs.fortune
];
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.05";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.emacs = { <2>
enable = true;
extraPackages = epkgs: [
epkgs.nix-mode
epkgs.magit
];
};
services.gpg-agent = { <3>
enable = true;
defaultCacheTtl = 1800;
enableSshSupport = true;
};
}
----
<1> Nixpkgs packages can be installed to the user profile using <<opt-home.packages>>.
<2> The option names of a program module typically start with `programs.<package name>`.
<3> Similarly, for a service module, the names start with `services.<package name>`. Note in some cases a package has both programs _and_ service options Emacs is such an example.
To activate this configuration you can run
[source,console]
home-manager switch
or if you are not feeling so lucky,
[source,console]
home-manager build
which will create a `result` link to a directory containing an
activation script and the generated home directory files.
=== Rollbacks
While the `home-manager` tool does not explicitly support rollbacks at the moment it is relatively easy to perform one manually. The steps to do so are
1. Run `home-manager generations` to determine which generation you wish to rollback to:
+
[source,console]
----
$ home-manager generations
2018-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation
2018-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation
2018-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
2017-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation
2017-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation
----
2. Copy the Nix store path of the generation you chose, e.g.,
+
----
/nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
----
+
for generation 763.
3. Run the `activate` script inside the copied store path:
+
[source,console]
----
$ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate
Starting home manager activation
----
=== Keeping your ~ safe from harm
To configure programs and services Home Manager must write various things to your home directory. To prevent overwriting any existing files when switching to a new generation, Home Manager will attempt to detect collisions between existing files and generated files. If any such collision is detected the activation will terminate before changing anything on your computer.
For example, suppose you have a wonderful, painstakingly created `~/.config/git/config` and add
[source,nix]
----
{
# …
programs.git = {
enable = true;
userName = "Jane Doe";
userEmail = "jane.doe@example.org";
};
# …
}
----
to your configuration. Attempting to switch to the generation will then result in
[source,console]
----
$ home-manager switch
Activating checkLinkTargets
Existing file '/home/jdoe/.config/git/config' is in the way
Please move the above files and try again
----
=== Graphical services
Home Manager includes a number of services intended to run in a graphical session, for example `xscreensaver` and `dunst`. Unfortunately, such services will not be started automatically unless you let Home Manager start your X session. That is, you have something like
[source,nix]
----
{
# …
services.xserver.enable = true;
# …
}
----
in your system configuration and
[source,nix]
----
{
# …
xsession.enable = true;
xsession.windowManager.command = "…";
# …
}
----
in your Home Manager configuration.

View file

@ -30,6 +30,15 @@
defaultPackage = defaultPackage =
forAllSystems (system: self.packages.${system}.home-manager); forAllSystems (system: self.packages.${system}.home-manager);
apps = forAllSystems (system: {
home-manager = {
type = "app";
program = "${defaultPackage.${system}}/bin/home-manager";
};
});
defaultApp = forAllSystems (system: apps.${system}.home-manager);
lib = { lib = {
hm = import ./modules/lib { lib = nixpkgs.lib; }; hm = import ./modules/lib { lib = nixpkgs.lib; };
homeManagerConfiguration = { configuration, system, homeDirectory homeManagerConfiguration = { configuration, system, homeDirectory

View file

@ -16,7 +16,6 @@ let
in runCommand "home-manager" { in runCommand "home-manager" {
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
meta = with lib; { meta = with lib; {
description = "A user environment configurator"; description = "A user environment configurator";
maintainers = [ maintainers.rycee ]; maintainers = [ maintainers.rycee ];

View file

@ -186,6 +186,18 @@ function doBuildAttr() {
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
} }
function doBuildFlake() {
local extraArgs=("$@")
if [[ -v VERBOSE ]]; then
extraArgs=("${extraArgs[@]}" "--verbose")
fi
nix build \
"${extraArgs[@]}" \
"${PASSTHROUGH_OPTS[@]}"
}
# Presents news to the user. Takes as argument the path to a "news # Presents news to the user. Takes as argument the path to a "news
# info" file as generated by `buildNews`. # info" file as generated by `buildNews`.
function presentNews() { function presentNews() {
@ -246,52 +258,32 @@ function doBuild() {
return 1 return 1
fi fi
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix build \
"${PASSTHROUGH_OPTS[@]}" \
${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \
"$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1
return $exitCode
fi
setWorkDir setWorkDir
local newsInfo setFlakeAttribute
newsInfo=$(buildNews) if [[ -v FLAKE_CONFIG_URI ]]; then
doBuildFlake \
"$FLAKE_CONFIG_URI.activationPackage" \
${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \
|| return
else
doBuildAttr \
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
|| return
local exitCode local newsInfo
doBuildAttr \ newsInfo=$(buildNews)
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
&& exitCode=0 || exitCode=1
presentNews "$newsInfo" presentNews "$newsInfo"
fi
return $exitCode
} }
function doSwitch() { function doSwitch() {
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix run \
"${PASSTHROUGH_OPTS[@]}" \
"$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1
return $exitCode
fi
setWorkDir setWorkDir
local newsInfo
newsInfo=$(buildNews)
local generation local generation
local exitCode=0
# Build the generation and run the activate script. Note, we # Build the generation and run the activate script. Note, we
# specify an output link so that it is treated as a GC root. This # specify an output link so that it is treated as a GC root. This
@ -299,14 +291,23 @@ function doSwitch() {
# before activation completes. # before activation completes.
generation="$WORK_DIR/generation" generation="$WORK_DIR/generation"
doBuildAttr \ setFlakeAttribute
--out-link "$generation" \ if [[ -v FLAKE_CONFIG_URI ]]; then
--attr activationPackage \ doBuildFlake \
&& "$generation/activate" || exitCode=1 "$FLAKE_CONFIG_URI.activationPackage" \
--out-link "$generation" \
&& "$generation/activate" || return
else
doBuildAttr \
--out-link "$generation" \
--attr activationPackage \
&& "$generation/activate" || return
presentNews "$newsInfo" local newsInfo
newsInfo=$(buildNews)
return $exitCode presentNews "$newsInfo"
fi
} }
function doListGens() { function doListGens() {
@ -403,13 +404,13 @@ function buildNews() {
output="$WORK_DIR/news-info.sh" output="$WORK_DIR/news-info.sh"
doBuildAttr \ doBuildAttr \
--out-link "$output" \ --out-link "$output" \
--no-build-output \ --no-build-output \
--quiet \ --quiet \
--arg check false \ --arg check false \
--argstr newsReadIdsFile "$(newsReadIdsFile)" \ --argstr newsReadIdsFile "$(newsReadIdsFile)" \
--attr newsInfo \ --attr newsInfo \
> /dev/null > /dev/null
echo "$output" echo "$output"
} }
@ -524,6 +525,7 @@ function doHelp() {
echo " --show-trace" echo " --show-trace"
echo " --(no-)substitute" echo " --(no-)substitute"
echo " --no-out-link Do not create a symlink to the output path" echo " --no-out-link Do not create a symlink to the output path"
echo " --no-write-lock-file"
echo " --builders VALUE" echo " --builders VALUE"
echo echo
echo "Commands" echo "Commands"
@ -632,7 +634,7 @@ while [[ $# -gt 0 ]]; do
export VERBOSE=1 export VERBOSE=1
;; ;;
--version) --version)
echo 21.11 echo 22.05
exit 0 exit 0
;; ;;
*) *)

View file

@ -3,7 +3,6 @@
runCommand "home-manager-install" { runCommand "home-manager-install" {
propagatedBuildInputs = [ home-manager ]; propagatedBuildInputs = [ home-manager ];
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
shellHookOnly = true; shellHookOnly = true;
shellHook = '' shellHook = ''
confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix"
@ -32,9 +31,6 @@ runCommand "home-manager-install" {
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home.username = "$USER"; home.username = "$USER";
@ -48,7 +44,10 @@ runCommand "home-manager-install" {
# You can update Home Manager without changing this value. See # You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version # the Home Manager release notes for a list of state version
# changes in each release. # changes in each release.
home.stateVersion = "21.11"; home.stateVersion = "22.05";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
} }
EOF EOF
fi fi

View file

@ -188,7 +188,7 @@ let
}; };
flavor = mkOption { flavor = mkOption {
type = types.enum [ "plain" "gmail.com" "runbox.com" ]; type = types.enum [ "plain" "gmail.com" "runbox.com" "fastmail.com" ];
default = "plain"; default = "plain";
description = '' description = ''
Some email providers have peculiar behavior that require Some email providers have peculiar behavior that require
@ -328,7 +328,17 @@ let
name = name; name = name;
maildir = mkOptionDefault { path = "${name}"; }; maildir = mkOptionDefault { path = "${name}"; };
} }
(mkIf (config.flavor == "fastmail.com") {
userName = mkDefault config.address;
smtp = {
host = "smtp.fastmail.com";
port = if config.smtp.tls.useStartTls then 587 else 465;
};
imap = {
host = "imap.fastmail.com";
port = 993;
};
})
(mkIf (config.flavor == "gmail.com") { (mkIf (config.flavor == "gmail.com") {
userName = mkDefault config.address; userName = mkDefault config.address;

View file

@ -36,7 +36,7 @@ let
in { in {
meta.maintainers = with maintainers; [ midchildan ]; meta.maintainers = with maintainers; [ midchildan ];
config = mkIf pkgs.hostPlatform.isLinux { config = mkIf pkgs.stdenv.hostPlatform.isLinux {
# For shell sessions. # For shell sessions.
home.sessionVariables = localeVars; home.sessionVariables = localeVars;

View file

@ -205,12 +205,13 @@ in
home.profileDirectory = mkOption { home.profileDirectory = mkOption {
type = types.path; type = types.path;
defaultText = "~/.nix-profile"; defaultText = literalExpression ''
internal = true; "''${home.homeDirectory}/.nix-profile" or
"/etc/profiles/per-user/''${home.username}"
'';
readOnly = true; readOnly = true;
description = '' description = ''
The profile directory where Home Manager generations are The profile directory where Home Manager generations are installed.
installed.
''; '';
}; };
@ -233,6 +234,26 @@ in
''; '';
}; };
home.shellAliases = mkOption {
type = with types; attrsOf str;
default = { };
example = literalExpression ''
{
g = "git";
"..." = "cd ../..";
}
'';
description = ''
An attribute set that maps aliases (the top level attribute names
in this option) to command strings or directly to build outputs.
</para><para>
This option should only be used to manage simple aliases that are
compatible across all shells. If you need to use a shell specific
feature then make sure to use a shell specific option, for example
<xref linkend="opt-programs.bash.shellAliases"/> for Bash.
'';
};
home.sessionVariables = mkOption { home.sessionVariables = mkOption {
default = {}; default = {};
type = types.attrs; type = types.attrs;
@ -419,7 +440,7 @@ in
home.enableNixpkgsReleaseCheck = mkOption { home.enableNixpkgsReleaseCheck = mkOption {
type = types.bool; type = types.bool;
default = true; default = false; # Temporarily disabled until release stabilizes.
description = '' description = ''
Determines whether to check for release version mismatch between Home Determines whether to check for release version mismatch between Home
Manager and Nixpkgs. Using mismatched versions is likely to cause errors Manager and Nixpkgs. Using mismatched versions is likely to cause errors
@ -483,6 +504,10 @@ in
then "/etc/profiles/per-user/${cfg.username}" then "/etc/profiles/per-user/${cfg.username}"
else cfg.homeDirectory + "/.nix-profile"; else cfg.homeDirectory + "/.nix-profile";
programs.bash.shellAliases = cfg.shellAliases;
programs.zsh.shellAliases = cfg.shellAliases;
programs.fish.shellAliases = cfg.shellAliases;
home.sessionVariables = home.sessionVariables =
let let
maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; }; maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; };
@ -628,7 +653,6 @@ in
"home-manager-generation" "home-manager-generation"
{ {
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
} }
'' ''
mkdir -p $out mkdir -p $out

View file

@ -133,4 +133,11 @@
github = "hawkw"; github = "hawkw";
githubId = 2796466; githubId = 2796466;
}; };
pamplemousse = {
name = "Xavier Maso";
email = "xav.maso@gmail.com";
github = "pamplemousse";
githubId = 2647236;
};
} }

View file

@ -2233,6 +2233,53 @@ in
A new module is available: 'programs.hexchat'. A new module is available: 'programs.hexchat'.
''; '';
} }
{
time = "2021-11-21T17:21:04+00:00";
condition = config.wayland.windowManager.sway.enable;
message = ''
A new module is available: 'wayland.windowManager.sway.swaynag'.
'';
}
{
time = "2021-11-23T20:26:37+00:00";
condition = config.programs.taskwarrior.enable;
message = ''
Taskwarrior version 2.6.0 respects XDG Specification for the config
file now. Option 'programs.taskwarrior.config' and friends now
generate the config file at '$XDG_CONFIG_HOME/task/taskrc' instead of
'~/.taskrc'.
'';
}
{
time = "2021-11-30T22:28:12+00:00";
message = ''
A new module is available: 'programs.less'.
'';
}
{
time = "2021-11-29T15:15:59+00:00";
condition = hostPlatform.isDarwin;
message = ''
The option 'targets.darwin.defaults."com.apple.menuextra.battery".ShowPercent'
has been deprecated since it no longer works on the latest version of
macOS.
'';
}
{
time = "2021-12-02T02:59:59+00:00";
condition = config.programs.waybar.enable;
message = ''
The Waybar module now allows defining modules directly under the 'settings'
option instead of nesting the modules under 'settings.modules'.
The Waybar module will also stop reporting errors about unused or misnamed
modules.
'';
}
]; ];
}; };
} }

View file

@ -14,6 +14,7 @@ with lib;
"21.03" "21.03"
"21.05" "21.05"
"21.11" "21.11"
"22.05"
]; ];
default = "18.09"; default = "18.09";
description = '' description = ''

View file

@ -10,7 +10,7 @@ in {
options = { options = {
xdg.mime.enable = mkOption { xdg.mime.enable = mkOption {
type = types.bool; type = types.bool;
default = pkgs.hostPlatform.isLinux; default = pkgs.stdenv.hostPlatform.isLinux;
defaultText = defaultText =
literalExpression "true if host platform is Linux, false otherwise"; literalExpression "true if host platform is Linux, false otherwise";
description = '' description = ''

View file

@ -108,7 +108,7 @@ in {
xdg.cacheHome = mkDefault defaultCacheHome; xdg.cacheHome = mkDefault defaultCacheHome;
xdg.configHome = mkDefault defaultConfigHome; xdg.configHome = mkDefault defaultConfigHome;
xdg.dataHome = mkDefault defaultDataHome; xdg.dataHome = mkDefault defaultDataHome;
xdg.stateHome = mkDefault stateHome; xdg.stateHome = mkDefault defaultStateHome;
}) })
{ {

View file

@ -86,6 +86,7 @@ let
./programs/keychain.nix ./programs/keychain.nix
./programs/kitty.nix ./programs/kitty.nix
./programs/lazygit.nix ./programs/lazygit.nix
./programs/less.nix
./programs/lesspipe.nix ./programs/lesspipe.nix
./programs/lf.nix ./programs/lf.nix
./programs/lieer.nix ./programs/lieer.nix
@ -227,6 +228,7 @@ let
./services/window-managers/bspwm/default.nix ./services/window-managers/bspwm/default.nix
./services/window-managers/i3-sway/i3.nix ./services/window-managers/i3-sway/i3.nix
./services/window-managers/i3-sway/sway.nix ./services/window-managers/i3-sway/sway.nix
./services/window-managers/i3-sway/swaynag.nix
./services/window-managers/xmonad.nix ./services/window-managers/xmonad.nix
./services/wlsunset.nix ./services/wlsunset.nix
./services/xcape.nix ./services/xcape.nix

View file

@ -15,6 +15,8 @@ in {
"direnv" "direnv"
"enableNixDirenvIntegration" "enableNixDirenvIntegration"
] [ "programs" "direnv" "nix-direnv" "enable" ]) ] [ "programs" "direnv" "nix-direnv" "enable" ])
(mkRemovedOptionModule [ "programs" "direnv" "nix-direnv" "enableFlakes" ]
"Flake support is now always enabled.")
]; ];
meta.maintainers = [ maintainers.rycee ]; meta.maintainers = [ maintainers.rycee ];
@ -79,7 +81,6 @@ in {
<link <link
xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>, xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>,
a fast, persistent use_nix implementation for direnv''; a fast, persistent use_nix implementation for direnv'';
enableFlakes = mkEnableOption "Flake support in nix-direnv";
}; };
}; };
@ -92,11 +93,9 @@ in {
}; };
xdg.configFile."direnv/direnvrc" = let xdg.configFile."direnv/direnvrc" = let
package =
pkgs.nix-direnv.override { inherit (cfg.nix-direnv) enableFlakes; };
text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib
++ optional cfg.nix-direnv.enable ++ optional cfg.nix-direnv.enable
"source ${package}/share/nix-direnv/direnvrc"); "source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc");
in mkIf (text != "") { inherit text; }; in mkIf (text != "") { inherit text; };
programs.bash.initExtra = mkIf cfg.enableBashIntegration ( programs.bash.initExtra = mkIf cfg.enableBashIntegration (

View file

@ -370,8 +370,8 @@ in {
"${profilesPath}/${profile.path}/chrome/userContent.css" = "${profilesPath}/${profile.path}/chrome/userContent.css" =
mkIf (profile.userContent != "") { text = profile.userContent; }; mkIf (profile.userContent != "") { text = profile.userContent; };
"${profilesPath}/${profile.path}/user.js" = "${profilesPath}/${profile.path}/user.js" = mkIf (profile.settings != { }
mkIf (profile.settings != { } || profile.extraConfig != "") { || profile.extraConfig != "" || profile.bookmarks != { }) {
text = text =
mkUserJs profile.settings profile.extraConfig profile.bookmarks; mkUserJs profile.settings profile.extraConfig profile.bookmarks;
}; };

View file

@ -310,7 +310,6 @@ in {
nativeBuildInputs = [ pkgs.python2 ]; nativeBuildInputs = [ pkgs.python2 ];
buildInputs = [ cfg.package ]; buildInputs = [ cfg.package ];
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
} '' } ''
mkdir -p $out mkdir -p $out
if [ -d $src/share/man ]; then if [ -d $src/share/man ]; then

View file

@ -21,6 +21,110 @@ let
} cfg.scdaemonSettings; } cfg.scdaemonSettings;
primitiveType = types.oneOf [ types.str types.bool ]; primitiveType = types.oneOf [ types.str types.bool ];
publicKeyOpts = { config, ...}: {
options = {
text = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Text of an OpenPGP public key.
'';
};
source = mkOption {
type = types.path;
description = ''
Path of an OpenPGP public key file.
'';
};
trust = mkOption {
type = types.nullOr (types.enum [ 1 2 3 4 5 ]);
default = null;
description = ''
The amount of trust you have in the key ownership and the care the
owner puts into signing other keys. The available levels are
<variablelist>
<varlistentry>
<term><literal>1</literal></term>
<listitem><para>I don't know or won't say.</para></listitem>
</varlistentry>
<varlistentry>
<term><literal>2</literal></term>
<listitem><para>I do NOT trust.</para></listitem>
</varlistentry>
<varlistentry>
<term><literal>3</literal></term>
<listitem><para>I trust marginally.</para></listitem>
</varlistentry>
<varlistentry>
<term><literal>4</literal></term>
<listitem><para>I trust fully.</para></listitem>
</varlistentry>
<varlistentry>
<term><literal>5</literal></term>
<listitem><para>I trust ultimately.</para></listitem>
</varlistentry>
</variablelist>
</para><para>
See <link xlink:href="https://www.gnupg.org/gph/en/manual/x334.html"/>
for more.
'';
};
};
config = {
source = mkIf (config.text != null)
(pkgs.writeText "gpg-pubkey" config.text);
};
};
importTrustBashFunctions =
let gpg = "${cfg.package}/bin/gpg";
in ''
function gpgKeyId() {
${gpg} --show-key --with-colons "$1" \
| grep ^pub: \
| cut -d: -f5
}
function importTrust() {
local keyId trust
keyId="$(gpgKeyId "$1")"
trust="$2"
if [[ -n $keyId ]] ; then
echo -e "trust\n$trust\ny\nquit" \
| ${gpg} --no-tty --command-fd 0 --edit-key "$keyId"
fi
}
'';
keyringFiles =
let
gpg = "${cfg.package}/bin/gpg";
importKey = { source, trust, ... }: ''
${gpg} --import ${source}
${optionalString (trust != null) ''
importTrust "${source}" ${toString trust}''}
'';
importKeys = concatMapStringsSep "\n" importKey cfg.publicKeys;
in pkgs.runCommand "gpg-pubring" { buildInputs = [ cfg.package ]; } ''
export GNUPGHOME
GNUPGHOME=$(mktemp -d)
${importTrustBashFunctions}
${importKeys}
mkdir $out
cp $GNUPGHOME/pubring.kbx $out/pubring.kbx
if [[ -e $GNUPGHOME/trustdb.gpg ]] ; then
cp $GNUPGHOME/trustdb.gpg $out/trustdb.gpg
fi
'';
in in
{ {
options.programs.gpg = { options.programs.gpg = {
@ -73,6 +177,48 @@ in
defaultText = literalExpression "\"\${config.home.homeDirectory}/.gnupg\""; defaultText = literalExpression "\"\${config.home.homeDirectory}/.gnupg\"";
description = "Directory to store keychains and configuration."; description = "Directory to store keychains and configuration.";
}; };
mutableKeys = mkOption {
type = types.bool;
default = true;
description = ''
If set to <literal>true</literal>, you may manage your keyring as a user
using the <literal>gpg</literal> command. Upon activation, the keyring
will have managed keys added without overwriting unmanaged keys.
</para><para>
If set to <literal>false</literal>, the path
<filename>$GNUPGHOME/pubring.kbx</filename> will become an immutable
link to the Nix store, denying modifications.
'';
};
mutableTrust = mkOption {
type = types.bool;
default = true;
description = ''
If set to <literal>true</literal>, you may manage trust as a user using
the <command>gpg</command> command. Upon activation, trusted keys have
their trust set without overwriting unmanaged keys.
</para><para>
If set to <literal>false</literal>, the path
<filename>$GNUPGHOME/trustdb.gpg</filename> will be
<emphasis>overwritten</emphasis> on each activation, removing trust for
any unmanaged keys. Be careful to make a backup of your old
<filename>trustdb.gpg</filename> before switching to immutable trust!
'';
};
publicKeys = mkOption {
type = types.listOf (types.submodule publicKeyOpts);
example = literalExpression ''
[ { source = ./pubkeys.txt; } ]
'';
default = [ ];
description = ''
A list of public keys to be imported into GnuPG. Note, these key files
will be copied into the world-readable Nix store.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -109,5 +255,48 @@ in
home.file."${cfg.homedir}/gpg.conf".text = cfgText; home.file."${cfg.homedir}/gpg.conf".text = cfgText;
home.file."${cfg.homedir}/scdaemon.conf".text = scdaemonCfgText; home.file."${cfg.homedir}/scdaemon.conf".text = scdaemonCfgText;
# Link keyring if keys are not mutable
home.file."${cfg.homedir}/pubring.kbx" =
mkIf (!cfg.mutableKeys && cfg.publicKeys != []) {
source = "${keyringFiles}/pubring.kbx";
};
home.activation = mkIf (cfg.publicKeys != []) {
importGpgKeys =
let
gpg = "${cfg.package}/bin/gpg";
importKey = { source, trust, ... }:
# Import mutable keys
optional cfg.mutableKeys ''
$DRY_RUN_CMD ${gpg} $QUIET_ARG --import ${source}''
# Import mutable trust
++ optional (trust != null && cfg.mutableTrust) ''
$DRY_RUN_CMD importTrust "${source}" ${toString trust}'';
anyTrust = any (k: k.trust != null) cfg.publicKeys;
importKeys = concatStringsSep "\n" (concatMap importKey cfg.publicKeys);
# If any key/trust should be imported then create the block. Otherwise
# leave it empty.
block = concatStringsSep "\n" (
optional (importKeys != "") ''
export GNUPGHOME=${escapeShellArg cfg.homedir}
if [[ ! -v VERBOSE ]]; then
QUIET_ARG="--quiet"
else
QUIET_ARG=""
fi
${importTrustBashFunctions}
${importKeys}
unset GNUPGHOME QUIET_ARG keyId importTrust
'' ++ optional (!cfg.mutableTrust && anyTrust) ''
install -m 0700 ${keyringFiles}/trustdb.gpg "${cfg.homedir}/trustdb.gpg"''
);
in lib.hm.dag.entryAfter ["linkGeneration"] block;
};
}; };
} }

View file

@ -0,0 +1,32 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.less;
in {
meta.maintainers = [ maintainers.pamplemousse ];
options = {
programs.less = {
enable = mkEnableOption "less, opposite of more";
keys = mkOption {
type = types.lines;
default = "";
example = ''
s back-line
t forw-line
'';
description = ''
Extra configuration for <command>less</command> written to
<filename>$HOME/.lesskey</filename>.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.less ];
home.file.".lesskey".text = cfg.keys;
};
}

View file

@ -65,7 +65,7 @@ let
remotePassEval = remotePassEval =
let arglist = concatMapStringsSep "," (x: "'${x}'") passwordCommand; let arglist = concatMapStringsSep "," (x: "'${x}'") passwordCommand;
in optionalAttrs (passwordCommand != null) { in optionalAttrs (passwordCommand != null) {
remotepasseval = ''get_pass("${name}", [${arglist}]).strip("\n")''; remotepasseval = ''get_pass("${name}", [${arglist}]).strip(b"\n")'';
}; };
in toIni { in toIni {
"Account ${name}" = { "Account ${name}" = {

View file

@ -80,16 +80,25 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.pet.settings = { programs.pet.settings = let
selectcmd = mkDefault "fzf"; defaultGeneral = {
snippetfile = config.xdg.configHome + "/pet/snippet.toml"; selectcmd = mkDefault "fzf";
}; snippetfile = config.xdg.configHome + "/pet/snippet.toml";
};
in if versionAtLeast config.home.stateVersion "21.11" then {
General = defaultGeneral;
} else
defaultGeneral;
home.packages = [ pkgs.pet cfg.selectcmdPackage ]; home.packages = [ pkgs.pet cfg.selectcmdPackage ];
xdg.configFile = { xdg.configFile = {
"pet/config.toml".source = "pet/config.toml".source = format.generate "config.toml"
format.generate "config.toml" { General = cfg.settings; }; (if versionAtLeast config.home.stateVersion "21.11" then
cfg.settings
else {
General = cfg.settings;
});
"pet/snippet.toml".source = "pet/snippet.toml".source =
format.generate "snippet.toml" { snippets = cfg.snippets; }; format.generate "snippet.toml" { snippets = cfg.snippets; };
}; };

View file

@ -19,22 +19,29 @@ let
builtins.toString value; builtins.toString value;
modulesArgument = optionalString (cfg.modules != null) modulesArgument = optionalString (cfg.modules != null)
"-modules ${valueToString cfg.modules}"; " -modules ${valueToString cfg.modules}";
newlineArgument = optionalString cfg.newline "-newline"; modulesRightArgument = optionalString (cfg.modulesRight != null)
" -modules-right ${valueToString cfg.modulesRight}";
evalMode = cfg.modulesRight != null;
evalArgument = optionalString (evalMode) " -eval";
newlineArgument = optionalString cfg.newline " -newline";
pathAliasesArgument = optionalString (cfg.pathAliases != null) pathAliasesArgument = optionalString (cfg.pathAliases != null)
"-path-aliases ${valueToString cfg.pathAliases}"; " -path-aliases ${valueToString cfg.pathAliases}";
otherSettingPairArgument = name: value: otherSettingPairArgument = name: value:
if value == true then "-${name}" else "-${name} ${valueToString value}"; if value == true then " -${name}" else " -${name} ${valueToString value}";
otherSettingsArgument = optionalString (cfg.settings != { }) otherSettingsArgument = optionalString (cfg.settings != { })
(concatStringsSep " " (concatStringsSep ""
(mapAttrsToList otherSettingPairArgument cfg.settings)); (mapAttrsToList otherSettingPairArgument cfg.settings));
commandLineArguments = '' commandLineArguments = ''
${modulesArgument} ${newlineArgument} ${pathAliasesArgument} ${otherSettingsArgument} ${evalArgument}${modulesArgument}${modulesRightArgument}${newlineArgument}${pathAliasesArgument}${otherSettingsArgument}
''; '';
in { in {
@ -56,6 +63,18 @@ in {
example = [ "host" "ssh" "cwd" "gitlite" "jobs" "exit" ]; example = [ "host" "ssh" "cwd" "gitlite" "jobs" "exit" ];
}; };
modulesRight = mkOption {
default = null;
type = types.nullOr (types.listOf types.str);
description = ''
List of module names to load to be displayed on the right side.
Currently not supported by bash. Specifying a value for this
option will force powerline-go to use the eval format to set
the prompt.
'';
example = [ "host" "venv" "git" ];
};
newline = mkOption { newline = mkOption {
default = false; default = false;
type = types.bool; type = types.bool;
@ -111,7 +130,9 @@ in {
mkIf (cfg.enable && config.programs.bash.enable) '' mkIf (cfg.enable && config.programs.bash.enable) ''
function _update_ps1() { function _update_ps1() {
local old_exit_status=$? local old_exit_status=$?
PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status ${commandLineArguments})" ${
if evalMode then "eval " else "PS1="
}"$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status -shell bash${commandLineArguments})"
${cfg.extraUpdatePS1} ${cfg.extraUpdatePS1}
return $old_exit_status return $old_exit_status
} }
@ -123,7 +144,9 @@ in {
programs.zsh.initExtra = mkIf (cfg.enable && config.programs.zsh.enable) '' programs.zsh.initExtra = mkIf (cfg.enable && config.programs.zsh.enable) ''
function powerline_precmd() { function powerline_precmd() {
PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh ${commandLineArguments})" ${
if evalMode then "eval " else "PS1="
}"$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh${commandLineArguments})"
${cfg.extraUpdatePS1} ${cfg.extraUpdatePS1}
} }
@ -145,7 +168,7 @@ in {
programs.fish.interactiveShellInit = programs.fish.interactiveShellInit =
mkIf (cfg.enable && config.programs.fish.enable) '' mkIf (cfg.enable && config.programs.fish.enable) ''
function fish_prompt function fish_prompt
eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p)) ${commandLineArguments} eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p))${commandLineArguments}
${cfg.extraUpdatePS1} ${cfg.extraUpdatePS1}
end end
''; '';

View file

@ -35,10 +35,10 @@ let
${configStr}} ${configStr}}
'' ''
else else
mkKeyValue { (mkKeyValue {
sep = " "; sep = " ";
end = ""; end = "";
} name value; } name value) + "\n";
toRasi = attrs: concatStringsSep "\n" (mapAttrsToList mkRasiSection attrs); toRasi = attrs: concatStringsSep "\n" (mapAttrsToList mkRasiSection attrs);
@ -266,9 +266,9 @@ in {
location = (getAttr cfg.location locationsMap); location = (getAttr cfg.location locationsMap);
xoffset = cfg.xoffset; xoffset = cfg.xoffset;
yoffset = cfg.yoffset; yoffset = cfg.yoffset;
theme = themeName;
} // cfg.extraConfig); } // cfg.extraConfig);
}; # @theme must go after configuration but attrs are output in alphabetical order ('@' first)
} + (optionalString (themeName != null) (toRasi { "@theme" = themeName; }));
xdg.dataFile = mkIf (themePath != null) (if themePath == "custom" then { xdg.dataFile = mkIf (themePath != null) (if themePath == "custom" then {
"rofi/themes/${themeName}.rasi".text = toRasi cfg.theme; "rofi/themes/${themeName}.rasi".text = toRasi cfg.theme;

View file

@ -414,6 +414,22 @@ in
''; '';
}; };
includes = mkOption {
type = types.listOf types.str;
default = [];
description = ''
File globs of ssh config files that should be included via the
<literal>Include</literal> directive.
</para><para>
See
<citerefentry>
<refentrytitle>ssh_config</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
for more information.
'';
};
matchBlocks = mkOption { matchBlocks = mkOption {
type = hm.types.listOrDagOf matchBlockModule; type = hm.types.listOrDagOf matchBlockModule;
default = {}; default = {};
@ -474,9 +490,12 @@ in
else abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}"; else abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}";
in '' in ''
${concatStringsSep "\n" ( ${concatStringsSep "\n" (
mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)} (mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)
++ (optional (cfg.includes != [ ]) ''
${concatStringsSep "\n\n" (map (block: matchBlockStr block.data) matchBlocks)} Include ${concatStringsSep " " cfg.includes}
'')
++ (map (block: matchBlockStr block.data) matchBlocks)
)}
Host * Host *
ForwardAgent ${yn cfg.forwardAgent} ForwardAgent ${yn cfg.forwardAgent}

View file

@ -6,16 +6,6 @@ let
cfg = config.programs.taskwarrior; cfg = config.programs.taskwarrior;
themePath = theme: "${pkgs.taskwarrior}/share/doc/task/rc/${theme}.theme";
includeTheme = location:
if location == null then
""
else if isString location then
"include ${themePath location}"
else
"include ${location}";
formatValue = value: formatValue = value:
if isBool value then if isBool value then
if value then "true" else "false" if value then "true" else "false"
@ -59,7 +49,7 @@ in {
''; '';
description = '' description = ''
Key-value configuration written to Key-value configuration written to
<filename>~/.taskrc</filename>. <filename>$XDG_CONFIG_HOME/task/taskrc</filename>.
''; '';
}; };
@ -89,7 +79,7 @@ in {
default = ""; default = "";
description = '' description = ''
Additional content written at the end of Additional content written at the end of
<filename>~/.taskrc</filename>. <filename>$XDG_CONFIG_HOME/task/taskrc</filename>.
''; '';
}; };
}; };
@ -98,9 +88,12 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ pkgs.taskwarrior ]; home.packages = [ pkgs.taskwarrior ];
home.file.".taskrc".text = '' xdg.configFile."task/taskrc".text = ''
data.location=${cfg.dataLocation} data.location=${cfg.dataLocation}
${includeTheme cfg.colorTheme} ${optionalString (cfg.colorTheme != null) (if isString cfg.colorTheme then
"include ${cfg.colorTheme}.theme"
else
"include ${cfg.colorTheme}")}
${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)} ${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)}

View file

@ -127,11 +127,13 @@ in {
# Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2 # Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2
home.file = let home.file = let
subDir = "share/vscode/extensions"; subDir = "share/vscode/extensions";
toPaths = path: toPaths = ext:
# Links every dir in path to the extension path. # Links every dir in ext to the extension path.
mapAttrsToList map (k: { "${extensionPath}/${k}".source = "${ext}/${subDir}/${k}"; })
(k: _: { "${extensionPath}/${k}".source = "${path}/${subDir}/${k}"; }) (if ext ? vscodeExtUniqueId then
(builtins.readDir (path + "/${subDir}")); [ ext.vscodeExtUniqueId ]
else
builtins.attrNames (builtins.readDir (ext + "/${subDir}")));
toSymlink = concatMap toPaths cfg.extensions; toSymlink = concatMap toPaths cfg.extensions;
dropNullFields = filterAttrs (_: v: v != null); dropNullFields = filterAttrs (_: v: v != null);
in foldr (a: b: a // b) { in foldr (a: b: a // b) {

View file

@ -2,72 +2,26 @@
let let
inherit (lib) inherit (lib)
any attrByPath attrNames concatMap concatMapStringsSep elem elemAt filter all filterAttrs hasAttr isStorePath literalExpression optionalAttrs types;
filterAttrs flip foldl' hasPrefix head length literalExpression mergeAttrs
optionalAttrs stringLength subtractLists types unique;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
cfg = config.programs.waybar; cfg = config.programs.waybar;
# Used when generating warnings
modulesPath = "programs.waybar.settings.[].modules";
jsonFormat = pkgs.formats.json { }; jsonFormat = pkgs.formats.json { };
# Taken from <https://github.com/Alexays/Waybar/blob/cc3acf8102c71d470b00fd55126aef4fb335f728/src/factory.cpp> (2020/10/10) mkMargin = name:
# Order is preserved from the file for easier matching mkOption {
defaultModuleNames = [ type = types.nullOr types.int;
"battery" default = null;
"sway/mode" example = 10;
"sway/workspaces" description = "Margin value without unit.";
"sway/window"
"sway/language"
"wlr/taskbar"
"river/tags"
"idle_inhibitor"
"memory"
"cpu"
"clock"
"disk"
"tray"
"network"
"backlight"
"pulseaudio"
"mpd"
"sndio"
"temperature"
"bluetooth"
];
# Allow specifying a CSS id after the default module name
isValidDefaultModuleName = x:
any (name:
let
res = builtins.split name x;
# if exact match of default module name
in if res == [ "" [ ] ] || res == [ "" [ ] "" ] then
true
else
head res == "" && length res >= 3 && hasPrefix "#" (elemAt res 2))
defaultModuleNames;
isValidCustomModuleName = x: hasPrefix "custom/" x && stringLength x > 7;
margins = let
mkMargin = name: {
"margin-${name}" = mkOption {
type = types.nullOr types.int;
default = null;
example = 10;
description = "Margins value without unit.";
};
}; };
margins = map mkMargin [ "top" "left" "bottom" "right" ];
in foldl' mergeAttrs { } margins;
waybarBarConfig = with lib.types; waybarBarConfig = with types;
submodule { submodule {
freeformType = jsonFormat.type;
options = { options = {
layer = mkOption { layer = mkOption {
type = nullOr (enum [ "top" "bottom" ]); type = nullOr (enum [ "top" "bottom" ]);
@ -164,7 +118,10 @@ let
example = "20 5"; example = "20 5";
}; };
inherit (margins) margin-top margin-left margin-bottom margin-right; margin-left = mkMargin "left";
margin-right = mkMargin "right";
margin-bottom = mkMargin "bottom";
margin-top = mkMargin "top";
name = mkOption { name = mkOption {
type = nullOr str; type = nullOr str;
@ -192,9 +149,9 @@ in {
package = mkOption { package = mkOption {
type = package; type = package;
default = pkgs.waybar; default = pkgs.waybar;
defaultText = "pkgs.waybar"; defaultText = literalExpression "pkgs.waybar";
description = '' description = ''
Waybar package to use. Set to <code>null</code> to use the default module. Waybar package to use. Set to <code>null</code> to use the default package.
''; '';
}; };
@ -241,12 +198,17 @@ in {
systemd.enable = mkEnableOption "Waybar systemd integration"; systemd.enable = mkEnableOption "Waybar systemd integration";
style = mkOption { style = mkOption {
type = nullOr str; type = nullOr (either path str);
default = null; default = null;
description = '' description = ''
CSS style of the bar. CSS style of the bar.
</para>
<para>
See <link xlink:href="https://github.com/Alexays/Waybar/wiki/Configuration"/> See <link xlink:href="https://github.com/Alexays/Waybar/wiki/Configuration"/>
for the documentation. for the documentation.
</para>
<para>
If the value is set to a path literal, then the path will be used as the css file.
''; '';
example = '' example = ''
* { * {
@ -266,122 +228,62 @@ in {
}; };
config = let config = let
writePrettyJSON = jsonFormat.generate; # Removes nulls because Waybar ignores them.
# This is not recursive.
removeNulls = filterAttrs (_: v: v != null);
configSource = let # Makes the actual valid configuration Waybar accepts
# Removes nulls because Waybar ignores them for most values # (strips our custom settings before converting to JSON)
removeNulls = filterAttrs (_: v: v != null); makeConfiguration = configuration:
let
# The "modules" option is not valid in the JSON
# as its descendants have to live at the top-level
settingsWithoutModules = removeAttrs configuration [ "modules" ];
settingsModules =
optionalAttrs (configuration.modules != { }) configuration.modules;
in removeNulls (settingsWithoutModules // settingsModules);
# The clean list of configurations
finalConfiguration = map makeConfiguration cfg.settings;
# Makes the actual valid configuration Waybar accepts configSource = jsonFormat.generate "waybar-config.json" finalConfiguration;
# (strips our custom settings before converting to JSON)
makeConfiguration = configuration:
let
# The "modules" option is not valid in the JSON
# as its descendants have to live at the top-level
settingsWithoutModules = removeAttrs configuration [ "modules" ];
settingsModules =
optionalAttrs (configuration.modules != { }) configuration.modules;
in removeNulls (settingsWithoutModules // settingsModules);
# The clean list of configurations
finalConfiguration = map makeConfiguration cfg.settings;
in writePrettyJSON "waybar-config.json" finalConfiguration;
#
# Warnings are generated based on the following things:
# 1. A `module` is referenced in any of `modules-{left,center,right}` that is neither
# a default module name nor defined in `modules`.
# 2. A `module` is defined in `modules` but is not referenced in either of
# `modules-{left,center,right}`.
# 3. A custom `module` configuration is defined in `modules` but has an invalid name
# for a custom module (i.e. not "custom/my-module-name").
#
warnings = let
mkUnreferencedModuleWarning = name:
"The module '${name}' defined in '${modulesPath}' is not referenced "
+ "in either `modules-left`, `modules-center` or `modules-right` of Waybar's options";
mkUndefinedModuleWarning = settings: name:
let
# Locations where the module is undefined (a combination modules-{left,center,right})
locations = flip filter [ "left" "center" "right" ]
(x: elem name settings."modules-${x}");
mkPath = loc: "'${modulesPath}-${loc}'";
# The modules-{left,center,right} configuration that includes
# an undefined module
path = concatMapStringsSep " and " mkPath locations;
in "The module '${name}' defined in ${path} is neither "
+ "a default module or a custom module declared in '${modulesPath}'";
mkInvalidModuleNameWarning = name:
"The custom module '${name}' defined in '${modulesPath}' is not a valid "
+ "module name. A custom module's name must start with 'custom/' "
+ "like 'custom/mymodule' for instance";
allFaultyModules = flip map cfg.settings (settings:
let
allModules = unique
(concatMap (x: attrByPath [ "modules-${x}" ] [ ] settings) [
"left"
"center"
"right"
]);
declaredModules = attrNames settings.modules;
# Modules declared in `modules` but not referenced in `modules-{left,center,right}`
unreferencedModules = subtractLists allModules declaredModules;
# Modules listed in modules-{left,center,right} that are not default modules
nonDefaultModules =
filter (x: !isValidDefaultModuleName x) allModules;
# Modules referenced in `modules-{left,center,right}` but not declared in `modules`
undefinedModules = subtractLists declaredModules nonDefaultModules;
# Check for invalid module names
invalidModuleNames = filter
(m: !isValidCustomModuleName m && !isValidDefaultModuleName m)
declaredModules;
in {
# The Waybar bar configuration (since config.settings is a list)
inherit settings;
undef = undefinedModules;
unref = unreferencedModules;
invalidName = invalidModuleNames;
});
allWarnings = flip concatMap allFaultyModules
({ settings, undef, unref, invalidName }:
let
unreferenced = map mkUnreferencedModuleWarning unref;
undefined = map (mkUndefinedModuleWarning settings) undef;
invalid = map mkInvalidModuleNameWarning invalidName;
in undefined ++ unreferenced ++ invalid);
in allWarnings;
in mkIf cfg.enable (mkMerge [ in mkIf cfg.enable (mkMerge [
{ {
assertions = [ assertions = [
(lib.hm.assertions.assertPlatform "programs.waybar" pkgs (lib.hm.assertions.assertPlatform "programs.waybar" pkgs
lib.platforms.linux) lib.platforms.linux)
({
assertion =
if lib.versionAtLeast config.home.stateVersion "22.05" then
all (x: !hasAttr "modules" x) cfg.settings
else
true;
message = ''
The `programs.waybar.settings.[].modules` option has been removed.
It is now possible to declare modules in the configuration without nesting them under the `modules` option.
'';
})
]; ];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
}
(mkIf (cfg.settings != [ ]) { xdg.configFile."waybar/config" = mkIf (cfg.settings != [ ]) {
# Generate warnings about defined but unreferenced modules
inherit warnings;
xdg.configFile."waybar/config" = {
source = configSource; source = configSource;
onChange = '' onChange = ''
${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true
''; '';
}; };
})
(mkIf (cfg.style != null) { xdg.configFile."waybar/style.css" = mkIf (cfg.style != null) {
xdg.configFile."waybar/style.css" = { source = if builtins.isPath cfg.style || isStorePath cfg.style then
text = cfg.style; cfg.style
else
pkgs.writeText "waybar/style.css" cfg.style;
onChange = '' onChange = ''
${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true
''; '';
}; };
}) }
(mkIf cfg.systemd.enable { (mkIf cfg.systemd.enable {
systemd.user.services.waybar = { systemd.user.services.waybar = {

View file

@ -6,8 +6,6 @@ let
cfg = config.services.flameshot; cfg = config.services.flameshot;
package = pkgs.flameshot;
iniFormat = pkgs.formats.ini { }; iniFormat = pkgs.formats.ini { };
iniFile = iniFormat.generate "flameshot.ini" cfg.settings; iniFile = iniFormat.generate "flameshot.ini" cfg.settings;
@ -18,6 +16,13 @@ in {
options.services.flameshot = { options.services.flameshot = {
enable = mkEnableOption "Flameshot"; enable = mkEnableOption "Flameshot";
package = mkOption {
type = types.package;
default = pkgs.flameshot;
defaultText = literalExpression "pkgs.flameshot";
description = "Package providing <command>flameshot</command>.";
};
settings = mkOption { settings = mkOption {
type = iniFormat.type; type = iniFormat.type;
default = { }; default = { };
@ -41,7 +46,7 @@ in {
lib.platforms.linux) lib.platforms.linux)
]; ];
home.packages = [ package ]; home.packages = [ cfg.package ];
xdg.configFile = mkIf (cfg.settings != { }) { xdg.configFile = mkIf (cfg.settings != { }) {
"flameshot/flameshot.ini".source = iniFile; "flameshot/flameshot.ini".source = iniFile;
@ -60,7 +65,7 @@ in {
Service = { Service = {
Environment = "PATH=${config.home.profileDirectory}/bin"; Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart = "${package}/bin/flameshot"; ExecStart = "${cfg.package}/bin/flameshot";
Restart = "on-abort"; Restart = "on-abort";
# Sandboxing. # Sandboxing.

View file

@ -10,6 +10,8 @@ let
iniFormat = pkgs.formats.ini { }; iniFormat = pkgs.formats.ini { };
in { in {
meta.maintainers = with maintainers; [ polykernel ];
options = { options = {
services.fnott = { services.fnott = {
enable = mkEnableOption '' enable = mkEnableOption ''

View file

@ -24,7 +24,7 @@ let
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${pkgs.gmailieer}/bin/gmi sync"; ExecStart = "${config.programs.lieer.package}/bin/gmi sync";
WorkingDirectory = account.maildir.absPath; WorkingDirectory = account.maildir.absPath;
Environment = Environment =
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"; "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc";

View file

@ -112,7 +112,9 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = types.attrsOf types.attrs; type = with types;
let ty = oneOf [ bool int float str (listOf ty) (attrsOf ty) ];
in attrsOf (attrsOf ty // { description = "attribute sets"; });
description = '' description = ''
Polybar configuration. This takes a nix attrset and converts it to the Polybar configuration. This takes a nix attrset and converts it to the
strange data format that polybar uses. strange data format that polybar uses.

View file

@ -0,0 +1,70 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.wayland.windowManager.sway.swaynag;
iniFormat = pkgs.formats.ini { };
confFormat = with types;
let
confAtom = nullOr (oneOf [ bool int float str ]) // {
description = "Swaynag config atom (null, bool, int, float, str)";
};
in attrsOf confAtom;
in {
meta.maintainers = with maintainers; [ polykernel ];
options = {
wayland.windowManager.sway.swaynag = {
enable = mkEnableOption
"configuration of swaynag, a lightweight error bar for sway";
settings = mkOption {
type = types.attrsOf confFormat;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/swaynag/config</filename>.
</para><para>
See
<citerefentry>
<refentrytitle>swaynag</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
for a list of avaliable options and an example configuration.
Note, configurations declared under <literal>&lt;config&gt;</literal>
will override the default type values of swaynag.
'';
example = literalExpression ''
{
"<config>" = {
edge = "bottom";
font = "Dina 12";
};
green = {
edge = "top";
background = "00AA00";
text = "FFFFFF";
button-background = "00CC00";
message-padding = 10;
};
}
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "wayland.windowManager.sway.swaynag" pkgs
platforms.linux)
];
xdg.configFile."swaynag/config" = mkIf (cfg.settings != { }) {
source = iniFormat.generate "swaynag.conf" cfg.settings;
};
};
}

View file

@ -132,9 +132,9 @@ in {
# The resulting binary name depends on the arch and os # The resulting binary name depends on the arch and os
# https://github.com/xmonad/xmonad/blob/56b0f850bc35200ec23f05c079eca8b0a1f90305/src/XMonad/Core.hs#L565-L572 # https://github.com/xmonad/xmonad/blob/56b0f850bc35200ec23f05c079eca8b0a1f90305/src/XMonad/Core.hs#L565-L572
mv "$XMONAD_DATA_DIR/xmonad-${pkgs.hostPlatform.system}" $out/bin/ mv "$XMONAD_DATA_DIR/xmonad-${pkgs.stdenv.hostPlatform.system}" $out/bin/
'' ''
}/bin/xmonad-${pkgs.hostPlatform.system}"; }/bin/xmonad-${pkgs.stdenv.hostPlatform.system}";
in mkIf cfg.enable (mkMerge [ in mkIf cfg.enable (mkMerge [
{ {
@ -157,7 +157,7 @@ in {
(mkIf (cfg.config != null) { (mkIf (cfg.config != null) {
xsession.windowManager.command = xmonadBin; xsession.windowManager.command = xmonadBin;
home.file.".xmonad/xmonad.hs".source = cfg.config; home.file.".xmonad/xmonad.hs".source = cfg.config;
home.file.".xmonad/xmonad-${pkgs.hostPlatform.system}" = { home.file.".xmonad/xmonad-${pkgs.stdenv.hostPlatform.system}" = {
source = xmonadBin; source = xmonadBin;
onChange = '' onChange = ''
# Attempt to restart xmonad if X is running. # Attempt to restart xmonad if X is running.

View file

@ -258,7 +258,8 @@ in {
# If we run under a Linux system we assume that systemd is # If we run under a Linux system we assume that systemd is
# available, in particular we assume that systemctl is in PATH. # available, in particular we assume that systemctl is in PATH.
(mkIf pkgs.stdenv.isLinux { # Do not install any user services if username is root.
(mkIf (pkgs.stdenv.isLinux && config.home.username != "root") {
xdg.configFile = mkMerge [ xdg.configFile = mkMerge [
(lib.listToAttrs ((buildServices "service" cfg.services) (lib.listToAttrs ((buildServices "service" cfg.services)
++ (buildServices "slices" cfg.slices) ++ (buildServices "slices" cfg.slices)

View file

@ -19,6 +19,8 @@ let
writableDefaults = filterAttrs (domain: attrs: attrs != { }) nonNullDefaults; writableDefaults = filterAttrs (domain: attrs: attrs != { }) nonNullDefaults;
activationCmds = mapAttrsToList toActivationCmd writableDefaults; activationCmds = mapAttrsToList toActivationCmd writableDefaults;
in { in {
meta.maintainers = [ maintainers.midchildan ];
imports = [ ./fonts.nix ./keybindings.nix ./linkapps.nix ./search.nix ]; imports = [ ./fonts.nix ./keybindings.nix ./linkapps.nix ./search.nix ];
options.targets.darwin.defaults = mkOption { options.targets.darwin.defaults = mkOption {
@ -48,6 +50,24 @@ in {
platforms.darwin) platforms.darwin)
]; ];
warnings = let
batteryPercentage =
attrByPath [ "com.apple.menuextra.battery" "ShowPercent" ] null
cfg.defaults;
webkitDevExtras = attrByPath [
"com.apple.Safari"
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled"
] null cfg.defaults;
in optional (batteryPercentage != null) ''
The option 'com.apple.menuextra.battery.ShowPercent' no longer works on
macOS 11 and later. Instead, open System Preferences, go to "Dock &amp;
Menu Bar", select "Battery", and toggle the checkbox labeled "Show
Percentage."
'' ++ optional (webkitDevExtras != null) ''
The option 'com.apple.Safari.com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled'
is no longer present in recent versions of Safari.
'';
home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] ''
$VERBOSE_ECHO "Configuring macOS user defaults" $VERBOSE_ECHO "Configuring macOS user defaults"
${concatStringsSep "\n" activationCmds} ${concatStringsSep "\n" activationCmds}

View file

@ -12,7 +12,7 @@ let
fonts = "${fontsEnv}/share/fonts"; fonts = "${fontsEnv}/share/fonts";
in { in {
# macOS won't recognize symlinked fonts # macOS won't recognize symlinked fonts
config = mkIf pkgs.hostPlatform.isDarwin { config = mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] ''
copyFonts() { copyFonts() {
rm -rf ${homeDir}/Library/Fonts/HomeManager || : rm -rf ${homeDir}/Library/Fonts/HomeManager || :

View file

@ -98,7 +98,13 @@ in {
"com.apple.menuextra.battery".ShowPercent = mkNullableOption { "com.apple.menuextra.battery".ShowPercent = mkNullableOption {
type = types.enum [ "YES" "NO" ]; type = types.enum [ "YES" "NO" ];
example = "NO"; example = "NO";
description = "Whether to show battery percentage in the menu bar."; description = ''
This option no longer works on macOS 11 and later. Instead, open System
Preferences, go to "Dock &amp; Menu Bar", select "Battery", and toggle
the checkbox labeled "Show Percentage."
Whether to show battery percentage in the menu bar.
'';
}; };
"com.apple.Safari" = { "com.apple.Safari" = {
@ -125,20 +131,35 @@ in {
</warning> </warning>
''; '';
}; };
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = "WebKitPreferences.developerExtrasEnabled" = mkNullableOption {
mkNullableOption { type = types.bool;
type = types.bool; description = ''
description = '' Configures the web inspector.
Configures the web inspector.
<warning> <warning>
<para> <para>
Instead of setting this option directly, set Instead of setting this option directly, set
<option>IncludeDevelopMenu</option> instead. <option>IncludeDevelopMenu</option> instead.
</para> </para>
</warning> </warning>
''; '';
}; };
};
"com.apple.Safari.SandboxBroker" = {
ShowDevelopMenu = mkNullableOption {
type = types.bool;
description = ''
Show the "Develop" menu in Safari's menubar.
<warning>
<para>
Instead of setting this option directly, set
<option>"com.apple.Safari".IncludeDevelopMenu</option> instead.
</para>
</warning>
'';
};
}; };
"com.googlecode.iterm2" = { "com.googlecode.iterm2" = {
@ -182,8 +203,11 @@ in {
config = { config = {
"com.apple.Safari" = mkIf (safari.IncludeDevelopMenu != null) { "com.apple.Safari" = mkIf (safari.IncludeDevelopMenu != null) {
WebKitDeveloperExtrasEnabledPreferenceKey = safari.IncludeDevelopMenu; WebKitDeveloperExtrasEnabledPreferenceKey = safari.IncludeDevelopMenu;
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = "WebKitPreferences.developerExtrasEnabled" = safari.IncludeDevelopMenu;
safari.IncludeDevelopMenu;
}; };
"com.apple.Safari.SandboxBroker" =
mkIf (safari.IncludeDevelopMenu != null) {
ShowDevelopMenu = safari.IncludeDevelopMenu;
};
}; };
} }

View file

@ -63,8 +63,10 @@ in
extraSpecialArgs = mkOption { extraSpecialArgs = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = { };
example = literalExpression "{ inherit emacs-overlay; }";
description = '' description = ''
Extra <literal>specialArgs</literal> passed to Home Manager. Extra <literal>specialArgs</literal> passed to Home Manager. This
option can be used to pass additional arguments to all modules.
''; '';
}; };

View file

@ -74,8 +74,10 @@ in {
extraSpecialArgs = mkOption { extraSpecialArgs = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = { };
example = literalExpression "{ inherit emacs-overlay; }";
description = '' description = ''
Extra <literal>specialArgs</literal> passed to Home Manager. Extra <literal>specialArgs</literal> passed to Home Manager. This
option can be used to pass additional arguments to all modules.
''; '';
}; };

View file

@ -66,6 +66,7 @@ import nmt {
./modules/programs/irssi ./modules/programs/irssi
./modules/programs/kakoune ./modules/programs/kakoune
./modules/programs/kitty ./modules/programs/kitty
./modules/programs/less
./modules/programs/lf ./modules/programs/lf
./modules/programs/lieer ./modules/programs/lieer
./modules/programs/man ./modules/programs/man
@ -87,6 +88,7 @@ import nmt {
./modules/programs/sm64ex ./modules/programs/sm64ex
./modules/programs/ssh ./modules/programs/ssh
./modules/programs/starship ./modules/programs/starship
./modules/programs/taskwarrior
./modules/programs/texlive ./modules/programs/texlive
./modules/programs/tmux ./modules/programs/tmux
./modules/programs/topgrade ./modules/programs/topgrade

View file

@ -0,0 +1,35 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
# Test fallback behavior for stateVersion >= 20.09, which is pure.
xdg.enable = lib.mkForce false;
home.stateVersion = "20.09";
xdg.configFile.test.text = "config";
xdg.dataFile.test.text = "data";
home.file."${config.xdg.cacheHome}/test".text = "cache";
home.file."${config.xdg.stateHome}/test".text = "state";
nmt.script = ''
assertFileExists home-files/.config/test
assertFileExists home-files/.local/share/test
assertFileExists home-files/.cache/test
assertFileExists home-files/.local/state/test
assertFileContent \
home-files/.config/test \
${builtins.toFile "test" "config"}
assertFileContent \
home-files/.local/share/test \
${builtins.toFile "test" "data"}
assertFileContent \
home-files/.cache/test \
${builtins.toFile "test" "cache"}
assertFileContent \
home-files/.local/state/test \
${builtins.toFile "test" "state"}
'';
};
}

View file

@ -3,4 +3,5 @@
xdg-system-dirs = ./system-dirs.nix; xdg-system-dirs = ./system-dirs.nix;
xdg-desktop-entries = ./desktop-entries.nix; xdg-desktop-entries = ./desktop-entries.nix;
xdg-file-gen = ./file-gen.nix; xdg-file-gen = ./file-gen.nix;
xdg-default-locations = ./default-locations.nix;
} }

View file

@ -15,7 +15,7 @@ with lib;
meta.description = "I pretend to be Firefox"; meta.description = "I pretend to be Firefox";
passthru.gtk3 = null; passthru.gtk3 = null;
} '' } ''
mkdir -p "$out/bin" mkdir -p "$out"/{bin,lib}
touch "$out/bin/firefox" touch "$out/bin/firefox"
chmod 755 "$out/bin/firefox" chmod 755 "$out/bin/firefox"
''; '';

View file

@ -32,10 +32,9 @@ with lib;
firefox-unwrapped = pkgs.runCommand "firefox-0" { firefox-unwrapped = pkgs.runCommand "firefox-0" {
meta.description = "I pretend to be Firefox"; meta.description = "I pretend to be Firefox";
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
passthru.gtk3 = null; passthru.gtk3 = null;
} '' } ''
mkdir -p "$out/bin" mkdir -p "$out"/{bin,lib}
touch "$out/bin/firefox" touch "$out/bin/firefox"
chmod 755 "$out/bin/firefox" chmod 755 "$out/bin/firefox"
''; '';

View file

@ -13,10 +13,9 @@ with lib;
firefox-unwrapped = pkgs.runCommand "firefox-0" { firefox-unwrapped = pkgs.runCommand "firefox-0" {
meta.description = "I pretend to be Firefox"; meta.description = "I pretend to be Firefox";
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false;
passthru.gtk3 = null; passthru.gtk3 = null;
} '' } ''
mkdir -p "$out/bin" mkdir -p "$out"/{bin,lib}
touch "$out/bin/firefox" touch "$out/bin/firefox"
chmod 755 "$out/bin/firefox" chmod 755 "$out/bin/firefox"
''; '';

View file

@ -1 +1,5 @@
{ gpg-override-defaults = ./override-defaults.nix; } {
gpg-immutable-keyfiles = ./immutable-keyfiles.nix;
gpg-mutable-keyfiles = ./mutable-keyfiles.nix;
gpg-override-defaults = ./override-defaults.nix;
}

View file

@ -0,0 +1,52 @@
{ config, lib, pkgs, ... }:
{
programs.gpg = {
enable = true;
mutableKeys = false;
mutableTrust = false;
publicKeys = [
{
source = pkgs.fetchurl {
url =
"https://keybase.io/rycee/pgp_keys.asc?fingerprint=36cacf52d098cc0e78fb0cb13573356c25c424d4";
sha256 = "082mjy6llvrdry6i9r5gx97nw9d89blnam7bghza4ynsjk1mmx6c";
};
trust = 1;
}
{
source = pkgs.fetchurl {
url = "https://www.rsync.net/resources/pubkey.txt";
sha256 = "16nzqfb1kvsxjkq919hxsawx6ydvip3md3qyhdmw54qx6drnxckl";
};
trust = 2;
}
];
};
nmt.script = ''
assertFileNotRegex activate "^export GNUPGHOME='/home/hm-user/.gnupg'$"
assertFileRegex activate \
'^install -m 0700 /nix/store/[0-9a-z]*-gpg-pubring/trustdb.gpg "/home/hm-user/.gnupg/trustdb.gpg"$'
# Setup GPGHOME
export GNUPGHOME=$(mktemp -d)
cp -r $TESTED/home-files/.gnupg/* $GNUPGHOME
TRUSTDB=$(grep -o '/nix/store/[0-9a-z]*-gpg-pubring/trustdb.gpg' $TESTED/activate)
install -m 0700 $TRUSTDB $GNUPGHOME/trustdb.gpg
# Export Trust
export WORKDIR=$(mktemp -d)
${pkgs.gnupg}/bin/gpg -q --export-ownertrust > $WORKDIR/gpgtrust.txt
# Check Trust
assertFileRegex $WORKDIR/gpgtrust.txt \
'^36CACF52D098CC0E78FB0CB13573356C25C424D4:2:$'
assertFileRegex $WORKDIR/gpgtrust.txt \
'^BB847B5A69EF343CEF511B29073C282D7D6F806C:3:$'
'';
}

View file

@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
{
programs.gpg = {
enable = true;
publicKeys = [
{
source = builtins.toFile "key1" "key1";
trust = 1;
}
{ source = builtins.toFile "key2" "key2"; }
];
};
test.stubs.gnupg = { };
nmt.script = ''
assertFileContains activate "export GNUPGHOME='/home/hm-user/.gnupg'"
assertFileContains activate "unset GNUPGHOME QUIET_ARG keyId importTrust"
assertFileRegex activate \
'^\$DRY_RUN_CMD @gnupg@/bin/gpg \$QUIET_ARG --import /nix/store/[0-9a-z]*-key1$'
assertFileRegex activate \
'^\$DRY_RUN_CMD importTrust "/nix/store/[0-9a-z]*-key1" 1$'
assertFileRegex activate \
'^\$DRY_RUN_CMD @gnupg@/bin/gpg \$QUIET_ARG --import /nix/store/[0-9a-z]*-key2$'
'';
}

View file

@ -23,6 +23,8 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileExists home-files/bar/foopg/gpg.conf assertFileExists home-files/bar/foopg/gpg.conf
assertFileContent home-files/bar/foopg/gpg.conf ${./override-defaults-expected.conf} assertFileContent home-files/bar/foopg/gpg.conf ${./override-defaults-expected.conf}
assertFileNotRegex activate "^unset GNUPGHOME keyId importTrust$"
''; '';
}; };
} }

View file

@ -1,8 +1,6 @@
{ {
kakoune-no-plugins = ./no-plugins.nix; kakoune-no-plugins = ./no-plugins.nix;
# Temporarily disabled until https://github.com/NixOS/nixpkgs/pull/110196 kakoune-use-plugins = ./use-plugins.nix;
# reaches the unstable channel.
# kakoune-use-plugins = ./use-plugins.nix;
kakoune-whitespace-highlighter = ./whitespace-highlighter.nix; kakoune-whitespace-highlighter = ./whitespace-highlighter.nix;
kakoune-whitespace-highlighter-corner-cases = kakoune-whitespace-highlighter-corner-cases =
./whitespace-highlighter-corner-cases.nix; ./whitespace-highlighter-corner-cases.nix;

View file

@ -3,11 +3,11 @@
with lib; with lib;
{ {
config = { imports = [ ./stubs.nix ];
programs.kakoune = { enable = true; };
nmt.script = '' programs.kakoune = { enable = true; };
assertPathNotExists home-path/share/kak/autoload/plugins
''; nmt.script = ''
}; assertPathNotExists home-path/share/kak/autoload/plugins
'';
} }

View file

@ -0,0 +1,12 @@
{
test.stubs.kakoune-unwrapped = {
name = "dummy-kakoune";
version = "1";
outPath = null;
buildScript = ''
mkdir -p $out/bin $out/share/kak/doc
touch $out/bin/kak
chmod +x $out/bin/kak
'';
};
}

View file

@ -3,14 +3,14 @@
with lib; with lib;
{ {
config = { imports = [ ./stubs.nix ];
programs.kakoune = {
enable = true;
plugins = [ pkgs.kakounePlugins.kak-prelude ];
};
nmt.script = '' programs.kakoune = {
assertDirectoryNotEmpty home-path/share/kak/autoload/plugins enable = true;
''; plugins = [ pkgs.kakounePlugins.prelude-kak ];
}; };
nmt.script = ''
assertDirectoryNotEmpty home-path/share/kak/autoload/plugins
'';
} }

View file

@ -3,23 +3,23 @@
with lib; with lib;
{ {
config = { imports = [ ./stubs.nix ];
programs.kakoune = {
enable = true;
config.showWhitespace = {
enable = true;
lineFeed = ''"'';
space = " ";
nonBreakingSpace = "' '"; # backwards compat
tab = "'";
# tabStop = <default>
};
};
nmt.script = '' programs.kakoune = {
assertFileExists home-files/.config/kak/kakrc enable = true;
assertFileContains home-files/.config/kak/kakrc \ config.showWhitespace = {
"add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'" enable = true;
''; lineFeed = ''"'';
space = " ";
nonBreakingSpace = "' '"; # backwards compat
tab = "'";
# tabStop = <default>
};
}; };
nmt.script = ''
assertFileExists home-files/.config/kak/kakrc
assertFileContains home-files/.config/kak/kakrc \
"add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'"
'';
} }

View file

@ -3,23 +3,23 @@
with lib; with lib;
{ {
config = { imports = [ ./stubs.nix ];
programs.kakoune = {
enable = true;
config.showWhitespace = {
enable = true;
lineFeed = "1";
space = "2";
nonBreakingSpace = "3";
tab = "4";
tabStop = "5";
};
};
nmt.script = '' programs.kakoune = {
assertFileExists home-files/.config/kak/kakrc enable = true;
assertFileContains home-files/.config/kak/kakrc \ config.showWhitespace = {
"add-highlighter global/ show-whitespaces -tab '4' -tabpad '5' -spc '2' -nbsp '3' -lf '1'" enable = true;
''; lineFeed = "1";
space = "2";
nonBreakingSpace = "3";
tab = "4";
tabStop = "5";
};
}; };
nmt.script = ''
assertFileExists home-files/.config/kak/kakrc
assertFileContains home-files/.config/kak/kakrc \
"add-highlighter global/ show-whitespaces -tab '4' -tabpad '5' -spc '2' -nbsp '3' -lf '1'"
'';
} }

View file

@ -0,0 +1 @@
{ less-with-custom-keys = ./less-with-custom-keys.nix; }

View file

@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
with lib;
{
programs.less = {
enable = true;
keys = ''
s back-line
t forw-line
'';
};
test.stubs.less = { };
nmt.script = ''
assertFileExists home-files/.lesskey
assertFileContent home-files/.lesskey ${
builtins.toFile "less.expected" ''
s back-line
t forw-line
''
}
'';
}

View file

@ -1,4 +1,5 @@
{ {
mpv-example-settings = ./mpv-example-settings.nix; # Temporarily commented until fixed for recent changes in Nixpkgs.
mpv-invalid-settings = ./mpv-invalid-settings.nix; # mpv-example-settings = ./mpv-example-settings.nix;
# mpv-invalid-settings = ./mpv-invalid-settings.nix;
} }

View file

@ -1 +1,5 @@
{ pet-snippets = ./snippets.nix; } {
pet-snippets = ./snippets.nix;
pet-settings_21_05 = ./settings_21_05.nix;
pet-settings_21_11 = ./settings_21_11.nix;
}

View file

@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
with lib;
{
home.stateVersion = "21.05";
programs.pet = {
enable = true;
selectcmdPackage = config.lib.test.mkStubPackage { };
settings.editor = "nvim";
};
test.stubs.pet = { };
nmt.script = ''
assertFileContent home-files/.config/pet/config.toml \
${
builtins.toFile "pet-settings.toml" ''
[General]
editor = "nvim"
selectcmd = "fzf"
snippetfile = "/home/hm-user/.config/pet/snippet.toml"
''
}
'';
}

View file

@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:
with lib;
{
home.stateVersion = "21.11";
programs.pet = {
enable = true;
selectcmdPackage = config.lib.test.mkStubPackage { };
settings = {
General = {
backend = "Gitlab";
editor = "nvim";
};
Gitlab = {
access_token = "1234";
file_name = "pet-snippets.toml";
visibility = "public";
};
};
};
test.stubs.pet = { };
nmt.script = ''
assertFileContent home-files/.config/pet/config.toml \
${
builtins.toFile "pet-settings.toml" ''
[General]
backend = "Gitlab"
editor = "nvim"
selectcmd = "fzf"
snippetfile = "/home/hm-user/.config/pet/snippet.toml"
[Gitlab]
access_token = "1234"
file_name = "pet-snippets.toml"
visibility = "public"
''
}
'';
}

View file

@ -24,7 +24,10 @@ with lib;
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileContains \ assertFileContains \
home-files/.bashrc \ home-files/.bashrc \
'/bin/powerline-go -error $old_exit_status -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' 'PS1='
assertFileContains \
home-files/.bashrc \
'/bin/powerline-go -error $old_exit_status -shell bash -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2'
''; '';
}; };
} }

View file

@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs = {
bash.enable = true;
powerline-go = {
enable = true;
newline = true;
modules = [ "nix-shell" ];
modulesRight = [ "git" ];
pathAliases = { "\\~/project/foo" = "prj-foo"; };
settings = {
ignore-repos = [ "/home/me/project1" "/home/me/project2" ];
};
};
};
test.stubs.powerline-go = { };
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileContains \
home-files/.bashrc \
'eval'
assertFileContains \
home-files/.bashrc \
'/bin/powerline-go -error $old_exit_status -shell bash -eval -modules nix-shell -modules-right git -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2'
'';
};
}

View file

@ -2,4 +2,6 @@
powerline-go-bash = ./bash.nix; powerline-go-bash = ./bash.nix;
powerline-go-zsh = ./zsh.nix; powerline-go-zsh = ./zsh.nix;
powerline-go-fish = ./fish.nix; powerline-go-fish = ./fish.nix;
powerline-go-bashmodulesright = ./bashmodulesright.nix;
powerline-go-zshmodulesright = ./zshmodulesright.nix;
} }

View file

@ -25,6 +25,9 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'PS1='
assertFileContains \ assertFileContains \
home-files/.zshrc \ home-files/.zshrc \
'/bin/powerline-go -error $? -shell zsh -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' '/bin/powerline-go -error $? -shell zsh -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2'

View file

@ -0,0 +1,37 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs = {
zsh.enable = true;
powerline-go = {
enable = true;
newline = true;
modules = [ "nix-shell" ];
modulesRight = [ "git" ];
pathAliases = { "\\~/project/foo" = "prj-foo"; };
settings = {
ignore-repos = [ "/home/me/project1" "/home/me/project2" ];
};
};
};
test.stubs = {
powerline-go = { };
zsh = { };
};
nmt.script = ''
assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'eval'
assertFileContains \
home-files/.zshrc \
'/bin/powerline-go -error $? -shell zsh -eval -modules nix-shell -modules-right git -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2'
'';
};
}

View file

@ -1,6 +1,6 @@
configuration { configuration {
location: 0; location: 0;
theme: "custom";
xoffset: 0; xoffset: 0;
yoffset: 0; yoffset: 0;
} }
@theme "custom"

View file

@ -16,4 +16,4 @@ foreground-color: rgba ( 250, 251, 252, 100 % );
width: 512; width: 512;
} }
@import "~/.cache/wal/colors-rofi-dark" @import "~/.cache/wal/colors-rofi-dark"

View file

@ -1,7 +1,5 @@
Host * Host *
ForwardAgent no ForwardAgent no
Compression no Compression no

View file

@ -1,5 +1,6 @@
{ {
ssh-defaults = ./default-config.nix; ssh-defaults = ./default-config.nix;
ssh-includes = ./includes.nix;
ssh-match-blocks = ./match-blocks-attrs.nix; ssh-match-blocks = ./match-blocks-attrs.nix;
ssh-forwards-dynamic-valid-bind-no-asserts = ssh-forwards-dynamic-valid-bind-no-asserts =

View file

@ -1,8 +1,5 @@
Host dynamicBindAddressWithPort Host dynamicBindAddressWithPort
DynamicForward [127.0.0.1]:3000 DynamicForward [127.0.0.1]:3000
Host dynamicBindPathNoPort Host dynamicBindPathNoPort
DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
config = {
programs.ssh = {
enable = true;
includes = [ "config.d/*" "other/dir" ];
};
nmt.script = ''
assertFileExists home-files/.ssh/config
assertFileContains home-files/.ssh/config "Include config.d/* other/dir"
'';
};
}

View file

@ -1,13 +1,9 @@
Host * !github.com Host * !github.com
Port 516 Port 516
IdentityFile file1 IdentityFile file1
IdentityFile file2 IdentityFile file2
Host abc Host abc
ProxyJump jump-host ProxyJump jump-host
Host xyz Host xyz
ServerAliveInterval 60 ServerAliveInterval 60
ServerAliveCountMax 10 ServerAliveCountMax 10
@ -16,7 +12,6 @@ Host xyz
RemoteForward [localhost]:8081 [10.0.0.2]:80 RemoteForward [localhost]:8081 [10.0.0.2]:80
RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent
DynamicForward [localhost]:2839 DynamicForward [localhost]:2839
Host ordered Host ordered
Port 1 Port 1

View file

@ -0,0 +1 @@
{ taskwarrior = ./taskwarrior.nix; }

View file

@ -0,0 +1,40 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.taskwarrior = {
enable = true;
colorTheme = "dark-violets-256";
dataLocation = "/some/data/location";
config = {
urgency.user.tag.next.coefficient = 42.42;
urgency.blocked.coefficient = -42;
};
extraConfig = ''
include /my/stuff
urgency.user.tag.test.coefficient=-42.42
'';
};
test.stubs.taskwarrior = { };
nmt.script = ''
assertFileExists home-files/.config/task/taskrc
assertFileContent home-files/.config/task/taskrc ${
pkgs.writeText "taskwarrior.expected" ''
data.location=/some/data/location
include dark-violets-256.theme
urgency.blocked.coefficient=-42
urgency.user.tag.next.coefficient=42.420000
include /my/stuff
urgency.user.tag.test.coefficient=-42.42
''
}
'';
};
}

View file

@ -3,5 +3,5 @@
./systemd-with-graphical-session-target.nix; ./systemd-with-graphical-session-target.nix;
waybar-styling = ./styling.nix; waybar-styling = ./styling.nix;
waybar-settings-complex = ./settings-complex.nix; waybar-settings-complex = ./settings-complex.nix;
waybar-warnings = ./warnings-tests.nix; waybar-deprecated-modules-option = ./deprecated-modules-option.nix;
} }

View file

@ -0,0 +1,43 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.stateVersion = "22.05";
programs.waybar = {
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true;
settings = [{
modules-center = [ "test" ];
modules = { "test" = { }; };
}];
};
test.asserts.assertions.expected = [''
The `programs.waybar.settings.[].modules` option has been removed.
It is now possible to declare modules in the configuration without nesting them under the `modules` option.
''];
nmt.script = ''
assertPathNotExists home-files/.config/waybar/style.css
assertFileContent \
home-files/.config/waybar/config \
${
builtins.toFile "waybar-deprecated-modules-option.json" ''
[
{
"modules-center": [
"test"
],
"modules-left": [],
"modules-right": [],
"test": {}
}
]
''
}
'';
};
}

View file

@ -4,6 +4,8 @@ with lib;
{ {
config = { config = {
home.stateVersion = "21.11";
programs.waybar = { programs.waybar = {
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;

View file

@ -4,6 +4,8 @@ with lib;
{ {
config = { config = {
home.stateVersion = "21.11";
programs.waybar = { programs.waybar = {
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;

View file

@ -4,6 +4,8 @@ with lib;
{ {
config = { config = {
home.stateVersion = "21.11";
programs.waybar = { programs.waybar = {
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;

View file

@ -1,62 +0,0 @@
{ config, pkgs, lib, ... }:
with lib;
{
config = {
programs.waybar = {
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true;
settings = [{
modules-left = [ "custom/my-module" ];
modules-center =
[ "this_module_is_not_a_valid_default_module_nor_custom_module" ];
modules-right = [
"battery#bat1" # CSS identifier is allowed
"custom/this_custom_module_doesn't_have_a_definition_in_modules"
];
modules = {
"custom/this_module_is_not_referenced" = { };
"battery#bat1" = { };
"custom/my-module" = { };
};
}];
};
test.asserts.warnings.expected = [
"The module 'this_module_is_not_a_valid_default_module_nor_custom_module' defined in 'programs.waybar.settings.[].modules-center' is neither a default module or a custom module declared in 'programs.waybar.settings.[].modules'"
"The module 'custom/this_custom_module_doesn't_have_a_definition_in_modules' defined in 'programs.waybar.settings.[].modules-right' is neither a default module or a custom module declared in 'programs.waybar.settings.[].modules'"
"The module 'custom/this_module_is_not_referenced' defined in 'programs.waybar.settings.[].modules' is not referenced in either `modules-left`, `modules-center` or `modules-right` of Waybar's options"
];
nmt.script = ''
assertPathNotExists home-files/.config/waybar/style.css
assertFileContent \
home-files/.config/waybar/config \
${
pkgs.writeText "expected-json" ''
[
{
"battery#bat1": {},
"custom/my-module": {},
"custom/this_module_is_not_referenced": {},
"modules-center": [
"this_module_is_not_a_valid_default_module_nor_custom_module"
],
"modules-left": [
"custom/my-module"
],
"modules-right": [
"battery#bat1",
"custom/this_custom_module_doesn't_have_a_definition_in_modules"
]
}
]
''
}
'';
};
}

View file

@ -10,4 +10,6 @@
sway-post-2003 = ./sway-post-2003.nix; sway-post-2003 = ./sway-post-2003.nix;
sway-workspace-default = ./sway-workspace-default.nix; sway-workspace-default = ./sway-workspace-default.nix;
sway-workspace-output = ./sway-workspace-output.nix; sway-workspace-output = ./sway-workspace-output.nix;
swaynag-example-settings = ./swaynag-example-settings.nix;
swaynag-empty-settings = ./swaynag-empty-settings.nix;
} }

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
config = {
wayland.windowManager.sway.swaynag = {
enable = true;
settings = { };
};
nmt.script = ''
assertPathNotExists home-files/.config/swaynag
'';
};
}

View file

@ -0,0 +1,10 @@
[<config>]
edge=bottom
font=Dina 12
[green]
background=00AA00
button-background=00CC00
edge=top
message-padding=10
text=FFFFFF

View file

@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
{
config = {
wayland.windowManager.sway.swaynag = {
enable = true;
settings = {
"<config>" = {
edge = "bottom";
font = "Dina 12";
};
green = {
edge = "top";
background = "00AA00";
text = "FFFFFF";
button-background = "00CC00";
message-padding = 10;
};
};
};
nmt.script = ''
assertFileContent \
home-files/.config/swaynag/config \
${./swaynag-example-settings-expected.conf}
'';
};
}

View file

@ -1,5 +1,6 @@
{ {
systemd-services = ./services.nix; systemd-services = ./services.nix;
systemd-services-disabled-for-root = ./services-disabled-for-root.nix;
systemd-session-variables = ./session-variables.nix; systemd-session-variables = ./session-variables.nix;
systemd-timers = ./timers.nix; systemd-timers = ./timers.nix;
} }

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.username = mkForce "root";
systemd.user.services."test-service@" = {
Unit = { Description = "A basic test service"; };
Service = {
Environment = [ "VAR1=1" "VAR2=2" ];
ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
};
};
nmt.script = ''
serviceFile=home-files/.config/systemd/user/test-service@.service
assertPathNotExists $serviceFile
'';
};
}