diff --git a/third_party/home-manager/.github/CODEOWNERS b/third_party/home-manager/.github/CODEOWNERS index a12d9d950a..843ce3bb19 100644 --- a/third_party/home-manager/.github/CODEOWNERS +++ b/third_party/home-manager/.github/CODEOWNERS @@ -113,6 +113,9 @@ /modules/programs/lazygit.nix @kalhauge +/modules/programs/less.nix @pamplemousse +/tests/modules/programs/less @pamplemousse + /modules/programs/lesspipe.nix @rycee /modules/programs/lf.nix @owm111 @@ -353,6 +356,8 @@ /modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans /tests/modules/services/window-managers/sway @sumnerevans +/modules/services/window-managers/i3-sway/swaynag.nix @polykernel + /modules/services/wlsunset.nix @matrss /tests/modules/services/wlsunset @matrss @@ -376,4 +381,7 @@ /modules/services/volnoti.nix @IvanMalison +/modules/targets/darwin @midchildan +/tests/modules/targets-darwin @midchildan + Makefile @thiagokokada diff --git a/third_party/home-manager/.github/workflows/github_pages.yml b/third_party/home-manager/.github/workflows/github_pages.yml index 24eaafa27a..97e784bda0 100644 --- a/third_party/home-manager/.github/workflows/github_pages.yml +++ b/third_party/home-manager/.github/workflows/github_pages.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v14 + - uses: cachix/install-nix-action@v16 with: nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v10 diff --git a/third_party/home-manager/.github/workflows/test.yml b/third_party/home-manager/.github/workflows/test.yml index 4608d481a7..7b1fdbf77c 100644 --- a/third_party/home-manager/.github/workflows/test.yml +++ b/third_party/home-manager/.github/workflows/test.yml @@ -12,13 +12,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v14.1 + - uses: cachix/install-nix-action@v16 with: nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v10 with: name: nix-community signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + - run: | + if grep -R --exclude stdlib-extended.nix literalExample modules ; then + echo "Error: literalExample should be replaced by literalExpression" > /dev/stderr + exit 1 + fi - run: ./format -c - run: nix-shell . -A install - run: nix-shell --arg enableBig false --pure tests -A run.all diff --git a/third_party/home-manager/.release b/third_party/home-manager/.release index a6cf7c3a7f..a01c758c18 100644 --- a/third_party/home-manager/.release +++ b/third_party/home-manager/.release @@ -1 +1 @@ -21.11 +22.05 diff --git a/third_party/home-manager/README.md b/third_party/home-manager/README.md index 85d8db6020..9cffe4ef35 100644 --- a/third_party/home-manager/README.md +++ b/third_party/home-manager/README.md @@ -32,7 +32,7 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwritten was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] unstable and NixOS version 21.05 (the +Home Manager targets [NixOS][] unstable and NixOS version 21.11 (the current stable version), it may or may not work on other Linux distributions and NixOS versions. @@ -53,270 +53,25 @@ You can chat with us on IRC in the channel [#home-manager][] on Installation ------------ -Currently the easiest way to install Home Manager is as follows: - -1. Make sure you have a working Nix installation. Specifically, make - sure that your user is able to build and install Nix packages. For - example, you should be able to successfully run a command like - `nix-instantiate '' -A hello` without having to switch to - the root user. For a multi-user install of Nix this means that - your user must be covered by the - [`allowed-users`][nixAllowedUsers] Nix option. On NixOS you can - control this option using the - [`nix.allowedUsers`][nixosAllowedUsers] system option. - - Note that Nix 2.4 (`nixUnstable`) is not yet supported. - -2. Add the appropriate Home Manager channel. If you are following - Nixpkgs master or an unstable channel you can run - - ```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 - - ```shell - nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager - nix-channel --update - ``` - - On NixOS you may need to log out and back in for the channel to - become available. On non-NixOS you may have to add - - ```shell - export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH - ``` - - to your shell (see [nix#2033](https://github.com/NixOS/nix/issues/2033)). - -3. Install Home Manager and create the first Home Manager generation: - - ```shell - nix-shell '' -A install - ``` - - Once finished, Home Manager should be active and available in your - user environment. - -3. If you do not plan on having Home Manager manage your shell - configuration then you must source the - - ```shell - $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh - ``` - - file in your shell configuration. This file can be sourced - directly by POSIX.2-like shells such as [Bash][] or [Z shell][]. - [Fish][] users can use utilities such as [foreign-env][] or - [babelfish][]. - - For example, if you use Bash then add - - ```bash - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - ``` - - or this when managing home configuration together with system - configuration - - ```bash - . "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh" - ``` - - to your `~/.profile` file. - -If instead of using channels you want to run Home Manager from a Git -checkout of the repository then you can use the -`programs.home-manager.path` option to specify the absolute path to -the repository. - -Usage ------ - -Home Manager is typically managed through the `home-manager` tool. -This tool can, for example, apply configurations to your home -directory, list user packages installed by the tool, and list the -configuration generations. - -As an example, let us expand the initial configuration file from the -installation above to install the htop and fortune packages, install -Emacs with a few extra packages enabled, install Firefox with -smooth scrolling disabled, and enable the user gpg-agent service. - -To satisfy the above setup we should elaborate the -`~/.config/nixpkgs/home.nix` file as follows: - -```nix -{ pkgs, ... }: - -{ - home.packages = [ - pkgs.htop - pkgs.fortune - ]; - - programs.emacs = { - enable = true; - extraPackages = epkgs: [ - epkgs.nix-mode - epkgs.magit - ]; - }; - - programs.firefox = { - enable = true; - profiles = { - myprofile = { - settings = { - "general.smoothScroll" = false; - }; - }; - }; - }; - - services.gpg-agent = { - enable = true; - defaultCacheTtl = 1800; - enableSshSupport = true; - }; - - programs.home-manager = { - enable = true; - path = "…"; - }; -} -``` - -To activate this configuration you can then run - -```shell -home-manager switch -``` - -or if you are not feeling so lucky, - -```shell -home-manager build -``` - -which will create a `result` link to a directory containing an -activation script and the generated home directory files. - -Documentation of available configuration options, including -descriptions and usage examples, is available in the [Home Manager -manual][configuration options] or offline by running - -```shell -man home-configuration.nix -``` - -Rollbacks ---------- - -While the `home-manager` tool does not explicitly support rollbacks at -the moment it is relatively easy to perform one manually. The steps to -do so are - -1. Run `home-manager generations` to determine which generation you - wish to rollback to: - - ```console - $ home-manager generations - 2018-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation - 2018-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation - 2018-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation - 2017-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation - 2017-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation - … - ``` - -2. Copy the Nix store path of the generation you chose, e.g., - - /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation - - for generation 763. - -3. Run the `activate` script inside the copied store path: - - ```console - $ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate - Starting home manager activation - … - ``` - -Keeping your ~ safe from harm ------------------------------ - -To configure programs and services Home Manager must write various -things to your home directory. To prevent overwriting any existing -files when switching to a new generation, Home Manager will attempt to -detect collisions between existing files and generated files. If any -such collision is detected the activation will terminate before -changing anything on your computer. - -For example, suppose you have a wonderful, painstakingly created -`~/.config/git/config` and add - -```nix -{ - # … - - programs.git = { - enable = true; - userName = "Jane Doe"; - userEmail = "jane.doe@example.org"; - }; - - # … -} -``` - -to your configuration. Attempting to switch to the generation will -then result in - -```console -$ home-manager switch -… -Activating checkLinkTargets -Existing file '/home/jdoe/.config/git/config' is in the way -Please move the above files and try again -``` - -Graphical services ------------------- - -Home Manager includes a number of services intended to run in a -graphical session, for example `xscreensaver` and `dunst`. -Unfortunately, such services will not be started automatically unless -you let Home Manager start your X session. That is, you have something -like - -```nix -{ - # … - - services.xserver.enable = true; - - # … -} -``` - -in your system configuration and - -```nix -{ - # … - - xsession.enable = true; - xsession.windowManager.command = "…"; - - # … -} -``` - -in your Home Manager configuration. +Home Manager can be used in three primary ways: + +1. Using the standalone `home-manager` tool. For platforms other than + NixOS and Darwin, this is the only available choice. It is also + recommended for people on NixOS or Darwin that want to manage their + home directory independently of the system as a whole. See + [Standalone installation][manual standalone install] in the manual + for instructions on how to perform this installation. + +2. As a module within a NixOS system configuration. This allows the + user profiles to be built together with the system when running + `nixos-rebuild`. See [NixOS module installation][manual nixos + install] in the manual for a description of this setup. + +3. As a module within a [nix-darwin][] system configuration. This + allows the user profiles to be built together with the system when + running `darwin-rebuild`. See [nix-darwin module + installation][manual nix-darwin install] in the manual for a + description of this setup. Nix Flakes ---------- @@ -345,6 +100,9 @@ as follows: home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.jdoe = import ./home.nix; + + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix } ]; }; @@ -353,6 +111,33 @@ as follows: } ``` +If you are not using NixOS you can place the following flake in +`~/.config/nixpkgs/flake.nix` to load your standard Home Manager +configuration: + +```nix +{ + description = "A Home Manager flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs: { + homeConfigurations = { + jdoe = inputs.home-manager.lib.homeManagerConfiguration { + system = "x86_64-linux"; + homeDirectory = "/home/jdoe"; + username = "jdoe"; + configuration.imports = [ ./home.nix ]; + }; + }; + }; +} +``` + Note, the Home Manager library is exported by the flake under `lib.hm`. @@ -367,24 +152,26 @@ Home Manager is developed against `nixpkgs-unstable` branch, which often causes it to contain tweaks for changes/packages not yet released in stable NixOS. To avoid breaking users' configurations, Home Manager is released in branches corresponding to NixOS releases -(e.g. `release-21.05`). These branches get fixes, but usually not new +(e.g. `release-21.11`). These branches get fixes, but usually not new modules. If you need a module to be backported, then feel free to open an issue. -[Bash]: https://www.gnu.org/software/bash/ +License +------- + +This project is licensed under the terms of the [MIT license](LICENSE). + [Nix]: https://nixos.org/nix/ [NixOS]: https://nixos.org/ [Nixpkgs]: https://nixos.org/nixpkgs/ -[nixAllowedUsers]: https://nixos.org/nix/manual/#conf-allowed-users -[nixosAllowedUsers]: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers -[Z shell]: http://zsh.sourceforge.net/ [manual]: https://nix-community.github.io/home-manager/ +[manual usage]: https://nix-community.github.io/home-manager/#ch-usage [configuration options]: https://nix-community.github.io/home-manager/options.html [#home-manager]: https://webchat.oftc.net/?channels=home-manager [OFTC]: https://oftc.net/ -[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 +[nix-darwin]: https://github.com/LnL7/nix-darwin/ +[manual standalone install]: https://nix-community.github.io/home-manager/index.html#sec-install-standalone +[manual nixos install]: https://nix-community.github.io/home-manager/index.html#sec-install-nixos-module +[manual nix-darwin install]: https://nix-community.github.io/home-manager/index.html#sec-install-nix-darwin-module diff --git a/third_party/home-manager/docs/default.nix b/third_party/home-manager/docs/default.nix index d5ff901061..fd038d1a80 100644 --- a/third_party/home-manager/docs/default.nix +++ b/third_party/home-manager/docs/default.nix @@ -9,8 +9,8 @@ let name = "nmd"; owner = "rycee"; repo = "nmd"; - rev = "12bc57594e12525d2e4422fa7034b2d54e9ea09a"; - sha256 = "0fpankfx2c99x4n1mhdy730yxy2b03qcw4zvjxyk4b1v60h8057n"; + rev = "527245ff605bde88c2dd2ddae21c6479bb7cf8aa"; + sha256 = "1zi0f9y3wq4bpslx1py3sfgrgd9av41ahpandvs6rvkpisfsqqlp"; }; nmd = import nmdSrc { inherit lib pkgs; }; diff --git a/third_party/home-manager/docs/installation.adoc b/third_party/home-manager/docs/installation.adoc index 82d890f193..19df6fcab3 100644 --- a/third_party/home-manager/docs/installation.adoc +++ b/third_party/home-manager/docs/installation.adoc @@ -8,7 +8,7 @@ Home Manager can be used in three primary ways: 1. Using the standalone `home-manager` tool. For platforms other than NixOS and Darwin, this is the only available choice. It is also recommended for people on NixOS or Darwin that want to manage their -home directory independent of the system as a whole. See +home directory independently of the system as a whole. See <> for instructions on how to perform this installation. @@ -27,6 +27,11 @@ for a description of this setup. :nix-allowed-users: https://nixos.org/nix/manual/#conf-allowed-users :nixos-allowed-users: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers +:bash: https://www.gnu.org/software/bash/ +:zsh: http://zsh.sourceforge.net/ +:fish: https://fishshell.com +:plugin-foreign-env: https://github.com/oh-my-fish/plugin-foreign-env +:babelfish: https://github.com/bouk/babelfish 1. Make sure you have a working Nix installation. Specifically, make sure that your user is able to build and install Nix packages. For @@ -36,10 +41,12 @@ root user. For a multi-user install of Nix this means that your user must be covered by the {nix-allowed-users}[`allowed-users`] Nix option. On NixOS you can control this option using the {nixos-allowed-users}[`nix.allowedUsers`] system option. ++ +Note that Nix 2.4 is not yet fully supported. Most significantly, Home +Manager is incompatible with the new `nix profile`. -2. Add the Home Manager channel that you wish to follow. If you are -following Nixpkgs master or an unstable channel then this is done by -running +2. Add the appropriate Home Manager channel. If you are following +Nixpkgs master or an unstable channel you can run + [source,console] ---- @@ -47,11 +54,11 @@ $ nix-channel --add https://github.com/nix-community/home-manager/archive/master $ nix-channel --update ---- + -and if you follow a Nixpkgs version 21.05 channel, you can run +and if you follow a Nixpkgs version 21.11 channel you can run + [source,console] ---- -$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager +$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager $ nix-channel --update ---- + @@ -87,11 +94,8 @@ file in your shell configuration. Alternatively source when managing home configuration together with system configuration. + 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]. 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]. +{bash}[Bash] or {zsh}[Z shell]. {fish}[Fish] users can use utilities +such as {plugin-foreign-env}[foreign-env] or {babelfish}[babelfish]. + For example, if you use Bash then add + @@ -107,6 +111,9 @@ checkout of the repository then you can use the <> option to specify the absolute path to the repository. +Once installed you can see <> for a more detailed +description of Home Manager and how to use it. + [[sec-install-nixos-module]] === NixOS module @@ -128,11 +135,11 @@ or an unstable channel, you can run # nix-channel --update ---- -and if you follow a Nixpkgs version 21.05 channel, you can run +and if you follow a Nixpkgs version 21.11 channel, you can run [source,console] ---- -# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager +# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager # nix-channel --update ---- @@ -159,6 +166,27 @@ home-manager.users.eve = { pkgs, ... }: { and after a `nixos-rebuild switch` the user eve's environment should include a basic Bash configuration and the packages atool and httpie. +If you do not plan on having Home Manager manage your shell +configuration then you must add either + +[source,bash] +---- +. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" +---- + +or + +[source,bash] +---- +. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh" +---- + +to your shell configuration, depending on whether +<> is enabled. This file can +be sourced directly by POSIX.2-like shells such as {bash}[Bash] or +{zsh}[Z shell]. {fish}[Fish] users can use utilities such as +{plugin-foreign-env}[foreign-env] or {babelfish}[babelfish]. + [NOTE] ==== By default packages will be installed to `$HOME/.nix-profile` but they @@ -187,6 +215,9 @@ the dependency on `NIX_PATH`, which is otherwise used for importing Nixpkgs. ==== +Once installed you can see <> for a more detailed +description of Home Manager and how to use it. + [[sec-install-nix-darwin-module]] === nix-darwin module @@ -206,11 +237,11 @@ or an unstable channel, you can run # nix-channel --update ---- -and if you follow a Nixpkgs version 21.05 channel, you can run +and if you follow a Nixpkgs version 21.11 channel, you can run [source,console] ---- -# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager +# nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager # nix-channel --update ---- @@ -241,6 +272,27 @@ and after a `darwin-rebuild switch` the user eve's environment should include a basic Bash configuration and the packages atool and httpie. +If you do not plan on having Home Manager manage your shell +configuration then you must add either + +[source,bash] +---- +. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" +---- + +or + +[source,bash] +---- +. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh" +---- + +to your shell configuration, depending on whether +<> is enabled. This file +can be sourced directly by POSIX.2-like shells such as {bash}[Bash] or +{zsh}[Z shell]. {fish}[Fish] users can use utilities such as +{plugin-foreign-env}[foreign-env] or {babelfish}[babelfish]. + [NOTE] ==== By default user packages will not be ignored in favor of @@ -268,3 +320,6 @@ This saves an extra Nixpkgs evaluation, adds consistency, and removes the dependency on `NIX_PATH`, which is otherwise used for importing Nixpkgs. ==== + +Once installed you can see <> for a more detailed +description of Home Manager and how to use it. diff --git a/third_party/home-manager/docs/manual.xml b/third_party/home-manager/docs/manual.xml index 812a72eba5..693f0a92f7 100644 --- a/third_party/home-manager/docs/manual.xml +++ b/third_party/home-manager/docs/manual.xml @@ -29,6 +29,7 @@ + diff --git a/third_party/home-manager/docs/release-notes/release-notes.adoc b/third_party/home-manager/docs/release-notes/release-notes.adoc index 826b991d56..56bfa20b62 100644 --- a/third_party/home-manager/docs/release-notes/release-notes.adoc +++ b/third_party/home-manager/docs/release-notes/release-notes.adoc @@ -6,6 +6,8 @@ This section lists the release notes for stable versions of Home Manager and the :leveloffset: 1 +include::rl-2205.adoc[] + include::rl-2111.adoc[] include::rl-2105.adoc[] diff --git a/third_party/home-manager/docs/release-notes/rl-2111.adoc b/third_party/home-manager/docs/release-notes/rl-2111.adoc index ecd189956b..0ac83a322e 100644 --- a/third_party/home-manager/docs/release-notes/rl-2111.adoc +++ b/third_party/home-manager/docs/release-notes/rl-2111.adoc @@ -1,8 +1,7 @@ [[sec-release-21.11]] == Release 21.11 -This is the current unstable branch and the information in this -section is therefore not final. +The 21.11 release branch became the stable branch in November, 2021. [[sec-release-21.11-highlights]] === Highlights @@ -37,6 +36,10 @@ https://github.com/nix-community/home-manager/issues/1906[issue #1906]. + You can replicate your old configuration by moving those options to <>. Keep in mind that the syntax is different so you may need to do some changes. +* Taskwarrior version 2.6.0 respects XDG Specification for the config file now. +Option <> and friends now generate the config file at +`$XDG_CONFIG_HOME/task/taskrc` instead of `~/.taskrc`. + [[sec-release-21.11-state-version-changes]] === State Version Changes @@ -45,3 +48,26 @@ changes are only active if the `home.stateVersion` option is set to "21.11" or later. * The <> option now defaults to `null`, meaning that Home Manager won't do any keyboard layout management. For example, `setxkbmap` won't be run in X sessions. + +* The <> option no longer place its value inside a `General` attribute. +For example, ++ +[source,nix] +programs.pet.settings.editor = "nvim"; ++ +becomes ++ +[source,nix] +programs.pet.settings.General.editor = "nvim"; + +* The <> option now allows defining modules directly under <>. +For example, ++ +[source,nix] +programs.waybar.settings.modules."custom/my-module" = { }; ++ +becomes ++ +[source,nix] +programs.waybar.settings."custom/my-module" = { }; + diff --git a/third_party/home-manager/docs/release-notes/rl-2205.adoc b/third_party/home-manager/docs/release-notes/rl-2205.adoc new file mode 100644 index 0000000000..0684bab61d --- /dev/null +++ b/third_party/home-manager/docs/release-notes/rl-2205.adoc @@ -0,0 +1,31 @@ +[[sec-release-22.05]] +== Release 22.05 + +This is the current unstable branch and the information in this section is therefore not final. + +[[sec-release-22.05-highlights]] +=== Highlights + +This release has the following notable changes: + +* The `programs.waybar.settings.modules` option was removed. +Waybar modules should now be declared directly under `programs.waybar.settings`. + +[[sec-release-22.05-state-version-changes]] +=== State Version Changes + +The state version in this release includes the changes below. +These changes are only active if the `home.stateVersion` option is set to "22.05" or later. + +* The <> option now allows defining modules directly under <>. +Defining modules under `programs.waybar.settings.modules` will now be an error. +For example, ++ +[source,nix] +programs.waybar.settings.modules."custom/my-module" = { }; ++ +becomes ++ +[source,nix] +programs.waybar.settings."custom/my-module" = { }; + diff --git a/third_party/home-manager/docs/usage.adoc b/third_party/home-manager/docs/usage.adoc new file mode 100644 index 0000000000..285835b296 --- /dev/null +++ b/third_party/home-manager/docs/usage.adoc @@ -0,0 +1,226 @@ +[[ch-usage]] +== Using Home Manager + +Your use of Home Manager is centered around the configuration file, which is typically found at `~/.config/nixpkgs/home.nix`. + +This configuration file can be _built_ and _activated_. + +Building a configuration produces a directory in the Nix store that contains all files and programs that should be available in your home directory and Nix user profile, respectively. The build step also checks that the configuration is valid and it will fail with an error if you, for example, assign a value to an option that does not exist or assign a value of the wrong type. Some modules also have custom assertions that perform more detailed, module specific, checks. + +Concretely, if your configuration contains + +[source,nix] +programs.emacs.enable = "yes"; + +then building it, for example using `home-manager build`, will result in an error message saying something like + +[source,console] +---- +$ home-manager build +error: A definition for option `programs.emacs.enable' is not of type `boolean'. Definition values: +- In `/home/jdoe/.config/nixpkgs/home.nix': "yes" +(use '--show-trace' to show detailed location information) +---- + +The message indicates that you must provide a Boolean value for this option, that is, either `true` or `false`. The documentation of each option will state the expected type, for <> you will see ``Type: boolean''. You there also find information about the default value and a description of the option. You can find the complete option documentation in <> or directly in the terminal by running + +[source,console] +man home-configuration.nix + +Once a configuration is successfully built, it can be activated. The activation performs the steps necessary to make the files, programs, and services available in your user environment. The `home-manager switch` command performs a combined build and activation. + +=== Configuration Example + +A fresh install of Home Manager will generate a minimal `~/.config/nixpkgs/home.nix` file containing something like + +[source,nix] +---- +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "jdoe"; + home.homeDirectory = "/home/jdoe"; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "22.05"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} +---- + +You can use this as a base for your further configurations. + +[NOTE] +If you are not very familiar with the Nix language and NixOS modules then it is encouraged to start with small and simple changes. As you learn you can gradually grow the configuration with confidence. + +As an example, let us expand the initial configuration file to also install the htop and fortune packages, install Emacs with a few extra packages available, and enable the user gpg-agent service. + +To satisfy the above setup we should elaborate the `home.nix` file as follows: + +[source,nix] +---- +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "jdoe"; + home.homeDirectory = "/home/jdoe"; + + # Packages that should be installed to the user profile. + home.packages = [ <1> + pkgs.htop + pkgs.fortune + ]; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "22.05"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + programs.emacs = { <2> + enable = true; + extraPackages = epkgs: [ + epkgs.nix-mode + epkgs.magit + ]; + }; + + services.gpg-agent = { <3> + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + }; +} +---- +<1> Nixpkgs packages can be installed to the user profile using <>. +<2> The option names of a program module typically start with `programs.`. +<3> Similarly, for a service module, the names start with `services.`. Note in some cases a package has both programs _and_ service options – Emacs is such an example. + +To activate this configuration you can run + +[source,console] +home-manager switch + +or if you are not feeling so lucky, + +[source,console] +home-manager build + +which will create a `result` link to a directory containing an +activation script and the generated home directory files. + +=== Rollbacks + +While the `home-manager` tool does not explicitly support rollbacks at the moment it is relatively easy to perform one manually. The steps to do so are + +1. Run `home-manager generations` to determine which generation you wish to rollback to: ++ +[source,console] +---- +$ home-manager generations +2018-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation +2018-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation +2018-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation +2017-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation +2017-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation +… +---- + +2. Copy the Nix store path of the generation you chose, e.g., ++ +---- +/nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation +---- ++ +for generation 763. + +3. Run the `activate` script inside the copied store path: ++ +[source,console] +---- +$ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate +Starting home manager activation +… +---- + +=== Keeping your ~ safe from harm + +To configure programs and services Home Manager must write various things to your home directory. To prevent overwriting any existing files when switching to a new generation, Home Manager will attempt to detect collisions between existing files and generated files. If any such collision is detected the activation will terminate before changing anything on your computer. + +For example, suppose you have a wonderful, painstakingly created `~/.config/git/config` and add + +[source,nix] +---- +{ + # … + + programs.git = { + enable = true; + userName = "Jane Doe"; + userEmail = "jane.doe@example.org"; + }; + + # … +} +---- + +to your configuration. Attempting to switch to the generation will then result in + +[source,console] +---- +$ home-manager switch +… +Activating checkLinkTargets +Existing file '/home/jdoe/.config/git/config' is in the way +Please move the above files and try again +---- + +=== Graphical services + +Home Manager includes a number of services intended to run in a graphical session, for example `xscreensaver` and `dunst`. Unfortunately, such services will not be started automatically unless you let Home Manager start your X session. That is, you have something like + +[source,nix] +---- +{ + # … + + services.xserver.enable = true; + + # … +} +---- + +in your system configuration and + +[source,nix] +---- +{ + # … + + xsession.enable = true; + xsession.windowManager.command = "…"; + + # … +} +---- + +in your Home Manager configuration. diff --git a/third_party/home-manager/flake.nix b/third_party/home-manager/flake.nix index 3114798e23..9382351e6d 100644 --- a/third_party/home-manager/flake.nix +++ b/third_party/home-manager/flake.nix @@ -30,6 +30,15 @@ defaultPackage = forAllSystems (system: self.packages.${system}.home-manager); + apps = forAllSystems (system: { + home-manager = { + type = "app"; + program = "${defaultPackage.${system}}/bin/home-manager"; + }; + }); + + defaultApp = forAllSystems (system: apps.${system}.home-manager); + lib = { hm = import ./modules/lib { lib = nixpkgs.lib; }; homeManagerConfiguration = { configuration, system, homeDirectory diff --git a/third_party/home-manager/home-manager/default.nix b/third_party/home-manager/home-manager/default.nix index 1c5ab5d81f..47281bc643 100644 --- a/third_party/home-manager/home-manager/default.nix +++ b/third_party/home-manager/home-manager/default.nix @@ -16,7 +16,6 @@ let in runCommand "home-manager" { preferLocalBuild = true; - allowSubstitutes = false; meta = with lib; { description = "A user environment configurator"; maintainers = [ maintainers.rycee ]; diff --git a/third_party/home-manager/home-manager/home-manager b/third_party/home-manager/home-manager/home-manager index e474141719..a5fe62013b 100644 --- a/third_party/home-manager/home-manager/home-manager +++ b/third_party/home-manager/home-manager/home-manager @@ -186,6 +186,18 @@ function doBuildAttr() { --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" } +function doBuildFlake() { + local extraArgs=("$@") + + if [[ -v VERBOSE ]]; then + extraArgs=("${extraArgs[@]}" "--verbose") + fi + + nix build \ + "${extraArgs[@]}" \ + "${PASSTHROUGH_OPTS[@]}" +} + # Presents news to the user. Takes as argument the path to a "news # info" file as generated by `buildNews`. function presentNews() { @@ -246,52 +258,32 @@ function doBuild() { return 1 fi - setFlakeAttribute - if [[ -v FLAKE_CONFIG_URI ]]; then - local exitCode=0 - nix build \ - "${PASSTHROUGH_OPTS[@]}" \ - ${DRY_RUN+--dry-run} \ - ${NO_OUT_LINK+--no-link} \ - "$FLAKE_CONFIG_URI.activationPackage" \ - || exitCode=1 - return $exitCode - fi - setWorkDir - local newsInfo - newsInfo=$(buildNews) + setFlakeAttribute + if [[ -v FLAKE_CONFIG_URI ]]; then + doBuildFlake \ + "$FLAKE_CONFIG_URI.activationPackage" \ + ${DRY_RUN+--dry-run} \ + ${NO_OUT_LINK+--no-link} \ + || return + else + doBuildAttr \ + ${NO_OUT_LINK+--no-out-link} \ + --attr activationPackage \ + || return - local exitCode - doBuildAttr \ - ${NO_OUT_LINK+--no-out-link} \ - --attr activationPackage \ - && exitCode=0 || exitCode=1 + local newsInfo + newsInfo=$(buildNews) - presentNews "$newsInfo" - - return $exitCode + presentNews "$newsInfo" + fi } function doSwitch() { - setFlakeAttribute - if [[ -v FLAKE_CONFIG_URI ]]; then - local exitCode=0 - nix run \ - "${PASSTHROUGH_OPTS[@]}" \ - "$FLAKE_CONFIG_URI.activationPackage" \ - || exitCode=1 - return $exitCode - fi - setWorkDir - local newsInfo - newsInfo=$(buildNews) - local generation - local exitCode=0 # Build the generation and run the activate script. Note, we # specify an output link so that it is treated as a GC root. This @@ -299,14 +291,23 @@ function doSwitch() { # before activation completes. generation="$WORK_DIR/generation" - doBuildAttr \ - --out-link "$generation" \ - --attr activationPackage \ - && "$generation/activate" || exitCode=1 + setFlakeAttribute + if [[ -v FLAKE_CONFIG_URI ]]; then + doBuildFlake \ + "$FLAKE_CONFIG_URI.activationPackage" \ + --out-link "$generation" \ + && "$generation/activate" || return + else + doBuildAttr \ + --out-link "$generation" \ + --attr activationPackage \ + && "$generation/activate" || return - presentNews "$newsInfo" + local newsInfo + newsInfo=$(buildNews) - return $exitCode + presentNews "$newsInfo" + fi } function doListGens() { @@ -403,13 +404,13 @@ function buildNews() { output="$WORK_DIR/news-info.sh" doBuildAttr \ - --out-link "$output" \ - --no-build-output \ - --quiet \ - --arg check false \ - --argstr newsReadIdsFile "$(newsReadIdsFile)" \ - --attr newsInfo \ - > /dev/null + --out-link "$output" \ + --no-build-output \ + --quiet \ + --arg check false \ + --argstr newsReadIdsFile "$(newsReadIdsFile)" \ + --attr newsInfo \ + > /dev/null echo "$output" } @@ -524,6 +525,7 @@ function doHelp() { echo " --show-trace" echo " --(no-)substitute" echo " --no-out-link Do not create a symlink to the output path" + echo " --no-write-lock-file" echo " --builders VALUE" echo echo "Commands" @@ -632,7 +634,7 @@ while [[ $# -gt 0 ]]; do export VERBOSE=1 ;; --version) - echo 21.11 + echo 22.05 exit 0 ;; *) diff --git a/third_party/home-manager/home-manager/install.nix b/third_party/home-manager/home-manager/install.nix index e707c57332..cf45f14dcc 100644 --- a/third_party/home-manager/home-manager/install.nix +++ b/third_party/home-manager/home-manager/install.nix @@ -3,7 +3,6 @@ runCommand "home-manager-install" { propagatedBuildInputs = [ home-manager ]; preferLocalBuild = true; - allowSubstitutes = false; shellHookOnly = true; shellHook = '' confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" @@ -32,9 +31,6 @@ runCommand "home-manager-install" { { config, pkgs, ... }: { - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - # Home Manager needs a bit of information about you and the # paths it should manage. home.username = "$USER"; @@ -48,7 +44,10 @@ runCommand "home-manager-install" { # You can update Home Manager without changing this value. See # the Home Manager release notes for a list of state version # changes in each release. - home.stateVersion = "21.11"; + home.stateVersion = "22.05"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; } EOF fi diff --git a/third_party/home-manager/modules/accounts/email.nix b/third_party/home-manager/modules/accounts/email.nix index a06a1d2837..e48024e023 100644 --- a/third_party/home-manager/modules/accounts/email.nix +++ b/third_party/home-manager/modules/accounts/email.nix @@ -188,7 +188,7 @@ let }; flavor = mkOption { - type = types.enum [ "plain" "gmail.com" "runbox.com" ]; + type = types.enum [ "plain" "gmail.com" "runbox.com" "fastmail.com" ]; default = "plain"; description = '' Some email providers have peculiar behavior that require @@ -328,7 +328,17 @@ let name = name; maildir = mkOptionDefault { path = "${name}"; }; } - + (mkIf (config.flavor == "fastmail.com") { + userName = mkDefault config.address; + smtp = { + host = "smtp.fastmail.com"; + port = if config.smtp.tls.useStartTls then 587 else 465; + }; + imap = { + host = "imap.fastmail.com"; + port = 993; + }; + }) (mkIf (config.flavor == "gmail.com") { userName = mkDefault config.address; diff --git a/third_party/home-manager/modules/config/i18n.nix b/third_party/home-manager/modules/config/i18n.nix index c795bbcffe..e9b01b4efd 100644 --- a/third_party/home-manager/modules/config/i18n.nix +++ b/third_party/home-manager/modules/config/i18n.nix @@ -36,7 +36,7 @@ let in { meta.maintainers = with maintainers; [ midchildan ]; - config = mkIf pkgs.hostPlatform.isLinux { + config = mkIf pkgs.stdenv.hostPlatform.isLinux { # For shell sessions. home.sessionVariables = localeVars; diff --git a/third_party/home-manager/modules/home-environment.nix b/third_party/home-manager/modules/home-environment.nix index b3e904e5b4..dd8b9817f1 100644 --- a/third_party/home-manager/modules/home-environment.nix +++ b/third_party/home-manager/modules/home-environment.nix @@ -205,12 +205,13 @@ in home.profileDirectory = mkOption { type = types.path; - defaultText = "~/.nix-profile"; - internal = true; + defaultText = literalExpression '' + "''${home.homeDirectory}/.nix-profile" or + "/etc/profiles/per-user/''${home.username}" + ''; readOnly = true; description = '' - The profile directory where Home Manager generations are - installed. + The profile directory where Home Manager generations are installed. ''; }; @@ -233,6 +234,26 @@ in ''; }; + home.shellAliases = mkOption { + type = with types; attrsOf str; + default = { }; + example = literalExpression '' + { + g = "git"; + "..." = "cd ../.."; + } + ''; + description = '' + An attribute set that maps aliases (the top level attribute names + in this option) to command strings or directly to build outputs. + + This option should only be used to manage simple aliases that are + compatible across all shells. If you need to use a shell specific + feature then make sure to use a shell specific option, for example + for Bash. + ''; + }; + home.sessionVariables = mkOption { default = {}; type = types.attrs; @@ -419,7 +440,7 @@ in home.enableNixpkgsReleaseCheck = mkOption { type = types.bool; - default = true; + default = false; # Temporarily disabled until release stabilizes. description = '' Determines whether to check for release version mismatch between Home Manager and Nixpkgs. Using mismatched versions is likely to cause errors @@ -483,6 +504,10 @@ in then "/etc/profiles/per-user/${cfg.username}" else cfg.homeDirectory + "/.nix-profile"; + programs.bash.shellAliases = cfg.shellAliases; + programs.zsh.shellAliases = cfg.shellAliases; + programs.fish.shellAliases = cfg.shellAliases; + home.sessionVariables = let maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; }; @@ -628,7 +653,6 @@ in "home-manager-generation" { preferLocalBuild = true; - allowSubstitutes = false; } '' mkdir -p $out diff --git a/third_party/home-manager/modules/lib/maintainers.nix b/third_party/home-manager/modules/lib/maintainers.nix index dba4d5e304..0a88c66457 100644 --- a/third_party/home-manager/modules/lib/maintainers.nix +++ b/third_party/home-manager/modules/lib/maintainers.nix @@ -133,4 +133,11 @@ github = "hawkw"; githubId = 2796466; }; + + pamplemousse = { + name = "Xavier Maso"; + email = "xav.maso@gmail.com"; + github = "pamplemousse"; + githubId = 2647236; + }; } diff --git a/third_party/home-manager/modules/misc/news.nix b/third_party/home-manager/modules/misc/news.nix index 5bdb31f821..a850bd8d78 100644 --- a/third_party/home-manager/modules/misc/news.nix +++ b/third_party/home-manager/modules/misc/news.nix @@ -2233,6 +2233,53 @@ in A new module is available: 'programs.hexchat'. ''; } + + { + time = "2021-11-21T17:21:04+00:00"; + condition = config.wayland.windowManager.sway.enable; + message = '' + A new module is available: 'wayland.windowManager.sway.swaynag'. + ''; + } + + { + time = "2021-11-23T20:26:37+00:00"; + condition = config.programs.taskwarrior.enable; + message = '' + Taskwarrior version 2.6.0 respects XDG Specification for the config + file now. Option 'programs.taskwarrior.config' and friends now + generate the config file at '$XDG_CONFIG_HOME/task/taskrc' instead of + '~/.taskrc'. + ''; + } + + { + time = "2021-11-30T22:28:12+00:00"; + message = '' + A new module is available: 'programs.less'. + ''; + } + + { + time = "2021-11-29T15:15:59+00:00"; + condition = hostPlatform.isDarwin; + message = '' + The option 'targets.darwin.defaults."com.apple.menuextra.battery".ShowPercent' + has been deprecated since it no longer works on the latest version of + macOS. + ''; + } + + { + time = "2021-12-02T02:59:59+00:00"; + condition = config.programs.waybar.enable; + message = '' + The Waybar module now allows defining modules directly under the 'settings' + option instead of nesting the modules under 'settings.modules'. + The Waybar module will also stop reporting errors about unused or misnamed + modules. + ''; + } ]; }; } diff --git a/third_party/home-manager/modules/misc/version.nix b/third_party/home-manager/modules/misc/version.nix index 270d3bc3db..9673c0ffa5 100644 --- a/third_party/home-manager/modules/misc/version.nix +++ b/third_party/home-manager/modules/misc/version.nix @@ -14,6 +14,7 @@ with lib; "21.03" "21.05" "21.11" + "22.05" ]; default = "18.09"; description = '' diff --git a/third_party/home-manager/modules/misc/xdg-mime.nix b/third_party/home-manager/modules/misc/xdg-mime.nix index fa7cdbc766..c9c7658d11 100644 --- a/third_party/home-manager/modules/misc/xdg-mime.nix +++ b/third_party/home-manager/modules/misc/xdg-mime.nix @@ -10,7 +10,7 @@ in { options = { xdg.mime.enable = mkOption { type = types.bool; - default = pkgs.hostPlatform.isLinux; + default = pkgs.stdenv.hostPlatform.isLinux; defaultText = literalExpression "true if host platform is Linux, false otherwise"; description = '' diff --git a/third_party/home-manager/modules/misc/xdg.nix b/third_party/home-manager/modules/misc/xdg.nix index 1790b87dc5..5961cac398 100644 --- a/third_party/home-manager/modules/misc/xdg.nix +++ b/third_party/home-manager/modules/misc/xdg.nix @@ -108,7 +108,7 @@ in { xdg.cacheHome = mkDefault defaultCacheHome; xdg.configHome = mkDefault defaultConfigHome; xdg.dataHome = mkDefault defaultDataHome; - xdg.stateHome = mkDefault stateHome; + xdg.stateHome = mkDefault defaultStateHome; }) { diff --git a/third_party/home-manager/modules/modules.nix b/third_party/home-manager/modules/modules.nix index ab2761f81d..b62d6f4aa6 100644 --- a/third_party/home-manager/modules/modules.nix +++ b/third_party/home-manager/modules/modules.nix @@ -86,6 +86,7 @@ let ./programs/keychain.nix ./programs/kitty.nix ./programs/lazygit.nix + ./programs/less.nix ./programs/lesspipe.nix ./programs/lf.nix ./programs/lieer.nix @@ -227,6 +228,7 @@ let ./services/window-managers/bspwm/default.nix ./services/window-managers/i3-sway/i3.nix ./services/window-managers/i3-sway/sway.nix + ./services/window-managers/i3-sway/swaynag.nix ./services/window-managers/xmonad.nix ./services/wlsunset.nix ./services/xcape.nix diff --git a/third_party/home-manager/modules/programs/direnv.nix b/third_party/home-manager/modules/programs/direnv.nix index 9974a28fb3..ad4c499346 100644 --- a/third_party/home-manager/modules/programs/direnv.nix +++ b/third_party/home-manager/modules/programs/direnv.nix @@ -15,6 +15,8 @@ in { "direnv" "enableNixDirenvIntegration" ] [ "programs" "direnv" "nix-direnv" "enable" ]) + (mkRemovedOptionModule [ "programs" "direnv" "nix-direnv" "enableFlakes" ] + "Flake support is now always enabled.") ]; meta.maintainers = [ maintainers.rycee ]; @@ -79,7 +81,6 @@ in { nix-direnv, a fast, persistent use_nix implementation for direnv''; - enableFlakes = mkEnableOption "Flake support in nix-direnv"; }; }; @@ -92,11 +93,9 @@ in { }; xdg.configFile."direnv/direnvrc" = let - package = - pkgs.nix-direnv.override { inherit (cfg.nix-direnv) enableFlakes; }; text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib ++ optional cfg.nix-direnv.enable - "source ${package}/share/nix-direnv/direnvrc"); + "source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc"); in mkIf (text != "") { inherit text; }; programs.bash.initExtra = mkIf cfg.enableBashIntegration ( diff --git a/third_party/home-manager/modules/programs/firefox.nix b/third_party/home-manager/modules/programs/firefox.nix index 07de012c45..292bbb91aa 100644 --- a/third_party/home-manager/modules/programs/firefox.nix +++ b/third_party/home-manager/modules/programs/firefox.nix @@ -370,8 +370,8 @@ in { "${profilesPath}/${profile.path}/chrome/userContent.css" = mkIf (profile.userContent != "") { text = profile.userContent; }; - "${profilesPath}/${profile.path}/user.js" = - mkIf (profile.settings != { } || profile.extraConfig != "") { + "${profilesPath}/${profile.path}/user.js" = mkIf (profile.settings != { } + || profile.extraConfig != "" || profile.bookmarks != { }) { text = mkUserJs profile.settings profile.extraConfig profile.bookmarks; }; diff --git a/third_party/home-manager/modules/programs/fish.nix b/third_party/home-manager/modules/programs/fish.nix index 0387df799a..e39a141ceb 100644 --- a/third_party/home-manager/modules/programs/fish.nix +++ b/third_party/home-manager/modules/programs/fish.nix @@ -310,7 +310,6 @@ in { nativeBuildInputs = [ pkgs.python2 ]; buildInputs = [ cfg.package ]; preferLocalBuild = true; - allowSubstitutes = false; } '' mkdir -p $out if [ -d $src/share/man ]; then diff --git a/third_party/home-manager/modules/programs/gpg.nix b/third_party/home-manager/modules/programs/gpg.nix index d32a819243..31ddf2e8c4 100644 --- a/third_party/home-manager/modules/programs/gpg.nix +++ b/third_party/home-manager/modules/programs/gpg.nix @@ -21,6 +21,110 @@ let } cfg.scdaemonSettings; primitiveType = types.oneOf [ types.str types.bool ]; + + publicKeyOpts = { config, ...}: { + options = { + text = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Text of an OpenPGP public key. + ''; + }; + + source = mkOption { + type = types.path; + description = '' + Path of an OpenPGP public key file. + ''; + }; + + trust = mkOption { + type = types.nullOr (types.enum [ 1 2 3 4 5 ]); + default = null; + description = '' + The amount of trust you have in the key ownership and the care the + owner puts into signing other keys. The available levels are + + + 1 + I don't know or won't say. + + + 2 + I do NOT trust. + + + 3 + I trust marginally. + + + 4 + I trust fully. + + + 5 + I trust ultimately. + + + + See + for more. + ''; + }; + }; + + config = { + source = mkIf (config.text != null) + (pkgs.writeText "gpg-pubkey" config.text); + }; + }; + + importTrustBashFunctions = + let gpg = "${cfg.package}/bin/gpg"; + in '' + function gpgKeyId() { + ${gpg} --show-key --with-colons "$1" \ + | grep ^pub: \ + | cut -d: -f5 + } + + function importTrust() { + local keyId trust + keyId="$(gpgKeyId "$1")" + trust="$2" + if [[ -n $keyId ]] ; then + echo -e "trust\n$trust\ny\nquit" \ + | ${gpg} --no-tty --command-fd 0 --edit-key "$keyId" + fi + } + ''; + + keyringFiles = + let + gpg = "${cfg.package}/bin/gpg"; + + importKey = { source, trust, ... }: '' + ${gpg} --import ${source} + ${optionalString (trust != null) '' + importTrust "${source}" ${toString trust}''} + ''; + + importKeys = concatMapStringsSep "\n" importKey cfg.publicKeys; + in pkgs.runCommand "gpg-pubring" { buildInputs = [ cfg.package ]; } '' + export GNUPGHOME + GNUPGHOME=$(mktemp -d) + + ${importTrustBashFunctions} + ${importKeys} + + mkdir $out + cp $GNUPGHOME/pubring.kbx $out/pubring.kbx + if [[ -e $GNUPGHOME/trustdb.gpg ]] ; then + cp $GNUPGHOME/trustdb.gpg $out/trustdb.gpg + fi + ''; + in { options.programs.gpg = { @@ -73,6 +177,48 @@ in defaultText = literalExpression "\"\${config.home.homeDirectory}/.gnupg\""; description = "Directory to store keychains and configuration."; }; + + mutableKeys = mkOption { + type = types.bool; + default = true; + description = '' + If set to true, you may manage your keyring as a user + using the gpg command. Upon activation, the keyring + will have managed keys added without overwriting unmanaged keys. + + If set to false, the path + $GNUPGHOME/pubring.kbx will become an immutable + link to the Nix store, denying modifications. + ''; + }; + + mutableTrust = mkOption { + type = types.bool; + default = true; + description = '' + If set to true, you may manage trust as a user using + the gpg command. Upon activation, trusted keys have + their trust set without overwriting unmanaged keys. + + If set to false, the path + $GNUPGHOME/trustdb.gpg will be + overwritten on each activation, removing trust for + any unmanaged keys. Be careful to make a backup of your old + trustdb.gpg before switching to immutable trust! + ''; + }; + + publicKeys = mkOption { + type = types.listOf (types.submodule publicKeyOpts); + example = literalExpression '' + [ { source = ./pubkeys.txt; } ] + ''; + default = [ ]; + description = '' + A list of public keys to be imported into GnuPG. Note, these key files + will be copied into the world-readable Nix store. + ''; + }; }; config = mkIf cfg.enable { @@ -109,5 +255,48 @@ in home.file."${cfg.homedir}/gpg.conf".text = cfgText; home.file."${cfg.homedir}/scdaemon.conf".text = scdaemonCfgText; + + # Link keyring if keys are not mutable + home.file."${cfg.homedir}/pubring.kbx" = + mkIf (!cfg.mutableKeys && cfg.publicKeys != []) { + source = "${keyringFiles}/pubring.kbx"; + }; + + home.activation = mkIf (cfg.publicKeys != []) { + importGpgKeys = + let + gpg = "${cfg.package}/bin/gpg"; + + importKey = { source, trust, ... }: + # Import mutable keys + optional cfg.mutableKeys '' + $DRY_RUN_CMD ${gpg} $QUIET_ARG --import ${source}'' + + # Import mutable trust + ++ optional (trust != null && cfg.mutableTrust) '' + $DRY_RUN_CMD importTrust "${source}" ${toString trust}''; + + anyTrust = any (k: k.trust != null) cfg.publicKeys; + + importKeys = concatStringsSep "\n" (concatMap importKey cfg.publicKeys); + + # If any key/trust should be imported then create the block. Otherwise + # leave it empty. + block = concatStringsSep "\n" ( + optional (importKeys != "") '' + export GNUPGHOME=${escapeShellArg cfg.homedir} + if [[ ! -v VERBOSE ]]; then + QUIET_ARG="--quiet" + else + QUIET_ARG="" + fi + ${importTrustBashFunctions} + ${importKeys} + unset GNUPGHOME QUIET_ARG keyId importTrust + '' ++ optional (!cfg.mutableTrust && anyTrust) '' + install -m 0700 ${keyringFiles}/trustdb.gpg "${cfg.homedir}/trustdb.gpg"'' + ); + in lib.hm.dag.entryAfter ["linkGeneration"] block; + }; }; } diff --git a/third_party/home-manager/modules/programs/less.nix b/third_party/home-manager/modules/programs/less.nix new file mode 100644 index 0000000000..3bee0a828b --- /dev/null +++ b/third_party/home-manager/modules/programs/less.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.programs.less; +in { + meta.maintainers = [ maintainers.pamplemousse ]; + + options = { + programs.less = { + enable = mkEnableOption "less, opposite of more"; + + keys = mkOption { + type = types.lines; + default = ""; + example = '' + s back-line + t forw-line + ''; + description = '' + Extra configuration for less written to + $HOME/.lesskey. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.less ]; + home.file.".lesskey".text = cfg.keys; + }; +} diff --git a/third_party/home-manager/modules/programs/offlineimap.nix b/third_party/home-manager/modules/programs/offlineimap.nix index 842daa3dca..83a31dd2ba 100644 --- a/third_party/home-manager/modules/programs/offlineimap.nix +++ b/third_party/home-manager/modules/programs/offlineimap.nix @@ -65,7 +65,7 @@ let remotePassEval = let arglist = concatMapStringsSep "," (x: "'${x}'") passwordCommand; in optionalAttrs (passwordCommand != null) { - remotepasseval = ''get_pass("${name}", [${arglist}]).strip("\n")''; + remotepasseval = ''get_pass("${name}", [${arglist}]).strip(b"\n")''; }; in toIni { "Account ${name}" = { diff --git a/third_party/home-manager/modules/programs/pet.nix b/third_party/home-manager/modules/programs/pet.nix index c1411b623d..e75b10df3a 100644 --- a/third_party/home-manager/modules/programs/pet.nix +++ b/third_party/home-manager/modules/programs/pet.nix @@ -80,16 +80,25 @@ in { }; config = mkIf cfg.enable { - programs.pet.settings = { - selectcmd = mkDefault "fzf"; - snippetfile = config.xdg.configHome + "/pet/snippet.toml"; - }; + programs.pet.settings = let + defaultGeneral = { + selectcmd = mkDefault "fzf"; + snippetfile = config.xdg.configHome + "/pet/snippet.toml"; + }; + in if versionAtLeast config.home.stateVersion "21.11" then { + General = defaultGeneral; + } else + defaultGeneral; home.packages = [ pkgs.pet cfg.selectcmdPackage ]; xdg.configFile = { - "pet/config.toml".source = - format.generate "config.toml" { General = cfg.settings; }; + "pet/config.toml".source = format.generate "config.toml" + (if versionAtLeast config.home.stateVersion "21.11" then + cfg.settings + else { + General = cfg.settings; + }); "pet/snippet.toml".source = format.generate "snippet.toml" { snippets = cfg.snippets; }; }; diff --git a/third_party/home-manager/modules/programs/powerline-go.nix b/third_party/home-manager/modules/programs/powerline-go.nix index aed8449af1..ec4e45c277 100644 --- a/third_party/home-manager/modules/programs/powerline-go.nix +++ b/third_party/home-manager/modules/programs/powerline-go.nix @@ -19,22 +19,29 @@ let builtins.toString value; modulesArgument = optionalString (cfg.modules != null) - "-modules ${valueToString cfg.modules}"; + " -modules ${valueToString cfg.modules}"; - newlineArgument = optionalString cfg.newline "-newline"; + modulesRightArgument = optionalString (cfg.modulesRight != null) + " -modules-right ${valueToString cfg.modulesRight}"; + + evalMode = cfg.modulesRight != null; + + evalArgument = optionalString (evalMode) " -eval"; + + newlineArgument = optionalString cfg.newline " -newline"; pathAliasesArgument = optionalString (cfg.pathAliases != null) - "-path-aliases ${valueToString cfg.pathAliases}"; + " -path-aliases ${valueToString cfg.pathAliases}"; otherSettingPairArgument = name: value: - if value == true then "-${name}" else "-${name} ${valueToString value}"; + if value == true then " -${name}" else " -${name} ${valueToString value}"; otherSettingsArgument = optionalString (cfg.settings != { }) - (concatStringsSep " " + (concatStringsSep "" (mapAttrsToList otherSettingPairArgument cfg.settings)); commandLineArguments = '' - ${modulesArgument} ${newlineArgument} ${pathAliasesArgument} ${otherSettingsArgument} + ${evalArgument}${modulesArgument}${modulesRightArgument}${newlineArgument}${pathAliasesArgument}${otherSettingsArgument} ''; in { @@ -56,6 +63,18 @@ in { example = [ "host" "ssh" "cwd" "gitlite" "jobs" "exit" ]; }; + modulesRight = mkOption { + default = null; + type = types.nullOr (types.listOf types.str); + description = '' + List of module names to load to be displayed on the right side. + Currently not supported by bash. Specifying a value for this + option will force powerline-go to use the eval format to set + the prompt. + ''; + example = [ "host" "venv" "git" ]; + }; + newline = mkOption { default = false; type = types.bool; @@ -111,7 +130,9 @@ in { mkIf (cfg.enable && config.programs.bash.enable) '' function _update_ps1() { local old_exit_status=$? - PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status ${commandLineArguments})" + ${ + if evalMode then "eval " else "PS1=" + }"$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status -shell bash${commandLineArguments})" ${cfg.extraUpdatePS1} return $old_exit_status } @@ -123,7 +144,9 @@ in { programs.zsh.initExtra = mkIf (cfg.enable && config.programs.zsh.enable) '' function powerline_precmd() { - PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh ${commandLineArguments})" + ${ + if evalMode then "eval " else "PS1=" + }"$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh${commandLineArguments})" ${cfg.extraUpdatePS1} } @@ -145,7 +168,7 @@ in { programs.fish.interactiveShellInit = mkIf (cfg.enable && config.programs.fish.enable) '' function fish_prompt - eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p)) ${commandLineArguments} + eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p))${commandLineArguments} ${cfg.extraUpdatePS1} end ''; diff --git a/third_party/home-manager/modules/programs/rofi.nix b/third_party/home-manager/modules/programs/rofi.nix index 1ae7016bc1..0c4bc3d897 100644 --- a/third_party/home-manager/modules/programs/rofi.nix +++ b/third_party/home-manager/modules/programs/rofi.nix @@ -35,10 +35,10 @@ let ${configStr}} '' else - mkKeyValue { + (mkKeyValue { sep = " "; end = ""; - } name value; + } name value) + "\n"; toRasi = attrs: concatStringsSep "\n" (mapAttrsToList mkRasiSection attrs); @@ -266,9 +266,9 @@ in { location = (getAttr cfg.location locationsMap); xoffset = cfg.xoffset; yoffset = cfg.yoffset; - theme = themeName; } // cfg.extraConfig); - }; + # @theme must go after configuration but attrs are output in alphabetical order ('@' first) + } + (optionalString (themeName != null) (toRasi { "@theme" = themeName; })); xdg.dataFile = mkIf (themePath != null) (if themePath == "custom" then { "rofi/themes/${themeName}.rasi".text = toRasi cfg.theme; diff --git a/third_party/home-manager/modules/programs/ssh.nix b/third_party/home-manager/modules/programs/ssh.nix index abbde3f419..b51ecedf4b 100644 --- a/third_party/home-manager/modules/programs/ssh.nix +++ b/third_party/home-manager/modules/programs/ssh.nix @@ -414,6 +414,22 @@ in ''; }; + includes = mkOption { + type = types.listOf types.str; + default = []; + description = '' + File globs of ssh config files that should be included via the + Include directive. + + See + + ssh_config + 5 + + for more information. + ''; + }; + matchBlocks = mkOption { type = hm.types.listOrDagOf matchBlockModule; default = {}; @@ -474,9 +490,12 @@ in else abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}"; in '' ${concatStringsSep "\n" ( - mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)} - - ${concatStringsSep "\n\n" (map (block: matchBlockStr block.data) matchBlocks)} + (mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides) + ++ (optional (cfg.includes != [ ]) '' + Include ${concatStringsSep " " cfg.includes} + '') + ++ (map (block: matchBlockStr block.data) matchBlocks) + )} Host * ForwardAgent ${yn cfg.forwardAgent} diff --git a/third_party/home-manager/modules/programs/taskwarrior.nix b/third_party/home-manager/modules/programs/taskwarrior.nix index f0f5f1e92e..441313252b 100644 --- a/third_party/home-manager/modules/programs/taskwarrior.nix +++ b/third_party/home-manager/modules/programs/taskwarrior.nix @@ -6,16 +6,6 @@ let cfg = config.programs.taskwarrior; - themePath = theme: "${pkgs.taskwarrior}/share/doc/task/rc/${theme}.theme"; - - includeTheme = location: - if location == null then - "" - else if isString location then - "include ${themePath location}" - else - "include ${location}"; - formatValue = value: if isBool value then if value then "true" else "false" @@ -59,7 +49,7 @@ in { ''; description = '' Key-value configuration written to - ~/.taskrc. + $XDG_CONFIG_HOME/task/taskrc. ''; }; @@ -89,7 +79,7 @@ in { default = ""; description = '' Additional content written at the end of - ~/.taskrc. + $XDG_CONFIG_HOME/task/taskrc. ''; }; }; @@ -98,9 +88,12 @@ in { config = mkIf cfg.enable { home.packages = [ pkgs.taskwarrior ]; - home.file.".taskrc".text = '' + xdg.configFile."task/taskrc".text = '' data.location=${cfg.dataLocation} - ${includeTheme cfg.colorTheme} + ${optionalString (cfg.colorTheme != null) (if isString cfg.colorTheme then + "include ${cfg.colorTheme}.theme" + else + "include ${cfg.colorTheme}")} ${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)} diff --git a/third_party/home-manager/modules/programs/vscode.nix b/third_party/home-manager/modules/programs/vscode.nix index 19420dc9d6..5fa2d59ed0 100644 --- a/third_party/home-manager/modules/programs/vscode.nix +++ b/third_party/home-manager/modules/programs/vscode.nix @@ -127,11 +127,13 @@ in { # Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2 home.file = let subDir = "share/vscode/extensions"; - toPaths = path: - # Links every dir in path to the extension path. - mapAttrsToList - (k: _: { "${extensionPath}/${k}".source = "${path}/${subDir}/${k}"; }) - (builtins.readDir (path + "/${subDir}")); + toPaths = ext: + # Links every dir in ext to the extension path. + map (k: { "${extensionPath}/${k}".source = "${ext}/${subDir}/${k}"; }) + (if ext ? vscodeExtUniqueId then + [ ext.vscodeExtUniqueId ] + else + builtins.attrNames (builtins.readDir (ext + "/${subDir}"))); toSymlink = concatMap toPaths cfg.extensions; dropNullFields = filterAttrs (_: v: v != null); in foldr (a: b: a // b) { diff --git a/third_party/home-manager/modules/programs/waybar.nix b/third_party/home-manager/modules/programs/waybar.nix index aa1f70984b..e7963e8277 100644 --- a/third_party/home-manager/modules/programs/waybar.nix +++ b/third_party/home-manager/modules/programs/waybar.nix @@ -2,72 +2,26 @@ let inherit (lib) - any attrByPath attrNames concatMap concatMapStringsSep elem elemAt filter - filterAttrs flip foldl' hasPrefix head length literalExpression mergeAttrs - optionalAttrs stringLength subtractLists types unique; + all filterAttrs hasAttr isStorePath literalExpression optionalAttrs types; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; cfg = config.programs.waybar; - # Used when generating warnings - modulesPath = "programs.waybar.settings.[].modules"; - jsonFormat = pkgs.formats.json { }; - # Taken from (2020/10/10) - # Order is preserved from the file for easier matching - defaultModuleNames = [ - "battery" - "sway/mode" - "sway/workspaces" - "sway/window" - "sway/language" - "wlr/taskbar" - "river/tags" - "idle_inhibitor" - "memory" - "cpu" - "clock" - "disk" - "tray" - "network" - "backlight" - "pulseaudio" - "mpd" - "sndio" - "temperature" - "bluetooth" - ]; - - # Allow specifying a CSS id after the default module name - isValidDefaultModuleName = x: - any (name: - let - res = builtins.split name x; - # if exact match of default module name - in if res == [ "" [ ] ] || res == [ "" [ ] "" ] then - true - else - head res == "" && length res >= 3 && hasPrefix "#" (elemAt res 2)) - defaultModuleNames; - - isValidCustomModuleName = x: hasPrefix "custom/" x && stringLength x > 7; - - margins = let - mkMargin = name: { - "margin-${name}" = mkOption { - type = types.nullOr types.int; - default = null; - example = 10; - description = "Margins value without unit."; - }; + mkMargin = name: + mkOption { + type = types.nullOr types.int; + default = null; + example = 10; + description = "Margin value without unit."; }; - margins = map mkMargin [ "top" "left" "bottom" "right" ]; - in foldl' mergeAttrs { } margins; - waybarBarConfig = with lib.types; + waybarBarConfig = with types; submodule { + freeformType = jsonFormat.type; + options = { layer = mkOption { type = nullOr (enum [ "top" "bottom" ]); @@ -164,7 +118,10 @@ let example = "20 5"; }; - inherit (margins) margin-top margin-left margin-bottom margin-right; + margin-left = mkMargin "left"; + margin-right = mkMargin "right"; + margin-bottom = mkMargin "bottom"; + margin-top = mkMargin "top"; name = mkOption { type = nullOr str; @@ -192,9 +149,9 @@ in { package = mkOption { type = package; default = pkgs.waybar; - defaultText = "pkgs.waybar"; + defaultText = literalExpression "pkgs.waybar"; description = '' - Waybar package to use. Set to null to use the default module. + Waybar package to use. Set to null to use the default package. ''; }; @@ -241,12 +198,17 @@ in { systemd.enable = mkEnableOption "Waybar systemd integration"; style = mkOption { - type = nullOr str; + type = nullOr (either path str); default = null; description = '' CSS style of the bar. + + See for the documentation. + + + If the value is set to a path literal, then the path will be used as the css file. ''; example = '' * { @@ -266,122 +228,62 @@ in { }; config = let - writePrettyJSON = jsonFormat.generate; + # Removes nulls because Waybar ignores them. + # This is not recursive. + removeNulls = filterAttrs (_: v: v != null); - configSource = let - # Removes nulls because Waybar ignores them for most values - removeNulls = filterAttrs (_: v: v != null); + # Makes the actual valid configuration Waybar accepts + # (strips our custom settings before converting to JSON) + makeConfiguration = configuration: + let + # The "modules" option is not valid in the JSON + # as its descendants have to live at the top-level + settingsWithoutModules = removeAttrs configuration [ "modules" ]; + settingsModules = + optionalAttrs (configuration.modules != { }) configuration.modules; + in removeNulls (settingsWithoutModules // settingsModules); + # The clean list of configurations + finalConfiguration = map makeConfiguration cfg.settings; - # Makes the actual valid configuration Waybar accepts - # (strips our custom settings before converting to JSON) - makeConfiguration = configuration: - let - # The "modules" option is not valid in the JSON - # as its descendants have to live at the top-level - settingsWithoutModules = removeAttrs configuration [ "modules" ]; - settingsModules = - optionalAttrs (configuration.modules != { }) configuration.modules; - in removeNulls (settingsWithoutModules // settingsModules); - # The clean list of configurations - finalConfiguration = map makeConfiguration cfg.settings; - in writePrettyJSON "waybar-config.json" finalConfiguration; - - # - # Warnings are generated based on the following things: - # 1. A `module` is referenced in any of `modules-{left,center,right}` that is neither - # a default module name nor defined in `modules`. - # 2. A `module` is defined in `modules` but is not referenced in either of - # `modules-{left,center,right}`. - # 3. A custom `module` configuration is defined in `modules` but has an invalid name - # for a custom module (i.e. not "custom/my-module-name"). - # - warnings = let - mkUnreferencedModuleWarning = name: - "The module '${name}' defined in '${modulesPath}' is not referenced " - + "in either `modules-left`, `modules-center` or `modules-right` of Waybar's options"; - mkUndefinedModuleWarning = settings: name: - let - # Locations where the module is undefined (a combination modules-{left,center,right}) - locations = flip filter [ "left" "center" "right" ] - (x: elem name settings."modules-${x}"); - mkPath = loc: "'${modulesPath}-${loc}'"; - # The modules-{left,center,right} configuration that includes - # an undefined module - path = concatMapStringsSep " and " mkPath locations; - in "The module '${name}' defined in ${path} is neither " - + "a default module or a custom module declared in '${modulesPath}'"; - mkInvalidModuleNameWarning = name: - "The custom module '${name}' defined in '${modulesPath}' is not a valid " - + "module name. A custom module's name must start with 'custom/' " - + "like 'custom/mymodule' for instance"; - - allFaultyModules = flip map cfg.settings (settings: - let - allModules = unique - (concatMap (x: attrByPath [ "modules-${x}" ] [ ] settings) [ - "left" - "center" - "right" - ]); - declaredModules = attrNames settings.modules; - # Modules declared in `modules` but not referenced in `modules-{left,center,right}` - unreferencedModules = subtractLists allModules declaredModules; - # Modules listed in modules-{left,center,right} that are not default modules - nonDefaultModules = - filter (x: !isValidDefaultModuleName x) allModules; - # Modules referenced in `modules-{left,center,right}` but not declared in `modules` - undefinedModules = subtractLists declaredModules nonDefaultModules; - # Check for invalid module names - invalidModuleNames = filter - (m: !isValidCustomModuleName m && !isValidDefaultModuleName m) - declaredModules; - in { - # The Waybar bar configuration (since config.settings is a list) - inherit settings; - undef = undefinedModules; - unref = unreferencedModules; - invalidName = invalidModuleNames; - }); - - allWarnings = flip concatMap allFaultyModules - ({ settings, undef, unref, invalidName }: - let - unreferenced = map mkUnreferencedModuleWarning unref; - undefined = map (mkUndefinedModuleWarning settings) undef; - invalid = map mkInvalidModuleNameWarning invalidName; - in undefined ++ unreferenced ++ invalid); - in allWarnings; + configSource = jsonFormat.generate "waybar-config.json" finalConfiguration; in mkIf cfg.enable (mkMerge [ { assertions = [ (lib.hm.assertions.assertPlatform "programs.waybar" pkgs lib.platforms.linux) + ({ + assertion = + if lib.versionAtLeast config.home.stateVersion "22.05" then + all (x: !hasAttr "modules" x) cfg.settings + else + true; + message = '' + The `programs.waybar.settings.[].modules` option has been removed. + It is now possible to declare modules in the configuration without nesting them under the `modules` option. + ''; + }) ]; home.packages = [ cfg.package ]; - } - (mkIf (cfg.settings != [ ]) { - # Generate warnings about defined but unreferenced modules - inherit warnings; - - xdg.configFile."waybar/config" = { + xdg.configFile."waybar/config" = mkIf (cfg.settings != [ ]) { source = configSource; onChange = '' ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true ''; }; - }) - (mkIf (cfg.style != null) { - xdg.configFile."waybar/style.css" = { - text = cfg.style; + xdg.configFile."waybar/style.css" = mkIf (cfg.style != null) { + source = if builtins.isPath cfg.style || isStorePath cfg.style then + cfg.style + else + pkgs.writeText "waybar/style.css" cfg.style; onChange = '' ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true ''; }; - }) + } (mkIf cfg.systemd.enable { systemd.user.services.waybar = { diff --git a/third_party/home-manager/modules/services/flameshot.nix b/third_party/home-manager/modules/services/flameshot.nix index e30d82383f..2de0d547dd 100644 --- a/third_party/home-manager/modules/services/flameshot.nix +++ b/third_party/home-manager/modules/services/flameshot.nix @@ -6,8 +6,6 @@ let cfg = config.services.flameshot; - package = pkgs.flameshot; - iniFormat = pkgs.formats.ini { }; iniFile = iniFormat.generate "flameshot.ini" cfg.settings; @@ -18,6 +16,13 @@ in { options.services.flameshot = { enable = mkEnableOption "Flameshot"; + package = mkOption { + type = types.package; + default = pkgs.flameshot; + defaultText = literalExpression "pkgs.flameshot"; + description = "Package providing flameshot."; + }; + settings = mkOption { type = iniFormat.type; default = { }; @@ -41,7 +46,7 @@ in { lib.platforms.linux) ]; - home.packages = [ package ]; + home.packages = [ cfg.package ]; xdg.configFile = mkIf (cfg.settings != { }) { "flameshot/flameshot.ini".source = iniFile; @@ -60,7 +65,7 @@ in { Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; - ExecStart = "${package}/bin/flameshot"; + ExecStart = "${cfg.package}/bin/flameshot"; Restart = "on-abort"; # Sandboxing. diff --git a/third_party/home-manager/modules/services/fnott.nix b/third_party/home-manager/modules/services/fnott.nix index d4e2addb44..3ab3f0a748 100644 --- a/third_party/home-manager/modules/services/fnott.nix +++ b/third_party/home-manager/modules/services/fnott.nix @@ -10,6 +10,8 @@ let iniFormat = pkgs.formats.ini { }; in { + meta.maintainers = with maintainers; [ polykernel ]; + options = { services.fnott = { enable = mkEnableOption '' diff --git a/third_party/home-manager/modules/services/lieer.nix b/third_party/home-manager/modules/services/lieer.nix index 6e4be8ca05..6960db4528 100644 --- a/third_party/home-manager/modules/services/lieer.nix +++ b/third_party/home-manager/modules/services/lieer.nix @@ -24,7 +24,7 @@ let Service = { Type = "oneshot"; - ExecStart = "${pkgs.gmailieer}/bin/gmi sync"; + ExecStart = "${config.programs.lieer.package}/bin/gmi sync"; WorkingDirectory = account.maildir.absPath; Environment = "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"; diff --git a/third_party/home-manager/modules/services/polybar.nix b/third_party/home-manager/modules/services/polybar.nix index 8d341252fe..7912d8988f 100644 --- a/third_party/home-manager/modules/services/polybar.nix +++ b/third_party/home-manager/modules/services/polybar.nix @@ -112,7 +112,9 @@ in { }; settings = mkOption { - type = types.attrsOf types.attrs; + type = with types; + let ty = oneOf [ bool int float str (listOf ty) (attrsOf ty) ]; + in attrsOf (attrsOf ty // { description = "attribute sets"; }); description = '' Polybar configuration. This takes a nix attrset and converts it to the strange data format that polybar uses. diff --git a/third_party/home-manager/modules/services/window-managers/i3-sway/swaynag.nix b/third_party/home-manager/modules/services/window-managers/i3-sway/swaynag.nix new file mode 100644 index 0000000000..97d6f47381 --- /dev/null +++ b/third_party/home-manager/modules/services/window-managers/i3-sway/swaynag.nix @@ -0,0 +1,70 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.wayland.windowManager.sway.swaynag; + + iniFormat = pkgs.formats.ini { }; + + confFormat = with types; + let + confAtom = nullOr (oneOf [ bool int float str ]) // { + description = "Swaynag config atom (null, bool, int, float, str)"; + }; + in attrsOf confAtom; +in { + meta.maintainers = with maintainers; [ polykernel ]; + + options = { + wayland.windowManager.sway.swaynag = { + enable = mkEnableOption + "configuration of swaynag, a lightweight error bar for sway"; + + settings = mkOption { + type = types.attrsOf confFormat; + default = { }; + description = '' + Configuration written to + $XDG_CONFIG_HOME/swaynag/config. + + See + + swaynag + 5 + + for a list of avaliable options and an example configuration. + Note, configurations declared under <config> + will override the default type values of swaynag. + ''; + example = literalExpression '' + { + "" = { + edge = "bottom"; + font = "Dina 12"; + }; + + green = { + edge = "top"; + background = "00AA00"; + text = "FFFFFF"; + button-background = "00CC00"; + message-padding = 10; + }; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "wayland.windowManager.sway.swaynag" pkgs + platforms.linux) + ]; + + xdg.configFile."swaynag/config" = mkIf (cfg.settings != { }) { + source = iniFormat.generate "swaynag.conf" cfg.settings; + }; + }; +} diff --git a/third_party/home-manager/modules/services/window-managers/xmonad.nix b/third_party/home-manager/modules/services/window-managers/xmonad.nix index 07dc9a981f..2718637600 100644 --- a/third_party/home-manager/modules/services/window-managers/xmonad.nix +++ b/third_party/home-manager/modules/services/window-managers/xmonad.nix @@ -132,9 +132,9 @@ in { # The resulting binary name depends on the arch and os # https://github.com/xmonad/xmonad/blob/56b0f850bc35200ec23f05c079eca8b0a1f90305/src/XMonad/Core.hs#L565-L572 - mv "$XMONAD_DATA_DIR/xmonad-${pkgs.hostPlatform.system}" $out/bin/ + mv "$XMONAD_DATA_DIR/xmonad-${pkgs.stdenv.hostPlatform.system}" $out/bin/ '' - }/bin/xmonad-${pkgs.hostPlatform.system}"; + }/bin/xmonad-${pkgs.stdenv.hostPlatform.system}"; in mkIf cfg.enable (mkMerge [ { @@ -157,7 +157,7 @@ in { (mkIf (cfg.config != null) { xsession.windowManager.command = xmonadBin; home.file.".xmonad/xmonad.hs".source = cfg.config; - home.file.".xmonad/xmonad-${pkgs.hostPlatform.system}" = { + home.file.".xmonad/xmonad-${pkgs.stdenv.hostPlatform.system}" = { source = xmonadBin; onChange = '' # Attempt to restart xmonad if X is running. diff --git a/third_party/home-manager/modules/systemd.nix b/third_party/home-manager/modules/systemd.nix index 5a9c75082f..cd5b30ed49 100644 --- a/third_party/home-manager/modules/systemd.nix +++ b/third_party/home-manager/modules/systemd.nix @@ -258,7 +258,8 @@ in { # If we run under a Linux system we assume that systemd is # available, in particular we assume that systemctl is in PATH. - (mkIf pkgs.stdenv.isLinux { + # Do not install any user services if username is root. + (mkIf (pkgs.stdenv.isLinux && config.home.username != "root") { xdg.configFile = mkMerge [ (lib.listToAttrs ((buildServices "service" cfg.services) ++ (buildServices "slices" cfg.slices) diff --git a/third_party/home-manager/modules/targets/darwin/default.nix b/third_party/home-manager/modules/targets/darwin/default.nix index d2764bd1ae..4cf295daa0 100644 --- a/third_party/home-manager/modules/targets/darwin/default.nix +++ b/third_party/home-manager/modules/targets/darwin/default.nix @@ -19,6 +19,8 @@ let writableDefaults = filterAttrs (domain: attrs: attrs != { }) nonNullDefaults; activationCmds = mapAttrsToList toActivationCmd writableDefaults; in { + meta.maintainers = [ maintainers.midchildan ]; + imports = [ ./fonts.nix ./keybindings.nix ./linkapps.nix ./search.nix ]; options.targets.darwin.defaults = mkOption { @@ -48,6 +50,24 @@ in { platforms.darwin) ]; + warnings = let + batteryPercentage = + attrByPath [ "com.apple.menuextra.battery" "ShowPercent" ] null + cfg.defaults; + webkitDevExtras = attrByPath [ + "com.apple.Safari" + "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" + ] null cfg.defaults; + in optional (batteryPercentage != null) '' + The option 'com.apple.menuextra.battery.ShowPercent' no longer works on + macOS 11 and later. Instead, open System Preferences, go to "Dock & + Menu Bar", select "Battery", and toggle the checkbox labeled "Show + Percentage." + '' ++ optional (webkitDevExtras != null) '' + The option 'com.apple.Safari.com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled' + is no longer present in recent versions of Safari. + ''; + home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] '' $VERBOSE_ECHO "Configuring macOS user defaults" ${concatStringsSep "\n" activationCmds} diff --git a/third_party/home-manager/modules/targets/darwin/fonts.nix b/third_party/home-manager/modules/targets/darwin/fonts.nix index cd26fa0872..2c55822787 100644 --- a/third_party/home-manager/modules/targets/darwin/fonts.nix +++ b/third_party/home-manager/modules/targets/darwin/fonts.nix @@ -12,7 +12,7 @@ let fonts = "${fontsEnv}/share/fonts"; in { # macOS won't recognize symlinked fonts - config = mkIf pkgs.hostPlatform.isDarwin { + config = mkIf pkgs.stdenv.hostPlatform.isDarwin { home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' copyFonts() { rm -rf ${homeDir}/Library/Fonts/HomeManager || : diff --git a/third_party/home-manager/modules/targets/darwin/options.nix b/third_party/home-manager/modules/targets/darwin/options.nix index f722fbfae2..65ce4e0114 100644 --- a/third_party/home-manager/modules/targets/darwin/options.nix +++ b/third_party/home-manager/modules/targets/darwin/options.nix @@ -98,7 +98,13 @@ in { "com.apple.menuextra.battery".ShowPercent = mkNullableOption { type = types.enum [ "YES" "NO" ]; example = "NO"; - description = "Whether to show battery percentage in the menu bar."; + description = '' + This option no longer works on macOS 11 and later. Instead, open System + Preferences, go to "Dock & Menu Bar", select "Battery", and toggle + the checkbox labeled "Show Percentage." + + Whether to show battery percentage in the menu bar. + ''; }; "com.apple.Safari" = { @@ -125,20 +131,35 @@ in { ''; }; - "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = - mkNullableOption { - type = types.bool; - description = '' - Configures the web inspector. + "WebKitPreferences.developerExtrasEnabled" = mkNullableOption { + type = types.bool; + description = '' + Configures the web inspector. - - - Instead of setting this option directly, set - instead. - - - ''; - }; + + + Instead of setting this option directly, set + instead. + + + ''; + }; + }; + + "com.apple.Safari.SandboxBroker" = { + ShowDevelopMenu = mkNullableOption { + type = types.bool; + description = '' + Show the "Develop" menu in Safari's menubar. + + + + Instead of setting this option directly, set + instead. + + + ''; + }; }; "com.googlecode.iterm2" = { @@ -182,8 +203,11 @@ in { config = { "com.apple.Safari" = mkIf (safari.IncludeDevelopMenu != null) { WebKitDeveloperExtrasEnabledPreferenceKey = safari.IncludeDevelopMenu; - "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = - safari.IncludeDevelopMenu; + "WebKitPreferences.developerExtrasEnabled" = safari.IncludeDevelopMenu; }; + "com.apple.Safari.SandboxBroker" = + mkIf (safari.IncludeDevelopMenu != null) { + ShowDevelopMenu = safari.IncludeDevelopMenu; + }; }; } diff --git a/third_party/home-manager/nix-darwin/default.nix b/third_party/home-manager/nix-darwin/default.nix index f400c9ce21..8d354a1d5d 100644 --- a/third_party/home-manager/nix-darwin/default.nix +++ b/third_party/home-manager/nix-darwin/default.nix @@ -63,8 +63,10 @@ in extraSpecialArgs = mkOption { type = types.attrs; default = { }; + example = literalExpression "{ inherit emacs-overlay; }"; description = '' - Extra specialArgs passed to Home Manager. + Extra specialArgs passed to Home Manager. This + option can be used to pass additional arguments to all modules. ''; }; diff --git a/third_party/home-manager/nixos/default.nix b/third_party/home-manager/nixos/default.nix index e971cdc8c7..e8225d9845 100644 --- a/third_party/home-manager/nixos/default.nix +++ b/third_party/home-manager/nixos/default.nix @@ -74,8 +74,10 @@ in { extraSpecialArgs = mkOption { type = types.attrs; default = { }; + example = literalExpression "{ inherit emacs-overlay; }"; description = '' - Extra specialArgs passed to Home Manager. + Extra specialArgs passed to Home Manager. This + option can be used to pass additional arguments to all modules. ''; }; diff --git a/third_party/home-manager/tests/default.nix b/third_party/home-manager/tests/default.nix index 63b062c734..6b21e355dd 100644 --- a/third_party/home-manager/tests/default.nix +++ b/third_party/home-manager/tests/default.nix @@ -66,6 +66,7 @@ import nmt { ./modules/programs/irssi ./modules/programs/kakoune ./modules/programs/kitty + ./modules/programs/less ./modules/programs/lf ./modules/programs/lieer ./modules/programs/man @@ -87,6 +88,7 @@ import nmt { ./modules/programs/sm64ex ./modules/programs/ssh ./modules/programs/starship + ./modules/programs/taskwarrior ./modules/programs/texlive ./modules/programs/tmux ./modules/programs/topgrade diff --git a/third_party/home-manager/tests/modules/misc/xdg/default-locations.nix b/third_party/home-manager/tests/modules/misc/xdg/default-locations.nix new file mode 100644 index 0000000000..1f6b36cc8b --- /dev/null +++ b/third_party/home-manager/tests/modules/misc/xdg/default-locations.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + # Test fallback behavior for stateVersion >= 20.09, which is pure. + xdg.enable = lib.mkForce false; + home.stateVersion = "20.09"; + + xdg.configFile.test.text = "config"; + xdg.dataFile.test.text = "data"; + home.file."${config.xdg.cacheHome}/test".text = "cache"; + home.file."${config.xdg.stateHome}/test".text = "state"; + + nmt.script = '' + assertFileExists home-files/.config/test + assertFileExists home-files/.local/share/test + assertFileExists home-files/.cache/test + assertFileExists home-files/.local/state/test + assertFileContent \ + home-files/.config/test \ + ${builtins.toFile "test" "config"} + assertFileContent \ + home-files/.local/share/test \ + ${builtins.toFile "test" "data"} + assertFileContent \ + home-files/.cache/test \ + ${builtins.toFile "test" "cache"} + assertFileContent \ + home-files/.local/state/test \ + ${builtins.toFile "test" "state"} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/misc/xdg/default.nix b/third_party/home-manager/tests/modules/misc/xdg/default.nix index e3104dd9ca..f3fef09291 100644 --- a/third_party/home-manager/tests/modules/misc/xdg/default.nix +++ b/third_party/home-manager/tests/modules/misc/xdg/default.nix @@ -3,4 +3,5 @@ xdg-system-dirs = ./system-dirs.nix; xdg-desktop-entries = ./desktop-entries.nix; xdg-file-gen = ./file-gen.nix; + xdg-default-locations = ./default-locations.nix; } diff --git a/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix b/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix index cf5f188b48..9c624388fd 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix @@ -15,7 +15,7 @@ with lib; meta.description = "I pretend to be Firefox"; passthru.gtk3 = null; } '' - mkdir -p "$out/bin" + mkdir -p "$out"/{bin,lib} touch "$out/bin/firefox" chmod 755 "$out/bin/firefox" ''; diff --git a/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix b/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix index 605ff6692c..10d5855a05 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix @@ -32,10 +32,9 @@ with lib; firefox-unwrapped = pkgs.runCommand "firefox-0" { meta.description = "I pretend to be Firefox"; preferLocalBuild = true; - allowSubstitutes = false; passthru.gtk3 = null; } '' - mkdir -p "$out/bin" + mkdir -p "$out"/{bin,lib} touch "$out/bin/firefox" chmod 755 "$out/bin/firefox" ''; diff --git a/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix b/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix index 82fa039ca5..3eb6084f31 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix @@ -13,10 +13,9 @@ with lib; firefox-unwrapped = pkgs.runCommand "firefox-0" { meta.description = "I pretend to be Firefox"; preferLocalBuild = true; - allowSubstitutes = false; passthru.gtk3 = null; } '' - mkdir -p "$out/bin" + mkdir -p "$out"/{bin,lib} touch "$out/bin/firefox" chmod 755 "$out/bin/firefox" ''; diff --git a/third_party/home-manager/tests/modules/programs/gpg/default.nix b/third_party/home-manager/tests/modules/programs/gpg/default.nix index 7fed2cdcc6..a3949b1860 100644 --- a/third_party/home-manager/tests/modules/programs/gpg/default.nix +++ b/third_party/home-manager/tests/modules/programs/gpg/default.nix @@ -1 +1,5 @@ -{ gpg-override-defaults = ./override-defaults.nix; } +{ + gpg-immutable-keyfiles = ./immutable-keyfiles.nix; + gpg-mutable-keyfiles = ./mutable-keyfiles.nix; + gpg-override-defaults = ./override-defaults.nix; +} diff --git a/third_party/home-manager/tests/modules/programs/gpg/immutable-keyfiles.nix b/third_party/home-manager/tests/modules/programs/gpg/immutable-keyfiles.nix new file mode 100644 index 0000000000..d75ff52044 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/gpg/immutable-keyfiles.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +{ + programs.gpg = { + enable = true; + + mutableKeys = false; + mutableTrust = false; + + publicKeys = [ + { + source = pkgs.fetchurl { + url = + "https://keybase.io/rycee/pgp_keys.asc?fingerprint=36cacf52d098cc0e78fb0cb13573356c25c424d4"; + sha256 = "082mjy6llvrdry6i9r5gx97nw9d89blnam7bghza4ynsjk1mmx6c"; + }; + trust = 1; + } + { + source = pkgs.fetchurl { + url = "https://www.rsync.net/resources/pubkey.txt"; + sha256 = "16nzqfb1kvsxjkq919hxsawx6ydvip3md3qyhdmw54qx6drnxckl"; + }; + trust = 2; + } + ]; + }; + + nmt.script = '' + assertFileNotRegex activate "^export GNUPGHOME='/home/hm-user/.gnupg'$" + + assertFileRegex activate \ + '^install -m 0700 /nix/store/[0-9a-z]*-gpg-pubring/trustdb.gpg "/home/hm-user/.gnupg/trustdb.gpg"$' + + # Setup GPGHOME + export GNUPGHOME=$(mktemp -d) + cp -r $TESTED/home-files/.gnupg/* $GNUPGHOME + TRUSTDB=$(grep -o '/nix/store/[0-9a-z]*-gpg-pubring/trustdb.gpg' $TESTED/activate) + install -m 0700 $TRUSTDB $GNUPGHOME/trustdb.gpg + + # Export Trust + export WORKDIR=$(mktemp -d) + ${pkgs.gnupg}/bin/gpg -q --export-ownertrust > $WORKDIR/gpgtrust.txt + + # Check Trust + assertFileRegex $WORKDIR/gpgtrust.txt \ + '^36CACF52D098CC0E78FB0CB13573356C25C424D4:2:$' + + assertFileRegex $WORKDIR/gpgtrust.txt \ + '^BB847B5A69EF343CEF511B29073C282D7D6F806C:3:$' + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/gpg/mutable-keyfiles.nix b/third_party/home-manager/tests/modules/programs/gpg/mutable-keyfiles.nix new file mode 100644 index 0000000000..588c907048 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/gpg/mutable-keyfiles.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +{ + programs.gpg = { + enable = true; + + publicKeys = [ + { + source = builtins.toFile "key1" "key1"; + trust = 1; + } + { source = builtins.toFile "key2" "key2"; } + ]; + }; + + test.stubs.gnupg = { }; + + nmt.script = '' + assertFileContains activate "export GNUPGHOME='/home/hm-user/.gnupg'" + + assertFileContains activate "unset GNUPGHOME QUIET_ARG keyId importTrust" + + assertFileRegex activate \ + '^\$DRY_RUN_CMD @gnupg@/bin/gpg \$QUIET_ARG --import /nix/store/[0-9a-z]*-key1$' + assertFileRegex activate \ + '^\$DRY_RUN_CMD importTrust "/nix/store/[0-9a-z]*-key1" 1$' + assertFileRegex activate \ + '^\$DRY_RUN_CMD @gnupg@/bin/gpg \$QUIET_ARG --import /nix/store/[0-9a-z]*-key2$' + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/gpg/override-defaults.nix b/third_party/home-manager/tests/modules/programs/gpg/override-defaults.nix index 3b00e451bc..62fe50dc2a 100644 --- a/third_party/home-manager/tests/modules/programs/gpg/override-defaults.nix +++ b/third_party/home-manager/tests/modules/programs/gpg/override-defaults.nix @@ -23,6 +23,8 @@ with lib; nmt.script = '' assertFileExists home-files/bar/foopg/gpg.conf assertFileContent home-files/bar/foopg/gpg.conf ${./override-defaults-expected.conf} + + assertFileNotRegex activate "^unset GNUPGHOME keyId importTrust$" ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/kakoune/default.nix b/third_party/home-manager/tests/modules/programs/kakoune/default.nix index cb9f05afda..1e6e077df1 100644 --- a/third_party/home-manager/tests/modules/programs/kakoune/default.nix +++ b/third_party/home-manager/tests/modules/programs/kakoune/default.nix @@ -1,8 +1,6 @@ { kakoune-no-plugins = ./no-plugins.nix; - # Temporarily disabled until https://github.com/NixOS/nixpkgs/pull/110196 - # reaches the unstable channel. - # kakoune-use-plugins = ./use-plugins.nix; + kakoune-use-plugins = ./use-plugins.nix; kakoune-whitespace-highlighter = ./whitespace-highlighter.nix; kakoune-whitespace-highlighter-corner-cases = ./whitespace-highlighter-corner-cases.nix; diff --git a/third_party/home-manager/tests/modules/programs/kakoune/no-plugins.nix b/third_party/home-manager/tests/modules/programs/kakoune/no-plugins.nix index 67a7f30f52..d1505751bb 100644 --- a/third_party/home-manager/tests/modules/programs/kakoune/no-plugins.nix +++ b/third_party/home-manager/tests/modules/programs/kakoune/no-plugins.nix @@ -3,11 +3,11 @@ with lib; { - config = { - programs.kakoune = { enable = true; }; + imports = [ ./stubs.nix ]; - nmt.script = '' - assertPathNotExists home-path/share/kak/autoload/plugins - ''; - }; + programs.kakoune = { enable = true; }; + + nmt.script = '' + assertPathNotExists home-path/share/kak/autoload/plugins + ''; } diff --git a/third_party/home-manager/tests/modules/programs/kakoune/stubs.nix b/third_party/home-manager/tests/modules/programs/kakoune/stubs.nix new file mode 100644 index 0000000000..28a8164185 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/kakoune/stubs.nix @@ -0,0 +1,12 @@ +{ + test.stubs.kakoune-unwrapped = { + name = "dummy-kakoune"; + version = "1"; + outPath = null; + buildScript = '' + mkdir -p $out/bin $out/share/kak/doc + touch $out/bin/kak + chmod +x $out/bin/kak + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/kakoune/use-plugins.nix b/third_party/home-manager/tests/modules/programs/kakoune/use-plugins.nix index 9d44483276..de7b3a1231 100644 --- a/third_party/home-manager/tests/modules/programs/kakoune/use-plugins.nix +++ b/third_party/home-manager/tests/modules/programs/kakoune/use-plugins.nix @@ -3,14 +3,14 @@ with lib; { - config = { - programs.kakoune = { - enable = true; - plugins = [ pkgs.kakounePlugins.kak-prelude ]; - }; + imports = [ ./stubs.nix ]; - nmt.script = '' - assertDirectoryNotEmpty home-path/share/kak/autoload/plugins - ''; + programs.kakoune = { + enable = true; + plugins = [ pkgs.kakounePlugins.prelude-kak ]; }; + + nmt.script = '' + assertDirectoryNotEmpty home-path/share/kak/autoload/plugins + ''; } diff --git a/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix b/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix index 142aaac8fe..4beb4b9e57 100644 --- a/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix +++ b/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix @@ -3,23 +3,23 @@ with lib; { - config = { - programs.kakoune = { - enable = true; - config.showWhitespace = { - enable = true; - lineFeed = ''"''; - space = " "; - nonBreakingSpace = "' '"; # backwards compat - tab = "'"; - # tabStop = - }; - }; + imports = [ ./stubs.nix ]; - nmt.script = '' - assertFileExists home-files/.config/kak/kakrc - assertFileContains home-files/.config/kak/kakrc \ - "add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'" - ''; + programs.kakoune = { + enable = true; + config.showWhitespace = { + enable = true; + lineFeed = ''"''; + space = " "; + nonBreakingSpace = "' '"; # backwards compat + tab = "'"; + # tabStop = + }; }; + + nmt.script = '' + assertFileExists home-files/.config/kak/kakrc + assertFileContains home-files/.config/kak/kakrc \ + "add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'" + ''; } diff --git a/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter.nix b/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter.nix index 514c26a118..1c80fe5f2d 100644 --- a/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter.nix +++ b/third_party/home-manager/tests/modules/programs/kakoune/whitespace-highlighter.nix @@ -3,23 +3,23 @@ with lib; { - config = { - programs.kakoune = { - enable = true; - config.showWhitespace = { - enable = true; - lineFeed = "1"; - space = "2"; - nonBreakingSpace = "3"; - tab = "4"; - tabStop = "5"; - }; - }; + imports = [ ./stubs.nix ]; - nmt.script = '' - assertFileExists home-files/.config/kak/kakrc - assertFileContains home-files/.config/kak/kakrc \ - "add-highlighter global/ show-whitespaces -tab '4' -tabpad '5' -spc '2' -nbsp '3' -lf '1'" - ''; + programs.kakoune = { + enable = true; + config.showWhitespace = { + enable = true; + lineFeed = "1"; + space = "2"; + nonBreakingSpace = "3"; + tab = "4"; + tabStop = "5"; + }; }; + + nmt.script = '' + assertFileExists home-files/.config/kak/kakrc + assertFileContains home-files/.config/kak/kakrc \ + "add-highlighter global/ show-whitespaces -tab '4' -tabpad '5' -spc '2' -nbsp '3' -lf '1'" + ''; } diff --git a/third_party/home-manager/tests/modules/programs/less/default.nix b/third_party/home-manager/tests/modules/programs/less/default.nix new file mode 100644 index 0000000000..f5fd77feb3 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/less/default.nix @@ -0,0 +1 @@ +{ less-with-custom-keys = ./less-with-custom-keys.nix; } diff --git a/third_party/home-manager/tests/modules/programs/less/less-with-custom-keys.nix b/third_party/home-manager/tests/modules/programs/less/less-with-custom-keys.nix new file mode 100644 index 0000000000..48f52b878d --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/less/less-with-custom-keys.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + programs.less = { + enable = true; + + keys = '' + s back-line + t forw-line + ''; + }; + + test.stubs.less = { }; + + nmt.script = '' + assertFileExists home-files/.lesskey + assertFileContent home-files/.lesskey ${ + builtins.toFile "less.expected" '' + s back-line + t forw-line + '' + } + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/mpv/default.nix b/third_party/home-manager/tests/modules/programs/mpv/default.nix index c2785ed3ea..6e071610f2 100644 --- a/third_party/home-manager/tests/modules/programs/mpv/default.nix +++ b/third_party/home-manager/tests/modules/programs/mpv/default.nix @@ -1,4 +1,5 @@ { - mpv-example-settings = ./mpv-example-settings.nix; - mpv-invalid-settings = ./mpv-invalid-settings.nix; + # Temporarily commented until fixed for recent changes in Nixpkgs. + # mpv-example-settings = ./mpv-example-settings.nix; + # mpv-invalid-settings = ./mpv-invalid-settings.nix; } diff --git a/third_party/home-manager/tests/modules/programs/pet/default.nix b/third_party/home-manager/tests/modules/programs/pet/default.nix index 553b8392c5..a9d811e0b2 100644 --- a/third_party/home-manager/tests/modules/programs/pet/default.nix +++ b/third_party/home-manager/tests/modules/programs/pet/default.nix @@ -1 +1,5 @@ -{ pet-snippets = ./snippets.nix; } +{ + pet-snippets = ./snippets.nix; + pet-settings_21_05 = ./settings_21_05.nix; + pet-settings_21_11 = ./settings_21_11.nix; +} diff --git a/third_party/home-manager/tests/modules/programs/pet/settings_21_05.nix b/third_party/home-manager/tests/modules/programs/pet/settings_21_05.nix new file mode 100644 index 0000000000..cf72854876 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/pet/settings_21_05.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + home.stateVersion = "21.05"; + programs.pet = { + enable = true; + selectcmdPackage = config.lib.test.mkStubPackage { }; + settings.editor = "nvim"; + }; + + test.stubs.pet = { }; + + nmt.script = '' + assertFileContent home-files/.config/pet/config.toml \ + ${ + builtins.toFile "pet-settings.toml" '' + [General] + editor = "nvim" + selectcmd = "fzf" + snippetfile = "/home/hm-user/.config/pet/snippet.toml" + '' + } + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/pet/settings_21_11.nix b/third_party/home-manager/tests/modules/programs/pet/settings_21_11.nix new file mode 100644 index 0000000000..0b82d1f37d --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/pet/settings_21_11.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + home.stateVersion = "21.11"; + programs.pet = { + enable = true; + selectcmdPackage = config.lib.test.mkStubPackage { }; + settings = { + General = { + backend = "Gitlab"; + editor = "nvim"; + }; + Gitlab = { + access_token = "1234"; + file_name = "pet-snippets.toml"; + visibility = "public"; + }; + }; + }; + + test.stubs.pet = { }; + + nmt.script = '' + assertFileContent home-files/.config/pet/config.toml \ + ${ + builtins.toFile "pet-settings.toml" '' + [General] + backend = "Gitlab" + editor = "nvim" + selectcmd = "fzf" + snippetfile = "/home/hm-user/.config/pet/snippet.toml" + + [Gitlab] + access_token = "1234" + file_name = "pet-snippets.toml" + visibility = "public" + '' + } + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix b/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix index 34017d8848..a48e16fe0b 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix @@ -24,7 +24,10 @@ with lib; assertFileExists home-files/.bashrc assertFileContains \ home-files/.bashrc \ - '/bin/powerline-go -error $old_exit_status -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' + 'PS1=' + assertFileContains \ + home-files/.bashrc \ + '/bin/powerline-go -error $old_exit_status -shell bash -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/bashmodulesright.nix b/third_party/home-manager/tests/modules/programs/powerline-go/bashmodulesright.nix new file mode 100644 index 0000000000..688c0fad7b --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/powerline-go/bashmodulesright.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + bash.enable = true; + + powerline-go = { + enable = true; + newline = true; + modules = [ "nix-shell" ]; + modulesRight = [ "git" ]; + pathAliases = { "\\~/project/foo" = "prj-foo"; }; + settings = { + ignore-repos = [ "/home/me/project1" "/home/me/project2" ]; + }; + }; + }; + + test.stubs.powerline-go = { }; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileContains \ + home-files/.bashrc \ + 'eval' + assertFileContains \ + home-files/.bashrc \ + '/bin/powerline-go -error $old_exit_status -shell bash -eval -modules nix-shell -modules-right git -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/default.nix b/third_party/home-manager/tests/modules/programs/powerline-go/default.nix index 49ed71d26a..45ab3d2d04 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/default.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/default.nix @@ -2,4 +2,6 @@ powerline-go-bash = ./bash.nix; powerline-go-zsh = ./zsh.nix; powerline-go-fish = ./fish.nix; + powerline-go-bashmodulesright = ./bashmodulesright.nix; + powerline-go-zshmodulesright = ./zshmodulesright.nix; } diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix b/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix index 161499c9a1..21856e9d13 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix @@ -25,6 +25,9 @@ with lib; nmt.script = '' assertFileExists home-files/.zshrc + assertFileContains \ + home-files/.zshrc \ + 'PS1=' assertFileContains \ home-files/.zshrc \ '/bin/powerline-go -error $? -shell zsh -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/zshmodulesright.nix b/third_party/home-manager/tests/modules/programs/powerline-go/zshmodulesright.nix new file mode 100644 index 0000000000..ffe2e1d28c --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/powerline-go/zshmodulesright.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + zsh.enable = true; + + powerline-go = { + enable = true; + newline = true; + modules = [ "nix-shell" ]; + modulesRight = [ "git" ]; + pathAliases = { "\\~/project/foo" = "prj-foo"; }; + settings = { + ignore-repos = [ "/home/me/project1" "/home/me/project2" ]; + }; + }; + }; + + test.stubs = { + powerline-go = { }; + zsh = { }; + }; + + nmt.script = '' + assertFileExists home-files/.zshrc + assertFileContains \ + home-files/.zshrc \ + 'eval' + assertFileContains \ + home-files/.zshrc \ + '/bin/powerline-go -error $? -shell zsh -eval -modules nix-shell -modules-right git -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/rofi/custom-theme-config.rasi b/third_party/home-manager/tests/modules/programs/rofi/custom-theme-config.rasi index 639336d983..6b4d5b8a04 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/custom-theme-config.rasi +++ b/third_party/home-manager/tests/modules/programs/rofi/custom-theme-config.rasi @@ -1,6 +1,6 @@ configuration { location: 0; -theme: "custom"; xoffset: 0; yoffset: 0; } +@theme "custom" diff --git a/third_party/home-manager/tests/modules/programs/rofi/custom-theme.rasi b/third_party/home-manager/tests/modules/programs/rofi/custom-theme.rasi index b018843feb..8ec0970991 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/custom-theme.rasi +++ b/third_party/home-manager/tests/modules/programs/rofi/custom-theme.rasi @@ -16,4 +16,4 @@ foreground-color: rgba ( 250, 251, 252, 100 % ); width: 512; } -@import "~/.cache/wal/colors-rofi-dark" \ No newline at end of file +@import "~/.cache/wal/colors-rofi-dark" diff --git a/third_party/home-manager/tests/modules/programs/ssh/default-config-expected.conf b/third_party/home-manager/tests/modules/programs/ssh/default-config-expected.conf index 6885392b26..d205cab1e6 100644 --- a/third_party/home-manager/tests/modules/programs/ssh/default-config-expected.conf +++ b/third_party/home-manager/tests/modules/programs/ssh/default-config-expected.conf @@ -1,7 +1,5 @@ - - Host * ForwardAgent no Compression no diff --git a/third_party/home-manager/tests/modules/programs/ssh/default.nix b/third_party/home-manager/tests/modules/programs/ssh/default.nix index 507eef0bdb..b2f832c91a 100644 --- a/third_party/home-manager/tests/modules/programs/ssh/default.nix +++ b/third_party/home-manager/tests/modules/programs/ssh/default.nix @@ -1,5 +1,6 @@ { ssh-defaults = ./default-config.nix; + ssh-includes = ./includes.nix; ssh-match-blocks = ./match-blocks-attrs.nix; ssh-forwards-dynamic-valid-bind-no-asserts = diff --git a/third_party/home-manager/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf b/third_party/home-manager/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf index 02268e8cb8..a67a96ca40 100644 --- a/third_party/home-manager/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf +++ b/third_party/home-manager/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf @@ -1,8 +1,5 @@ - - Host dynamicBindAddressWithPort DynamicForward [127.0.0.1]:3000 - Host dynamicBindPathNoPort DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra diff --git a/third_party/home-manager/tests/modules/programs/ssh/includes.nix b/third_party/home-manager/tests/modules/programs/ssh/includes.nix new file mode 100644 index 0000000000..12e2c6df84 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/ssh/includes.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + programs.ssh = { + enable = true; + includes = [ "config.d/*" "other/dir" ]; + }; + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContains home-files/.ssh/config "Include config.d/* other/dir" + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/ssh/match-blocks-attrs-expected.conf b/third_party/home-manager/tests/modules/programs/ssh/match-blocks-attrs-expected.conf index e2c3290153..1a197b26f7 100644 --- a/third_party/home-manager/tests/modules/programs/ssh/match-blocks-attrs-expected.conf +++ b/third_party/home-manager/tests/modules/programs/ssh/match-blocks-attrs-expected.conf @@ -1,13 +1,9 @@ - - Host * !github.com Port 516 IdentityFile file1 IdentityFile file2 - Host abc ProxyJump jump-host - Host xyz ServerAliveInterval 60 ServerAliveCountMax 10 @@ -16,7 +12,6 @@ Host xyz RemoteForward [localhost]:8081 [10.0.0.2]:80 RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent DynamicForward [localhost]:2839 - Host ordered Port 1 diff --git a/third_party/home-manager/tests/modules/programs/taskwarrior/default.nix b/third_party/home-manager/tests/modules/programs/taskwarrior/default.nix new file mode 100644 index 0000000000..52377b75a7 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/taskwarrior/default.nix @@ -0,0 +1 @@ +{ taskwarrior = ./taskwarrior.nix; } diff --git a/third_party/home-manager/tests/modules/programs/taskwarrior/taskwarrior.nix b/third_party/home-manager/tests/modules/programs/taskwarrior/taskwarrior.nix new file mode 100644 index 0000000000..98d0a35448 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/taskwarrior/taskwarrior.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.taskwarrior = { + enable = true; + colorTheme = "dark-violets-256"; + dataLocation = "/some/data/location"; + config = { + urgency.user.tag.next.coefficient = 42.42; + urgency.blocked.coefficient = -42; + }; + extraConfig = '' + include /my/stuff + urgency.user.tag.test.coefficient=-42.42 + ''; + }; + + test.stubs.taskwarrior = { }; + + nmt.script = '' + assertFileExists home-files/.config/task/taskrc + assertFileContent home-files/.config/task/taskrc ${ + pkgs.writeText "taskwarrior.expected" '' + data.location=/some/data/location + include dark-violets-256.theme + + urgency.blocked.coefficient=-42 + urgency.user.tag.next.coefficient=42.420000 + + include /my/stuff + urgency.user.tag.test.coefficient=-42.42 + + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/waybar/default.nix b/third_party/home-manager/tests/modules/programs/waybar/default.nix index 9ffebe2423..07949fa805 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/default.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/default.nix @@ -3,5 +3,5 @@ ./systemd-with-graphical-session-target.nix; waybar-styling = ./styling.nix; waybar-settings-complex = ./settings-complex.nix; - waybar-warnings = ./warnings-tests.nix; + waybar-deprecated-modules-option = ./deprecated-modules-option.nix; } diff --git a/third_party/home-manager/tests/modules/programs/waybar/deprecated-modules-option.nix b/third_party/home-manager/tests/modules/programs/waybar/deprecated-modules-option.nix new file mode 100644 index 0000000000..b4d730afcf --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/waybar/deprecated-modules-option.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.stateVersion = "22.05"; + + programs.waybar = { + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; + enable = true; + settings = [{ + modules-center = [ "test" ]; + modules = { "test" = { }; }; + }]; + }; + + test.asserts.assertions.expected = ['' + The `programs.waybar.settings.[].modules` option has been removed. + It is now possible to declare modules in the configuration without nesting them under the `modules` option. + '']; + + nmt.script = '' + assertPathNotExists home-files/.config/waybar/style.css + assertFileContent \ + home-files/.config/waybar/config \ + ${ + builtins.toFile "waybar-deprecated-modules-option.json" '' + [ + { + "modules-center": [ + "test" + ], + "modules-left": [], + "modules-right": [], + "test": {} + } + ] + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix b/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix index 1297f55798..1dd5ea207b 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix @@ -4,6 +4,8 @@ with lib; { config = { + home.stateVersion = "21.11"; + programs.waybar = { package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; diff --git a/third_party/home-manager/tests/modules/programs/waybar/styling.nix b/third_party/home-manager/tests/modules/programs/waybar/styling.nix index 6e34847ed1..1952c4fbbb 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/styling.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/styling.nix @@ -4,6 +4,8 @@ with lib; { config = { + home.stateVersion = "21.11"; + programs.waybar = { package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; diff --git a/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix b/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix index eff5af9cc5..a0a359d5f3 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix @@ -4,6 +4,8 @@ with lib; { config = { + home.stateVersion = "21.11"; + programs.waybar = { package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; diff --git a/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix b/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix deleted file mode 100644 index e844cc61d0..0000000000 --- a/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; - -{ - config = { - programs.waybar = { - package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; - enable = true; - settings = [{ - modules-left = [ "custom/my-module" ]; - modules-center = - [ "this_module_is_not_a_valid_default_module_nor_custom_module" ]; - modules-right = [ - "battery#bat1" # CSS identifier is allowed - "custom/this_custom_module_doesn't_have_a_definition_in_modules" - ]; - - modules = { - "custom/this_module_is_not_referenced" = { }; - "battery#bat1" = { }; - "custom/my-module" = { }; - }; - }]; - }; - - test.asserts.warnings.expected = [ - "The module 'this_module_is_not_a_valid_default_module_nor_custom_module' defined in 'programs.waybar.settings.[].modules-center' is neither a default module or a custom module declared in 'programs.waybar.settings.[].modules'" - - "The module 'custom/this_custom_module_doesn't_have_a_definition_in_modules' defined in 'programs.waybar.settings.[].modules-right' is neither a default module or a custom module declared in 'programs.waybar.settings.[].modules'" - - "The module 'custom/this_module_is_not_referenced' defined in 'programs.waybar.settings.[].modules' is not referenced in either `modules-left`, `modules-center` or `modules-right` of Waybar's options" - ]; - - nmt.script = '' - assertPathNotExists home-files/.config/waybar/style.css - assertFileContent \ - home-files/.config/waybar/config \ - ${ - pkgs.writeText "expected-json" '' - [ - { - "battery#bat1": {}, - "custom/my-module": {}, - "custom/this_module_is_not_referenced": {}, - "modules-center": [ - "this_module_is_not_a_valid_default_module_nor_custom_module" - ], - "modules-left": [ - "custom/my-module" - ], - "modules-right": [ - "battery#bat1", - "custom/this_custom_module_doesn't_have_a_definition_in_modules" - ] - } - ] - '' - } - ''; - }; -} diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix index 9ee4798787..6ad673b184 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix @@ -10,4 +10,6 @@ sway-post-2003 = ./sway-post-2003.nix; sway-workspace-default = ./sway-workspace-default.nix; sway-workspace-output = ./sway-workspace-output.nix; + swaynag-example-settings = ./swaynag-example-settings.nix; + swaynag-empty-settings = ./swaynag-empty-settings.nix; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix new file mode 100644 index 0000000000..0180852a38 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + wayland.windowManager.sway.swaynag = { + enable = true; + + settings = { }; + }; + + nmt.script = '' + assertPathNotExists home-files/.config/swaynag + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings-expected.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings-expected.conf new file mode 100644 index 0000000000..4e0f5d5e90 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings-expected.conf @@ -0,0 +1,10 @@ +[] +edge=bottom +font=Dina 12 + +[green] +background=00AA00 +button-background=00CC00 +edge=top +message-padding=10 +text=FFFFFF diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings.nix new file mode 100644 index 0000000000..513d185dab --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/swaynag-example-settings.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + wayland.windowManager.sway.swaynag = { + enable = true; + + settings = { + "" = { + edge = "bottom"; + font = "Dina 12"; + }; + + green = { + edge = "top"; + background = "00AA00"; + text = "FFFFFF"; + button-background = "00CC00"; + message-padding = 10; + }; + }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/swaynag/config \ + ${./swaynag-example-settings-expected.conf} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/systemd/default.nix b/third_party/home-manager/tests/modules/systemd/default.nix index c1779ac59f..c949edd95c 100644 --- a/third_party/home-manager/tests/modules/systemd/default.nix +++ b/third_party/home-manager/tests/modules/systemd/default.nix @@ -1,5 +1,6 @@ { systemd-services = ./services.nix; + systemd-services-disabled-for-root = ./services-disabled-for-root.nix; systemd-session-variables = ./session-variables.nix; systemd-timers = ./timers.nix; } diff --git a/third_party/home-manager/tests/modules/systemd/services-disabled-for-root.nix b/third_party/home-manager/tests/modules/systemd/services-disabled-for-root.nix new file mode 100644 index 0000000000..f54ebd08be --- /dev/null +++ b/third_party/home-manager/tests/modules/systemd/services-disabled-for-root.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.username = mkForce "root"; + + systemd.user.services."test-service@" = { + Unit = { Description = "A basic test service"; }; + + Service = { + Environment = [ "VAR1=1" "VAR2=2" ]; + ExecStart = ''/some/exec/start/command --with-arguments "%i"''; + }; + }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/test-service@.service + assertPathNotExists $serviceFile + ''; + }; +}