Project import generated by Copybara.

GitOrigin-RevId: 70c5b268e10025c70823767f4fb49e240b40151d
This commit is contained in:
Default email 2021-11-05 00:42:44 +08:00
parent 9c8f3824a8
commit cfcd52ff70
513 changed files with 7280 additions and 3929 deletions

View file

@ -19,6 +19,8 @@
/modules/misc/news.nix @rycee
/modules/misc/nixpkgs-disabled.nix @thiagokokada
/modules/misc/numlock.nix @evanjs
/tests/modules/misc/numlock @evanjs
@ -50,6 +52,9 @@
/modules/programs/autojump.nix @evanjs
/tests/modules/programs/autojump @evanjs
/modules/programs/atuin.nix @hawkw
/tests/modules/programs/atuin @hawkw
/modules/programs/autorandr.nix @uvNikita
/modules/programs/bash.nix @rycee
@ -58,6 +63,9 @@
/modules/programs/beets.nix @rycee
/modules/programs/bottom.nix @polykernel
/tests/modules/programs/bottom @polykernel
/modules/programs/broot.nix @aheaume
/modules/programs/dircolors.nix @JustinLovinger
@ -75,8 +83,8 @@
/modules/programs/foot.nix @plabadens
/tests/modules/programs/foot @plabadens
/modules/programs/gh.nix @Gerschtli
/tests/modules/programs/gh @Gerschtli
/modules/programs/gh.nix @Gerschtli @berbiche
/tests/modules/programs/gh @Gerschtli @berbiche
/modules/programs/git.nix @rycee
@ -84,17 +92,23 @@
/modules/programs/go.nix @rvolosatovs
/modules/programs/hexchat.nix @superherointj @thiagokokada
/tests/modules/programs/hexchat @thiagokokada
/modules/programs/himalaya.nix @ambroisie
/tests/modules/programs/himalaya @ambroisie
/modules/programs/home-manager.nix @rycee
/modules/programs/htop.nix @bjpbakker
/tests/modules/htop @bjpbakker
/modules/programs/i3status.nix @JustinLovinger
/modules/programs/i3status-rust.nix @workflow
/modules/programs/java.nix @ShamrockLee
/modules/programs/keychain.nix @marsam
/modules/programs/lazygit.nix @kalhauge
@ -138,6 +152,9 @@
/modules/programs/nix-index.nix @ambroisie
/tests/modules/programs/nix-index @ambroisie
/modules/programs/nnn.nix @thiagokokada
/tests/modules/programs/nnn @thiagokokada
/modules/programs/noti.nix @marsam
/modules/programs/nushell.nix @Philipp-M
@ -180,6 +197,9 @@
/modules/programs/senpai.nix @malte-v
/modules/programs/sm64ex.nix @ivarwithoutbones
/tests/modules/programs/sm64ex @ivarwithoutbones
/modules/programs/ssh.nix @rycee
/modules/programs/starship.nix @marsam
@ -208,17 +228,24 @@
/modules/services/barrier.nix @Kritnich
/tests/modules/services/barrier @Kritnich
/modules/services/betterlockscreen.nix @SebTM
/modules/services/caffeine.nix @uvNikita
/modules/services/cbatticon.nix @pmiddend
/modules/services/clipmenu.nix @DamienCassou
/modules/services/devilspie2.nix @dawidsowa
/tests/modules/services/devilspie2 @dawidsowa
/modules/services/dropbox.nix @eyJhb
/tests/modules/services/dropbox @eyJhb
/modules/services/dunst.nix @rycee
/modules/services/easyeffects.nix @fufexan
/modules/services/emacs.nix @tadfisher
/modules/services/etesync-dav.nix @Valodim
@ -227,6 +254,11 @@
/modules/services/fluidsynth.nix @Valodim
/modules/services/fnott.nix @polykernel
/tests/modules/services/fnott @polykernel
/modules/services/git-sync.nix @IvanMalison
/modules/services/gnome-keyring.nix @rycee
/modules/services/gpg-agent.nix @rycee
@ -260,6 +292,8 @@
/modules/services/network-manager-applet.nix @rycee
/modules/services/notify-osd.nix @imalison
/modules/services/pantalaimon.nix @jojosch
/tests/modules/services/pantalaimon @jojosch
@ -288,6 +322,9 @@
/modules/services/redshift-gammastep @rycee @petabyteboy @thiagokokada
/tests/modules/redshift-gammastep @thiagokokada
/modules/services/screen-locker.nix @jrobsonchase
/tests/modules/services/screen-locker @jrobsonchase
/modules/services/status-notifier-watcher.nix @pltanton
/modules/services/syncthing.nix @rycee
@ -298,6 +335,9 @@
/modules/services/taskwarrior-sync.nix @minijackson @pacien
/modules/services/trayer.nix @AndreasMager
/tests/modules/services/trayer @AndreasMager
/modules/services/udiskie.nix @rycee
/modules/services/unison.nix @pacien
@ -333,3 +373,7 @@
/modules/xresources.nix @rycee
/modules/xsession.nix @rycee
/modules/services/volnoti.nix @IvanMalison
Makefile @thiagokokada

View file

@ -1,31 +0,0 @@
<!--
Don't forget to check if there already exists a relevant issue before
creating a new one.
-->
### Issue description
<!--
Please describe the issue. For support and help please use the IRC
channel #home-manager at irc.oftc.net or Matrix room
https://matrix.to/#/#hm:rycee.net instead.
-->
### Meta
#### Maintainer CC
<!--
Please @ people who are in the `meta.maintainers` list of the
offending module. If in doubt, check `git blame` for whoever last
touched something.
-->
#### Technical details
<!--
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the
result.
-->

View file

@ -0,0 +1,15 @@
---
name: Feature request
about: Ask for a new feature to be added (module, program, etc.)
title: ''
labels: feature request
assignees: rycee, berbiche, sumnerevans
---
<!--
Note: Please search to see if the feature has already been requested
-->
### Description

View file

@ -0,0 +1,46 @@
name: Bug Report
description: File a bug/issue
title: 'bug: '
labels: [bug, triage]
# We cannot use nix-community/home-manager
# See https://github.com/dear-github/dear-github/issues/170
assignees: [rycee, berbiche, sumnerevans]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: |
Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Issue description
description: |
Please describe the issue.
For support and help please use the IRC channel #home-manager at irc.oftc.net or
Matrix room <https://matrix.to/#/#hm:rycee.net> instead.
validations:
required: false
- type: textarea
attributes:
label: Maintainer CC
description: |
Please @ people who are in the `meta.maintainers` list of the offending module.
If in doubt, check `git blame` for whoever last touched something.
validations:
required: false
- type: textarea
id: system
attributes:
label: System information
description: |
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
render: markdown
validations:
required: true

View file

@ -15,7 +15,7 @@ pull-request.
Also make sure to read the guidelines found at
https://github.com/nix-community/home-manager/blob/master/doc/contributing.adoc#sec-guidelines
https://github.com/nix-community/home-manager/blob/master/docs/contributing.adoc#sec-guidelines
-->
@ -35,7 +35,7 @@ Also make sure to read the guidelines found at
{long description}
```
See [CONTRIBUTING](https://github.com/nix-community/home-manager/blob/master/doc/contributing.adoc#sec-commit-style) for more information and [recent commit messages](https://github.com/nix-community/home-manager/commits/master) for examples.
See [CONTRIBUTING](https://github.com/nix-community/home-manager/blob/master/docs/contributing.adoc#sec-commit-style) for more information and [recent commit messages](https://github.com/nix-community/home-manager/commits/master) for examples.
- If this PR adds a new module

View file

@ -10,7 +10,7 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "release-20.09"
target-branch: "release-21.05"
schedule:
interval: "weekly"
commit-message:

View file

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

View file

@ -6,12 +6,13 @@ on:
jobs:
tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v13
- uses: cachix/install-nix-action@v14.1
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
@ -20,4 +21,4 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: ./format -c
- run: nix-shell . -A install
- run: nix-shell --pure tests -A run.all
- run: nix-shell --arg enableBig false --pure tests -A run.all

View file

@ -1,258 +0,0 @@
[[ch-contributing]]
== Contributing
:open-issues: https://github.com/nix-community/home-manager/issues
:new-issue: https://github.com/nix-community/home-manager/issues/new
:fork-a-repo: https://help.github.com/articles/fork-a-repo/
:create-a-pull-request: https://help.github.com/articles/creating-a-pull-request/
:seven-rules: https://chris.beams.io/posts/git-commit/#seven-rules
:news-nix: https://github.com/nix-community/home-manager/blob/master/modules/misc/news.nix
:nixfmt: https://github.com/serokell/nixfmt/
:example-commit-message: https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef
Contributions to Home Manager are very welcome. To make the process as smooth as possible for both you and the Home Manager maintainers we provide some guidelines that we ask you to follow. See <<sec-contrib-getting-started>> for information on how to set up a suitable development environment and <<sec-guidelines>> for the actual guidelines.
This text is mainly directed at those who would like to make code contributions to Home Manager. If you just want to report a bug then first look among the already {open-issues}[open issues], if you find one matching yours then feel free to comment on it to add any additional information you may have. If no matching issue exists then go to the {new-issue}[new issue] page and write a description of your problem. Include as much information as you can, ideally also include relevant excerpts from your Home Manager configuration.
[[sec-contrib-getting-started]]
=== Getting started
If you have not previously forked Home Manager then you need to do that first. Have a look at GitHub's {fork-a-repo}[Fork a repo] for instructions on how to do this.
Once you have a fork of Home Manager you should create a branch starting at the most recent `master` branch. Give your branch a reasonably descriptive name. Commit your changes to this branch and when you are happy with the result and it fulfills <<sec-guidelines>> then push the branch to GitHub and {create-a-pull-request}[create a pull request].
Assuming your clone is at `$HOME/devel/home-manager` then you can make the `home-manager` command use it by either
1. overriding the default path by using the `-I` command line option:
+
[source,console]
$ home-manager -I home-manager=$HOME/devel/home-manager
+
or
2. changing the default path by ensuring your configuration includes
+
[source,nix]
----
programs.home-manager.enable = true;
programs.home-manager.path = "$HOME/devel/home-manager";
----
+
and running `home-manager switch` to activate the change. Afterwards, `home-manager build` and `home-manager switch` will use your cloned repository.
The first option is good if you only temporarily want to use your clone.
[[sec-guidelines]]
=== Guidelines
:irc-home-manager: https://webchat.oftc.net/?channels=home-manager
:valuable-options: https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md#valuable-options
:rfc-42: https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md
:assertions: https://nixos.org/manual/nixos/stable/index.html#sec-assertions
If your contribution satisfy the following rules then there is a good chance it will be merged without too much trouble. The rules are enforced by the Home Manager maintainers and to a lesser extent the Home Manager CI system.
If you are uncertain how these rules affect the change you would like to make then feel free to start a discussion in the {irc-home-manager}[#home-manager] IRC channel, ideally before you start developing.
[[sec-guidelines-back-compat]]
==== Maintain backward compatibility
Your contribution should not cause another user's existing configuration to break unless there is a very good reason and the change should be announced to the user through an {assertions}[assertion] or similar.
Remember that Home Manager is used in many different environments and you should consider how your change may effect others. For example,
- Does your change work for people that do not use NixOS? Consider other GNU/Linux distributions and macOS.
- Does your change work for people whose configuration is built on one system and deployed on another system?
[[sec-guidelines-forward-compat]]
==== Keep forward compatibility in mind
The master branch of Home Manager tracks the unstable channel of Nixpkgs, which may update package versions at any time. It is therefore important to consider how a package update may affect your code and try to reduce the risk of breakage.
The most effective way to reduce this risk is to follow the advice in <<sec-guidelines-valuable-options>>.
[[sec-guidelines-valuable-options]]
==== Add only valuable options
When creating a new module it is tempting to include every option supported by the software. This is _strongly_ discouraged. Providing many options increases maintenance burden and risk of breakage considerably. This is why only the most {valuable-options}[important software options] should be modeled explicitly. Less important options should be expressible through an `extraConfig` escape hatch.
A good rule of thumb for the first implementation of a module is to only add explicit options for those settings that absolutely must be set for the software to function correctly. It follows that a module for software that provides sensible default values for all settings would require no explicit options at all.
If the software uses a structured configuration format like a JSON, YAML, INI, TOML, or even a plain list of key/value pairs then consider using a `settings` option as described in {rfc-42}[Nix RFC 42].
[[sec-guidelines-add-tests]]
==== Add relevant tests
If at all possible, make sure to add new tests and expand existing tests so that your change will keep working in the future. See <<sec-tests>> for more information about the Home Manager test suite.
All contributed code _must_ pass the test suite.
[[sec-guidelines-module-maintainer]]
==== Add relevant documentation
:docbook: https://tdg.docbook.org/
:asciidoc: https://asciidoc.org/
:docbook-rocks: https://berbiche.github.io/docbook.rocks/
Many code changes require changing the documentation as well. Module options should be documented with DocBook. See {docbook-rocks}[DocBook rocks!] for a quick introduction and {docbook}[DocBook 5: The Definitive Guide] for in-depth information of DocBook. Home Manager is itself documented using a combination of DocBook and {asciidoc}[AsciiDoc]. All text is hosted in Home Manager's Git repository.
The HTML version of the manual containing both the module option descriptions and the documentation of Home Manager can be generated and opened by typing the following in a shell within a clone of the Home Manager Git repository:
[source,console]
$ nix-build -A docs.html
$ xdg-open ./result/share/doc/home-manager/index.html
When you have made changes to a module, it is a good idea to check that the man page version of the module options looks good:
[source,console]
$ nix-build -A docs.manPages
$ man ./result/share/man/man5/home-configuration.nix.5
==== Add yourself as a module maintainer
Every new module _must_ include a named maintainer using the `meta.maintainers` attribute. If you are a user of a module that currently lacks a maintainer then please consider adopting it.
If you are present in the NixOS maintainer list then you can use that entry. If you are not then you can add yourself to `modules/lib/maintainers.nix` in the Home Manager project.
Also add yourself to `.github/CODEOWNERS` as owner of the associated module files, including the test files. You will then be automatically added as a reviewer on any new pull request that touches your files.
Maintainers are encouraged to join the IRC channel and participate when they have opportunity.
[[sec-guidelines-code-style]]
==== Format your code
Make sure your code is formatted as described in <<sec-code-style>>. To maintain consistency throughout the project you are encouraged to browse through existing code and adopt its style also in new code.
[[sec-guidelines-commit-message-style]]
==== Format your commit messages
Similar to <<sec-guidelines-code-style>> we encourage a consistent commit message format as described in <<sec-commit-style>>.
[[sec-guidelines-news-style]]
==== Format your news entries
If your contribution includes a change that should be communicated to users of Home Manager then you can add a news entry. The entry must be formatted as described in <<sec-news>>.
When new modules are added a news entry should be included but you do not need to create this entry manually. The merging maintainer will create the entry for you. This is to reduce the risk of merge conflicts.
[[sec-guidelines-conditional-modules]]
==== Use conditional modules and news
Home Manager includes a number of modules that are only usable on some of the supported platforms. The most common example of platform specific modules are those that define systemd user services, which only works on Linux systems.
If you add a module that is platform specific then make sure to include a condition in the `loadModule` function call. This will make the module accessible only on systems where the condition evaluates to `true`.
Similarly, if you are adding a news entry then it should be shown only to users that may find it relevant, see <<sec-news>> for a description of conditional news.
[[sec-guidelines-licensing]]
==== Mind the license
The Home Manager project is covered by the MIT license and we can only accept contributions that fall under this license, or are licensed in a compatible way. When you contribute self written code and documentation it is assumed that you are doing so under the MIT license.
A potential gotcha with respect to licensing are option descriptions. Often it is convenient to copy from the upstream software documentation. When this is done it is important to verify that the license of the upstream documentation allows redistribution under the terms of the MIT license.
[[sec-commit-style]]
=== Commits
The commits in your pull request should be reasonably self-contained, that is, each commit should make sense in isolation. In particular, you will be asked to amend any commit that introduces syntax errors or similar problems even if they are fixed in a later commit.
The commit messages should follow the {seven-rules}[seven rules]. We also ask you to include the affected code component or module in the first line. That is, a commit message should follow the template
----
{component}: {description}
{long description}
----
where `{component}` refers to the code component (or module) your change affects, `{description}` is a very brief description of your change, and `{long description}` is an optional clarifying description. As a rare exception, if there is no clear component, or your change affects many components, then the `{component}` part is optional. See <<ex-commit-message>> for a commit message that fulfills these requirements.
[[ex-commit-message]]
.Compliant commit message
===============================================================================
The commit {example-commit-message}[69f8e47e9e74c8d3d060ca22e18246b7f7d988ef] contains the commit message
----
starship: allow running in Emacs if vterm is used
The vterm buffer is backed by libvterm and can handle Starship prompts
without issues.
----
which ticks all the boxes necessary to be accepted in Home Manager.
===============================================================================
Finally, when adding a new module, say `programs/foo.nix`, we use the fixed commit format `foo: add module`. You can, of course, still include a long description if you wish.
[[sec-code-style]]
=== Code Style
The code in Home Manager is formatted by the {nixfmt}[nixfmt] tool and the formatting is checked in the pull request tests. Run the `format` tool inside the project repository before submitting your pull request.
Keep lines at a reasonable width, ideally 80 characters or less. This also applies to string literals.
We prefer `lowerCamelCase` for variable and attribute names with the accepted exception of variables directly referencing packages in Nixpkgs which use a hyphenated style. For example, the Home Manager option `services.gpg-agent.enableSshSupport` references the `gpg-agent` package in Nixpkgs.
[[sec-news]]
=== News
Home Manager includes a system for presenting news to the user. When making a change you, therefore, have the option to also include an associated news entry. In general, a news entry should only be added for truly noteworthy news. For example, a bug fix or new option does generally not need a news entry.
If you do have a change worthy of a news entry then please add one in {news-nix}[`news.nix`] but you should follow some basic guidelines:
- The entry timestamp should be in ISO-8601 format having "+00:00" as time zone. For example, "2017-09-13T17:10:14+00:00". A suitable timestamp can be produced by the command
+
[source,console]
$ date --iso-8601=second --universal
- The entry condition should be as specific as possible. For example, if you are changing or deprecating a specific option then you could restrict the news to those users who actually use this option.
- Wrap the news message so that it will fit in the typical terminal, that is, at most 80 characters wide. Ideally a bit less.
- Unlike commit messages, news will be read without any connection to the Home Manager source code. It is therefore important to make the message understandable in isolation and to those who do not have knowledge of the Home Manager internals. To this end it should be written in more descriptive, prose like way.
- If you refer to an option then write its full attribute path. That is, instead of writing
+
----
The option 'foo' has been deprecated, please use 'bar' instead.
----
+
it should read
+
----
The option 'services.myservice.foo' has been deprecated, please
use 'services.myservice.bar' instead.
----
- A new module, say `foo.nix`, should always include a news entry that has a message along the lines of
+
----
A new module is available: 'services.foo'.
----
+
If the module is platform specific, e.g., a service module using systemd, then a condition like
+
[source,nix]
condition = hostPlatform.isLinux;
+
should be added. If you contribute a module then you don't need to add this entry, the merger will create an entry for you.
[[sec-tests]]
=== Tests
Home Manager includes a basic test suite and it is highly recommended to include at least one test when adding a module. Tests are typically in the form of "golden tests" where, for example, a generated configuration file is compared to a known correct file.
It is relatively easy to create tests by modeling the existing tests, found in the `tests` project directory.
The full Home Manager test suite can be run by executing
[source,console]
$ nix-shell --pure tests -A run.all
in the project root. List all test cases through
[source,console]
$ nix-shell --pure tests -A list
and run an individual test, for example `alacritty-empty-settings`, through
[source,console]
$ nix-shell --pure tests -A run.alacritty-empty-settings

View file

@ -1,173 +0,0 @@
[[ch-faq]]
== Frequently Asked Questions (FAQ)
=== Why is there a collision error when switching generation?
Home Manager currently installs packages into the user environment, precisely as if the packages were installed through `nix-env --install`. This means that you will get a collision error if your Home Manager configuration attempts to install a package that you already have installed manually, that is, packages that shows up when you run `nix-env --query`.
For example, imagine you have the `hello` package installed in your environment
[source,console]
----
$ nix-env --query
hello-2.10
----
and your Home Manager configuration contains
[source,nix]
----
home.packages = [ pkgs.hello ];
----
Then attempting to switch to this configuration will result in an error similar to
[source,console]
----
$ home-manager switch
these derivations will be built:
/nix/store/xg69wsnd1rp8xgs9qfsjal017nf0ldhm-home-manager-path.drv
[…]
Activating installPackages
replacing old home-manager-path
installing home-manager-path
building path(s) /nix/store/b5c0asjz9f06l52l9812w6k39ifr49jj-user-environment
Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79.
collision between /nix/store/fmwa4axzghz11cnln5absh31nbhs9lq1-home-manager-path/bin/hello and /nix/store/c2wyl8b9p4afivpcz8jplc9kis8rj36d-hello-2.10/bin/hello; use nix-env --set-flag priority NUMBER PKGNAME to change the priority of one of the conflicting packages
builder for /nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv failed with exit code 2
error: build of /nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv failed
----
The solution is typically to uninstall the package from the environment using `nix-env --uninstall` and reattempt the Home Manager generation switch.
You could also opt to unistall _all_ of the packages from your profile with `nix-env --uninstall '*'`.
=== Why are the session variables not set?
Home Manager is only able to set session variables automatically if it manages your Bash or Z shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding
[source,bash]
----
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
----
to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells.
=== How to set up a configuration for multiple users/machines?
:post-your-homenix: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/
A typical way to prepare a repository of configurations for multiple logins and machines is to prepare one "top-level" file for each unique combination.
For example, if you have two machines, called "kronos" and "rhea" on which you want to configure your user "jane" then you could create the files
- `kronos-jane.nix`,
- `rhea-jane.nix`, and
- `common.nix`
in your repository. On the kronos and rhea machines you can then make `~jane/.config/nixpkgs/home.nix` be a symbolic link to the corresponding file in your configuration repository.
The `kronos-jane.nix` and `rhea-jane.nix` files follow the format
[source,nix]
----
{ ... }:
{
imports = [ ./common.nix ];
# Various options that are specific for this machine/user.
}
----
while the `common.nix` file contains configuration shared across the two logins. Of course, instead of just a single `common.nix` file you can have multiple ones, even one per program or service.
You can get some inspiration from the {post-your-homenix}[Post your home-manager home.nix file!] Reddit thread.
=== Why do I get an error message about `ca.desrt.dconf`?
You are most likely trying to configure the GTK or Gnome Terminal but the DBus session is not aware of the dconf service. The full error you might get is
----
error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files
----
The solution on NixOS is to add
[source,nix]
services.dbus.packages = with pkgs; [ gnome.dconf ];
to your system configuration.
=== How do I install packages from Nixpkgs unstable?
If you are using a stable version of Nixpkgs but would like to install some particular packages from Nixpkgs unstable or some other channel then you can import the unstable Nixpkgs and refer to its packages within your configuration. Something like
[source,nix]
----
{ pkgs, config, ... }:
let
pkgsUnstable = import <nixpkgs-unstable> {};
in
{
home.packages = [
pkgsUnstable.foo
];
# …
}
----
should work provided you have a Nix channel called `nixpkgs-unstable`.
You can add the `nixpkgs-unstable` channel by running
[source,console]
----
# nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
# nix-channel --update
----
Note, the package will not be affected by any package overrides, overlays, etc.
=== How do I override the package used by a module?
:nixpkgs-overlays: https://nixos.org/nixpkgs/manual/#chap-overlays
By default Home Manager will install the package provided by your chosen `nixpkgs` channel but occasionally you might end up needing to change this package. This can typically be done in two ways.
1. If the module provides a `package` option, such as `programs.beets.package`, then this is the recommended way to perform the override. For example,
+
[source,nix]
programs.beets.package = pkgs.beets.override { enableCheck = true; };
2. If no `package` option is available then you can typically override the relevant package using an {nixpkgs-overlays}[overlay].
+
For example, if you want to use the `programs.skim` module but use the `skim` package from Nixpkgs unstable, then a configuration like
+
[source,nix]
----
{ pkgs, config, ... }:
let
pkgsUnstable = import <nixpkgs-unstable> {};
in
{
programs.skim.enable = true;
nixpkgs.overlays = [
(self: super: {
skim = pkgsUnstable.skim;
})
];
# …
}
----
+
should work OK.

20
third_party/home-manager/Makefile vendored Normal file
View file

@ -0,0 +1,20 @@
.PHONY: all all-tests test test-install format
NIXPKGS_REV := nixpkgs-unstable
NIX_PATH := nixpkgs=https://github.com/NixOS/nixpkgs/archive/${NIXPKGS_REV}.tar.gz
all: all-tests test-install
all-tests:
$(MAKE) test TEST=all
test:
ifndef TEST
$(error Use 'make test TEST=<test_name>' to run desired test)
endif
nix-shell --pure tests -I ${NIX_PATH} -A run.${TEST}
test-install:
HOME=$(shell mktemp -d) NIX_PATH=${NIX_PATH} nix-shell . -A install
format:
./format

View file

@ -70,16 +70,16 @@ Currently the easiest way to install Home Manager is as follows:
2. Add the appropriate Home Manager channel. If you are following
Nixpkgs master or an unstable channel you can run
```console
$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
$ nix-channel --update
```shell
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
```
and if you follow a Nixpkgs version 21.05 channel you can run
```console
$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager
$ nix-channel --update
```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
@ -93,8 +93,8 @@ Currently the easiest way to install Home Manager is as follows:
3. Install Home Manager and create the first Home Manager generation:
```console
$ nix-shell '<home-manager>' -A install
```shell
nix-shell '<home-manager>' -A install
```
Once finished, Home Manager should be active and available in your
@ -103,13 +103,14 @@ Currently the easiest way to install Home Manager is as follows:
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. Unfortunately, in this specific
case we currently only support POSIX.2-like shells such as
[Bash][] or [Z shell][].
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
@ -190,14 +191,14 @@ To satisfy the above setup we should elaborate the
To activate this configuration you can then run
```console
$ home-manager switch
```shell
home-manager switch
```
or if you are not feeling so lucky,
```console
$ home-manager build
```shell
home-manager build
```
which will create a `result` link to a directory containing an
@ -207,8 +208,8 @@ Documentation of available configuration options, including
descriptions and usage examples, is available in the [Home Manager
manual][configuration options] or offline by running
```console
$ man home-configuration.nix
```shell
man home-configuration.nix
```
Rollbacks
@ -384,3 +385,6 @@ an issue.
[samueldr]: https://github.com/samueldr/
[Nix Pills]: https://nixos.org/nixos/nix-pills/
[Nix Flakes]: https://nixos.wiki/wiki/Flakes
[Fish]: https://fishshell.com
[foreign-env]: https://github.com/oh-my-fish/plugin-foreign-env
[babelfish]: https://github.com/bouk/babelfish

View file

@ -1,7 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
rec {
docs = with import ./doc { inherit pkgs; }; {
docs = with import ./docs { inherit pkgs; }; {
html = manual.html;
manPages = manPages;
json = options.json;

View file

@ -1,21 +0,0 @@
[[sec-release-21.11]]
== Release 21.11
This is the current unstable branch and the information in this
section is therefore not final.
[[sec-release-21.11-highlights]]
=== Highlights
This release has the following notable changes:
* Nothing has happened.
[[sec-release-21.11-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
"21.11" or later.
* Nothing has happened.

View file

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

View file

@ -43,15 +43,21 @@ The solution is typically to uninstall the package from the environment using `n
You could also opt to unistall _all_ of the packages from your profile with `nix-env --uninstall '*'`.
=== Why are the session variables not set?
:foreign-env: https://github.com/oh-my-fish/plugin-foreign-env
Home Manager is only able to set session variables automatically if it manages your Bash or Z shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding
Home Manager is only able to set session variables automatically if it manages your Bash, Z shell, or fish shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding
[source,bash]
----
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
----
to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells.
to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. For fish shell, it is possible to source it using {foreign-env}[the foreign-env plugin]
[source,bash]
----
fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" > /dev/null
----
=== How to set up a configuration for multiple users/machines?
:post-your-homenix: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/
@ -94,7 +100,7 @@ error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.
The solution on NixOS is to add
[source,nix]
services.dbus.packages = with pkgs; [ gnome.dconf ];
programs.dconf.enable = true;
to your system configuration.

View file

@ -86,9 +86,12 @@ file in your shell configuration. Alternatively source
+
when managing home configuration together with system configuration.
+
Unfortunately, we currently only support 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
http://zsh.sourceforge.net/[Z shell].
http://zsh.sourceforge.net/[Z shell]. https://fishshell.com[Fish]
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
+
@ -224,6 +227,10 @@ For example, a nix-darwin configuration may include the lines
[source,nix]
----
users.users.eve = {
name = "eve";
home = "/Users/eve";
}
home-manager.users.eve = { pkgs, ... }: {
home.packages = [ pkgs.atool pkgs.httpie ];
programs.bash.enable = true;

View file

@ -139,6 +139,10 @@
--debug
</arg>
<arg>
--impure
</arg>
<arg>
--keep-failed
</arg>
@ -155,6 +159,10 @@
--(no-)substitute
</arg>
<arg>
--no-out-link
</arg>
<arg>
<group choice="req">
<arg choice="plain">
@ -488,6 +496,18 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--impure</option>
</term>
<listitem>
<para>
Passed on to <citerefentry>
<refentrytitle>nix-build</refentrytitle>
<manvolnum>1</manvolnum> </citerefentry>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--keep-failed</option>
@ -536,6 +556,19 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--no-out-link</option>
</term>
<listitem>
<para>
Passed on to <citerefentry>
<refentrytitle>nix-build</refentrytitle>
<manvolnum>1</manvolnum> </citerefentry>
when running <command>home-manager build</command>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-v</option>

View file

@ -9,7 +9,7 @@
<preface>
<title>Preface</title>
<para>
This manual will eventually describes how to install, use, and extend Home
This manual will eventually describe how to install, use, and extend Home
Manager.
</para>
<para>

View file

@ -0,0 +1,47 @@
[[sec-release-21.11]]
== Release 21.11
This is the current unstable branch and the information in this
section is therefore not final.
[[sec-release-21.11-highlights]]
=== Highlights
This release has the following notable changes:
* All Home Manager modules are now loaded on all platforms. With this
change you will get a more descriptive error message if you attempt to
enable a module that is incompatible with the host platform.
+
Previously, modules that were platform specific would only be loaded
on that particular platform. For example, a module defining a
https://systemd.io/[systemd] service would only be loaded when the
host platform was Linux. This reduced evaluation times, simplified the
generated documentation, and made it impossible to accidentally use
modules that do not support the host platform.
+
While the above benefits are quite nice, avoiding module loads also
brings a few problems. For example, the
https://nix-community.github.io/home-manager/[public documentation]
will only show the options available for Linux hosts and the
documentation cannot make references to options within modules that
are unavailable on some hosts. Finally, users who wish to use the same
configuration file for different platforms cannot do so, even if the
platform incompatible options are unused.
+
Ultimately, the benefits of loading all modules won and the behavior
has now changed. For associated discussion see
https://github.com/nix-community/home-manager/issues/1906[issue #1906].
* Rofi version 1.7.0 removed many options that were used by the module and replaced them with custom themes, which are more flexible and powerful.
+
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.
[[sec-release-21.11-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
"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.

View file

@ -18,8 +18,13 @@
darwinModules.home-manager = import ./nix-darwin;
darwinModule = self.darwinModules.home-manager;
packages = forAllSystems (system: {
packages = forAllSystems (system:
let docs = import ./docs { pkgs = nixpkgsFor.${system}; };
in {
home-manager = nixpkgsFor.${system}.callPackage ./home-manager { };
docs-html = docs.manual.html;
docs-manpages = docs.manPages;
docs-json = docs.options.json;
});
defaultPackage =

View file

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p findutils nixfmt
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/5edf5b60c3d8f82b5fc5e73e822b6f7460584945.tar.gz -i bash -p findutils nixfmt
CHECK_ARG=
@ -12,12 +12,9 @@ case $1 in
;;
esac
# The first block of excludes are files where nixfmt does a poor job,
# IMHO. The second block of excludes are files touched by open pull
# requests and we want to avoid merge conflicts.
# The excludes are for files touched by open pull requests and we want
# to avoid merge conflicts.
find . -name '*.nix' \
! -path ./modules/programs/irssi.nix \
\
! -path ./home-manager/home-manager.nix \
! -path ./modules/default.nix \
! -path ./modules/files.nix \
@ -26,25 +23,14 @@ find . -name '*.nix' \
! -path ./modules/lib/file-type.nix \
! -path ./modules/manual.nix \
! -path ./modules/misc/news.nix \
! -path ./modules/misc/nixpkgs.nix \
! -path ./modules/misc/xdg.nix \
! -path ./modules/modules.nix \
! -path ./modules/programs/bash.nix \
! -path ./modules/programs/firefox.nix \
! -path ./modules/programs/gpg.nix \
! -path ./modules/programs/ssh.nix \
! -path ./modules/programs/tmux.nix \
! -path ./modules/programs/zsh.nix \
! -path ./modules/services/gpg-agent.nix \
! -path ./modules/services/mpd.nix \
! -path ./modules/services/sxhkd.nix \
! -path ./modules/systemd.nix \
! -path ./nix-darwin/default.nix \
! -path ./tests/default.nix \
! -path ./tests/modules/home-environment/session-variables.nix \
! -path ./tests/modules/programs/gpg/override-defaults.nix \
! -path ./tests/modules/programs/zsh/session-variables.nix \
! -path ./tests/modules/services/sxhkd/service.nix \
! -path ./tests/modules/systemd/services.nix \
! -path ./tests/modules/systemd/session-variables.nix \
-exec nixfmt $CHECK_ARG {} +

View file

@ -290,8 +290,10 @@ _home-manager_completions ()
#--------------------------#
local Options
Options=( "-f" "--file" "-b" "-A" "-I" "-h" "--help" "-n" "--dry-run" "-v" "--verbose" \
"--cores" "--debug" "--keep-failed" "--keep-going" "-j" "--max-jobs" "--no-substitute" "--show-trace" "--substitute")
Options=( "-f" "--file" "-b" "-A" "-I" "-h" "--help" "-n" "--dry-run" "-v" \
"--verbose" "--cores" "--debug" "--impure" "--keep-failed" \
"--keep-going" "-j" "--max-jobs" "--no-substitute" "--no-out-link" \
"--show-trace" "--substitute" "--builders")
# ^ « home-manager »'s options.

View file

@ -0,0 +1,65 @@
#!/bin/env fish
##################################################
# « home-manager » command-line fish completion
#
# © 2021 "Ariel AxionL" <i at axionl dot me>
#
# MIT License
#
##################################################
### Functions
function __home_manager_generations --description "Get all generations"
for i in (home-manager generations)
set -l split (string split " " $i)
set -l gen_id $split[5]
set -l gen_datetime $split[1..2]
set -l gen_hash (string match -r '\w{32}' $i)
echo $gen_id\t$gen_datetime $gen_hash
end
end
### SubCommands
complete -c home-manager -n "__fish_use_subcommand" -f -a "help" -d "Print home-manager help"
complete -c home-manager -n "__fish_use_subcommand" -f -a "edit" -d "Open the home configuration in $EDITOR"
complete -c home-manager -n "__fish_use_subcommand" -f -a "option" -d "Inspect configuration option"
complete -c home-manager -n "__fish_use_subcommand" -f -a "build" -d "Build configuration into result directory"
complete -c home-manager -n "__fish_use_subcommand" -f -a "instantiate" -d "Instantiate the configuration and print the resulting derivation"
complete -c home-manager -n "__fish_use_subcommand" -f -a "switch" -d "Build and activate configuration"
complete -c home-manager -n "__fish_use_subcommand" -f -a "generations" -d "List all home environment generations"
complete -c home-manager -n "__fish_use_subcommand" -f -a "packages" -d "List all packages installed in home-manager-path"
complete -c home-manager -n "__fish_use_subcommand" -f -a "news" -d "Show news entries in a pager"
complete -c home-manager -n "__fish_use_subcommand" -f -a "uninstall" -d "Remove Home Manager"
complete -c home-manager -n "__fish_use_subcommand" -x -a "remove-generations" -d "Remove indicated generations"
complete -c home-manager -n "__fish_seen_subcommand_from remove-generations" -f -ka '(__home_manager_generations)'
complete -c home-manager -n "__fish_use_subcommand" -x -a "expire-generations" -d "Remove generations older than TIMESTAMP"
### Options
complete -c home-manager -F -s f -l "file" -d "The home configuration file"
complete -c home-manager -x -s A -d "Select an expression in the configuration file"
complete -c home-manager -F -s I -d "Add a path to the Nix expression search path"
complete -c home-manager -F -l "flake" -d "Use home-manager configuration at specified flake-uri"
complete -c home-manager -F -s b -d "Move existing files to new path rather than fail"
complete -c home-manager -f -s v -l "verbose" -d "Verbose output"
complete -c home-manager -f -s n -l "dry-run" -d "Do a dry run, only prints what actions would be taken"
complete -c home-manager -f -s h -l "help" -d "Print this help"
complete -c home-manager -x -l "arg" -d "Override inputs passed to home-manager.nix"
complete -c home-manager -x -l "argstr" -d "Like --arg but the value is a string"
complete -c home-manager -x -l "cores" -d "Threads per job (e.g. -j argument to make)"
complete -c home-manager -x -l "debug"
complete -c home-manager -x -l "impure"
complete -c home-manager -f -l "keep-failed" -d "Keep temporary directory used by failed builds"
complete -c home-manager -f -l "keep-going" -d "Keep going in case of failed builds"
complete -c home-manager -x -s j -l "max-jobs" -d "Max number of build jobs in parallel"
complete -c home-manager -x -l "option" -d "Set Nix configuration option"
complete -c home-manager -x -l "builders" -d "Remote builders"
complete -c home-manager -f -l "show-trace" -d "Print stack trace of evaluation errors"
complete -c home-manager -f -l "substitute"
complete -c home-manager -f -l "no-substitute"
complete -c home-manager -f -l "no-out-link"

View file

@ -8,6 +8,7 @@ _arguments \
'-b[backup files]:EXT:()' \
'--cores[cores]:NUM:()' \
'--debug[debug]' \
'--impure[impure]' \
'--keep-failed[keep failed]' \
'--keep-going[keep going]' \
'(-h --help)'{--help,-h}'[help]' \
@ -16,6 +17,7 @@ _arguments \
'(-f --file)'{--file,-f}'[configuration file]:FILE:_files' \
'(-j --max-jobs)'{--max-jobs,-j}'[max jobs]:NUM:()' \
'--option[option]:NAME VALUE:()' \
'--builders[builders]:SPEC:()' \
'--show-trace[show trace]' \
'1: :->cmds' \
'*:: :->args' && ret=0
@ -45,13 +47,16 @@ case "$state" in
_arguments \
'--cores[cores]:NUM:()' \
'--debug[debug]' \
'--impure[impure]' \
'--keep-failed[keep failed]' \
'--keep-going[keep going]' \
'--max-jobs[max jobs]:NUM:()' \
'--no-out-link[no out link]' \
'--no-substitute[no substitute]' \
'--option[option]:NAME VALUE:()' \
'--show-trace[show trace]' \
'--substitute[substitute]'
'--substitute[substitute]' \
'--builders[builders]:SPEC:()'
;;
esac
esac

View file

@ -11,8 +11,8 @@ let
pathStr = if path == null then "" else path;
nixos-option =
callPackage (pkgs.path + "/nixos/modules/installer/tools/nixos-option") { };
nixos-option = pkgs.nixos-option or (callPackage
(pkgs.path + "/nixos/modules/installer/tools/nixos-option") { });
in runCommand "home-manager" {
preferLocalBuild = true;
@ -39,4 +39,6 @@ in runCommand "home-manager" {
$out/share/bash-completion/completions/home-manager
install -D -m755 ${./completion.zsh} \
$out/share/zsh/site-functions/_home-manager
install -D -m755 ${./completion.fish} \
$out/share/fish/vendor_completions.d/home-manager.fish
''

View file

@ -252,6 +252,7 @@ function doBuild() {
nix build \
"${PASSTHROUGH_OPTS[@]}" \
${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \
"$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1
return $exitCode
@ -263,8 +264,9 @@ function doBuild() {
newsInfo=$(buildNews)
local exitCode
doBuildAttr --attr activationPackage \
doBuildAttr \
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
&& exitCode=0 || exitCode=1
presentNews "$newsInfo"
@ -514,12 +516,15 @@ function doHelp() {
echo " --arg(str) NAME VALUE Override inputs passed to home-manager.nix"
echo " --cores NUM"
echo " --debug"
echo " --impure"
echo " --keep-failed"
echo " --keep-going"
echo " -j, --max-jobs NUM"
echo " --option NAME VALUE"
echo " --show-trace"
echo " --(no-)substitute"
echo " --no-out-link Do not create a symlink to the output path"
echo " --builders VALUE"
echo
echo "Commands"
echo
@ -601,6 +606,9 @@ while [[ $# -gt 0 ]]; do
PASSTHROUGH_OPTS+=("$opt" "$1" "$2")
shift 2
;;
--no-out-link)
NO_OUT_LINK=1
;;
-h|--help)
doHelp
exit 0
@ -612,12 +620,12 @@ while [[ $# -gt 0 ]]; do
PASSTHROUGH_OPTS+=("$opt" "$1" "$2")
shift 2
;;
-j|--max-jobs|--cores)
-j|--max-jobs|--cores|--builders)
PASSTHROUGH_OPTS+=("$opt" "$1")
shift
;;
--debug|--keep-failed|--keep-going|--show-trace\
|--substitute|--no-substitute)
|--substitute|--no-substitute|--impure)
PASSTHROUGH_OPTS+=("$opt")
;;
-v|--verbose)
@ -695,3 +703,5 @@ case $COMMAND in
exit 1
;;
esac
# vim: ft=bash

View file

@ -5,9 +5,10 @@
, newsReadIdsFile ? null
}:
with pkgs.lib;
let
inherit (pkgs.lib)
concatMapStringsSep fileContents filter length optionalString removeSuffix
replaceStrings splitString;
env = import ../modules {
configuration =

View file

@ -23,6 +23,9 @@ runCommand "home-manager-install" {
if [[ -v XDG_DATA_HOME && $XDG_DATA_HOME != "$HOME/.local/share" ]]; then
xdgVars="$xdgVars xdg.dataHome = \"$XDG_DATA_HOME\";$nl"
fi
if [[ -v XDG_STATE_HOME && $XDG_STATE_HOME != "$HOME/.local/state" ]]; then
xdgVars="$xdgVars xdg.stateHome = \"$XDG_STATE_HOME\";$nl"
fi
mkdir -p "$(dirname "$confFile")"
cat > $confFile <<EOF

View file

@ -71,7 +71,7 @@ let
};
certificatesFile = mkOption {
type = types.path;
type = types.nullOr types.path;
default = config.accounts.email.certificatesFile;
defaultText = "config.accounts.email.certificatesFile";
description = ''
@ -354,7 +354,7 @@ let
in {
options.accounts.email = {
certificatesFile = mkOption {
type = types.path;
type = types.nullOr types.path;
default = "/etc/ssl/certs/ca-certificates.crt";
description = ''
Path to default file containing certificate authorities that

View file

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

View file

@ -106,7 +106,12 @@ in
$VERBOSE_ECHO "Skipping collision check for $targetPath"
elif [[ -e "$targetPath" \
&& ! "$(readlink "$targetPath")" == $homeFilePattern ]] ; then
if [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
# The target file already exists and it isn't a symlink owned by Home Manager.
if cmp -s "$sourcePath" "$targetPath"; then
# First compare the files' content. If they're equal, we're fine.
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be skipped since they are the same"
elif [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
# Next, try to move the file to a backup location if configured and possible
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT"
if [[ -e "$backup" ]]; then
errorEcho "Existing file '$backup' would be clobbered by backing up '$targetPath'"
@ -115,6 +120,7 @@ in
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be moved to '$backup'"
fi
else
# Fail if nothing else works
errorEcho "Existing file '$targetPath' is in the way of '$sourcePath'"
collision=1
fi
@ -122,7 +128,7 @@ in
done
if [[ -v collision ]] ; then
errorEcho "Please move the above files and try again or use -b <ext> to move automatically."
errorEcho "Please move the above files and try again or use 'home-manager switch -b backup' to back up existing files automatically."
exit 1
fi
'';
@ -169,11 +175,19 @@ in
relativePath="''${sourcePath#$newGenFiles/}"
targetPath="$HOME/$relativePath"
if [[ -e "$targetPath" && ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
# The target exists, back it up
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT"
$DRY_RUN_CMD mv $VERBOSE_ARG "$targetPath" "$backup" || errorEcho "Moving '$targetPath' failed!"
fi
if [[ -e "$targetPath" && ! -L "$targetPath" ]] && cmp -s "$sourcePath" "$targetPath" ; then
# The target exists but is identical don't do anything.
$VERBOSE_ECHO "Skipping '$targetPath' as it is identical to '$sourcePath'"
else
# Place that symlink, --force
$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")"
$DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath"
fi
done
'';
@ -284,9 +298,14 @@ in
home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] (
concatMapStrings (v: ''
if [[ ''${changedFiles[${escapeShellArg v.target}]} -eq 1 ]]; then
if (( ''${changedFiles[${escapeShellArg v.target}]} == 1 )); then
if [[ -v DRY_RUN || -v VERBOSE ]]; then
echo "Running onChange hook for" ${escapeShellArg v.target}
fi
if [[ ! -v DRY_RUN ]]; then
${v.onChange}
fi
fi
'') (filter (v: v.onChange != "") (attrValues cfg))
);

View file

@ -4,6 +4,8 @@ with lib;
let
inherit (config.home) stateVersion;
cfg = config.home;
languageSubModule = types.submodule {
@ -115,7 +117,7 @@ let
if versionAtLeast config.home.stateVersion "19.09"
then null
else "us";
defaultText = literalExample "null";
defaultText = literalExpression "null";
description = ''
Keyboard layout. If <literal>null</literal>, then the system
configuration will be used.
@ -149,7 +151,7 @@ let
if versionAtLeast config.home.stateVersion "19.09"
then null
else "";
defaultText = literalExample "null";
defaultText = literalExpression "null";
example = "colemak";
description = ''
X keyboard variant. If <literal>null</literal>, then the
@ -182,7 +184,7 @@ in
options = {
home.username = mkOption {
type = types.str;
defaultText = literalExample ''
defaultText = literalExpression ''
"$USER" for state version < 20.09,
undefined for state version 20.09
'';
@ -192,7 +194,7 @@ in
home.homeDirectory = mkOption {
type = types.path;
defaultText = literalExample ''
defaultText = literalExpression ''
"$HOME" for state version < 20.09,
undefined for state version 20.09
'';
@ -220,7 +222,11 @@ in
home.keyboard = mkOption {
type = types.nullOr keyboardSubModule;
default = {};
default = if versionAtLeast stateVersion "21.11" then null else { };
defaultText = literalExpression ''
"{ }" for state version < 21.11,
"null" for state version 21.11
'';
description = ''
Keyboard configuration. Set to <literal>null</literal> to
disable Home Manager keyboard management.
@ -268,11 +274,21 @@ in
type = with types; listOf str;
default = [ ];
example = [
".git/safe/../../bin"
"$HOME/.local/bin"
"\${xdg.configHome}/emacs/bin"
"~/.local/bin"
".git/safe/../../bin"
];
description = "Extra directories to add to <envar>PATH</envar>.";
description = ''
Extra directories to add to <envar>PATH</envar>.
</para><para>
These directories are added to the <envar>PATH</envar> variable in a
double-quoted context, so expressions like <code>$HOME</code> are
expanded by the shell. However, since expressions like <code>~</code> or
<code>*</code> are escaped, they will end up in the <envar>PATH</envar>
verbatim.
'';
};
home.sessionVariablesExtra = mkOption {
@ -321,7 +337,7 @@ in
home.activation = mkOption {
type = hm.types.dagOf types.str;
default = {};
example = literalExample ''
example = literalExpression ''
{
myActivationAction = lib.hm.dag.entryAfter ["writeBoundary"] '''
$DRY_RUN_CMD ln -s $VERBOSE_ARG \
@ -373,6 +389,16 @@ in
description = "The package containing the complete activation script.";
};
home.extraActivationPath = mkOption {
internal = true;
type = types.listOf types.package;
default = [ ];
description = ''
Extra packages to add to <envar>PATH</envar> within the activation
script.
'';
};
home.extraBuilderCommands = mkOption {
type = types.lines;
default = "";
@ -570,7 +596,8 @@ in
# Programs that always should be available on the activation
# script's PATH.
activationBinPaths = lib.makeBinPath [
activationBinPaths = lib.makeBinPath (
[
pkgs.bash
pkgs.coreutils
pkgs.diffutils # For `cmp` and `diff`.
@ -578,7 +605,8 @@ in
pkgs.gnugrep
pkgs.gnused
pkgs.ncurses # For `tput`.
]
] ++ config.home.extraActivationPath
)
+ optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH";
activationScript = pkgs.writeShellScript "activation-script" ''

View file

@ -95,6 +95,10 @@ in {
};
config = mkIf (cfg.enabled != null) {
assertions = [
(hm.assertions.assertPlatform "i18n.inputMethod" pkgs platforms.linux)
];
home.packages = [ cfg.package gtk2Cache gtk3Cache ];
};

View file

@ -17,7 +17,7 @@ in {
engines = mkOption {
type = with types; listOf fcitxEngine;
default = [ ];
example = literalExample "with pkgs.fcitx-engines; [ mozc hangul ]";
example = literalExpression "with pkgs.fcitx-engines; [ mozc hangul ]";
description = let
enginesDrv = filterAttrs (const isDerivation) pkgs.fcitx-engines;
engines = concatStringsSep ", "

View file

@ -12,7 +12,7 @@ in {
addons = mkOption {
type = with types; listOf package;
default = [ ];
example = literalExample "with pkgs; [ fcitx5-rime ]";
example = literalExpression "with pkgs; [ fcitx5-rime ]";
description = ''
Enabled Fcitx5 addons.
'';

View file

@ -9,7 +9,7 @@ in {
config = mkOption {
type = yamlFormat.type;
default = { };
example = literalExample ''
example = literalExpression ''
{
daemon = {
modules = ["Xim" "Indicator"];

View file

@ -5,9 +5,9 @@ function setupVars() {
local profilesPath="$nixStateDir/profiles/per-user/$USER"
local gcPath="$nixStateDir/gcroots/per-user/$USER"
genProfilePath="$profilesPath/home-manager"
newGenPath="@GENERATION_DIR@";
newGenGcPath="$gcPath/current-home"
declare -gr genProfilePath="$profilesPath/home-manager"
declare -gr newGenPath="@GENERATION_DIR@";
declare -gr newGenGcPath="$gcPath/current-home"
local greatestGenNum
greatestGenNum=$( \
@ -16,14 +16,15 @@ function setupVars() {
| sed -E 's/ *([[:digit:]]+) .*/\1/')
if [[ -n $greatestGenNum ]] ; then
oldGenNum=$greatestGenNum
newGenNum=$((oldGenNum + 1))
declare -gr oldGenNum=$greatestGenNum
declare -gr newGenNum=$((oldGenNum + 1))
else
newGenNum=1
declare -gr newGenNum=1
fi
if [[ -e $profilesPath/home-manager ]] ; then
oldGenPath="$(readlink -e "$profilesPath/home-manager")"
declare -gr oldGenPath
fi
$VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath"

View file

@ -0,0 +1,14 @@
{ lib }:
{
assertPlatform = module: pkgs: platforms: {
assertion = lib.elem pkgs.stdenv.hostPlatform.system platforms;
message = let
platformsStr = lib.concatStringsSep "\n"
(map (p: " - ${p}") (lib.sort (a: b: a < b) platforms));
in ''
The module ${module} does not support your platform. It only supports
${platformsStr}'';
};
}

View file

@ -9,9 +9,8 @@
{ lib }:
with lib;
rec {
let inherit (lib) all any filterAttrs mapAttrs mapAttrsToList toposort;
in rec {
emptyDag = { };

View file

@ -16,6 +16,8 @@ rec {
entryBefore = d.dagEntryBefore;
};
assertions = import ./assertions.nix { inherit lib; };
gvariant = import ./gvariant.nix { inherit lib; };
maintainers = import ./maintainers.nix;
strings = import ./strings.nix { inherit lib; };

View file

@ -1,7 +1,8 @@
{ homeDirectory, lib, pkgs }:
with lib;
let
inherit (lib) hasPrefix hm literalExpression mkDefault mkIf mkOption removePrefix types;
in
{
# Constructs a type suitable for a `home.file` like option. The
# target path may be either absolute or relative, in which case it
@ -21,7 +22,7 @@ with lib;
absPath = if hasPrefix "/" p then p else "${basePath}/${p}";
in
removePrefix (homeDirectory + "/") absPath;
defaultText = literalExample "<name>";
defaultText = literalExpression "<name>";
description = ''
Path to target file relative to ${basePathDesc}.
'';

View file

@ -5,9 +5,9 @@
{ lib }:
with lib;
let
inherit (lib)
concatMapStringsSep concatStrings escape hasPrefix head replaceStrings;
mkPrimitive = t: v: {
_type = "gvariant";
@ -71,6 +71,8 @@ in rec {
inherit type typeOf;
isGVariant = v: v._type or "" == "gvariant";
isArray = hasPrefix "a";
isMaybe = hasPrefix "m";
isTuple = hasPrefix "(";
@ -122,8 +124,9 @@ in rec {
};
mkString = v:
mkPrimitive type.string v // {
__toString = self: "'${escape [ "'" "\\" ] self.value}'";
let sanitize = s: replaceStrings [ "\n" ] [ "\\n" ] (escape [ "'" "\\" ] s);
in mkPrimitive type.string v // {
__toString = self: "'${sanitize self.value}'";
};
mkObjectpath = v:

View file

@ -75,12 +75,6 @@
fingerprint = "F0E0 0311 126A CD72 4392 25E6 68BF 2EAE 6D91 CAFF";
}];
};
thiagokokada = {
email = "thiagokokada@gmail.com";
name = "Thiago Kenji Okada";
github = "thiagokokada";
githubId = 844343;
};
fendse = {
email = "46252070+Fendse@users.noreply.github.com";
github = "Fendse";
@ -115,4 +109,28 @@
githubId = 56614642;
name = "Ilan Joselevich";
};
mager = {
email = "andreas@mager.eu";
github = "AndreasMager";
githubId = 5646732;
name = "Andreas Mager";
};
bjpbakker = {
email = "bart@thesoftwarecraft.com";
github = "bjpbakker";
githubId = 605641;
name = "Bart Bakker";
};
jrobsonchase = {
email = "josh@robsonchase.com";
github = "jrobsonchase";
githubId = 1553581;
name = "Josh Robson Chase";
};
hawkw = {
name = "Eliza Weisman";
email = "eliza@elizas.website";
github = "hawkw";
githubId = 2796466;
};
}

View file

@ -4,4 +4,10 @@
nixpkgsLib:
let mkHmLib = import ./.;
in nixpkgsLib.extend (self: super: { hm = mkHmLib { lib = super; }; })
in nixpkgsLib.extend (self: super: {
hm = mkHmLib { lib = self; };
# For forward compatibility.
literalExpression = super.literalExpression or super.literalExample;
literalDocBook = super.literalDocBook or super.literalExample;
})

View file

@ -1,8 +1,9 @@
{ lib }:
with lib;
{
let
inherit (lib)
genList length lowerChars replaceStrings stringToCharacters upperChars;
in {
# Figures out a valid Nix store name for the given path.
storeFileName = path:
let

View file

@ -1,8 +1,10 @@
{ dag, lib }:
with lib;
let
inherit (lib)
concatStringsSep defaultFunctor fixedWidthNumber imap1 isAttrs isList length
listToAttrs mapAttrs mkIf mkOption mkOptionType nameValuePair stringLength
types warn;
isDagEntry = e: isAttrs e && (e ? data) && (e ? after) && (e ? before);

View file

@ -1,9 +1,11 @@
{ lib, dag ? import ./dag.nix { inherit lib; }
, gvariant ? import ./gvariant.nix { inherit lib; } }:
with lib;
let
inherit (lib)
all concatMap foldl' getFiles getValues head isFunction literalExpression
mergeAttrs mergeDefaultOption mergeOneOption mergeOptions mkOption
mkOptionType showFiles showOption types;
typesDag = import ./types-dag.nix { inherit dag lib; };
@ -37,7 +39,7 @@ in rec {
package = mkOption {
type = types.nullOr types.package;
default = null;
example = literalExample "pkgs.dejavu_fonts";
example = literalExpression "pkgs.dejavu_fonts";
description = ''
Package providing the font. This package will be installed
to your profile. If <literal>null</literal> then the font
@ -70,7 +72,11 @@ in rec {
check = v: gvar.mkValue v != null;
merge = loc: defs:
let
vdefs = map (d: d // { value = gvar.mkValue d.value; }) defs;
vdefs = map (d:
d // {
value =
if gvar.isGVariant d.value then d.value else gvar.mkValue d.value;
}) defs;
vals = map (d: d.value) vdefs;
defTypes = map (x: x.type) vals;
sameOrNull = x: y: if x == y then y else null;
@ -82,8 +88,10 @@ in rec {
+ " mismatched GVariant types given in"
+ " ${showFiles (getFiles defs)}.")
else if gvar.isArray sharedDefType && allChecked then
(types.listOf gvariant).merge loc
(map (d: d // { value = d.value.value; }) vdefs)
gvar.mkValue ((types.listOf gvariant).merge loc
(map (d: d // { value = d.value.value; }) vdefs)) // {
type = sharedDefType;
}
else if gvar.isTuple sharedDefType && allChecked then
mergeOneOption loc defs
else if gvar.isMaybe sharedDefType && allChecked then

View file

@ -6,7 +6,7 @@ let
cfg = config.manual;
docs = import ../doc { inherit lib pkgs; };
docs = import ../docs { inherit lib pkgs; };
in

View file

@ -27,7 +27,7 @@ in {
settings = mkOption {
type = with types; attrsOf (attrsOf hm.types.gvariant);
default = { };
example = literalExample ''
example = literalExpression ''
{
"org/gnome/calculator" = {
button-mode = "programming";

View file

@ -36,22 +36,11 @@ in {
};
config = mkIf cfg.enable {
# Create two dummy files in /lib/fontconfig to make sure that
# buildEnv creates a real directory path. These files are removed
# in home.extraProfileCommands below so the packages will not
# become "runtime" dependencies.
home.packages = [
(pkgs.writeTextFile {
name = "hm-dummy1";
destination = "/lib/fontconfig/hm-dummy1";
text = "dummy";
})
(pkgs.writeTextFile {
name = "hm-dummy2";
destination = "/lib/fontconfig/hm-dummy2";
text = "dummy";
})
# Make sure that buildEnv creates a real directory path so that we avoid
# trying to write to a read-only location.
(pkgs.runCommandLocal "dummy-fc-dir1" { } "mkdir -p $out/lib/fontconfig")
(pkgs.runCommandLocal "dummy-fc-dir2" { } "mkdir -p $out/lib/fontconfig")
];
home.extraProfileCommands = ''
@ -76,9 +65,10 @@ in {
unset FONTCONFIG_FILE
fi
# Remove hacky dummy files.
rm $out/lib/fontconfig/hm-dummy?
# Remove the fontconfig directory if no files were available.
if [[ -d $out/lib/fontconfig ]] ; then
rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig
fi
'';
xdg.configFile = {

View file

@ -33,7 +33,7 @@ let
package = mkOption {
type = types.nullOr types.package;
default = null;
example = literalExample "pkgs.gnome.gnome_themes_standard";
example = literalExpression "pkgs.gnome.gnome_themes_standard";
description = ''
Package providing the theme. This package will be installed
to your profile. If <literal>null</literal> then the theme
@ -97,9 +97,9 @@ in {
type = types.path;
default = "${config.home.homeDirectory}/.gtkrc-2.0";
defaultText =
literalExample ''"''${config.home.homeDirectory}/.gtkrc-2.0"'';
literalExpression ''"''${config.home.homeDirectory}/.gtkrc-2.0"'';
example =
literalExample ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"'';
literalExpression ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"'';
description = ''
The location to put the GTK configuration file.
'';
@ -167,7 +167,7 @@ in {
++ optionalPackage cfg.iconTheme;
home.file.${cfg2.configLocation}.text =
concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n"
concatMapStrings (l: l + "\n") (mapAttrsToList formatGtk2Option ini)
+ cfg2.extraConfig;
home.sessionVariables.GTK2_RC_FILES = cfg2.configLocation;
@ -178,7 +178,7 @@ in {
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) {
text = concatStringsSep "\n" cfg3.bookmarks;
text = concatMapStrings (l: l + "\n") cfg3.bookmarks;
};
dconf.settings."org/gnome/desktop/interface" = dconfIni;

View file

@ -536,23 +536,6 @@ in
'';
}
{
time = "2018-02-09T21:14:42+00:00";
condition = with config.programs.rofi; enable && colors != null;
message = ''
The new and preferred way to configure the rofi theme is
using rasi themes through the 'programs.rofi.theme' option.
This option can take as value either the name of a
pre-installed theme or the path to a theme file.
A rasi theme can be generated from an Xresources config
using 'rofi -dump-theme'.
The option 'programs.rofi.colors' is still supported but may
become deprecated and removed in the future.
'';
}
{
time = "2018-02-19T21:45:26+00:00";
message = ''
@ -2118,6 +2101,138 @@ in
A new module is available: 'programs.himalaya'.
'';
}
{
time = "2021-07-11T17:45:56+00:00";
message = ''
A new module is available: 'programs.sm64ex'.
'';
}
{
time = "2021-07-15T13:38:32+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.xsettingsd'.
'';
}
{
time = "2021-07-14T20:06:18+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.volnoti'.
'';
}
{
time = "2021-07-23T22:22:31+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.trayer'.
'';
}
{
time = "2021-07-19T01:30:46+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.notify-osd'.
'';
}
{
time = "2021-08-10T21:28:40+00:00";
message = ''
A new module is available: 'programs.java'.
'';
}
{
time = "2021-08-11T13:55:51+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.easyeffects'.
'';
}
{
time = "2021-08-16T21:59:02+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.git-sync'.
'';
}
{
time = "2021-08-26T06:40:59+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.fnott'.
'';
}
{
time = "2021-08-31T18:44:26+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.betterlockscreen'.
'';
}
{
time = "2021-09-14T21:31:03+00:00";
message = ''
A new module is available: 'programs.bottom'.
'';
}
{
time = "2021-09-23T17:04:48+00:00";
condition = hostPlatform.isLinux && config.services.screen-locker.enable;
message = ''
'xautolock' is now optional in 'services.screen-locker', and the
'services.screen-locker' options have been reorganized for clarity.
See the 'xautolock' and 'xss-lock' options modules in
'services.screen-locker'.
'';
}
{
time = "2021-10-05T20:55:07+00:00";
message = ''
A new module is available: 'programs.atuin'.
'';
}
{
time = "2021-10-05T22:15:00+00:00";
message = ''
A new module is available: 'programs.nnn'.
'';
}
{
time = "2021-10-08T22:16:50+00:00";
condition = hostPlatform.isLinux && config.programs.rofi.enable;
message = ''
Rofi version '1.7.0' removed many options that were used by the module
and replaced them with custom themes, which are more flexible and
powerful.
You can replicate your old configuration by moving those options to
'programs.rofi.theme'. Keep in mind that the syntax is different so
you may need to do some changes.
'';
}
{
time = "2021-10-23T17:12:22+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'programs.hexchat'.
'';
}
];
};
}

View file

@ -0,0 +1,73 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.nixpkgs;
# Copied from nixpkgs.nix.
isConfig = x: builtins.isAttrs x || builtins.isFunction x;
# Copied from nixpkgs.nix.
optCall = f: x: if builtins.isFunction f then f x else f;
# Copied from nixpkgs.nix.
mergeConfig = lhs_: rhs_:
let
lhs = optCall lhs_ { inherit pkgs; };
rhs = optCall rhs_ { inherit pkgs; };
in lhs // rhs // optionalAttrs (lhs ? packageOverrides) {
packageOverrides = pkgs:
optCall lhs.packageOverrides pkgs
// optCall (attrByPath [ "packageOverrides" ] ({ }) rhs) pkgs;
} // optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides = pkgs:
optCall lhs.perlPackageOverrides pkgs
// optCall (attrByPath [ "perlPackageOverrides" ] ({ }) rhs) pkgs;
};
# Copied from nixpkgs.nix.
configType = mkOptionType {
name = "nixpkgs-config";
description = "nixpkgs config";
check = x:
let traceXIfNot = c: if c x then true else lib.traceSeqN 1 x false;
in traceXIfNot isConfig;
merge = args: fold (def: mergeConfig def.value) { };
};
# Copied from nixpkgs.nix.
overlayType = mkOptionType {
name = "nixpkgs-overlay";
description = "nixpkgs overlay";
check = builtins.isFunction;
merge = lib.mergeOneOption;
};
in {
meta.maintainers = with maintainers; [ thiagokokada ];
options.nixpkgs = {
config = mkOption {
default = null;
type = types.nullOr configType;
visible = false;
};
overlays = mkOption {
default = null;
type = types.nullOr (types.listOf overlayType);
visible = false;
};
};
config = {
assertions = [{
assertion = cfg.config == null || cfg.overlays == null;
message = ''
`nixpkgs` options are disabled when `home-manager.useGlobalPkgs` is enabled.
'';
}];
};
}

View file

@ -6,40 +6,31 @@ with lib;
let
isConfig = x:
builtins.isAttrs x || builtins.isFunction x;
isConfig = x: builtins.isAttrs x || builtins.isFunction x;
optCall = f: x:
if builtins.isFunction f
then f x
else f;
optCall = f: x: if builtins.isFunction f then f x else f;
mergeConfig = lhs_: rhs_:
let
lhs = optCall lhs_ { inherit pkgs; };
rhs = optCall rhs_ { inherit pkgs; };
in
lhs // rhs //
optionalAttrs (lhs ? packageOverrides) {
in lhs // rhs // optionalAttrs (lhs ? packageOverrides) {
packageOverrides = pkgs:
optCall lhs.packageOverrides pkgs //
optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs;
} //
optionalAttrs (lhs ? perlPackageOverrides) {
optCall lhs.packageOverrides pkgs
// optCall (attrByPath [ "packageOverrides" ] ({ }) rhs) pkgs;
} // optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides = pkgs:
optCall lhs.perlPackageOverrides pkgs //
optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs;
optCall lhs.perlPackageOverrides pkgs
// optCall (attrByPath [ "perlPackageOverrides" ] ({ }) rhs) pkgs;
};
configType = mkOptionType {
name = "nixpkgs-config";
description = "nixpkgs config";
check = x:
let traceXIfNot = c:
if c x then true
else lib.traceSeqN 1 x false;
let traceXIfNot = c: if c x then true else lib.traceSeqN 1 x false;
in traceXIfNot isConfig;
merge = args: fold (def: mergeConfig def.value) {};
merge = args: fold (def: mergeConfig def.value) { };
};
overlayType = mkOptionType {
@ -49,13 +40,9 @@ let
merge = lib.mergeOneOption;
};
_pkgs = import pkgsPath (
filterAttrs (n: v: v != null) config.nixpkgs
);
_pkgs = import pkgsPath (filterAttrs (n: v: v != null) config.nixpkgs);
in
{
in {
options.nixpkgs = {
config = mkOption {
default = null;
@ -91,8 +78,7 @@ in
overlays = mkOption {
default = null;
example = literalExample
''
example = literalExpression ''
[ (self: super: {
openssh = super.openssh.override {
hpnSupport = true;
@ -144,9 +130,10 @@ in
_module.args = {
pkgs = mkOverride modules.defaultPriority _pkgs;
pkgs_i686 =
if _pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86
then _pkgs.pkgsi686Linux
else { };
if _pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86 then
_pkgs.pkgsi686Linux
else
{ };
};
};
}

View file

@ -12,6 +12,10 @@ in {
options = { xsession.numlock.enable = mkEnableOption "Num Lock"; };
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "xsession.numlock" pkgs platforms.linux)
];
systemd.user.services.numlockx = {
Unit = {
Description = "NumLockX";

View file

@ -78,7 +78,7 @@ in {
package = mkOption {
type = types.nullOr types.package;
default = null;
example = literalExample "pkgs.adwaita-qt";
example = literalExpression "pkgs.adwaita-qt";
description = "Theme package to be used in Qt5 applications.";
};
};

View file

@ -25,6 +25,11 @@ in {
};
config = mkIf (cfg.rules != [ ]) {
assertions = [
(hm.assertions.assertPlatform "systemd.user.tmpfiles" pkgs
platforms.linux)
];
xdg = {
dataFile."user-tmpfiles.d/home-manager.conf" = {
text = ''

View file

@ -105,7 +105,7 @@ let
This may override other values.
'';
default = { };
example = literalExample ''
example = literalExpression ''
{
Keywords = "calc;math";
DBusActivatable = "false";
@ -157,7 +157,7 @@ in {
'';
default = { };
type = types.attrsOf (types.submodule desktopEntry);
example = literalExample ''
example = literalExpression ''
{
firefox = {
name = "Firefox";
@ -171,8 +171,13 @@ in {
'';
};
config.home.packages = mkIf (config.xdg.desktopEntries != { })
(map hiPrio # we need hiPrio to override existing entries
config = mkIf (config.xdg.desktopEntries != { }) {
assertions = [
(hm.assertions.assertPlatform "xdg.desktopEntries" pkgs platforms.linux)
];
home.packages = (map hiPrio # we need hiPrio to override existing entries
(attrsets.mapAttrsToList makeFile config.xdg.desktopEntries));
};
}

View file

@ -30,7 +30,7 @@ in {
associations.added = mkOption {
type = types.attrsOf strListOrSingleton;
default = { };
example = literalExample ''
example = literalExpression ''
{
"mimetype1" = [ "foo1.desktop" "foo2.desktop" "foo3.desktop" ];
"mimetype2" = "foo4.desktop";
@ -57,7 +57,7 @@ in {
defaultApplications = mkOption {
type = types.attrsOf strListOrSingleton;
default = { };
example = literalExample ''
example = literalExpression ''
{
"mimetype1" = [ "default1.desktop" "default2.desktop" ];
}
@ -73,6 +73,9 @@ in {
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.mimeApps" pkgs platforms.linux) ];
# Deprecated but still used by some applications.
xdg.dataFile."applications/mimeapps.list".source =
config.xdg.configFile."mimeapps.list".source;

View file

@ -10,7 +10,9 @@ in {
options = {
xdg.mime.enable = mkOption {
type = types.bool;
default = true;
default = pkgs.hostPlatform.isLinux;
defaultText =
literalExpression "true if host platform is Linux, false otherwise";
description = ''
Whether to install programs and files to support the
XDG Shared MIME-info specification and XDG MIME Applications
@ -24,6 +26,9 @@ in {
};
config = mkIf config.xdg.mime.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ];
home.packages = [
# Explicitly install package to provide basic mime types.
pkgs.shared-mime-info

View file

@ -17,7 +17,7 @@ in {
config = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExample ''[ "/etc/xdg" ]'';
example = literalExpression ''[ "/etc/xdg" ]'';
description = ''
Directory names to add to <envar>XDG_CONFIG_DIRS</envar>
in the user session.
@ -27,7 +27,7 @@ in {
data = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExample ''[ "/usr/share" "/usr/local/share" ]'';
example = literalExpression ''[ "/usr/share" "/usr/local/share" ]'';
description = ''
Directory names to add to <envar>XDG_DATA_DIRS</envar>
in the user session.
@ -36,6 +36,12 @@ in {
};
config = mkMerge [
(mkIf (cfg.config != [ ] || cfg.data != [ ]) {
assertions = [
(hm.assertions.assertPlatform "xdg.systemDirs" pkgs platforms.linux)
];
})
(mkIf (cfg.config != [ ]) {
home.sessionVariables.XDG_CONFIG_DIRS =
"${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";

View file

@ -103,6 +103,9 @@ in {
XDG_VIDEOS_DIR = cfg.videos;
} // cfg.extraConfig;
in mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.userDirs" pkgs platforms.linux) ];
xdg.configFile."user-dirs.dirs".text = let
# For some reason, these need to be wrapped with quotes to be valid.
wrapped = mapAttrs (_: value: ''"${value}"'') directories;

View file

@ -14,22 +14,20 @@ let
defaultCacheHome = "${config.home.homeDirectory}/.cache";
defaultConfigHome = "${config.home.homeDirectory}/.config";
defaultDataHome = "${config.home.homeDirectory}/.local/share";
defaultStateHome = "${config.home.homeDirectory}/.local/state";
getXdgDir = name: fallback:
let
value = builtins.getEnv name;
in
if value != "" then value else fallback;
getEnvFallback = name: fallback:
let value = builtins.getEnv name;
in if value != "" then value else fallback;
in
{
in {
options.xdg = {
enable = mkEnableOption "management of XDG base directories";
cacheHome = mkOption {
type = types.path;
defaultText = "~/.cache";
apply = toString;
description = ''
Absolute path to directory holding application caches.
'';
@ -37,7 +35,7 @@ in
configFile = mkOption {
type = fileType "<varname>xdg.configHome</varname>" cfg.configHome;
default = {};
default = { };
description = ''
Attribute set of files to link into the user's XDG
configuration home.
@ -47,6 +45,7 @@ in
configHome = mkOption {
type = types.path;
defaultText = "~/.config";
apply = toString;
description = ''
Absolute path to directory holding application configurations.
'';
@ -54,7 +53,7 @@ in
dataFile = mkOption {
type = fileType "<varname>xdg.dataHome</varname>" cfg.dataHome;
default = {};
default = { };
description = ''
Attribute set of files to link into the user's XDG
data home.
@ -64,10 +63,20 @@ in
dataHome = mkOption {
type = types.path;
defaultText = "~/.local/share";
apply = toString;
description = ''
Absolute path to directory holding application data.
'';
};
stateHome = mkOption {
type = types.path;
defaultText = "~/.local/state";
apply = toString;
description = ''
Absolute path to directory holding application states.
'';
};
};
config = mkMerge [
@ -75,19 +84,23 @@ in
xdg.cacheHome = mkDefault defaultCacheHome;
xdg.configHome = mkDefault defaultConfigHome;
xdg.dataHome = mkDefault defaultDataHome;
xdg.stateHome = mkDefault defaultStateHome;
home.sessionVariables = {
XDG_CACHE_HOME = cfg.cacheHome;
XDG_CONFIG_HOME = cfg.configHome;
XDG_DATA_HOME = cfg.dataHome;
XDG_STATE_HOME = cfg.stateHome;
};
})
# Legacy non-deterministic setup.
(mkIf (!cfg.enable && versionOlder config.home.stateVersion "20.09") {
xdg.cacheHome = getXdgDir "XDG_CACHE_HOME" defaultCacheHome;
xdg.configHome = getXdgDir "XDG_CONFIG_HOME" defaultConfigHome;
xdg.dataHome = getXdgDir "XDG_DATA_HOME" defaultDataHome;
xdg.cacheHome =
mkDefault (getEnvFallback "XDG_CACHE_HOME" defaultCacheHome);
xdg.configHome =
mkDefault (getEnvFallback "XDG_CONFIG_HOME" defaultConfigHome);
xdg.dataHome = mkDefault (getEnvFallback "XDG_DATA_HOME" defaultDataHome);
})
# "Modern" deterministic setup.
@ -95,17 +108,16 @@ in
xdg.cacheHome = mkDefault defaultCacheHome;
xdg.configHome = mkDefault defaultConfigHome;
xdg.dataHome = mkDefault defaultDataHome;
xdg.stateHome = mkDefault stateHome;
})
{
home.file = mkMerge [
(mapAttrs'
(name: file: nameValuePair "${config.xdg.configHome}/${name}" file)
(mapAttrs' (name: file: nameValuePair "${cfg.configHome}/${name}" file)
cfg.configFile)
(mapAttrs'
(name: file: nameValuePair "${config.xdg.dataHome}/${name}" file)
(mapAttrs' (name: file: nameValuePair "${cfg.dataHome}/${name}" file)
cfg.dataFile)
{ "${config.xdg.cacheHome}/.keep".text = ""; }
{ "${cfg.cacheHome}/.keep".text = ""; }
];
}
];

View file

@ -1,250 +1,256 @@
{ pkgs
# Note, this should be "the standard library" + HM extensions.
# Note, this should be "the standard library" + HM extensions.
, lib
# Whether to enable module type checking.
# Whether to enable module type checking.
, check ? true
# If disabled, the pkgs attribute passed to this function is used instead.
, useNixpkgsModule ? true
}:
# If disabled, the pkgs attribute passed to this function is used instead.
, useNixpkgsModule ? true }:
with lib;
let
hostPlatform = pkgs.stdenv.hostPlatform;
loadModule = file: { condition ? true }: {
inherit file condition;
};
allModules = [
(loadModule ./accounts/email.nix { })
(loadModule ./config/i18n.nix { condition = hostPlatform.isLinux; })
(loadModule ./files.nix { })
(loadModule ./home-environment.nix { })
(loadModule ./i18n/input-method/default.nix { condition = hostPlatform.isLinux; })
(loadModule ./manual.nix { })
(loadModule ./misc/dconf.nix { })
(loadModule ./misc/debug.nix { })
(loadModule ./misc/fontconfig.nix { })
(loadModule ./misc/gtk.nix { })
(loadModule ./misc/lib.nix { })
(loadModule ./misc/news.nix { })
(loadModule ./misc/nixpkgs.nix { condition = useNixpkgsModule; })
(loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/pam.nix { })
(loadModule ./misc/qt.nix { })
(loadModule ./misc/submodule-support.nix { })
(loadModule ./misc/tmpfiles.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/version.nix { })
(loadModule ./misc/vte.nix { })
(loadModule ./misc/xdg-system-dirs.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-desktop-entries.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-mime.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg.nix { })
(loadModule ./programs/abook.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/afew.nix { })
(loadModule ./programs/alacritty.nix { })
(loadModule ./programs/alot.nix { })
(loadModule ./programs/aria2.nix { })
(loadModule ./programs/astroid.nix { })
(loadModule ./programs/autojump.nix { })
(loadModule ./programs/autorandr.nix { })
(loadModule ./programs/bash.nix { })
(loadModule ./programs/bat.nix { })
(loadModule ./programs/beets.nix { })
(loadModule ./programs/broot.nix { })
(loadModule ./programs/browserpass.nix { })
(loadModule ./programs/chromium.nix { })
(loadModule ./programs/command-not-found/command-not-found.nix { })
(loadModule ./programs/dircolors.nix { })
(loadModule ./programs/direnv.nix { })
(loadModule ./programs/eclipse.nix { })
(loadModule ./programs/emacs.nix { })
(loadModule ./programs/exa.nix { })
(loadModule ./programs/feh.nix { })
(loadModule ./programs/firefox.nix { })
(loadModule ./programs/fish.nix { })
(loadModule ./programs/foot.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/fzf.nix { })
(loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/gh.nix { })
(loadModule ./programs/git.nix { })
(loadModule ./programs/gnome-terminal.nix { })
(loadModule ./programs/go.nix { })
(loadModule ./programs/gpg.nix { })
(loadModule ./programs/himalaya.nix { })
(loadModule ./programs/home-manager.nix { })
(loadModule ./programs/htop.nix { })
(loadModule ./programs/i3status.nix { })
(loadModule ./programs/i3status-rust.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/info.nix { })
(loadModule ./programs/irssi.nix { })
(loadModule ./programs/lieer.nix { })
(loadModule ./programs/jq.nix { })
(loadModule ./programs/kakoune.nix { })
(loadModule ./programs/keychain.nix { })
(loadModule ./programs/kitty.nix { })
(loadModule ./programs/lazygit.nix { })
(loadModule ./programs/lesspipe.nix { })
(loadModule ./programs/lf.nix { })
(loadModule ./programs/lsd.nix { })
(loadModule ./programs/man.nix { })
(loadModule ./programs/mangohud.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/matplotlib.nix { })
(loadModule ./programs/mbsync.nix { })
(loadModule ./programs/mcfly.nix { })
(loadModule ./programs/mercurial.nix { })
(loadModule ./programs/mpv.nix { })
(loadModule ./programs/msmtp.nix { })
(loadModule ./programs/mu.nix { })
(loadModule ./programs/ncmpcpp.nix { })
(loadModule ./programs/ncspot.nix { })
(loadModule ./programs/ne.nix { })
(loadModule ./programs/neomutt.nix { })
(loadModule ./programs/neovim.nix { })
(loadModule ./programs/newsboat.nix { })
(loadModule ./programs/nix-index.nix { })
(loadModule ./programs/noti.nix { })
(loadModule ./programs/notmuch.nix { })
(loadModule ./programs/nushell.nix { })
(loadModule ./programs/obs-studio.nix { })
(loadModule ./programs/octant.nix { })
(loadModule ./programs/offlineimap.nix { })
(loadModule ./programs/opam.nix { })
(loadModule ./programs/password-store.nix { })
(loadModule ./programs/pazi.nix { })
(loadModule ./programs/pet.nix { })
(loadModule ./programs/pidgin.nix { })
(loadModule ./programs/piston-cli.nix { })
(loadModule ./programs/powerline-go.nix { })
(loadModule ./programs/qutebrowser.nix { })
(loadModule ./programs/rbw.nix { })
(loadModule ./programs/readline.nix { })
(loadModule ./programs/rofi.nix { })
(loadModule ./programs/rofi-pass.nix { })
(loadModule ./programs/rtorrent.nix { })
(loadModule ./programs/scmpuff.nix { })
(loadModule ./programs/senpai.nix { })
(loadModule ./programs/skim.nix { })
(loadModule ./programs/starship.nix { })
(loadModule ./programs/sbt.nix { })
(loadModule ./programs/ssh.nix { })
(loadModule ./programs/taskwarrior.nix { })
(loadModule ./programs/termite.nix { })
(loadModule ./programs/texlive.nix { })
(loadModule ./programs/tmux.nix { })
(loadModule ./programs/terminator.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/topgrade.nix { })
(loadModule ./programs/urxvt.nix { })
(loadModule ./programs/vim.nix { })
(loadModule ./programs/vscode.nix { })
(loadModule ./programs/vscode/haskell.nix { })
(loadModule ./programs/waybar.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/xmobar.nix { })
(loadModule ./programs/z-lua.nix { })
(loadModule ./programs/zathura.nix { })
(loadModule ./programs/zoxide.nix { })
(loadModule ./programs/zplug.nix { })
(loadModule ./programs/zsh.nix { })
(loadModule ./programs/zsh/prezto.nix { })
(loadModule ./services/barrier.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/blueman-applet.nix { })
(loadModule ./services/caffeine.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/cbatticon.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/clipmenu.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/compton.nix { })
(loadModule ./services/dropbox.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/dunst.nix { })
(loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/etesync-dav.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/flameshot.nix { })
(loadModule ./services/fluidsynth.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/redshift-gammastep/gammastep.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/gnome-keyring.nix { })
(loadModule ./services/gpg-agent.nix { })
(loadModule ./services/grobi.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/hound.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/kanshi.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/kbfs.nix { })
(loadModule ./services/kdeconnect.nix { })
(loadModule ./services/keepassx.nix { })
(loadModule ./services/keybase.nix { })
(loadModule ./services/keynav.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/lieer.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/lorri.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/mako.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/mbsync.nix { })
(loadModule ./services/mpd.nix { })
(loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/mpris-proxy.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/muchsync.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/network-manager-applet.nix { })
(loadModule ./services/nextcloud-client.nix { })
(loadModule ./services/owncloud-client.nix { })
(loadModule ./services/pantalaimon.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/parcellite.nix { })
(loadModule ./services/pass-secret-service.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/password-store-sync.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/pasystray.nix { })
(loadModule ./services/pbgopy.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/picom.nix { })
(loadModule ./services/plan9port.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/playerctld.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/polybar.nix { })
(loadModule ./services/poweralertd.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/random-background.nix { })
(loadModule ./services/redshift-gammastep/redshift.nix { })
(loadModule ./services/rsibreak.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/screen-locker.nix { })
(loadModule ./services/stalonetray.nix { })
(loadModule ./services/status-notifier-watcher.nix { })
(loadModule ./services/spotifyd.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/sxhkd.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/syncthing.nix { })
(loadModule ./services/taffybar.nix { })
(loadModule ./services/tahoe-lafs.nix { })
(loadModule ./services/taskwarrior-sync.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/udiskie.nix { })
(loadModule ./services/unclutter.nix { })
(loadModule ./services/unison.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/window-managers/awesome.nix { })
(loadModule ./services/window-managers/bspwm/default.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/window-managers/i3-sway/i3.nix { })
(loadModule ./services/window-managers/i3-sway/sway.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/window-managers/xmonad.nix { })
(loadModule ./services/wlsunset.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/xidlehook.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/xscreensaver.nix { })
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
(loadModule ./systemd.nix { })
(loadModule ./targets/darwin { condition = hostPlatform.isDarwin; })
(loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; })
(loadModule ./xcursor.nix { })
(loadModule ./xresources.nix { })
(loadModule ./xsession.nix { })
(loadModule (pkgs.path + "/nixos/modules/misc/assertions.nix") { })
(loadModule (pkgs.path + "/nixos/modules/misc/meta.nix") { })
];
modules = map (getAttr "file") (filter (getAttr "condition") allModules);
modules = [
./accounts/email.nix
./config/i18n.nix
./files.nix
./home-environment.nix
./i18n/input-method/default.nix
./manual.nix
./misc/dconf.nix
./misc/debug.nix
./misc/fontconfig.nix
./misc/gtk.nix
./misc/lib.nix
./misc/news.nix
./misc/numlock.nix
./misc/pam.nix
./misc/qt.nix
./misc/submodule-support.nix
./misc/tmpfiles.nix
./misc/version.nix
./misc/vte.nix
./misc/xdg-desktop-entries.nix
./misc/xdg-mime-apps.nix
./misc/xdg-mime.nix
./misc/xdg-system-dirs.nix
./misc/xdg-user-dirs.nix
./misc/xdg.nix
./programs/abook.nix
./programs/afew.nix
./programs/alacritty.nix
./programs/alot.nix
./programs/aria2.nix
./programs/astroid.nix
./programs/atuin.nix
./programs/autojump.nix
./programs/autorandr.nix
./programs/bash.nix
./programs/bat.nix
./programs/beets.nix
./programs/bottom.nix
./programs/broot.nix
./programs/browserpass.nix
./programs/chromium.nix
./programs/command-not-found/command-not-found.nix
./programs/dircolors.nix
./programs/direnv.nix
./programs/eclipse.nix
./programs/emacs.nix
./programs/exa.nix
./programs/feh.nix
./programs/firefox.nix
./programs/fish.nix
./programs/foot.nix
./programs/fzf.nix
./programs/getmail.nix
./programs/gh.nix
./programs/git.nix
./programs/gnome-terminal.nix
./programs/go.nix
./programs/gpg.nix
./programs/hexchat.nix
./programs/himalaya.nix
./programs/home-manager.nix
./programs/htop.nix
./programs/i3status-rust.nix
./programs/i3status.nix
./programs/info.nix
./programs/irssi.nix
./programs/java.nix
./programs/jq.nix
./programs/kakoune.nix
./programs/keychain.nix
./programs/kitty.nix
./programs/lazygit.nix
./programs/lesspipe.nix
./programs/lf.nix
./programs/lieer.nix
./programs/lsd.nix
./programs/man.nix
./programs/mangohud.nix
./programs/matplotlib.nix
./programs/mbsync.nix
./programs/mcfly.nix
./programs/mercurial.nix
./programs/mpv.nix
./programs/msmtp.nix
./programs/mu.nix
./programs/ncmpcpp.nix
./programs/ncspot.nix
./programs/ne.nix
./programs/neomutt.nix
./programs/neovim.nix
./programs/newsboat.nix
./programs/nix-index.nix
./programs/nnn.nix
./programs/noti.nix
./programs/notmuch.nix
./programs/nushell.nix
./programs/obs-studio.nix
./programs/octant.nix
./programs/offlineimap.nix
./programs/opam.nix
./programs/password-store.nix
./programs/pazi.nix
./programs/pet.nix
./programs/pidgin.nix
./programs/piston-cli.nix
./programs/powerline-go.nix
./programs/qutebrowser.nix
./programs/rbw.nix
./programs/readline.nix
./programs/rofi-pass.nix
./programs/rofi.nix
./programs/rtorrent.nix
./programs/sbt.nix
./programs/scmpuff.nix
./programs/senpai.nix
./programs/skim.nix
./programs/sm64ex.nix
./programs/ssh.nix
./programs/starship.nix
./programs/taskwarrior.nix
./programs/terminator.nix
./programs/termite.nix
./programs/texlive.nix
./programs/tmux.nix
./programs/topgrade.nix
./programs/urxvt.nix
./programs/vim.nix
./programs/vscode.nix
./programs/vscode/haskell.nix
./programs/waybar.nix
./programs/xmobar.nix
./programs/z-lua.nix
./programs/zathura.nix
./programs/zoxide.nix
./programs/zplug.nix
./programs/zsh.nix
./programs/zsh/prezto.nix
./services/barrier.nix
./services/betterlockscreen.nix
./services/blueman-applet.nix
./services/caffeine.nix
./services/cbatticon.nix
./services/clipmenu.nix
./services/compton.nix
./services/devilspie2.nix
./services/dropbox.nix
./services/dunst.nix
./services/dwm-status.nix
./services/easyeffects.nix
./services/emacs.nix
./services/etesync-dav.nix
./services/flameshot.nix
./services/fluidsynth.nix
./services/fnott.nix
./services/getmail.nix
./services/git-sync.nix
./services/gnome-keyring.nix
./services/gpg-agent.nix
./services/grobi.nix
./services/hound.nix
./services/imapnotify.nix
./services/kanshi.nix
./services/kbfs.nix
./services/kdeconnect.nix
./services/keepassx.nix
./services/keybase.nix
./services/keynav.nix
./services/lieer.nix
./services/lorri.nix
./services/mako.nix
./services/mbsync.nix
./services/mpd.nix
./services/mpdris2.nix
./services/mpris-proxy.nix
./services/muchsync.nix
./services/network-manager-applet.nix
./services/nextcloud-client.nix
./services/notify-osd.nix
./services/owncloud-client.nix
./services/pantalaimon.nix
./services/parcellite.nix
./services/pass-secret-service.nix
./services/password-store-sync.nix
./services/pasystray.nix
./services/pbgopy.nix
./services/picom.nix
./services/plan9port.nix
./services/playerctld.nix
./services/polybar.nix
./services/poweralertd.nix
./services/pulseeffects.nix
./services/random-background.nix
./services/redshift-gammastep/gammastep.nix
./services/redshift-gammastep/redshift.nix
./services/rsibreak.nix
./services/screen-locker.nix
./services/spotifyd.nix
./services/stalonetray.nix
./services/status-notifier-watcher.nix
./services/sxhkd.nix
./services/syncthing.nix
./services/taffybar.nix
./services/tahoe-lafs.nix
./services/taskwarrior-sync.nix
./services/trayer.nix
./services/udiskie.nix
./services/unclutter.nix
./services/unison.nix
./services/volnoti.nix
./services/window-managers/awesome.nix
./services/window-managers/bspwm/default.nix
./services/window-managers/i3-sway/i3.nix
./services/window-managers/i3-sway/sway.nix
./services/window-managers/xmonad.nix
./services/wlsunset.nix
./services/xcape.nix
./services/xembed-sni-proxy.nix
./services/xidlehook.nix
./services/xscreensaver.nix
./services/xsettingsd.nix
./services/xsuspender.nix
./systemd.nix
./targets/darwin
./targets/generic-linux.nix
./xcursor.nix
./xresources.nix
./xsession.nix
(pkgs.path + "/nixos/modules/misc/assertions.nix")
(pkgs.path + "/nixos/modules/misc/meta.nix")
] ++ optional useNixpkgsModule ./misc/nixpkgs.nix
++ optional (!useNixpkgsModule) ./misc/nixpkgs-disabled.nix;
pkgsModule = { config, ... }: {
config = {
_module.args.baseModules = modules;
_module.args.pkgsPath = lib.mkDefault (
if versionAtLeast config.home.stateVersion "20.09" then
_module.args.pkgsPath = lib.mkDefault
(if versionAtLeast config.home.stateVersion "20.09" then
pkgs.path
else
<nixpkgs>);
@ -252,10 +258,8 @@ let
_module.check = check;
lib = lib.hm;
} // optionalAttrs useNixpkgsModule {
nixpkgs.system = mkDefault pkgs.system;
nixpkgs.system = mkDefault pkgs.stdenv.hostPlatform.system;
};
};
in
modules ++ [ pkgsModule ]
in modules ++ [ pkgsModule ]

View file

@ -27,7 +27,11 @@ in {
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.abook" pkgs platforms.linux) ];
home.packages = [ pkgs.abook ];
xdg.configFile."abook/abookrc" = mkIf (cfg.extraConfig != "") {
text = ''
# Generated by Home Manager.

View file

@ -13,14 +13,14 @@ in {
package = mkOption {
type = types.package;
default = pkgs.alacritty;
defaultText = literalExample "pkgs.alacritty";
defaultText = literalExpression "pkgs.alacritty";
description = "The Alacritty package to install.";
};
settings = mkOption {
type = yamlFormat.type;
default = { };
example = literalExample ''
example = literalExpression ''
{
window.dimensions = {
lines = 3;

View file

@ -25,7 +25,7 @@ with lib;
+ "}[,\\]]?'";
shellcommand_external_filtering = "False";
};
example = literalExample ''
example = literalExpression ''
{
type = "shellcommand";
command = "abook --mutt-query";

View file

@ -200,7 +200,7 @@ in {
handle_mouse = true;
prefer_plaintext = true;
};
example = literalExample ''
example = literalExpression ''
{
auto_remove_unread = true;
ask_subject = false;

View file

@ -31,7 +31,7 @@ in {
</citerefentry>
for options.
'';
example = literalExample ''
example = literalExpression ''
{
listen-port = 60000;
dht-listen-port = 60000;

View file

@ -22,9 +22,9 @@ let
sendmail = astroid.sendMailCommand;
additional_sent_tags = "";
default = boolOpt primary;
save_drafts_to = "${maildir.absPath}/${folders.drafts}";
save_drafts_to = "${maildir.absPath}/${folders.drafts}/cur/";
save_sent = "true";
save_sent_to = "${maildir.absPath}/${folders.sent}";
save_sent_to = "${maildir.absPath}/${folders.sent}/cur/";
select_query = "";
} // optionalAttrs (signature.showSignature != "none") {
signature_attach = boolOpt (signature.showSignature == "attach");
@ -93,7 +93,7 @@ in {
extraConfig = mkOption {
type = jsonFormat.type;
default = { };
example = literalExample ''
example = literalExpression ''
{
poll.interval = 0;
}

View file

@ -0,0 +1,90 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.atuin;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ maintainers.hawkw ];
options.programs.atuin = {
enable = mkEnableOption "atuin";
package = mkOption {
type = types.package;
default = pkgs.atuin;
defaultText = literalExpression "pkgs.atuin";
description = "The package to use for atuin.";
};
enableBashIntegration = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Atuin's Bash integration. This will bind
<literal>ctrl-r</literal> to open the Atuin history.
'';
};
enableZshIntegration = mkEnableOption "Zsh integration" // {
default = true;
description = ''
Whether to enable Atuin's Zsh integration.
</para><para>
If enabled, this will bind <literal>ctrl-r</literal> and the up-arrow
key to open the Atuin history.
'';
};
settings = mkOption {
type = with types;
let
prim = oneOf [ bool int str ];
primOrPrimAttrs = either prim (attrsOf prim);
entry = either prim (listOf primOrPrimAttrs);
entryOrAttrsOf = t: either entry (attrsOf t);
entries = entryOrAttrsOf (entryOrAttrsOf entry);
in attrsOf entries // { description = "Atuin configuration"; };
default = { };
example = literalExpression ''
{
auto_sync = true;
sync_frequency = "5m";
sync_address = "https://api.atuin.sh";
search_mode = "prefix";
}
'';
description = ''
Configuration written to
<filename>~/.config/atuin/config.toml</filename>.
</para><para>
See <link xlink:href="https://github.com/ellie/atuin/blob/main/docs/config.md" /> for the full list
of options.
'';
};
};
config = mkIf cfg.enable {
# Always add the configured `atuin` package.
home.packages = [ cfg.package ];
# If there are user-provided settings, generate the config file.
xdg.configFile."atuin/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "atuin-config" cfg.settings;
};
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh"
eval "$(${cfg.package}/bin/atuin init bash)"
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${cfg.package}/bin/atuin init zsh)"
'';
};
}

View file

@ -49,7 +49,7 @@ in {
. ${package}/share/autojump/autojump.zsh
'';
programs.fish.promptInit = mkIf cfg.enableFishIntegration ''
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
. ${package}/share/autojump/autojump.fish
'';
};

View file

@ -106,7 +106,7 @@ let
transform = mkOption {
type = types.nullOr (matrixOf 3 3 types.float);
default = null;
example = literalExample ''
example = literalExpression ''
[
[ 0.6 0.0 0.0 ]
[ 0.0 0.6 0.0 ]
@ -169,7 +169,7 @@ let
exclusive.
'';
default = null;
example = literalExample ''
example = literalExpression ''
{
x = 1.25;
y = 1.25;
@ -280,7 +280,7 @@ in {
type = globalHooksModule;
description = "Global hook scripts";
default = { };
example = literalExample ''
example = literalExpression ''
{
postswitch = {
"notify-i3" = "''${pkgs.i3}/bin/i3-msg restart";
@ -312,7 +312,7 @@ in {
type = types.attrsOf profileModule;
description = "Autorandr profiles specification.";
default = { };
example = literalExample ''
example = literalExpression ''
{
"work" = {
fingerprint = {

View file

@ -75,7 +75,14 @@ in
# Warn if closing shell with running jobs.
"checkjobs"
];
description = "Shell options to set.";
example = [
"extglob"
"-cdspell"
];
description = ''
Shell options to set. Prefix an option with
<quote><literal>-</literal></quote> to unset.
'';
};
sessionVariables = mkOption {
@ -90,7 +97,7 @@ in
shellAliases = mkOption {
default = {};
type = types.attrsOf types.str;
example = literalExample ''
example = literalExpression ''
{
ll = "ls -l";
".." = "cd ..";
@ -146,8 +153,10 @@ in
mapAttrsToList (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
);
shoptsStr = concatStringsSep "\n" (
map (v: "shopt -s ${v}") cfg.shellOptions
shoptsStr = let
switch = v: if hasPrefix "-" v then "-u" else "-s";
in concatStringsSep "\n" (
map (v: "shopt ${switch v} ${removePrefix "-" v}") cfg.shellOptions
);
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;

View file

@ -6,6 +6,11 @@ let
cfg = config.programs.bat;
toConfigFile = generators.toKeyValue {
mkKeyValue = k: v: "--${k}=${lib.escapeShellArg v}";
listsAsDuplicateKeys = true;
};
in {
meta.maintainers = [ maintainers.marsam ];
@ -13,11 +18,12 @@ in {
enable = mkEnableOption "bat, a cat clone with wings";
config = mkOption {
type = types.attrsOf types.str;
type = with types; attrsOf (either str (listOf str));
default = { };
example = {
theme = "TwoDark";
pager = "less -FR";
map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ];
};
description = ''
Bat configuration.
@ -27,7 +33,7 @@ in {
themes = mkOption {
type = types.attrsOf types.lines;
default = { };
example = literalExample ''
example = literalExpression ''
{
dracula = builtins.readFile (pkgs.fetchFromGitHub {
owner = "dracula";
@ -48,10 +54,8 @@ in {
home.packages = [ pkgs.bat ];
xdg.configFile = mkMerge ([{
"bat/config" = mkIf (cfg.config != { }) {
text = concatStringsSep "\n"
(mapAttrsToList (n: v: ''--${n}="${v}"'') cfg.config);
};
"bat/config" =
mkIf (cfg.config != { }) { text = toConfigFile cfg.config; };
}] ++ flip mapAttrsToList cfg.themes
(name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; }));
};

View file

@ -31,9 +31,9 @@ in {
package = mkOption {
type = types.package;
default = pkgs.beets;
defaultText = literalExample "pkgs.beets";
defaultText = literalExpression "pkgs.beets";
example =
literalExample "(pkgs.beets.override { enableCheck = true; })";
literalExpression "(pkgs.beets.override { enableCheck = true; })";
description = ''
The <literal>beets</literal> package to use.
Can be used to specify extensions.

View file

@ -0,0 +1,66 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.bottom;
tomlFormat = pkgs.formats.toml { };
configDir = if pkgs.stdenv.isDarwin then
"Library/Application Support"
else
config.xdg.configHome;
in {
options = {
programs.bottom = {
enable = mkEnableOption ''
bottom, a cross-platform graphical process/system monitor with a
customizable interface'';
package = mkOption {
type = types.package;
default = pkgs.bottom;
defaultText = literalExpression "pkgs.bottom";
description = "Package providing <command>bottom</command>.";
};
settings = mkOption {
type = tomlFormat.type;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/bottom/bottom.toml</filename> on Linux or
<filename>$HOME/Library/Application Support/bottom/bottom.toml</filename> on Darwin.
</para><para>
See <link xlink:href="https://github.com/ClementTsang/bottom/blob/master/sample_configs/default_config.toml"/>
for the default configuration.
'';
example = literalExpression ''
{
flags = {
avg_cpu = true;
temperature_type = "c";
};
colors = {
low_battery_color = "red";
};
}
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file."${configDir}/bottom/bottom.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "bottom.toml" cfg.settings;
};
};
meta.maintainers = [ maintainers.polykernel ];
}

View file

@ -11,6 +11,7 @@ let
brootConf = {
verbs = cfg.verbs;
skin = cfg.skin;
modal = cfg.modal;
};
in {
@ -43,6 +44,8 @@ in {
'';
};
modal = mkEnableOption "modal (vim) mode";
verbs = mkOption {
type = with types; listOf (attrsOf (either bool str));
default = [
@ -64,7 +67,7 @@ in {
execution = "less {file}";
}
];
example = literalExample ''
example = literalExpression ''
[
{ invocation = "p"; execution = ":parent"; }
{ invocation = "edit"; shortcut = "e"; execution = "$EDITOR {file}" ; }
@ -121,14 +124,14 @@ in {
package = mkOption {
type = types.package;
default = pkgs.broot;
defaultText = literalExample "pkgs.broot";
defaultText = literalExpression "pkgs.broot";
description = "Package providing broot";
};
skin = mkOption {
type = types.attrsOf types.str;
default = { };
example = literalExample ''
example = literalExpression ''
{
status_normal_fg = "grayscale(18)";
status_normal_bg = "grayscale(3)";

View file

@ -21,7 +21,7 @@ let
inherit visible;
type = types.package;
default = defaultPkg;
defaultText = literalExample "pkgs.${browser}";
defaultText = literalExpression "pkgs.${browser}";
description = "The ${name} package to use.";
};
} // optionalAttrs (!isProprietaryChrome) {
@ -72,7 +72,7 @@ let
};
in listOf (coercedTo str (v: { id = v; }) extensionType);
default = [ ];
example = literalExample ''
example = literalExpression ''
[
{ id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin
{
@ -114,10 +114,12 @@ let
brave = "BraveSoftware/Brave-Browser";
};
linuxDirs = { brave = "BraveSoftware/Brave-Browser"; };
configDir = if pkgs.stdenv.isDarwin then
"Library/Application Support/${getAttr browser darwinDirs}"
"Library/Application Support/" + (darwinDirs."${browser}" or browser)
else
"${config.xdg.configHome}/${browser}";
"${config.xdg.configHome}/" + (linuxDirs."${browser}" or browser);
extensionJson = ext:
assert ext.crxPath != null -> ext.version != null;

View file

@ -51,7 +51,7 @@ in {
See <command>dircolors --print-database</command>
for options.
'';
example = literalExample ''
example = literalExpression ''
{
OTHER_WRITABLE = "30;46";
".sh" = "01;32";

View file

@ -66,8 +66,11 @@ in {
enableFishIntegration = mkOption {
default = true;
type = types.bool;
readOnly = true;
description = ''
Whether to enable Fish integration.
Whether to enable Fish integration. Note, enabling the direnv module
will always active its functionality for Fish since the direnv package
automatically gets loaded in Fish.
'';
};
@ -106,9 +109,5 @@ in {
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
'';
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
${pkgs.direnv}/bin/direnv hook fish | source
'';
};
}

View file

@ -16,8 +16,8 @@ in {
package = mkOption {
type = types.package;
default = pkgs.eclipses.eclipse-platform;
defaultText = literalExample "pkgs.eclipses.eclipse-platform";
example = literalExample "pkgs.eclipses.eclipse-java";
defaultText = literalExpression "pkgs.eclipses.eclipse-platform";
example = literalExpression "pkgs.eclipses.eclipse-java";
description = ''
The Eclipse package to install.
'';

View file

@ -13,6 +13,12 @@ let
emacsWithPackages = emacsPackages.emacsWithPackages;
createConfPackage = epkgs:
epkgs.trivialBuild {
pname = "default";
src = pkgs.writeText "default.el" cfg.extraConfig;
};
in {
meta.maintainers = [ maintainers.rycee ];
@ -23,16 +29,33 @@ in {
package = mkOption {
type = types.package;
default = pkgs.emacs;
defaultText = literalExample "pkgs.emacs";
example = literalExample "pkgs.emacs25-nox";
defaultText = literalExpression "pkgs.emacs";
example = literalExpression "pkgs.emacs25-nox";
description = "The Emacs package to use.";
};
# NOTE: The config is placed in default.el instead of ~/.emacs.d so that
# it won't conflict with Emacs configuration frameworks. Users of these
# frameworks would still benefit from this option as it would easily allow
# them to have Nix-computed paths in their configuration.
extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
(setq standard-indent 2)
'';
description = ''
Configuration to include in the Emacs default init file. See
<link xlink:href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html"/>
for more.
'';
};
extraPackages = mkOption {
default = self: [ ];
type = hm.types.selectorFunction;
defaultText = "epkgs: []";
example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]";
example = literalExpression "epkgs: [ epkgs.emms epkgs.magit ]";
description = ''
Extra packages available to Emacs. To get a list of
available packages run:
@ -44,7 +67,7 @@ in {
default = self: super: { };
type = hm.types.overlayFunction;
defaultText = "self: super: {}";
example = literalExample ''
example = literalExpression ''
self: super: rec {
haskell-mode = self.melpaPackages.haskell-mode;
# ...
@ -68,6 +91,10 @@ in {
config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages;
programs.emacs = {
finalPackage = emacsWithPackages cfg.extraPackages;
extraPackages = epkgs:
optional (cfg.extraConfig != "") (createConfPackage epkgs);
};
};
}

View file

@ -9,19 +9,15 @@ let
cfg = config.programs.firefox;
mozillaConfigPath =
if isDarwin
then "Library/Application Support/Mozilla"
else ".mozilla";
if isDarwin then "Library/Application Support/Mozilla" else ".mozilla";
firefoxConfigPath =
if isDarwin
then "Library/Application Support/Firefox"
else "${mozillaConfigPath}/firefox";
firefoxConfigPath = if isDarwin then
"Library/Application Support/Firefox"
else
"${mozillaConfigPath}/firefox";
profilesPath =
if isDarwin
then "${firefoxConfigPath}/Profiles"
else firefoxConfigPath;
if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath;
# The extensions path shared by all profiles; will not be supported
# by future Firefox versions.
@ -32,46 +28,72 @@ let
paths = cfg.extensions;
};
profiles =
flip mapAttrs' cfg.profiles (_: profile:
profiles = flip mapAttrs' cfg.profiles (_: profile:
nameValuePair "Profile${toString profile.id}" {
Name = profile.name;
Path =
if isDarwin
then "Profiles/${profile.path}"
else profile.path;
Path = if isDarwin then "Profiles/${profile.path}" else profile.path;
IsRelative = 1;
Default = if profile.isDefault then 1 else 0;
}
) // {
General = {
StartWithLastProfile = 1;
};
}) // {
General = { StartWithLastProfile = 1; };
};
profilesIni = generators.toINI {} profiles;
profilesIni = generators.toINI { } profiles;
mkUserJs = prefs: extraPrefs: ''
mkUserJs = prefs: extraPrefs: bookmarks:
let
prefs' = lib.optionalAttrs ({ } != bookmarks) {
"browser.bookmarks.file" = toString (firefoxBookmarksFile bookmarks);
"browser.places.importBookmarksHTML" = true;
} // prefs;
in ''
// Generated by Home Manager.
${concatStrings (mapAttrsToList (name: value: ''
user_pref("${name}", ${builtins.toJSON value});
'') prefs)}
'') prefs')}
${extraPrefs}
'';
in
firefoxBookmarksFile = bookmarks:
let
escapeXML = replaceStrings [ ''"'' "'" "<" ">" "&" ] [
"&quot;"
"&apos;"
"&lt;"
"&gt;"
"&amp;"
];
mapper = _: entry: ''
<DT><A HREF="${escapeXML entry.url}" ADD_DATE="0" LAST_MODIFIED="0"${
lib.optionalString (entry.keyword != null)
" SHORTCUTURL=\"${escapeXML entry.keyword}\""
}>${escapeXML entry.name}</A>
'';
bookmarksEntries = lib.attrsets.mapAttrsToList mapper bookmarks;
in pkgs.writeText "firefox-bookmarks.html" ''
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
<DL><p>
${concatStrings bookmarksEntries}
</p></DL>
'';
{
in {
meta.maintainers = [ maintainers.rycee ];
imports = [
(mkRemovedOptionModule ["programs" "firefox" "enableAdobeFlash"]
(mkRemovedOptionModule [ "programs" "firefox" "enableAdobeFlash" ]
"Support for this option has been removed.")
(mkRemovedOptionModule ["programs" "firefox" "enableGoogleTalk"]
(mkRemovedOptionModule [ "programs" "firefox" "enableGoogleTalk" ]
"Support for this option has been removed.")
(mkRemovedOptionModule ["programs" "firefox" "enableIcedTea"]
(mkRemovedOptionModule [ "programs" "firefox" "enableIcedTea" ]
"Support for this option has been removed.")
];
@ -81,12 +103,12 @@ in
package = mkOption {
type = types.package;
default =
if versionAtLeast config.home.stateVersion "19.09"
then pkgs.firefox
else pkgs.firefox-unwrapped;
defaultText = literalExample "pkgs.firefox";
example = literalExample ''
default = if versionAtLeast config.home.stateVersion "19.09" then
pkgs.firefox
else
pkgs.firefox-unwrapped;
defaultText = literalExpression "pkgs.firefox";
example = literalExpression ''
pkgs.firefox.override {
# See nixpkgs' firefox/wrapper.nix to check which options you can use
cfg = {
@ -106,8 +128,8 @@ in
extensions = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample ''
default = [ ];
example = literalExpression ''
with pkgs.nur.repos.rycee.firefox-addons; [
https-everywhere
privacy-badger
@ -141,7 +163,7 @@ in
};
profiles = mkOption {
type = types.attrsOf (types.submodule ({config, name, ...}: {
type = types.attrsOf (types.submodule ({ config, name, ... }: {
options = {
name = mkOption {
type = types.str;
@ -159,8 +181,8 @@ in
settings = mkOption {
type = with types; attrsOf (either bool (either int str));
default = {};
example = literalExample ''
default = { };
example = literalExpression ''
{
"browser.startup.homepage" = "https://nixos.org";
"browser.search.region" = "GB";
@ -210,6 +232,45 @@ in
'';
};
bookmarks = mkOption {
type = types.attrsOf (types.submodule ({ config, name, ... }: {
options = {
name = mkOption {
type = types.str;
default = name;
description = "Bookmark name.";
};
keyword = mkOption {
type = types.nullOr types.str;
default = null;
description = "Bookmark search keyword.";
};
url = mkOption {
type = types.str;
description = "Bookmark url, use %s for search terms.";
};
};
}));
default = { };
example = literalExpression ''
{
wikipedia = {
keyword = "wiki";
url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
};
"kernel.org" = {
url = "https://www.kernel.org";
};
}
'';
description = ''
Preloaded bookmarks. Note, this may silently overwrite any
previously existing bookmarks!
'';
};
path = mkOption {
type = types.str;
default = name;
@ -224,7 +285,7 @@ in
};
};
}));
default = {};
default = { };
description = "Attribute set of Firefox profiles.";
};
@ -243,36 +304,27 @@ in
config = mkIf cfg.enable {
assertions = [
(
let
(let
defaults =
catAttrs "name" (filter (a: a.isDefault) (attrValues cfg.profiles));
in {
assertion = cfg.profiles == {} || length defaults == 1;
message =
"Must have exactly one default Firefox profile but found "
+ toString (length defaults)
+ optionalString (length defaults > 1)
assertion = cfg.profiles == { } || length defaults == 1;
message = "Must have exactly one default Firefox profile but found "
+ toString (length defaults) + optionalString (length defaults > 1)
(", namely " + concatStringsSep ", " defaults);
}
)
})
(
let
duplicates =
filterAttrs (_: v: length v != 1)
(zipAttrs
(mapAttrsToList (n: v: { "${toString v.id}" = n; })
(cfg.profiles)));
(let
duplicates = filterAttrs (_: v: length v != 1) (zipAttrs
(mapAttrsToList (n: v: { "${toString v.id}" = n; }) (cfg.profiles)));
mkMsg = n: v: " - ID ${n} is used by ${concatStringsSep ", " v}";
in {
assertion = duplicates == {};
message =
"Must not have Firefox profiles with duplicate IDs but\n"
+ concatStringsSep "\n" (mapAttrsToList mkMsg duplicates);
}
)
assertion = duplicates == { };
message = ''
Must not have Firefox profiles with duplicate IDs but
'' + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates);
})
];
warnings = optional (cfg.enableGnomeExtensions or false) ''
@ -282,65 +334,54 @@ in
its example for how to do this.
'';
home.packages =
let
home.packages = let
# The configuration expected by the Firefox wrapper.
fcfg = {
enableGnomeExtensions = cfg.enableGnomeExtensions;
};
fcfg = { enableGnomeExtensions = cfg.enableGnomeExtensions; };
# A bit of hackery to force a config into the wrapper.
browserName = cfg.package.browserName
or (builtins.parseDrvName cfg.package.name).name;
browserName = cfg.package.browserName or (builtins.parseDrvName
cfg.package.name).name;
# The configuration expected by the Firefox wrapper builder.
bcfg = setAttrByPath [browserName] fcfg;
bcfg = setAttrByPath [ browserName ] fcfg;
package =
if isDarwin then
package = if isDarwin then
cfg.package
else if versionAtLeast config.home.stateVersion "19.09" then
cfg.package.override (old: { cfg = old.cfg or {} // fcfg; })
cfg.package.override (old: { cfg = old.cfg or { } // fcfg; })
else
(pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { };
in
[ package ];
in [ package ];
home.file = mkMerge (
[{
"${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != []) {
home.file = mkMerge ([{
"${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != [ ]) {
source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}";
recursive = true;
};
"${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != {}) {
text = profilesIni;
};
}]
++ flip mapAttrsToList cfg.profiles (_: profile: {
"${firefoxConfigPath}/profiles.ini" =
mkIf (cfg.profiles != { }) { text = profilesIni; };
}] ++ flip mapAttrsToList cfg.profiles (_: profile: {
"${profilesPath}/${profile.path}/.keep".text = "";
"${profilesPath}/${profile.path}/chrome/userChrome.css" =
mkIf (profile.userChrome != "") {
text = profile.userChrome;
};
mkIf (profile.userChrome != "") { text = profile.userChrome; };
"${profilesPath}/${profile.path}/chrome/userContent.css" =
mkIf (profile.userContent != "") {
text = profile.userContent;
};
mkIf (profile.userContent != "") { text = profile.userContent; };
"${profilesPath}/${profile.path}/user.js" =
mkIf (profile.settings != {} || profile.extraConfig != "") {
text = mkUserJs profile.settings profile.extraConfig;
mkIf (profile.settings != { } || profile.extraConfig != "") {
text =
mkUserJs profile.settings profile.extraConfig profile.bookmarks;
};
"${profilesPath}/${profile.path}/extensions" = mkIf (cfg.extensions != []) {
"${profilesPath}/${profile.path}/extensions" =
mkIf (cfg.extensions != [ ]) {
source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}";
recursive = true;
force = true;
};
})
);
}));
};
}

View file

@ -146,6 +146,16 @@ let
(mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases);
in {
imports = [
(mkRemovedOptionModule [ "programs" "fish" "promptInit" ] ''
Prompt is now configured through the
programs.fish.interactiveShellInit
option. Please change to use that instead.
'')
];
options = {
programs.fish = {
enable = mkEnableOption "fish, the friendly interactive shell";
@ -153,7 +163,7 @@ in {
package = mkOption {
type = types.package;
default = pkgs.fish;
defaultText = literalExample "pkgs.fish";
defaultText = literalExpression "pkgs.fish";
description = ''
The fish package to install. May be used to change the version.
'';
@ -162,10 +172,10 @@ in {
shellAliases = mkOption {
type = with types; attrsOf str;
default = { };
example = literalExample ''
example = literalExpression ''
{
ll = "ls -l";
".." = "cd ..";
g = "git";
"..." = "cd ../..";
}
'';
description = ''
@ -214,20 +224,12 @@ in {
initialisation.
'';
};
promptInit = mkOption {
type = types.lines;
default = "";
description = ''
Shell script code used to initialise fish prompt.
'';
};
};
programs.fish.plugins = mkOption {
type = types.listOf pluginModule;
default = [ ];
example = literalExample ''
example = literalExpression ''
[
{
name = "z";
@ -261,7 +263,7 @@ in {
programs.fish.functions = mkOption {
type = with types; attrsOf (either lines functionModule);
default = { };
example = literalExample ''
example = literalExpression ''
{
__fish_command_not_found_handler = {
body = "__fish_default_command_not_found_handler $argv[1]";
@ -340,41 +342,24 @@ in {
# ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated
# automatically by home-manager.
# if we haven't sourced the general config, do it
if not set -q __fish_general_config_sourced
# Only execute this file once per shell.
set -q __fish_home_manager_config_sourced; and exit
set -g __fish_home_manager_config_sourced 1
set --prepend fish_function_path ${
if pkgs ? fishPlugins && pkgs.fishPlugins ? foreign-env then
"${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d"
else
"${pkgs.fish-foreign-env}/share/fish-foreign-env/functions"
}
set --prepend fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d
fenv source ${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh > /dev/null
set -e fish_function_path[1]
${cfg.shellInit}
# and leave a note so we don't source this config section again from
# this very shell (children will source the general config anew)
set -g __fish_general_config_sourced 1
end
# if we haven't sourced the login config, do it
status --is-login; and not set -q __fish_login_config_sourced
and begin
status --is-login; and begin
# Login shell initialisation
${cfg.loginShellInit}
# and leave a note so we don't source this config section again from
# this very shell (children will source the general config anew)
set -g __fish_login_config_sourced 1
end
# if we haven't sourced the interactive config, do it
status --is-interactive; and not set -q __fish_interactive_config_sourced
and begin
status --is-interactive; and begin
# Abbreviations
${abbrsStr}
@ -382,17 +367,9 @@ in {
# Aliases
${aliasesStr}
# Prompt initialisation
${cfg.promptInit}
# Interactive shell intialisation
${cfg.interactiveShellInit}
# and leave a note so we don't source this config section again from
# this very shell (children will source the general config anew,
# allowing configuration changes in, e.g, aliases, to propagate)
set -g __fish_interactive_config_sourced 1
end
'';
}

View file

@ -16,7 +16,7 @@ in {
package = mkOption {
type = types.package;
default = pkgs.foot;
defaultText = literalExample "pkgs.foot";
defaultText = literalExpression "pkgs.foot";
description = "The foot package to install";
};
@ -31,7 +31,7 @@ in {
xlink:href="https://codeberg.org/dnkl/foot/src/branch/master/foot.ini"/>
for a list of available options.
'';
example = literalExample ''
example = literalExpression ''
{
main = {
term = "xterm-256color";
@ -49,6 +49,9 @@ in {
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.foot" pkgs platforms.linux) ];
home.packages = [ cfg.package ];
xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) {

View file

@ -18,7 +18,7 @@ in {
package = mkOption {
type = types.package;
default = pkgs.fzf;
defaultText = literalExample "pkgs.fzf";
defaultText = literalExpression "pkgs.fzf";
description = "Package providing the <command>fzf</command> tool.";
};
@ -96,7 +96,7 @@ in {
shellIntegrationOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExample ''[ "-d 40%" ]'';
example = literalExpression ''[ "-d 40%" ]'';
description = ''
If <option>programs.fzf.tmux.enableShellIntegration</option> is set to <literal>true</literal>,
shell integration will use these options for fzf-tmux.
@ -146,19 +146,25 @@ in {
FZF_TMUX_OPTS = cfg.tmux.shellIntegrationOptions;
});
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence.
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
. ${cfg.package}/share/fzf/completion.bash
. ${cfg.package}/share/fzf/key-bindings.bash
fi
'';
'');
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence.
programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200 ''
if [[ $options[zle] = on ]]; then
. ${cfg.package}/share/fzf/completion.zsh
. ${cfg.package}/share/fzf/key-bindings.zsh
fi
'';
'');
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings

View file

@ -55,6 +55,10 @@ in {
};
config = mkIf getmailEnabled {
assertions = [
(hm.assertions.assertPlatform "programs.getmail" pkgs platforms.linux)
];
home.file = foldl' (a: b: a // b) { }
(map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; })
accounts);

Some files were not shown because too many files have changed in this diff Show more