From e4c63eb66aaa10e447f010b3d0f28e3a278ad30d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 14 Jan 2017 13:11:06 +0100 Subject: Add license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..216b3e3e076 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Robert Helgesson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. -- cgit v1.2.3 From d7d02c3ce8f723b3cff03ea7502011883eef8fde Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 7 Jan 2017 19:16:26 +0100 Subject: Initial import --- default.nix | 2 + home-manager/default.nix | 39 ++++ home-manager/home-manager | 62 ++++++ modules/default.nix | 47 +++++ modules/home-environment.nix | 314 ++++++++++++++++++++++++++++ modules/lib/generators.nix | 93 ++++++++ modules/programs/bash.nix | 159 ++++++++++++++ modules/programs/beets.nix | 28 +++ modules/programs/eclipse.nix | 39 ++++ modules/programs/emacs.nix | 29 +++ modules/programs/git.nix | 102 +++++++++ modules/programs/gnome-terminal.nix | 186 ++++++++++++++++ modules/programs/lesspipe.nix | 17 ++ modules/programs/texlive.nix | 32 +++ modules/services/dunst.nix | 35 ++++ modules/services/gnome-keyring.nix | 52 +++++ modules/services/gpg-agent.nix | 69 ++++++ modules/services/keepassx.nix | 27 +++ modules/services/network-manager-applet.nix | 27 +++ modules/services/random-background.nix | 74 +++++++ modules/services/taffybar.nix | 41 ++++ modules/services/tahoe-lafs.nix | 23 ++ modules/services/udiskie.nix | 29 +++ modules/services/xscreensaver.nix | 27 +++ modules/systemd.nix | 119 +++++++++++ modules/xsession.nix | 77 +++++++ 26 files changed, 1749 insertions(+) create mode 100644 default.nix create mode 100644 home-manager/default.nix create mode 100644 home-manager/home-manager create mode 100644 modules/default.nix create mode 100644 modules/home-environment.nix create mode 100644 modules/lib/generators.nix create mode 100644 modules/programs/bash.nix create mode 100644 modules/programs/beets.nix create mode 100644 modules/programs/eclipse.nix create mode 100644 modules/programs/emacs.nix create mode 100644 modules/programs/git.nix create mode 100644 modules/programs/gnome-terminal.nix create mode 100644 modules/programs/lesspipe.nix create mode 100644 modules/programs/texlive.nix create mode 100644 modules/services/dunst.nix create mode 100644 modules/services/gnome-keyring.nix create mode 100644 modules/services/gpg-agent.nix create mode 100644 modules/services/keepassx.nix create mode 100644 modules/services/network-manager-applet.nix create mode 100644 modules/services/random-background.nix create mode 100644 modules/services/taffybar.nix create mode 100644 modules/services/tahoe-lafs.nix create mode 100644 modules/services/udiskie.nix create mode 100644 modules/services/xscreensaver.nix create mode 100644 modules/systemd.nix create mode 100644 modules/xsession.nix diff --git a/default.nix b/default.nix new file mode 100644 index 00000000000..d9024779c74 --- /dev/null +++ b/default.nix @@ -0,0 +1,2 @@ +# Simply defer to the home-manager script derivation. +import ./home-manager diff --git a/home-manager/default.nix b/home-manager/default.nix new file mode 100644 index 00000000000..d00edbfbdb0 --- /dev/null +++ b/home-manager/default.nix @@ -0,0 +1,39 @@ +{ pkgs }: + +let + + homeManagerExpr = pkgs.writeText "home-manager.nix" '' + { pkgs ? import {}, confPath, modulesPath }: + + let + env = import modulesPath { + configuration = import confPath; + pkgs = pkgs; + }; + in + { + inherit (env) activation-script; + } + ''; + +in + +pkgs.stdenv.mkDerivation { + name = "home-manager"; + + phases = [ "installPhase" ]; + + installPhase = '' + install -v -D -m755 ${./home-manager} $out/bin/home-manager + + substituteInPlace $out/bin/home-manager \ + --subst-var-by bash "${pkgs.bash}" \ + --subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}" + ''; + + meta = with pkgs.stdenv.lib; { + description = "A user environment configurator"; + maintainers = [ maintainers.rycee ]; + platforms = platforms.linux; + }; +} diff --git a/home-manager/home-manager b/home-manager/home-manager new file mode 100644 index 00000000000..63dac595f7a --- /dev/null +++ b/home-manager/home-manager @@ -0,0 +1,62 @@ +#!@bash@/bin/bash + +function doRebuild() { + if [[ -z "$1" ]] ; then + echo "Need to provide path to configuration file." + exit 1 + fi + + local wrkdir + wrkdir="$(mktemp -d)" + + nix-build --show-trace \ + "@HOME_MANAGER_EXPR_PATH@" \ + --argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \ + --argstr confPath "$1" \ + -A activation-script \ + -o "$wrkdir/activate" + + "$wrkdir/activate/libexec/home-activate" + + rm -rv "$wrkdir" +} + +function doListGens() { + ls --color=yes -gG --sort time "/nix/var/nix/gcroots/per-user/$(whoami)" \ + | cut -d' ' -f 4- +} + +function doListPackages() { + local outPath + outPath="$(nix-env -q --out-path | grep -o '/.*home-manager-path$')" + nix-store -q --references "$outPath" | sed 's/[^-]*-//' +} + +function doHelp() { + echo "Usage: $0 {help | rebuild CONF | generations | packages}" + echo + echo "Commands" + echo " help Print this help" + echo " rebuild Rebuild the current environment" + echo " generations List all home environment generations" + echo " packages List all packages installed in home-manager-path" +} + +case $1 in + rebuild) + doRebuild "$2" + ;; + generations) + doListGens + ;; + packages) + doListPackages + ;; + help|--help) + doHelp + ;; + *) + echo "Unknown command: $1" + doHelp + exit 1 +esac diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 00000000000..6f42de2f4bc --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,47 @@ +{ configuration +, pkgs +, lib ? pkgs.stdenv.lib +}: + +let + + modules = [ + ./home-environment.nix + ./programs/bash.nix + ./programs/beets.nix + ./programs/eclipse.nix + ./programs/emacs.nix + ./programs/git.nix + ./programs/gnome-terminal.nix + ./programs/lesspipe.nix + ./programs/texlive.nix + ./services/dunst.nix + ./services/gnome-keyring.nix + ./services/gpg-agent.nix + ./services/keepassx.nix + ./services/network-manager-applet.nix + ./services/random-background.nix + ./services/taffybar.nix + ./services/tahoe-lafs.nix + ./services/udiskie.nix + ./services/xscreensaver.nix + ./systemd.nix + ./xsession.nix + ]; + + pkgsModule = { + config._module.args.pkgs = lib.mkForce pkgs; + }; + + module = lib.evalModules { + modules = [ configuration ] ++ modules ++ [ pkgsModule ]; + }; + +in + +{ + inherit (module) options config; + + activation-script = module.config.home.activationPackage; + home-path = module.config.home.path; +} diff --git a/modules/home-environment.nix b/modules/home-environment.nix new file mode 100644 index 00000000000..27911d0f399 --- /dev/null +++ b/modules/home-environment.nix @@ -0,0 +1,314 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.home; + + languageSubModule = types.submodule { + options = { + base = mkOption { + type = types.str; + description = '' + The language to use unless overridden by a more specific option. + ''; + }; + + address = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The language to use for addresses. + ''; + }; + + monetary = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The language to use for formatting currencies and money amounts. + ''; + }; + + paper = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The language to use for paper sizes. + ''; + }; + + time = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The language to use for formatting times. + ''; + }; + }; + }; + + keyboardSubModule = types.submodule { + options = { + layout = mkOption { + type = types.str; + default = "us"; + description = '' + Keyboard layout. + ''; + }; + + model = mkOption { + type = types.str; + default = "pc104"; + example = "presario"; + description = '' + Keyboard model. + ''; + }; + + options = mkOption { + type = types.listOf types.str; + default = []; + example = ["grp:caps_toggle" "grp_led:scroll"]; + description = '' + X keyboard options; layout switching goes here. + ''; + }; + + variant = mkOption { + type = types.str; + default = ""; + example = "colemak"; + description = '' + X keyboard variant. + ''; + }; + }; + }; + +in + +{ + options = { + home.file = mkOption { + description = "Attribute set of files to link into the user home."; + default = {}; + type = types.loaOf (types.submodule ( + { name, config, ... }: { + options = { + target = mkOption { + type = types.str; + description = "Path to target file relative to $HOME."; + }; + + text = mkOption { + default = null; + type = types.nullOr types.lines; + description = "Text of the file."; + }; + + source = mkOption { + type = types.path; + description = "Path of the source file."; + }; + + mode = mkOption { + type = types.str; + default = "444"; + description = "The permissions to apply to the file."; + }; + }; + + config = { + target = mkDefault name; + source = mkIf (config.text != null) ( + let name' = "user-etc-" + baseNameOf name; + in mkDefault (pkgs.writeText name' config.text) + ); + }; + }) + ); + }; + + home.language = mkOption { + type = languageSubModule; + default = {}; + description = "Language configuration."; + }; + + home.keyboard = mkOption { + type = keyboardSubModule; + default = {}; + description = "Keyboard configuration."; + }; + + home.sessionVariables = mkOption { + default = {}; + type = types.attrs; + description = "Environment variables to always set at login."; + }; + + home.packages = mkOption { + type = types.listOf types.package; + default = []; + description = "The set of packages to appear in the user environment."; + }; + + home.path = mkOption { + internal = true; + description = "The derivation installing the user packages."; + }; + + home.activation = mkOption { + internal = true; + default = {}; + type = types.attrs; + description = "Activation scripts for the home environment."; + }; + + home.activationPackage = mkOption { + internal = true; + type = types.package; + description = "The package containing the complete activation script."; + }; + }; + + config = { + home.sessionVariables = + let + maybeSet = name: value: + listToAttrs (optional (value != null) { inherit name value; }); + in + (maybeSet "LANG" cfg.language.base) + // + (maybeSet "LC_ADDRESS" cfg.language.address) + // + (maybeSet "LC_MONETARY" cfg.language.monetary) + // + (maybeSet "LC_PAPER" cfg.language.paper) + // + (maybeSet "LC_TIME" cfg.language.time); + + home.activation.linkages = + let + pak = pkgs.stdenv.mkDerivation { + name = "home-environment"; + + phases = [ "installPhase" ]; + + installPhase = + concatStringsSep "\n" ( + mapAttrsToList (name: value: + "install -v -D -m${value.mode} ${value.source} $out/${value.target}" + ) cfg.file + ); + }; + + link = pkgs.writeText "link" '' + for sourcePath in "$@" ; do + basePath="''${sourcePath#/nix/store/*-home-environment/}" + targetPath="$HOME/$basePath" + mkdir -vp "$(dirname "$targetPath")" + ln -vsf "$sourcePath" "$targetPath" + done + ''; + + cleanup = pkgs.writeText "cleanup" '' + for sourcePath in "$@" ; do + basePath="''${sourcePath#/nix/store/*-home-environment/}" + targetPath="$HOME/$basePath" + echo -n "Checking $targetPath" + if [[ -f "${pak}/$basePath" ]] ; then + echo " exists" + else + echo " gone (deleting)" + rm -v "$targetPath" + rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")" + fi + done + ''; + in + '' + function setupVars() { + local gcPath="/nix/var/nix/gcroots/per-user/$(whoami)" + local greatestGenNum=( \ + $(find "$gcPath" -name 'home-*' \ + | sed 's/^.*-\([0-9]*\)$/\1/' \ + | sort -rn \ + | head -1) \ + ) + if [[ -n "$greatestGenNum" ]] ; then + oldGenNum=$greatestGenNum + newGenNum=$(($oldGenNum + 1)) + oldGenPath="$(readlink -e "$gcPath/home-$oldGenNum")" + else + newGenNum=1 + fi + newGenPath="${pak}"; + newGenGcPath="$gcPath/home-$newGenNum" + } + + # Set some vars, these can be used later on as well. + setupVars + + if [[ "$oldGenPath" != "$newGenPath" ]] ; then + ln -sfv "$newGenPath" "$newGenGcPath" + find "$newGenPath" -type f -print0 | xargs -0 bash ${link} + if [[ -n "$oldGenPath" ]] ; then + echo "Cleaning up orphan links from $HOME" + find "$oldGenPath" -type f -print0 | xargs -0 bash ${cleanup} + fi + else + echo "Same home files as previous generation ... doing nothing" + fi + ''; + + home.activation.installPackages = + '' + nix-env -i ${cfg.path} + ''; + + home.activationPackage = + let + addHeader = n: v: + v // { + text = '' + echo Activating ${n} + ${v.text} + ''; + }; + toDepString = n: v: if isString v then noDepEntry v else v; + activationWithDeps = + mapAttrs addHeader (mapAttrs toDepString cfg.activation); + activationCmds = + textClosureMap id activationWithDeps (attrNames activationWithDeps); + + sf = pkgs.writeText "activation-script" '' + #!${pkgs.stdenv.shell} + + ${activationCmds} + ''; + in + pkgs.stdenv.mkDerivation { + name = "activate-home"; + + phases = [ "installPhase" ]; + + installPhase = '' + install -v -D -m755 ${sf} $out/libexec/home-activate + ''; + }; + + home.path = pkgs.buildEnv { + name = "home-manager-path"; + + paths = cfg.packages; + + meta = { + description = "Environment of packages installed through home-manager"; + }; + }; + }; +} diff --git a/modules/lib/generators.nix b/modules/lib/generators.nix new file mode 100644 index 00000000000..4190703e236 --- /dev/null +++ b/modules/lib/generators.nix @@ -0,0 +1,93 @@ +/* Functions that generate widespread file + * formats from nix data structures. + * + * They all follow a similar interface: + * generator { config-attrs } data + * + * Tests can be found in ./tests.nix + * Documentation in the manual, #sec-generators + */ +with import ; +let + libStr = import ; + libAttr = import ; + + flipMapAttrs = flip libAttr.mapAttrs; +in + +rec { + + /* Generate a line of key k and value v, separated by + * character sep. If sep appears in k, it is escaped. + * Helper for synaxes with different separators. + * + * mkKeyValueDefault ":" "f:oo" "bar" + * > "f\:oo:bar" + */ + mkKeyValueDefault = sep: k: v: + "${libStr.escape [sep] k}${sep}${toString v}"; + + + /* Generate a key-value-style config file from an attrset. + * + * mkKeyValue is the same as in toINI. + */ + toKeyValue = { + mkKeyValue ? mkKeyValueDefault "=" + }: attrs: + let mkLine = k: v: mkKeyValue k v + "\n"; + in libStr.concatStrings (libAttr.mapAttrsToList mkLine attrs); + + + /* Generate an INI-style config file from an + * attrset of sections to an attrset of key-value pairs. + * + * generators.toINI {} { + * foo = { hi = "${pkgs.hello}"; ciao = "bar"; }; + * baz = { "also, integers" = 42; }; + * } + * + *> [baz] + *> also, integers=42 + *> + *> [foo] + *> ciao=bar + *> hi=/nix/store/y93qql1p5ggfnaqjjqhxcw0vqw95rlz0-hello-2.10 + * + * The mk* configuration attributes can generically change + * the way sections and key-value strings are generated. + * + * For more examples see the test cases in ./tests.nix. + */ + toINI = { + # apply transformations (e.g. escapes) to section names + mkSectionName ? (name: libStr.escape [ "[" "]" ] name), + # format a setting line from key and value + mkKeyValue ? mkKeyValueDefault "=" + }: attrsOfAttrs: + let + # map function to string for each key val + mapAttrsToStringsSep = sep: mapFn: attrs: + libStr.concatStringsSep sep + (libAttr.mapAttrsToList mapFn attrs); + mkSection = sectName: sectValues: '' + [${mkSectionName sectName}] + '' + toKeyValue { inherit mkKeyValue; } sectValues; + in + # map input to ini sections + mapAttrsToStringsSep "\n" mkSection attrsOfAttrs; + + + /* Generates JSON from an arbitrary (non-function) value. + * For more information see the documentation of the builtin. + */ + toJSON = {}: builtins.toJSON; + + + /* YAML has been a strict superset of JSON since 1.2, so we + * use toJSON. Before it only had a few differences referring + * to implicit typing rules, so it should work with older + * parsers as well. + */ + toYAML = {}@args: toJSON args; +} diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix new file mode 100644 index 00000000000..f17b3f1bdd1 --- /dev/null +++ b/modules/programs/bash.nix @@ -0,0 +1,159 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.bash; + +in + +{ + options = { + programs.bash = { + enable = mkEnableOption "GNU Bourne-Again SHell"; + + historySize = mkOption { + type = types.int; + default = 10000; + description = "Number of history lines to keep in memory."; + }; + + historyFileSize = mkOption { + type = types.int; + default = 100000; + description = "Number of history lines to keep on file."; + }; + + historyControl = mkOption { + type = types.listOf (types.enum [ + "erasedups" + "ignoredups" + "ignorespace" + ]); + default = []; + description = "Controlling how commands are saved on the history list."; + }; + + historyIgnore = mkOption { + type = types.listOf types.str; + default = []; + description = "List of commands that should not be saved to the history list."; + }; + + shellOptions = mkOption { + type = types.listOf types.str; + default = [ + # Append to history file rather than replacing it. + "histappend" + + # check the window size after each command and, if + # necessary, update the values of LINES and COLUMNS. + "checkwinsize" + + # Extended globbing. + "extglob" + "globstar" + + # Warn if closing shell with running jobs. + "checkjobs" + ]; + description = "Shell options to set."; + }; + + shellAliases = mkOption { + default = {}; + example = { ll = "ls -l"; ".." = "cd .."; }; + description = '' + An attribute set that maps aliases (the top level attribute names in + this option) to command strings or directly to build outputs. The + aliases are added to all users' shells. + ''; + type = types.attrs; + }; + + enableAutojump = mkOption { + default = false; + type = types.bool; + description = "Enable the autojump navigation tool."; + }; + + profileExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .profile."; + }; + + initExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .bashrc."; + }; + }; + }; + + config = ( + let + aliasesStr = concatStringsSep "\n" ( + mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + ); + + shoptsStr = concatStringsSep "\n" ( + map (v: "shopt -s ${v}") cfg.shellOptions + ); + + export = n: v: "export ${n}=\"${toString v}\""; + exportIfNonNull = n: v: optionalString (v != null) (export n v); + exportIfNonEmpty = n: v: optionalString (v != "") (export n v); + + histControlStr = concatStringsSep ":" cfg.historyControl; + histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; + + envVarsStr = concatStringsSep "\n" ( + mapAttrsToList export config.home.sessionVariables + ); + in mkIf cfg.enable { + home.file.".bash_profile".text = '' + # -*- mode: sh -*- + + # include .profile if it exists + [[ -f ~/.profile ]] && . ~/.profile + + # include .bashrc if it exists + [[ -f ~/.bashrc ]] && . ~/.bashrc + ''; + + home.file.".profile".text = '' + # -*- mode: sh -*- + + ${envVarsStr} + + ${cfg.profileExtra} + ''; + + home.file.".bashrc".text = '' + # -*- mode: sh -*- + + # Skip if not running interactively. + [ -z "$PS1" ] && return + + ${export "HISTSIZE" cfg.historySize} + ${export "HISTFILESIZE" cfg.historyFileSize} + ${exportIfNonEmpty "HISTCONTROL" histControlStr} + ${exportIfNonEmpty "HISTIGNORE" histIgnoreStr} + + ${shoptsStr} + + ${aliasesStr} + + ${cfg.initExtra} + + ${optionalString cfg.enableAutojump + ". ${pkgs.autojump}/share/autojump/autojump.bash"} + ''; + + home.packages = + optional (cfg.enableAutojump) pkgs.autojump; + } + ); +} diff --git a/modules/programs/beets.nix b/modules/programs/beets.nix new file mode 100644 index 00000000000..46a17a9711f --- /dev/null +++ b/modules/programs/beets.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.beets; + +in + +{ + options = { + programs.beets = { + settings = mkOption { + type = types.attrs; + default = {}; + description = "Configuration written to ~/.config/beets/config.yaml"; + }; + }; + }; + + config = mkIf (cfg.settings != {}) { + home.packages = [ pkgs.beets ]; + + home.file.".config/beets/config.yaml".text = + builtins.toJSON config.programs.beets.settings; + }; +} diff --git a/modules/programs/eclipse.nix b/modules/programs/eclipse.nix new file mode 100644 index 00000000000..e9d4c060287 --- /dev/null +++ b/modules/programs/eclipse.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.eclipse; + +in + +{ + options = { + programs.eclipse = { + enable = mkEnableOption "Eclipse"; + + jvmArgs = mkOption { + type = types.listOf types.str; + default = []; + description = "JVM arguments to use for the Eclipse process."; + }; + + plugins = mkOption { + type = types.listOf types.package; + default = []; + description = "Plugins that should be added to Eclipse."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (pkgs.eclipses.eclipseWithPlugins { + eclipse = pkgs.eclipses.eclipse-platform; + jvmArgs = cfg.jvmArgs; + plugins = cfg.plugins; + }) + ]; + }; +} diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix new file mode 100644 index 00000000000..22a4ed4349e --- /dev/null +++ b/modules/programs/emacs.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.emacs; + +in + +{ + options = { + programs.emacs = { + enable = mkEnableOption "Emacs"; + + extraPackages = mkOption { + default = self: []; + example = literalExample '' + epkgs: [ epkgs.emms epkgs.magit ] + ''; + description = "Extra packages available to Emacs."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ (pkgs.emacsWithPackages cfg.extraPackages) ]; + }; +} diff --git a/modules/programs/git.nix b/modules/programs/git.nix new file mode 100644 index 00000000000..33fcbe428bf --- /dev/null +++ b/modules/programs/git.nix @@ -0,0 +1,102 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.git; + + toINI = (import ../lib/generators.nix).toINI {}; + + signModule = types.submodule ( + { ... }: { + options = { + key = mkOption { + type = types.str; + default = null; + description = "The default GPG signing key fingerprint."; + }; + + signByDefault = mkOption { + type = types.bool; + default = false; + description = "Whether commits should be signed by default."; + }; + + gpgPath = mkOption { + type = types.str; + default = "${pkgs.gnupg}/bin/gpg2"; + defaultText = "''${pkgs.gnupg}/bin/gpg2"; + description = "Path to GnuPG binary to use."; + }; + }; + } + ); + +in + +{ + options = { + programs.git = { + enable = mkEnableOption "Git"; + + package = mkOption { + type = types.package; + default = pkgs.git; + defaultText = "pkgs.git"; + description = "Git package to install."; + }; + + userName = mkOption { + type = types.str; + description = "Default user name to use."; + }; + + userEmail = mkOption { + type = types.str; + description = "Default user email to use."; + }; + + aliases = mkOption { + type = types.attrs; + default = {}; + description = "Git aliases to define."; + }; + + signing = mkOption { + type = types.nullOr signModule; + default = null; + description = "Options related to signing commits using GnuPG."; + }; + + extraConfig = mkOption { + type = types.lines; + default = null; + description = "Additional configuration to add."; + }; + }; + }; + + config = mkIf cfg.enable ( + let + ini = { + user = { + name = cfg.userName; + email = cfg.userEmail; + } // optionalAttrs (cfg.signing != null) { + signingKey = cfg.signing.key; + }; + } // optionalAttrs (cfg.signing != null) { + commit.gpgSign = cfg.signing.signByDefault; + gpg.program = cfg.signing.gpgPath; + } // optionalAttrs (cfg.aliases != {}) { + alias = cfg.aliases; + }; + in + { + home.packages = [ cfg.package ]; + + home.file.".gitconfig".text = toINI ini + "\n" + cfg.extraConfig; + } + ); +} diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix new file mode 100644 index 00000000000..90cf46adff1 --- /dev/null +++ b/modules/programs/gnome-terminal.nix @@ -0,0 +1,186 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.gnome-terminal; + + profileColorsSubModule = types.submodule ( + { ... }: { + options = { + foregroundColor = mkOption { + type = types.str; + description = "The foreground color."; + }; + + backgroundColor = mkOption { + type = types.str; + description = "The background color."; + }; + + boldColor = mkOption { + default = null; + type = types.nullOr types.str; + description = "The bold color, null to use same as foreground."; + }; + + palette = mkOption { + type = types.listOf types.str; + description = "The terminal palette."; + }; + }; + } + ); + + profileSubModule = types.submodule ( + { name, config, ... }: { + options = { + default = mkOption { + default = false; + type = types.bool; + description = "Whether this should be the default profile."; + }; + + visibleName = mkOption { + type = types.str; + description = "The profile name."; + }; + + colors = mkOption { + default = null; + type = types.nullOr profileColorsSubModule; + description = "The terminal colors, null to use system default."; + }; + + cursorShape = mkOption { + default = "block"; + type = types.enum [ "block" "ibeam" "underline" ]; + description = "The cursor shape."; + }; + + font = mkOption { + default = null; + type = types.nullOr types.str; + description = "The font name, null to use system default."; + }; + + scrollOnOutput = mkOption { + default = true; + type = types.bool; + description = "Whether to scroll when output is written."; + }; + + showScrollbar = mkOption { + default = true; + type = types.bool; + description = "Whether the scroll bar should be visible."; + }; + + scrollbackLines = mkOption { + default = 10000; + type = types.nullOr types.int; + description = + '' + The number of scrollback lines to keep, null for infinite. + ''; + }; + }; + } + ); + + toINI = (import ../lib/generators.nix).toINI { mkKeyValue = mkIniKeyValue; }; + + mkIniKeyValue = key: value: + let + tweakVal = v: + if isString v then "'${v}'" + else if isList v then "[" + concatStringsSep "," (map tweakVal v) + "]" + else if isBool v && v then "true" + else if isBool v && !v then "false" + else toString v; + in + "${key}=${tweakVal value}"; + + buildProfileSet = pcfg: + { + visible-name = pcfg.visibleName; + scrollbar-policy = if pcfg.showScrollbar then "always" else "never"; + scrollback-lines = pcfg.scrollbackLines; + cursor-shape = pcfg.cursorShape; + } + // ( + if (pcfg.font == null) + then { use-system-font = true; } + else { use-system-font = false; font = pcfg.font; } + ) // ( + if (pcfg.colors == null) + then { use-theme-colors = true; } + else ( + { + use-theme-colors = false; + foreground-color = pcfg.colors.foregroundColor; + background-color = pcfg.colors.backgroundColor; + palette = pcfg.colors.palette; + } + // ( + if (pcfg.colors.boldColor == null) + then { bold-color-same-as-fg = true; } + else { + bold-color-same-as-fg = false; + bold-color = pcfg.colors.boldColor; + } + ) + ) + ); + + buildIniSet = cfg: + { + "/" = { + default-show-menubar = cfg.showMenubar; + schema-version = 3; + }; + } + // + { + "profiles:" = { + default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile)); + list = attrNames cfg.profile; #mapAttrsToList (n: v: n) cfg.profile; + }; + } + // + mapAttrs' (name: value: + nameValuePair ("profiles:/:${name}") (buildProfileSet value) + ) cfg.profile; + +in + +{ + options = { + programs.gnome-terminal = { + enable = mkEnableOption "Gnome Terminal"; + + showMenubar = mkOption { + default = true; + type = types.bool; + description = "Whether to show the menubar by default"; + }; + + profile = mkOption { + default = {}; + type = types.loaOf profileSubModule; + }; + }; + }; + + config = mkIf cfg.enable { + home.activation.gnome-terminal = + let + sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); + dconfPath = "/org/gnome/terminal/legacy/"; + in + '' + ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} + ''; + }; +} diff --git a/modules/programs/lesspipe.nix b/modules/programs/lesspipe.nix new file mode 100644 index 00000000000..d250f535ad8 --- /dev/null +++ b/modules/programs/lesspipe.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + programs.lesspipe = { + enable = mkEnableOption "lesspipe preprocessor for less"; + }; + }; + + config = mkIf config.programs.lesspipe.enable { + home.sessionVariables = { + LESSOPEN = "|${pkgs.lesspipe}/bin/lesspipe.sh %s"; + }; + }; +} diff --git a/modules/programs/texlive.nix b/modules/programs/texlive.nix new file mode 100644 index 00000000000..afa8f7012c8 --- /dev/null +++ b/modules/programs/texlive.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.texlive; + +in + +{ + options = { + programs.texlive = { + enable = mkEnableOption "Texlive"; + + extraPackages = mkOption { + default = self: {}; + example = literalExample '' + tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; } + ''; + description = "Extra packages available to Texlive."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (pkgs.texlive.combine (cfg.extraPackages pkgs.texlive)) + ]; + + }; +} diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix new file mode 100644 index 00000000000..8042cf93d41 --- /dev/null +++ b/modules/services/dunst.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.dunst = { + enable = mkEnableOption "the dunst notification daemon"; + + settings = mkOption { + type = types.attrs; + default = {}; + description = "Configuration written to ~/.config/dunstrc"; + }; + }; + }; + + config = mkIf config.services.dunst.enable { + systemd.user.services.dunst = { + Unit = { + Description = "Dunst notification daemon"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + + Service = { + # Type = "dbus"; + # BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.dunst}/bin/dunst"; + }; + }; + }; +} diff --git a/modules/services/gnome-keyring.nix b/modules/services/gnome-keyring.nix new file mode 100644 index 00000000000..e5040906551 --- /dev/null +++ b/modules/services/gnome-keyring.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.gnome-keyring; + +in + +{ + options = { + services.gnome-keyring = { + enable = mkEnableOption "GNOME Keyring"; + + components = mkOption { + type = types.listOf (types.enum ["pkcs11" "secrets" "ssh"]); + default = []; + description = '' + The GNOME keyring components to start. If empty then the + default set of components will be started. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.gnome-keyring = { + Unit = { + Description = "GNOME Keyring"; + }; + + Service = { + ExecStart = + let + args = concatStringsSep " " ( + [ "--start" "--foreground" ] + ++ optional (cfg.components != []) ( + "--components=" + concatStringsSep "," cfg.components + ) + ); + in + "${pkgs.gnome3.gnome_keyring}/bin/gnome-keyring-daemon ${args}"; + Restart = "on-abort"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + }; + }; +} diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix new file mode 100644 index 00000000000..ac93a871ff8 --- /dev/null +++ b/modules/services/gpg-agent.nix @@ -0,0 +1,69 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.gpg-agent; + +in + +{ + options = { + services.gpg-agent = { + enable = mkEnableOption "GnuPG private key agent"; + + defaultCacheTtl = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Set the time a cache entry is valid to the given number of seconds. + ''; + }; + + enableSshSupport = mkOption { + type = types.bool; + default = false; + description = "Whether to use the GnuPG key agent for SSH keys."; + }; + }; + }; + + config = mkIf cfg.enable { + home.file.".gnupg/gpg-agent.conf".text = concatStringsSep "\n" ( + optional cfg.enableSshSupport + "enable-ssh-support" + ++ + optional (cfg.defaultCacheTtl != null) + "default-cache-ttl ${toString cfg.defaultCacheTtl}" + ); + + home.sessionVariables = + optionalAttrs cfg.enableSshSupport { + SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"; + }; + + programs.bash.initExtra = '' + GPG_TTY="$(tty)" + export GPG_TTY + gpg-connect-agent updatestartuptty /bye > /dev/null + ''; + + systemd.user.services.gpg-agent = { + Unit = { + Description = "GnuPG private key agent"; + IgnoreOnIsolate = true; + }; + + Service = { + Type = "forking"; + ExecStart = "${pkgs.gnupg}/bin/gpg-agent --daemon --use-standard-socket"; + Restart = "on-abort"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +} diff --git a/modules/services/keepassx.nix b/modules/services/keepassx.nix new file mode 100644 index 00000000000..799f0e5c339 --- /dev/null +++ b/modules/services/keepassx.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.keepassx = { + enable = mkEnableOption "the KeePassX password manager"; + }; + }; + + config = mkIf config.services.keepassx.enable { + systemd.user.services.keepassx = { + Unit = { + Description = "KeePassX password manager"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + + Service = { + ExecStart = "${pkgs.keepassx}/bin/keepassx -min -lock"; + }; + }; + }; +} diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix new file mode 100644 index 00000000000..8b529c5b6bf --- /dev/null +++ b/modules/services/network-manager-applet.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.network-manager-applet = { + enable = mkEnableOption "the Network Manager applet"; + }; + }; + + config = mkIf config.services.network-manager-applet.enable { + systemd.user.services.network-manager-applet = { + Unit = { + Description = "Network Manager applet"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + + Service = { + ExecStart = "${pkgs.networkmanagerapplet}/bin/nm-applet --sm-disable"; + }; + }; + }; +} diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix new file mode 100644 index 00000000000..0dabb87217a --- /dev/null +++ b/modules/services/random-background.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.random-background; + +in + +{ + options = { + services.random-background = { + enable = mkEnableOption "random desktop background"; + + imageDirectory = mkOption { + type = types.str; + description = + '' + The directory of images from which a background should be + chosen. Should be formatted in a way understood by + systemd, e.g., '%h' is the home directory. + ''; + }; + + interval = mkOption { + default = null; + type = types.nullOr types.str; + description = '' + The duration between changing background image, set to null + to only set background when logging in. + + Should be formatted as a duration understood by systemd. + ''; + }; + }; + }; + + config = mkIf cfg.enable ( + mkMerge ([ + { + systemd.user.services.random-background = { + Unit = { + Description = "Set random desktop background using feh"; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-fill %h/backgrounds/"; + IOSchedulingClass = "idle"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + }; + } + (mkIf (cfg.interval != null) { + systemd.user.timers.random-background = { + Unit = { + Description = "Set random desktop background using feh"; + }; + + Timer = { + OnUnitActiveSec = cfg.interval; + }; + + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }) + ])); +} diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix new file mode 100644 index 00000000000..f9ab2ee6142 --- /dev/null +++ b/modules/services/taffybar.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.taffybar; + +in + +{ + options = { + services.taffybar = { + enable = mkEnableOption "Taffybar"; + + package = mkOption { + default = pkgs.taffybar; + defaultText = "pkgs.taffybar"; + type = types.package; + example = literalExample "pkgs.taffybar"; + description = "The package to use for the Taffybar binary."; + }; + }; + }; + + config = mkIf config.services.taffybar.enable { + systemd.user.services.taffybar = { + Unit = { + Description = "Taffybar desktop bar"; + }; + + Service = { + ExecStart = "${cfg.package}/bin/taffybar"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + }; + }; +} diff --git a/modules/services/tahoe-lafs.nix b/modules/services/tahoe-lafs.nix new file mode 100644 index 00000000000..8d12b03e2bc --- /dev/null +++ b/modules/services/tahoe-lafs.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.tahoe-lafs = { + enable = mkEnableOption "Tahoe-LAFS"; + }; + }; + + config = mkIf config.services.tahoe-lafs.enable { + systemd.user.services.tahoe-lafs = { + Unit = { + Description = "Tahoe-LAFS"; + }; + + Service = { + ExecStart = "${pkgs.tahoelafs}/bin/tahoe run -C %h/.tahoe"; + }; + }; + }; +} diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix new file mode 100644 index 00000000000..964629c7a8f --- /dev/null +++ b/modules/services/udiskie.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.udiskie = { + enable = mkEnableOption "Udiskie mount daemon"; + }; + }; + + config = mkIf config.services.udiskie.enable { + systemd.user.services.udiskie = { + Unit = { + Description = "Udiskie mount daemon"; + Requires = [ "taffybar.service" ]; + After = [ "taffybar.service" ]; + }; + + Service = { + ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 -A -n -s"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + }; + }; +} diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix new file mode 100644 index 00000000000..58261553902 --- /dev/null +++ b/modules/services/xscreensaver.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.xscreensaver = { + enable = mkEnableOption "XScreenSaver"; + }; + }; + + config = mkIf config.services.xscreensaver.enable { + systemd.user.services.xscreensaver = { + Unit = { + Description = "XScreenSaver"; + }; + + Service = { + ExecStart = "${pkgs.xscreensaver}/bin/xscreensaver -no-splash"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + }; + }; +} diff --git a/modules/systemd.nix b/modules/systemd.nix new file mode 100644 index 00000000000..b927b04add4 --- /dev/null +++ b/modules/systemd.nix @@ -0,0 +1,119 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + toSystemdIni = (import lib/generators.nix).toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "true" else "false") + else toString value; + in + "${key}=${value'}"; + }; + + buildService = style: name: serviceCfg: + let + source = pkgs.writeText "${name}.${style}" (toSystemdIni serviceCfg); + + wantedBy = target: + { + name = ".config/systemd/user/${target}.wants/${name}.${style}"; + value = { inherit source; }; + }; + in + singleton { + name = ".config/systemd/user/${name}.${style}"; + value = { inherit source; }; + } + ++ + map wantedBy (serviceCfg.Install.WantedBy or []); + + buildServices = style: serviceCfgs: + concatLists (mapAttrsToList (buildService style) serviceCfgs); + +in + +{ + options = { + systemd.user = { + services = mkOption { + default = {}; + type = types.attrs; + description = "Definition of systemd per-user service units."; + }; + + timers = mkOption { + default = {}; + type = types.attrs; + description = "Definition of systemd per-user timers"; + }; + }; + }; + + config = { + home.file = + listToAttrs ( + (buildServices "service" config.systemd.user.services) + ++ + (buildServices "timer" config.systemd.user.timers) + ); + + home.activation.reloadSystemD = stringAfter ["linkages"] '' + function systemdPostReload() { + local servicesDiffFile="$(mktemp)" + + diff \ + --new-line-format='+%L' \ + --old-line-format='-%L' \ + --unchanged-line-format=' %L' \ + <(basename -a $(echo "$oldGenPath/.config/systemd/user/*.service") | sort) \ + <(basename -a $(echo "$newGenPath/.config/systemd/user/*.service") | sort) \ + > $servicesDiffFile + + local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) + local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) + local -a toStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) + local -a toRestart=( ) + + for f in ''${maybeRestart[@]} ; do + if systemctl --quiet --user is-active "$f" \ + && ! cmp --quiet \ + "$oldGenPath/.config/systemd/user/$f" \ + "$newGenPath/.config/systemd/user/$f" ; then + echo "Adding '$f' to restart list"; + toRestart+=("$f") + fi + done + + rm $servicesDiffFile + + sugg="" + + if [[ -n "''${toRestart[@]}" ]] ; then + sugg="$sugg\nsystemctl --user restart ''${toRestart[@]}" + fi + + if [[ -n "''${toStop[@]}" ]] ; then + sugg="$sugg\nsystemctl --user stop ''${toStop[@]}" + fi + + if [[ -n "''${toStart[@]}" ]] ; then + sugg="$sugg\nsystemctl --user start ''${toStart[@]}" + fi + + if [[ -n "$sugg" ]] ; then + echo "Suggested commands:" + echo -e "$sugg" + fi + } + + if [[ "$oldGenPath" != "$newGenPath" ]] ; then + systemctl --user daemon-reload + systemdPostReload + fi + ''; + }; +} diff --git a/modules/xsession.nix b/modules/xsession.nix new file mode 100644 index 00000000000..ab6629743d8 --- /dev/null +++ b/modules/xsession.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession; + +in + +{ + options = { + xsession = { + enable = mkEnableOption "X Session"; + + windowManager = mkOption { + default = {}; + type = types.str; + description = "Path to window manager to exec."; + }; + + initExtra = mkOption { + type = types.lines; + default = ""; + description = "Extra shell commands to run during initialization."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + }; + + Install = { + WantedBy = [ "xorg.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; + }; + + home.file.".xsession" = { + mode = "555"; + text = '' + # Rely on Bash to set session variables. + . "$HOME/.profile" + + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS + systemctl --user import-environment DISPLAY + systemctl --user import-environment SSH_AUTH_SOCK + systemctl --user import-environment XDG_DATA_DIRS + systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user start xorg.target + + ${cfg.initExtra} + + ${cfg.windowManager} + + systemctl --user stop xorg.target + ''; + }; + }; +} -- cgit v1.2.3 From a1cb111cc3c53066491f007b2dcaca4076def7ec Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 7 Jan 2017 19:36:39 +0100 Subject: home-manager: handle missing `home-manager-path` When listing packages we have to handle the case where the rebuild command has not yet been run. --- home-manager/home-manager | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 63dac595f7a..1667564a106 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -29,7 +29,11 @@ function doListGens() { function doListPackages() { local outPath outPath="$(nix-env -q --out-path | grep -o '/.*home-manager-path$')" - nix-store -q --references "$outPath" | sed 's/[^-]*-//' + if [[ -n "$outPath" ]] ; then + nix-store -q --references "$outPath" | sed 's/[^-]*-//' + else + echo "No home-manager packages seem to be installed." + fi } function doHelp() { -- cgit v1.2.3 From 671805009cde0cea186318724ef97397ed4b0b76 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 8 Jan 2017 10:24:16 +0100 Subject: home-manager: use absolute path to configuration Nix needs an absolute path and the user may have given a relative path for the configuration file. We therefore need to expand it using the `realpath` tool. --- home-manager/home-manager | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 1667564a106..fffffad0084 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -6,13 +6,16 @@ function doRebuild() { exit 1 fi + local confFile + confFile="$(realpath "$1")" + local wrkdir wrkdir="$(mktemp -d)" nix-build --show-trace \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \ - --argstr confPath "$1" \ + --argstr confPath "$confFile" \ -A activation-script \ -o "$wrkdir/activate" -- cgit v1.2.3 From 43fd747ba7c5fd9e92bfa02a32448fbb73c81113 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 8 Jan 2017 22:06:53 +0100 Subject: Use a generation directory Before we put only user files in the generation directory but that was quite limiting. In particular, we lost track of the activation script. --- home-manager/home-manager | 10 +++-- modules/home-environment.nix | 105 ++++++++++++++++++++++++++++++------------- modules/systemd.nix | 18 ++++---- 3 files changed, 89 insertions(+), 44 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index fffffad0084..9b0aa793148 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -17,16 +17,18 @@ function doRebuild() { --argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \ --argstr confPath "$confFile" \ -A activation-script \ - -o "$wrkdir/activate" + -o "$wrkdir/generation" - "$wrkdir/activate/libexec/home-activate" + "$wrkdir/generation/activate" - rm -rv "$wrkdir" + rm -r "$wrkdir" } function doListGens() { - ls --color=yes -gG --sort time "/nix/var/nix/gcroots/per-user/$(whoami)" \ + pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null + ls --color=yes -gG --sort time home-manager-*-link \ | cut -d' ' -f 4- + popd > /dev/null } function doListPackages() { diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 27911d0f399..2c335ba9ed8 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -193,34 +193,26 @@ in home.activation.linkages = let - pak = pkgs.stdenv.mkDerivation { - name = "home-environment"; - - phases = [ "installPhase" ]; - - installPhase = - concatStringsSep "\n" ( - mapAttrsToList (name: value: - "install -v -D -m${value.mode} ${value.source} $out/${value.target}" - ) cfg.file - ); - }; - link = pkgs.writeText "link" '' + newGenFiles="$1" + shift for sourcePath in "$@" ; do - basePath="''${sourcePath#/nix/store/*-home-environment/}" - targetPath="$HOME/$basePath" + relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")" + targetPath="$HOME/$relativePath" mkdir -vp "$(dirname "$targetPath")" ln -vsf "$sourcePath" "$targetPath" done ''; cleanup = pkgs.writeText "cleanup" '' + newGenFiles="$1" + oldGenFiles="$2" + shift 2 for sourcePath in "$@" ; do - basePath="''${sourcePath#/nix/store/*-home-environment/}" - targetPath="$HOME/$basePath" + relativePath="$(realpath --relative-to "$oldGenFiles" "$sourcePath")" + targetPath="$HOME/$relativePath" echo -n "Checking $targetPath" - if [[ -f "${pak}/$basePath" ]] ; then + if [[ -f "$newGenFiles/$relativePath" ]] ; then echo " exists" else echo " gone (deleting)" @@ -232,34 +224,67 @@ in in '' function setupVars() { + local profilesPath="/nix/var/nix/profiles/per-user/$(whoami)" local gcPath="/nix/var/nix/gcroots/per-user/$(whoami)" local greatestGenNum=( \ - $(find "$gcPath" -name 'home-*' \ - | sed 's/^.*-\([0-9]*\)$/\1/' \ + $(find "$profilesPath" -name 'home-manager-*-link' \ + | sed 's/^.*-\([0-9]*\)-link$/\1/' \ | sort -rn \ | head -1) \ ) + if [[ -n "$greatestGenNum" ]] ; then oldGenNum=$greatestGenNum newGenNum=$(($oldGenNum + 1)) - oldGenPath="$(readlink -e "$gcPath/home-$oldGenNum")" else newGenNum=1 fi - newGenPath="${pak}"; - newGenGcPath="$gcPath/home-$newGenNum" + + if [[ -e "$gcPath/current-home" ]] ; then + oldGenPath="$(readlink -e "$gcPath/current-home")" + fi + + newGenPath="@GENERATION_DIR@"; + newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" + newGenGcPath="$gcPath/current-home" } # Set some vars, these can be used later on as well. setupVars - if [[ "$oldGenPath" != "$newGenPath" ]] ; then - ln -sfv "$newGenPath" "$newGenGcPath" - find "$newGenPath" -type f -print0 | xargs -0 bash ${link} - if [[ -n "$oldGenPath" ]] ; then - echo "Cleaning up orphan links from $HOME" - find "$oldGenPath" -type f -print0 | xargs -0 bash ${cleanup} + echo oldGenNum=$oldGenNum + echo newGenNum=$newGenNum + echo oldGenPath=$oldGenPath + echo newGenPath=$newGenPath + echo newGenProfilePath=$newGenProfilePath + echo newGenGcPath=$newGenGcPath + + function linkNewGen() { + local newGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + find "$newGenFiles" -type f -print0 \ + | xargs -0 bash ${link} "$newGenFiles" + } + + function cleanOldGen() { + if [[ -z "$oldGenPath" ]] ; then + return fi + + echo "Cleaning up orphan links from $HOME" + + local newGenFiles oldGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + oldGenFiles="$(readlink -e "$oldGenPath/home-files")" + find "$oldGenFiles" -type f -print0 \ + | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" + } + + if [[ "$oldGenPath" != "$newGenPath" ]] ; then + ln -Tsfv "$newGenPath" "$newGenProfilePath" + ln -Tsfv "$newGenPath" "$newGenGcPath" + linkNewGen + cleanOldGen else echo "Same home files as previous generation ... doing nothing" fi @@ -290,14 +315,32 @@ in ${activationCmds} ''; + + home-files = pkgs.stdenv.mkDerivation { + name = "home-manager-files"; + + phases = [ "installPhase" ]; + + installPhase = + concatStringsSep "\n" ( + mapAttrsToList (name: value: + "install -v -D -m${value.mode} ${value.source} $out/${value.target}" + ) cfg.file + ); + }; in pkgs.stdenv.mkDerivation { - name = "activate-home"; + name = "home-manager-generation"; phases = [ "installPhase" ]; installPhase = '' - install -v -D -m755 ${sf} $out/libexec/home-activate + install -v -D -m755 ${sf} $out/activate + + substituteInPlace $out/activate \ + --subst-var-by GENERATION_DIR $out + + ln -vs ${home-files} $out/home-files ''; }; diff --git a/modules/systemd.nix b/modules/systemd.nix index b927b04add4..5e7cc6b4390 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -64,13 +64,15 @@ in home.activation.reloadSystemD = stringAfter ["linkages"] '' function systemdPostReload() { local servicesDiffFile="$(mktemp)" + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" + local newUserServicePath="$newGenPath/home-files/.config/systemd/user" diff \ --new-line-format='+%L' \ --old-line-format='-%L' \ --unchanged-line-format=' %L' \ - <(basename -a $(echo "$oldGenPath/.config/systemd/user/*.service") | sort) \ - <(basename -a $(echo "$newGenPath/.config/systemd/user/*.service") | sort) \ + <(basename -a $(echo "$oldUserServicePath/*.service") | sort) \ + <(basename -a $(echo "$newUserServicePath/*.service") | sort) \ > $servicesDiffFile local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) @@ -81,8 +83,8 @@ in for f in ''${maybeRestart[@]} ; do if systemctl --quiet --user is-active "$f" \ && ! cmp --quiet \ - "$oldGenPath/.config/systemd/user/$f" \ - "$newGenPath/.config/systemd/user/$f" ; then + "$oldUserServicePath/$f" \ + "$newUserServicePath/$f" ; then echo "Adding '$f' to restart list"; toRestart+=("$f") fi @@ -90,7 +92,7 @@ in rm $servicesDiffFile - sugg="" + local sugg="" if [[ -n "''${toRestart[@]}" ]] ; then sugg="$sugg\nsystemctl --user restart ''${toRestart[@]}" @@ -110,10 +112,8 @@ in fi } - if [[ "$oldGenPath" != "$newGenPath" ]] ; then - systemctl --user daemon-reload - systemdPostReload - fi + systemctl --user daemon-reload + systemdPostReload ''; }; } -- cgit v1.2.3 From 37831674e26152baf9e26ef1f2338ebf770bd23f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 8 Jan 2017 22:08:17 +0100 Subject: home-manager: minor Bash code fixes --- home-manager/home-manager | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 9b0aa793148..4405279011b 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -51,7 +51,7 @@ function doHelp() { echo " packages List all packages installed in home-manager-path" } -case $1 in +case "$1" in rebuild) doRebuild "$2" ;; @@ -68,4 +68,5 @@ case $1 in echo "Unknown command: $1" doHelp exit 1 + ;; esac -- cgit v1.2.3 From e4723b51cdd90d82fb0d9bd91ed6e496c578630d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 00:47:02 +0100 Subject: home-manager: make modules path more configurable --- home-manager/default.nix | 3 ++- home-manager/home-manager | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index d00edbfbdb0..a037c023f92 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,4 +1,4 @@ -{ pkgs }: +{ pkgs, modulesPath ? "$HOME/.nixpkgs/home-manager/modules" }: let @@ -28,6 +28,7 @@ pkgs.stdenv.mkDerivation { substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ + --subst-var-by MODULES_PATH '${modulesPath}' \ --subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}" ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index 4405279011b..f50dc446e68 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -14,7 +14,7 @@ function doRebuild() { nix-build --show-trace \ "@HOME_MANAGER_EXPR_PATH@" \ - --argstr modulesPath "$HOME/.nixpkgs/home-manager/modules" \ + --argstr modulesPath "@MODULES_PATH@" \ --argstr confPath "$confFile" \ -A activation-script \ -o "$wrkdir/generation" -- cgit v1.2.3 From 06a24c37e5df86e802fcfadd7c5f7fe1fab82ec5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 22:48:53 +0100 Subject: systemd: add support for creating target files --- modules/systemd.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/systemd.nix b/modules/systemd.nix index 5e7cc6b4390..6ea8b21c446 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -45,6 +45,12 @@ in description = "Definition of systemd per-user service units."; }; + targets = mkOption { + default = {}; + type = types.attrs; + description = "Definition of systemd per-user targets"; + }; + timers = mkOption { default = {}; type = types.attrs; @@ -58,6 +64,8 @@ in listToAttrs ( (buildServices "service" config.systemd.user.services) ++ + (buildServices "target" config.systemd.user.targets) + ++ (buildServices "timer" config.systemd.user.timers) ); -- cgit v1.2.3 From dd0e71d686146389a46decab8bb14be1dac264a0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 22:45:42 +0100 Subject: Rename xorg.target to graphical-session.target Also make sure graphical-session.target is generated. --- modules/services/dunst.nix | 2 +- modules/services/gnome-keyring.nix | 2 +- modules/services/keepassx.nix | 2 +- modules/services/network-manager-applet.nix | 2 +- modules/services/random-background.nix | 2 +- modules/services/taffybar.nix | 2 +- modules/services/udiskie.nix | 2 +- modules/services/xscreensaver.nix | 2 +- modules/xsession.nix | 14 +++++++++++--- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 8042cf93d41..4d866cec345 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -22,7 +22,7 @@ with lib; }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/gnome-keyring.nix b/modules/services/gnome-keyring.nix index e5040906551..b0edeaed478 100644 --- a/modules/services/gnome-keyring.nix +++ b/modules/services/gnome-keyring.nix @@ -45,7 +45,7 @@ in }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/modules/services/keepassx.nix b/modules/services/keepassx.nix index 799f0e5c339..0ed90dd0439 100644 --- a/modules/services/keepassx.nix +++ b/modules/services/keepassx.nix @@ -16,7 +16,7 @@ with lib; }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index 8b529c5b6bf..a7a90b618a5 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -16,7 +16,7 @@ with lib; }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index 0dabb87217a..d0412310cb5 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -51,7 +51,7 @@ in }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; } diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index f9ab2ee6142..87a84063483 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -34,7 +34,7 @@ in }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index 964629c7a8f..3fb038a74aa 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -22,7 +22,7 @@ with lib; }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix index 58261553902..0b1a4573a0f 100644 --- a/modules/services/xscreensaver.nix +++ b/modules/services/xscreensaver.nix @@ -20,7 +20,7 @@ with lib; }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/modules/xsession.nix b/modules/xsession.nix index ab6629743d8..ec6d4505510 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -34,7 +34,7 @@ in }; Install = { - WantedBy = [ "xorg.target" ]; + WantedBy = [ "graphical-session.target" ]; }; Service = { @@ -53,6 +53,14 @@ in }; }; + # A basic graphical session target. Apparently this will come + # standard in future Systemd versions. + systemd.user.targets.graphical-session = { + Unit = { + Description = "Graphical session"; + }; + }; + home.file.".xsession" = { mode = "555"; text = '' @@ -64,13 +72,13 @@ in systemctl --user import-environment SSH_AUTH_SOCK systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user start xorg.target + systemctl --user start graphical-session.target ${cfg.initExtra} ${cfg.windowManager} - systemctl --user stop xorg.target + systemctl --user stop graphical-session.target ''; }; }; -- cgit v1.2.3 From 8a196bb62b6df9fa508aeca4f5799cf0edb7d7b9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 22:49:29 +0100 Subject: systemd: fix quoting in glob pattern --- modules/systemd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 6ea8b21c446..cead653a5eb 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -79,8 +79,8 @@ in --new-line-format='+%L' \ --old-line-format='-%L' \ --unchanged-line-format=' %L' \ - <(basename -a $(echo "$oldUserServicePath/*.service") | sort) \ - <(basename -a $(echo "$newUserServicePath/*.service") | sort) \ + <(basename -a $(echo "$oldUserServicePath/"*.service) | sort) \ + <(basename -a $(echo "$newUserServicePath/"*.service) | sort) \ > $servicesDiffFile local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) -- cgit v1.2.3 From a578ea9527ddcf5bcc6351f8edaae07ec51d85f0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 22:55:44 +0100 Subject: xsession: import XAUTHORITY into systemd env --- modules/xsession.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/xsession.nix b/modules/xsession.nix index ec6d4505510..52393c7fb2a 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -70,6 +70,7 @@ in systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY systemctl --user import-environment SSH_AUTH_SOCK + systemctl --user import-environment XAUTHORITY systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR systemctl --user start graphical-session.target -- cgit v1.2.3 From 4efbf0e0902368784ee11f95bf3ce15d1f729ead Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Jan 2017 23:38:45 +0100 Subject: systemd: minor activation output fix --- modules/systemd.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index cead653a5eb..450d8f9f57a 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -103,20 +103,20 @@ in local sugg="" if [[ -n "''${toRestart[@]}" ]] ; then - sugg="$sugg\nsystemctl --user restart ''${toRestart[@]}" + sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" fi if [[ -n "''${toStop[@]}" ]] ; then - sugg="$sugg\nsystemctl --user stop ''${toStop[@]}" + sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" fi if [[ -n "''${toStart[@]}" ]] ; then - sugg="$sugg\nsystemctl --user start ''${toStart[@]}" + sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" fi if [[ -n "$sugg" ]] ; then echo "Suggested commands:" - echo -e "$sugg" + echo -n -e "$sugg" fi } -- cgit v1.2.3 From a617aeaa7318a3cbead8fa5a1898e8f87e393746 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 10 Jan 2017 00:35:54 +0100 Subject: gnome-terminal: add to packages --- modules/programs/gnome-terminal.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index 90cf46adff1..cc34bdbb7f4 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -174,6 +174,8 @@ in }; config = mkIf cfg.enable { + home.packages = [ pkgs.gnome3.gnome_terminal ]; + home.activation.gnome-terminal = let sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); -- cgit v1.2.3 From cbc4188b6803cb0c0d8aabf8752e552810f09b2d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 11 Jan 2017 00:36:05 +0100 Subject: home-manager: improve robustness With this commit the activation script is run only if nix-build succeeded. --- home-manager/home-manager | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index f50dc446e68..47c9ebd1bf0 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -12,14 +12,14 @@ function doRebuild() { local wrkdir wrkdir="$(mktemp -d)" - nix-build --show-trace \ - "@HOME_MANAGER_EXPR_PATH@" \ - --argstr modulesPath "@MODULES_PATH@" \ - --argstr confPath "$confFile" \ - -A activation-script \ - -o "$wrkdir/generation" - - "$wrkdir/generation/activate" + if nix-build --show-trace \ + "@HOME_MANAGER_EXPR_PATH@" \ + --argstr modulesPath "@MODULES_PATH@" \ + --argstr confPath "$confFile" \ + -A activation-script \ + -o "$wrkdir/generation" ; then + "$wrkdir/generation/activate" + fi rm -r "$wrkdir" } -- cgit v1.2.3 From 5cb1ede0344059964a853471a9dc1fffebbb7fae Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 11 Jan 2017 00:36:43 +0100 Subject: firefox: add module --- modules/default.nix | 1 + modules/programs/firefox.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 modules/programs/firefox.nix diff --git a/modules/default.nix b/modules/default.nix index 6f42de2f4bc..340cfefebac 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -11,6 +11,7 @@ let ./programs/beets.nix ./programs/eclipse.nix ./programs/emacs.nix + ./programs/firefox.nix ./programs/git.nix ./programs/gnome-terminal.nix ./programs/lesspipe.nix diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix new file mode 100644 index 00000000000..befacec24b5 --- /dev/null +++ b/modules/programs/firefox.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.firefox; + +in + +{ + options = { + programs.firefox = { + enable = mkEnableOption "Firefox"; + + package = mkOption { + type = types.package; + default = pkgs.firefox-unwrapped; + defaultText = "pkgs.firefox-unwrapped"; + description = "The unwrapped Firefox package to use."; + }; + + enableAdobeFlash = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the unfree Adobe Flash plugin."; + }; + + enableGoogleTalk = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the unfree Google Talk plugin."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = + let + # A bit of hackery to force a config into the wrapper. + browserName = cfg.package.browserName + or (builtins.parseDrvName cfg.package.name).name; + + fcfg = setAttrByPath [browserName] { + enableAdobeFlash = cfg.enableAdobeFlash; + enableGoogleTalkPlugin = cfg.enableGoogleTalk; + }; + + wrapper = pkgs.wrapFirefox.override { + config = fcfg; + }; + in + [ (wrapper cfg.package { }) ]; + }; +} -- cgit v1.2.3 From 94fd39c41c755f787d925bbdaa8f8ac5c7154e75 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 11 Jan 2017 22:55:31 +0100 Subject: home-manager: add `build` command This will build a configuration into an `result` output directory. Does not create a new generation. --- home-manager/home-manager | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 47c9ebd1bf0..8f8b2dc61ff 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -1,23 +1,33 @@ #!@bash@/bin/bash -function doRebuild() { - if [[ -z "$1" ]] ; then +function doBuild() { + if [[ -z "$1" ]]; then echo "Need to provide path to configuration file." exit 1 fi - local confFile + if [[ -z "$2" ]]; then + echo "Need to provide generation output path." + exit 1 + fi + + local confFile output confFile="$(realpath "$1")" + output="$(realpath "$2")" + nix-build --show-trace \ + "@HOME_MANAGER_EXPR_PATH@" \ + --argstr modulesPath "@MODULES_PATH@" \ + --argstr confPath "$confFile" \ + -A activation-script \ + -o "$output" +} + +function doRebuild() { local wrkdir wrkdir="$(mktemp -d)" - if nix-build --show-trace \ - "@HOME_MANAGER_EXPR_PATH@" \ - --argstr modulesPath "@MODULES_PATH@" \ - --argstr confPath "$confFile" \ - -A activation-script \ - -o "$wrkdir/generation" ; then + if doBuild "$1" "$wrkdir/generation" ; then "$wrkdir/generation/activate" fi @@ -42,16 +52,21 @@ function doListPackages() { } function doHelp() { - echo "Usage: $0 {help | rebuild CONF | generations | packages}" + echo "Usage: $0 {help | build CONF | rebuild CONF" + echo " | generations | packages}" echo echo "Commands" echo " help Print this help" - echo " rebuild Rebuild the current environment" + echo " build Build configuration into result directory" + echo " rebuild Build and activate environment" echo " generations List all home environment generations" echo " packages List all packages installed in home-manager-path" } case "$1" in + build) + doBuild "$2" "result" + ;; rebuild) doRebuild "$2" ;; -- cgit v1.2.3 From bd951cda66ab29376dcd707716d13cab7cf1910b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 11 Jan 2017 22:58:55 +0100 Subject: home-manager: rename `rebuild` to `switch` --- home-manager/home-manager | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 8f8b2dc61ff..e51cc65d551 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -23,7 +23,7 @@ function doBuild() { -o "$output" } -function doRebuild() { +function doSwitch() { local wrkdir wrkdir="$(mktemp -d)" @@ -58,7 +58,7 @@ function doHelp() { echo "Commands" echo " help Print this help" echo " build Build configuration into result directory" - echo " rebuild Build and activate environment" + echo " switch Build and activate configuration" echo " generations List all home environment generations" echo " packages List all packages installed in home-manager-path" } @@ -67,8 +67,8 @@ case "$1" in build) doBuild "$2" "result" ;; - rebuild) - doRebuild "$2" + switch) + doSwitch "$2" ;; generations) doListGens -- cgit v1.2.3 From 3d3a3f6d1398a35da49b85ac37c56e67e8b52396 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 12 Jan 2017 01:01:15 +0100 Subject: xresources: add module This module adds basic support for configuring X resources. --- modules/default.nix | 1 + modules/xresources.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 modules/xresources.nix diff --git a/modules/default.nix b/modules/default.nix index 340cfefebac..57f5c5c27cf 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -27,6 +27,7 @@ let ./services/udiskie.nix ./services/xscreensaver.nix ./systemd.nix + ./xresources.nix ./xsession.nix ]; diff --git a/modules/xresources.nix b/modules/xresources.nix new file mode 100644 index 00000000000..43e8ff1c899 --- /dev/null +++ b/modules/xresources.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xresources; + + formatLine = n: v: + let + v' = + if isBool v then (if v then "true" else "false") + else toString v; + in + "${n}: ${v'}"; + +in + +{ + options = { + xresources.properties = mkOption { + type = types.nullOr types.attrs; + default = null; + example = '' + { + "XTerm*faceName" = "dejavu sans mono"; + "Emacs*toolBar" = 0; + } + ''; + description = '' + X server resources that should be set. If null, then this + feature is disabled and no ~/.Xresources link is produced. + ''; + }; + }; + + config = mkIf (cfg.properties != null) { + home.file.".Xresources".text = + concatStringsSep "\n" ( + mapAttrsToList formatLine cfg.properties + ); + }; +} -- cgit v1.2.3 From 8d774ec6281c7f24f48eab36698f086c2b69e315 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 12 Jan 2017 22:26:24 +0100 Subject: home-manager: clean up usage help --- home-manager/home-manager | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index e51cc65d551..5c1d83f6179 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -52,15 +52,14 @@ function doListPackages() { } function doHelp() { - echo "Usage: $0 {help | build CONF | rebuild CONF" - echo " | generations | packages}" + echo "Usage: $0 COMMAND" echo echo "Commands" - echo " help Print this help" - echo " build Build configuration into result directory" - echo " switch Build and activate configuration" - echo " generations List all home environment generations" - echo " packages List all packages installed in home-manager-path" + echo " help Print this help" + echo " build CONF Build configuration into result directory" + echo " switch CONF Build and activate configuration" + echo " generations List all home environment generations" + echo " packages List all packages installed in home-manager-path" } case "$1" in -- cgit v1.2.3 From d02f8b17efd60811be6d268e7ad6b65354c496d8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 13 Jan 2017 01:12:26 +0100 Subject: xresources: add newline to end of file --- modules/xresources.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index 43e8ff1c899..61efd3d98a1 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -38,6 +38,6 @@ in home.file.".Xresources".text = concatStringsSep "\n" ( mapAttrsToList formatLine cfg.properties - ); + ) + "\n"; }; } -- cgit v1.2.3 From e0a37be5150b1b4e78e0675cd4ae0424b93e56ea Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 14 Jan 2017 13:02:58 +0100 Subject: home-manager: check output path In particular, error out if the output path already exists. --- home-manager/home-manager | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 5c1d83f6179..1c62468116a 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -11,6 +11,11 @@ function doBuild() { exit 1 fi + if [[ -e "$2" ]]; then + echo "The output path $2 already exists." + exit 1 + fi + local confFile output confFile="$(realpath "$1")" output="$(realpath "$2")" -- cgit v1.2.3 From 853e28647d064a61399fcf7f1954208f1771d245 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 14 Jan 2017 13:04:57 +0100 Subject: Add basic README file --- README.md | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000..179fcf1581b --- /dev/null +++ b/README.md @@ -0,0 +1,127 @@ +Home Manager using Nix +====================== + +This project provides a basic system for managing a user environment +using the [Nix][] package manager together with the Nix libraries +found in [Nixpkgs][]. Before attempting to use Home Manager please +read the warning below. + +Words of warning +---------------- + +This project is in early development! I personally use it to manage +several user configurations but it may fail catastrophically for you. +So beware! + +To configure programs and services the Home Manager must write various +things to your home directory and possibly overwrite files you have +previously created. For example, if you use Home Manager to install +and configure Git then your `~/.gitconfig` will be replaced by a link +to a configuration generated by Home Manager: + +``` +$ ls -gG ~/.gitconfig +lrwxrwxrwx 1 73 Jan 8 21:59 /home/rycee/.gitconfig -> /nix/store/pk7g12816avnxyhnkbdhqhnlzrw7fsga-home-manager-files/.gitconfig +``` + +So, if you already have a wonderful, painstakingly created +`~/.gitconfig` it will be gone. Home Manager will _not_ attempt to +backup the previous `~/.gitconfig` file. + +Further, Home Manager has only ever been used on [NixOS][] version +16.09 (the stable version), it may or may not work on other Linux +distributions and NixOS versions. + +Finally, the `home-manager` tool does not support rollbacks at the +moment so if your home directory gets messed up you'll have to fix it +yourself. + +Now when your expectations have been built up and you are eager to try +all this out you can go ahead and read the rest of this text. + +Installation +------------ + +Currently the easiest way to install Home Manager is as follows: + + 1. Make sure you have a working Nix installation. + + 2. Clone the Home Manager repository into the `~/.nixpkgs` directory: + + ``` + $ git clone https://github.com/rycee/home-manager ~/.nixpkgs/home-manager + ``` + + 3. Add Home Manager to your user's Nixpkgs, for example by adding it + to the `packageOverrides` section in your `~/.nixpkgs/config.nix` + file: + + ```nix + { + packageOverrides = pkgs: rec { + home-manager = import ./home-manager { inherit pkgs; }; + }; + } + ``` + + 4. Install the `home-manager` package: + + ``` + $ nix-env -f '' -iA home-manager + installing ‘home-manager’ + ``` + +Usage +----- + +The `home-manager` package installs a tool that is conveniently called +`home-manager`. This tool can apply configurations to your home +directory, list user packages installed by the tool, and list the +configuration generations. + +As an example, let us set up a very simple configuration that installs +the htop and fortune packages, installs Emacs with a few extra +packages enabled, installs Firefox with Adobe Flash enabled, and +enables the user gpg-agent service. + +First create a file `~/.nixpkgs/home.nix` containing + +```nix +{ pkgs }: + +{ + home.packages = [ + pkgs.htop + pkgs.fortune + ]; + + programs.emacs = { + enable = true; + extraPackages = epkgs: [ + epkgs.nix-mode + epkgs.magit + ]; + }; + + programs.firefox = { + enable = true; + enableAdobeFlash = true; + }; + + services.gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + }; +} +``` + +To activate this configuration you can then run + +``` +$ home-manager switch ~/.nixpkgs/home.nix +``` + +[Nix]: https://nixos.org/nix/ +[NixOS]: https://nixos.org/ +[Nixpkgs]: https://nixos.org/nixpkgs/ -- cgit v1.2.3 From 75bb0c8efb6b431bd30c1ca1a6983931834a0000 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 00:15:51 +0100 Subject: gpg-agent: remove deprecated argument --- modules/services/gpg-agent.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index ac93a871ff8..872b69b20d6 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -57,7 +57,7 @@ in Service = { Type = "forking"; - ExecStart = "${pkgs.gnupg}/bin/gpg-agent --daemon --use-standard-socket"; + ExecStart = "${pkgs.gnupg}/bin/gpg-agent --daemon"; Restart = "on-abort"; }; -- cgit v1.2.3 From 6ec3026e510d7e9440e8d0cbe206ef68a8e4251a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 10:46:20 +0100 Subject: xsession: improve initialization script This adds a `graphical-session-pre` target for things that need to run just before the main session starts. Also adds a loop during shutdown that waits until all deactivating units are gone. Inspired by . --- modules/xsession.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index 52393c7fb2a..3b36a5b537f 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -53,6 +53,14 @@ in }; }; + # For stuff that needs to start just before a graphical session + # starts. + systemd.user.targets.graphical-session-pre = { + Unit = { + Description = "Pre-graphical session"; + }; + }; + # A basic graphical session target. Apparently this will come # standard in future Systemd versions. systemd.user.targets.graphical-session = { @@ -73,13 +81,21 @@ in systemctl --user import-environment XAUTHORITY systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user start graphical-session.target + + systemctl --user restart graphical-session-pre.target + systemctl --user restart graphical-session.target ${cfg.initExtra} ${cfg.windowManager} systemctl --user stop graphical-session.target + systemctl --user stop graphical-session-pre.target + + # Wait until the units actually stop. + while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do + sleep 0.5 + done ''; }; }; -- cgit v1.2.3 From 071e631648924cd5929c33a02e626fb23aca3ae4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 20:03:55 +0100 Subject: Improve a few description fields --- modules/home-environment.nix | 5 ++++- modules/programs/bash.nix | 1 + modules/programs/beets.nix | 5 ++++- modules/programs/git.nix | 2 +- modules/programs/gnome-terminal.nix | 1 + modules/xresources.nix | 15 +++++++-------- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 2c335ba9ed8..41196186df6 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -100,7 +100,9 @@ in options = { target = mkOption { type = types.str; - description = "Path to target file relative to $HOME."; + description = '' + Path to target file relative to HOME. + ''; }; text = mkOption { @@ -147,6 +149,7 @@ in home.sessionVariables = mkOption { default = {}; type = types.attrs; + example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; description = "Environment variables to always set at login."; }; diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index f17b3f1bdd1..a2000274c81 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -38,6 +38,7 @@ in historyIgnore = mkOption { type = types.listOf types.str; default = []; + example = [ "ls" "cd" "exit" ]; description = "List of commands that should not be saved to the history list."; }; diff --git a/modules/programs/beets.nix b/modules/programs/beets.nix index 46a17a9711f..df9495ef267 100644 --- a/modules/programs/beets.nix +++ b/modules/programs/beets.nix @@ -14,7 +14,10 @@ in settings = mkOption { type = types.attrs; default = {}; - description = "Configuration written to ~/.config/beets/config.yaml"; + description = '' + Configuration written to + ~/.config/beets/config.yaml + ''; }; }; }; diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 33fcbe428bf..672bd7997ef 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -26,7 +26,7 @@ let gpgPath = mkOption { type = types.str; default = "${pkgs.gnupg}/bin/gpg2"; - defaultText = "''${pkgs.gnupg}/bin/gpg2"; + defaultText = "\${pkgs.gnupg}/bin/gpg2"; description = "Path to GnuPG binary to use."; }; }; diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index cc34bdbb7f4..4a7646f24b2 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -169,6 +169,7 @@ in profile = mkOption { default = {}; type = types.loaOf profileSubModule; + description = "A set of Gnome Terminal profiles."; }; }; }; diff --git a/modules/xresources.nix b/modules/xresources.nix index 61efd3d98a1..abeed0c1fc2 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -21,15 +21,14 @@ in xresources.properties = mkOption { type = types.nullOr types.attrs; default = null; - example = '' - { - "XTerm*faceName" = "dejavu sans mono"; - "Emacs*toolBar" = 0; - } - ''; + example = { + "XTerm*faceName" = "dejavu sans mono"; + "Emacs*toolBar" = 0; + }; description = '' - X server resources that should be set. If null, then this - feature is disabled and no ~/.Xresources link is produced. + X server resources that should be set. If null, + then this feature is disabled and no + ~/.Xresources link is produced. ''; }; }; -- cgit v1.2.3 From ed81b6848ef56d8f22f68bda73163445deb674f6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 20:56:18 +0100 Subject: manual: add module This module is capable of producing a bastardized NixOS configuration manual with Home Manager configuration options instead. --- modules/default.nix | 3 +++ modules/manual.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 modules/manual.nix diff --git a/modules/default.nix b/modules/default.nix index 57f5c5c27cf..7f5f48b58b2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,6 +7,7 @@ let modules = [ ./home-environment.nix + ./manual.nix ./programs/bash.nix ./programs/beets.nix ./programs/eclipse.nix @@ -29,10 +30,12 @@ let ./systemd.nix ./xresources.nix ./xsession.nix + ]; pkgsModule = { config._module.args.pkgs = lib.mkForce pkgs; + config._module.args.baseModules = modules; }; module = lib.evalModules { diff --git a/modules/manual.nix b/modules/manual.nix new file mode 100644 index 00000000000..0a947914460 --- /dev/null +++ b/modules/manual.nix @@ -0,0 +1,68 @@ +{ config, lib, pkgs, baseModules, ... }: + +with lib; + +let + + /* For the purpose of generating docs, evaluate options with each derivation + in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}". + It isn't perfect, but it seems to cover a vast majority of use cases. + Caveat: even if the package is reached by a different means, + the path above will be shown and not e.g. `${config.services.foo.package}`. */ + nixosManual = import { + inherit pkgs config; + version = "0.1"; + revision = "release-0.1"; + options = + let + scrubbedEval = evalModules { + modules = [ { nixpkgs.system = pkgs.stdenv.system; } ] ++ baseModules; + args = (config._module.args) // { modules = [ ]; }; + specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; }; + }; + scrubDerivations = namePrefix: pkgSet: mapAttrs + (name: value: + let wholeName = "${namePrefix}.${name}"; in + if isAttrs value then + scrubDerivations wholeName value + // (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; }) + else value + ) + pkgSet; + in scrubbedEval.options; + }; + + homeEnvironmentManPages = pkgs.runCommand "home-environment-manpages" { + allowedReferences = [ "out" ]; + } '' + install -v -D -m444 \ + ${nixosManual.manpages}/share/man/man5/configuration.nix.5 \ + $out/share/man/man5/home-configuration.nix.5 + ''; + +in + +{ + options = { + manual.manpages.enable = mkOption { + type = types.bool; + default = true; + example = false; + description = '' + Whether to install the configuration manual page. The manual can + be reached by man home-configuration.nix. + + When looking at the manual page pretend that all references to + NixOS stuff are actually references to Home Manager stuff. + Thanks! + ''; + }; + }; + + config = mkIf config.manual.manpages.enable { + # To fix error during manpage build. + meta.doc = builtins.toFile "nothingness" ""; + + home.packages = [ homeEnvironmentManPages ]; + }; +} -- cgit v1.2.3 From e0fd58709cde87094b4ff57e80e2d3a730f74e69 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 21:07:39 +0100 Subject: home-manager: improve error checking a bit --- home-manager/home-manager | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 1c62468116a..380a2fa0a0a 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -18,8 +18,17 @@ function doBuild() { local confFile output confFile="$(realpath "$1")" + + if [[ $? -ne 0 ]]; then + exit 1 + fi + output="$(realpath "$2")" + if [[ $? -ne 0 ]]; then + exit 1 + fi + nix-build --show-trace \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr modulesPath "@MODULES_PATH@" \ -- cgit v1.2.3 From a5c8362f7b33e995f8fb3e18c0c236052fdb23b0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Jan 2017 23:32:57 +0100 Subject: home-manager: improve command line option handling --- README.md | 11 ++++++++++- home-manager/home-manager | 49 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 179fcf1581b..f86fb90f3ba 100644 --- a/README.md +++ b/README.md @@ -119,9 +119,18 @@ First create a file `~/.nixpkgs/home.nix` containing To activate this configuration you can then run ``` -$ home-manager switch ~/.nixpkgs/home.nix +$ home-manager switch ``` +or if you are not feeling so lucky, + +``` +$ home-manager build +``` + +which will create a `result` link to a directory containing an +activation script and the generated home directory files. + [Nix]: https://nixos.org/nix/ [NixOS]: https://nixos.org/ [Nixpkgs]: https://nixos.org/nixpkgs/ diff --git a/home-manager/home-manager b/home-manager/home-manager index 380a2fa0a0a..9f25f321208 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -66,22 +66,55 @@ function doListPackages() { } function doHelp() { - echo "Usage: $0 COMMAND" + echo "Usage: $0 [OPTION] COMMAND" + echo + echo "Options" + echo + echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix" + echo " -n Do a dry run, only prints what actions would be taken" + echo " -h Print this help" echo echo "Commands" echo " help Print this help" - echo " build CONF Build configuration into result directory" - echo " switch CONF Build and activate configuration" + echo " build Build configuration into result directory" + echo " switch Build and activate configuration" echo " generations List all home environment generations" echo " packages List all packages installed in home-manager-path" } -case "$1" in +CONFIG_FILE="$HOME/.nixpkgs/home.nix" + +while getopts f:nh opt; do + case $opt in + f) + CONFIG_FILE=$OPTARG + ;; + n) + export DRY_RUN=1 + ;; + h) + doHelp + exit 0 + ;; + *) + echo "Unknown option -$OPTARG" >&2 + doHelp >&2 + exit 1 + ;; + esac +done + +# Get rid of the options. +shift "$((OPTIND-1))" + +cmd="$*" + +case "$cmd" in build) - doBuild "$2" "result" + doBuild "$CONFIG_FILE" "result" ;; switch) - doSwitch "$2" + doSwitch "$CONFIG_FILE" ;; generations) doListGens @@ -93,8 +126,8 @@ case "$1" in doHelp ;; *) - echo "Unknown command: $1" - doHelp + echo "Unknown command: $cmd" + doHelp >&2 exit 1 ;; esac -- cgit v1.2.3 From b1f84ada60705fcf83f70d851321e944e40deff0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Jan 2017 00:06:27 +0100 Subject: Support dry run in activation script If the `DRY_RUN` variable is set then no actual change should be performed. Only printing what actions would be taken. --- modules/home-environment.nix | 30 +++++++++++++++++++++++------- modules/programs/gnome-terminal.nix | 6 +++++- modules/systemd.nix | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 41196186df6..0ea92147762 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -168,7 +168,15 @@ in internal = true; default = {}; type = types.attrs; - description = "Activation scripts for the home environment."; + description = '' + Activation scripts for the home environment. + + Any script should respect the DRY_RUN + variable, if it is set then no actual action should be taken. + The variable DRY_RUN_CMD is set to + echo if dry run is enabled. Thus, many cases you + can use the idiom $DRY_RUN_CMD rm -rf /. + ''; }; home.activationPackage = mkOption { @@ -202,8 +210,8 @@ in for sourcePath in "$@" ; do relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")" targetPath="$HOME/$relativePath" - mkdir -vp "$(dirname "$targetPath")" - ln -vsf "$sourcePath" "$targetPath" + $DRY_RUN_CMD mkdir -vp "$(dirname "$targetPath")" + $DRY_RUN_CMD ln -vsf "$sourcePath" "$targetPath" done ''; @@ -219,8 +227,8 @@ in echo " exists" else echo " gone (deleting)" - rm -v "$targetPath" - rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")" + $DRY_RUN_CMD rm -v "$targetPath" + $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")" fi done ''; @@ -284,8 +292,8 @@ in } if [[ "$oldGenPath" != "$newGenPath" ]] ; then - ln -Tsfv "$newGenPath" "$newGenProfilePath" - ln -Tsfv "$newGenPath" "$newGenGcPath" + $DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenProfilePath" + $DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenGcPath" linkNewGen cleanOldGen else @@ -316,6 +324,14 @@ in sf = pkgs.writeText "activation-script" '' #!${pkgs.stdenv.shell} + if [[ $DRY_RUN ]] ; then + echo "Performing dry run" + export DRY_RUN_CMD=echo + else + echo "Performing live run" + unset DRY_RUN_CMD + fi + ${activationCmds} ''; diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index 4a7646f24b2..6d483b90da0 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -183,7 +183,11 @@ in dconfPath = "/org/gnome/terminal/legacy/"; in '' - ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} + if [[ $DRY_RUN ]]; then + echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${sf} + else + ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} + fi ''; }; } diff --git a/modules/systemd.nix b/modules/systemd.nix index 450d8f9f57a..784be8db69c 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -120,7 +120,7 @@ in fi } - systemctl --user daemon-reload + $DRY_RUN_CMD systemctl --user daemon-reload systemdPostReload ''; }; -- cgit v1.2.3 From 8ce389ce2acca7a630c3d25466fa20993843d28c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Jan 2017 00:14:52 +0100 Subject: home-manager: handle missing configuration file Make it look a little nicer than having nix-build emit the error. --- home-manager/home-manager | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 9f25f321208..41089f872c0 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -23,6 +23,11 @@ function doBuild() { exit 1 fi + if [[ ! -r "$confFile" ]]; then + echo "No such configuration file: $1" + exit 1 + fi + output="$(realpath "$2")" if [[ $? -ne 0 ]]; then -- cgit v1.2.3 From f35b9a9970ef66eb8ede5a5595b01777e55fde4a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Jan 2017 20:26:42 +0100 Subject: Add initial section of activation script The initial section creates some useful variables for use by later activation sections. --- modules/activation-init.sh | 46 ++++++++++++++++++++++++++++++++++++++++++ modules/home-environment.nix | 48 ++++---------------------------------------- modules/systemd.nix | 2 +- 3 files changed, 51 insertions(+), 45 deletions(-) create mode 100755 modules/activation-init.sh diff --git a/modules/activation-init.sh b/modules/activation-init.sh new file mode 100755 index 00000000000..91ad791076d --- /dev/null +++ b/modules/activation-init.sh @@ -0,0 +1,46 @@ +function setupVars() { + local profilesPath="/nix/var/nix/profiles/per-user/$USER" + local gcPath="/nix/var/nix/gcroots/per-user/$USER" + local greatestGenNum + + greatestGenNum=$( \ + find "$profilesPath" -name 'home-manager-*-link' \ + | sed 's/^.*-\([0-9]*\)-link$/\1/' \ + | sort -rn \ + | head -1) + + if [[ -n "$greatestGenNum" ]] ; then + oldGenNum=$greatestGenNum + newGenNum=$((oldGenNum + 1)) + else + newGenNum=1 + fi + + if [[ -e "$gcPath/current-home" ]] ; then + oldGenPath="$(readlink -e "$gcPath/current-home")" + fi + + newGenPath="@GENERATION_DIR@"; + newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" + newGenGcPath="$gcPath/current-home" +} + +setupVars + +echo "Starting home manager activation" + +if [[ $DRY_RUN ]] ; then + echo "This is a dry run" + export DRY_RUN_CMD=echo +else + echo "This is a live run" + unset DRY_RUN_CMD +fi + +echo "Activation variables:" +echo " oldGenNum=$oldGenNum" +echo " newGenNum=$newGenNum" +echo " oldGenPath=$oldGenPath" +echo " newGenPath=$newGenPath" +echo " newGenProfilePath=$newGenProfilePath" +echo " newGenGcPath=$newGenGcPath" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 0ea92147762..c4dda2ef8c8 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -202,7 +202,7 @@ in // (maybeSet "LC_TIME" cfg.language.time); - home.activation.linkages = + home.activation.linkGeneration = let link = pkgs.writeText "link" '' newGenFiles="$1" @@ -234,42 +234,6 @@ in ''; in '' - function setupVars() { - local profilesPath="/nix/var/nix/profiles/per-user/$(whoami)" - local gcPath="/nix/var/nix/gcroots/per-user/$(whoami)" - local greatestGenNum=( \ - $(find "$profilesPath" -name 'home-manager-*-link' \ - | sed 's/^.*-\([0-9]*\)-link$/\1/' \ - | sort -rn \ - | head -1) \ - ) - - if [[ -n "$greatestGenNum" ]] ; then - oldGenNum=$greatestGenNum - newGenNum=$(($oldGenNum + 1)) - else - newGenNum=1 - fi - - if [[ -e "$gcPath/current-home" ]] ; then - oldGenPath="$(readlink -e "$gcPath/current-home")" - fi - - newGenPath="@GENERATION_DIR@"; - newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" - newGenGcPath="$gcPath/current-home" - } - - # Set some vars, these can be used later on as well. - setupVars - - echo oldGenNum=$oldGenNum - echo newGenNum=$newGenNum - echo oldGenPath=$oldGenPath - echo newGenPath=$newGenPath - echo newGenProfilePath=$newGenProfilePath - echo newGenGcPath=$newGenGcPath - function linkNewGen() { local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" @@ -324,13 +288,9 @@ in sf = pkgs.writeText "activation-script" '' #!${pkgs.stdenv.shell} - if [[ $DRY_RUN ]] ; then - echo "Performing dry run" - export DRY_RUN_CMD=echo - else - echo "Performing live run" - unset DRY_RUN_CMD - fi + set -e + + ${builtins.readFile ./activation-init.sh} ${activationCmds} ''; diff --git a/modules/systemd.nix b/modules/systemd.nix index 784be8db69c..de3492308a9 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -69,7 +69,7 @@ in (buildServices "timer" config.systemd.user.timers) ); - home.activation.reloadSystemD = stringAfter ["linkages"] '' + home.activation.reloadSystemD = '' function systemdPostReload() { local servicesDiffFile="$(mktemp)" local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" -- cgit v1.2.3 From 5fbbbd1ea4978c22d527af00c9b8af66b0bfcba8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Jan 2017 23:54:45 +0100 Subject: pam: add module Also make it possible to set session variables using PAM rather than Bash. --- modules/default.nix | 1 + modules/home-environment.nix | 19 ++++++++++++++++++- modules/misc/pam.nix | 20 ++++++++++++++++++++ modules/programs/bash.nix | 3 ++- modules/xsession.nix | 8 ++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 modules/misc/pam.nix diff --git a/modules/default.nix b/modules/default.nix index 7f5f48b58b2..b9a4be4d9ca 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,6 +8,7 @@ let modules = [ ./home-environment.nix ./manual.nix + ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix ./programs/eclipse.nix diff --git a/modules/home-environment.nix b/modules/home-environment.nix index c4dda2ef8c8..3623bc20380 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -150,7 +150,24 @@ in default = {}; type = types.attrs; example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; - description = "Environment variables to always set at login."; + description = '' + Environment variables to always set at login. + ''; + }; + + home.sessionVariableSetter = mkOption { + default = "pam"; + type = types.enum [ "pam" "bash" ]; + example = "bash"; + description = '' + Identifies the module that should set the session variables. + + If "bash" is set then config.bash.enable + must also be enabled. + + If "pam" is set then PAM must be used to set the system + environment. + ''; }; home.packages = mkOption { diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix new file mode 100644 index 00000000000..89040aa841c --- /dev/null +++ b/modules/misc/pam.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + homeCfg = config.home; + +in + +{ + options = {}; + + config = mkIf (homeCfg.sessionVariableSetter == "pam") { + home.file.".pam_environment".text = + concatStringsSep "\n" ( + mapAttrsToList (n: v: "${n} OVERRIDE=${v}") homeCfg.sessionVariables + ) + "\n"; + }; +} diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index a2000274c81..a8004580d8a 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -127,7 +127,8 @@ in home.file.".profile".text = '' # -*- mode: sh -*- - ${envVarsStr} + ${optionalString (config.home.sessionVariableSetter == "bash") + envVarsStr} ${cfg.profileExtra} ''; diff --git a/modules/xsession.nix b/modules/xsession.nix index 3b36a5b537f..f498d51786a 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -72,8 +72,12 @@ in home.file.".xsession" = { mode = "555"; text = '' - # Rely on Bash to set session variables. - . "$HOME/.profile" + ${ + # If we want bash to set the session variables then we need + # to pull in .profile since that's where they are. + optionalString (config.home.sessionVariableSetter == "bash") + ". \"$HOME/.profile\"" + } systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY -- cgit v1.2.3 From 30e30688b8a06f7c9b365087cc3cead9a889296a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 17 Jan 2017 00:47:03 +0100 Subject: gtk: add module Quite rough around the edges, though. --- modules/default.nix | 1 + modules/misc/gtk.nix | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 modules/misc/gtk.nix diff --git a/modules/default.nix b/modules/default.nix index b9a4be4d9ca..a95870b50e4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,6 +8,7 @@ let modules = [ ./home-environment.nix ./manual.nix + ./misc/gtk.nix ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix new file mode 100644 index 00000000000..258dd4ade81 --- /dev/null +++ b/modules/misc/gtk.nix @@ -0,0 +1,131 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.gtk; + cfg2 = config.gtk.gtk2; + cfg3 = config.gtk.gtk3; + + toGtk3Ini = (import ../lib/generators.nix).toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "true" else "false") + else toString value; + in + "${key}=${value'}"; + }; + + formatGtk2Option = n: v: + let + v' = + if isBool v then (if v then "true" else "false") + else if isString v then "\"${v}\"" + else toString v; + in + "${n} = ${v'}"; + +in + +{ + options = { + gtk = { + enable = mkEnableOption "GTK 2/3 configuration"; + + fontName = mkOption { + type = types.nullOr types.str; + default = null; + example = "DejaVu Sans 8"; + description = '' + The font to use in GTK+ 2/3 applications. + ''; + }; + + themeName = mkOption { + type = types.nullOr types.str; + default = null; + example = "Vertex-Dark"; + description = "The name of the GTK+2/3 theme to use."; + }; + + iconThemeName = mkOption { + type = types.nullOr types.str; + default = null; + example = "Tango"; + description = "The name of the icon theme to use."; + }; + + gtk2 = mkOption { + description = "Options specific to GTK+ 2"; + default = {}; + type = types.submodule { + options = { + extraConfig = mkOption { + type = types.lines; + default = ""; + example = "gtk-can-change-accels = 1"; + description = '' + Extra configuration lines to add verbatim to + ~/.gtkrc-2.0. + ''; + }; + }; + }; + }; + + gtk3 = mkOption { + description = "Options specific to GTK+ 3"; + default = {}; + type = types.submodule { + options = { + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; + description = '' + Extra configuration options to add to + ~/.config/gtk-3.0/settings.ini. + ''; + }; + + extraCss = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration lines to add verbatim to + ~/.config/gtk-3.0/gtk.css. + ''; + }; + }; + }; + }; + }; + }; + + config = mkIf (cfg.enable != null) ( + let + ini = + optionalAttrs (cfg.fontName != null) + { gtk-font-name = cfg.fontName; } + // + optionalAttrs (cfg.themeName != null) + { gtk-theme-name = cfg.themeName; } + // + optionalAttrs (cfg.iconThemeName != null) + { gtk-icon-theme-name = cfg.iconThemeName; }; + in + { + home.file.".gtkrc-2.0".text = + concatStringsSep "\n" ( + mapAttrsToList formatGtk2Option ini + ) + "\n" + cfg2.extraConfig; + + home.file.".config/gtk-3.0/settings.ini".text = + toGtk3Ini { Settings = ini // cfg3.extraConfig; }; + + home.file.".config/gtk-3.0/gtk.css".text = cfg3.extraCss; + } + ); +} -- cgit v1.2.3 From 5221dee9ce989dfa6f606d79eee282aeaaaeb2f7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 17 Jan 2017 01:13:31 +0100 Subject: home-environment: use Bash to set variables Until a few more standard variables are available to PAM it is a bit risky to default to it. --- modules/home-environment.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 3623bc20380..4df0c4711db 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -156,9 +156,9 @@ in }; home.sessionVariableSetter = mkOption { - default = "pam"; + default = "bash"; type = types.enum [ "pam" "bash" ]; - example = "bash"; + example = "pam"; description = '' Identifies the module that should set the session variables. @@ -166,7 +166,8 @@ in must also be enabled. If "pam" is set then PAM must be used to set the system - environment. + environment. Also mind that typical environment variables + might not be set by the time PAM starts up. ''; }; -- cgit v1.2.3 From d7a70c87cdafe95f2c3ff4c5c69c43db25e41b8e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 17 Jan 2017 18:16:45 +0100 Subject: gtk: fix bug in condition --- modules/misc/gtk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 258dd4ade81..ab58ead6b38 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -104,7 +104,7 @@ in }; }; - config = mkIf (cfg.enable != null) ( + config = mkIf cfg.enable ( let ini = optionalAttrs (cfg.fontName != null) -- cgit v1.2.3 From 86217419e7085b501916db127b643136a7c915d6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 17 Jan 2017 22:12:51 +0100 Subject: home-environment: handle no home files If no files should be installed into the home directory then an error would occur since the directory holding the files would never be created. With this change the directory is unconditionally created. --- modules/home-environment.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 4df0c4711db..7e3775cd326 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -319,6 +319,7 @@ in phases = [ "installPhase" ]; installPhase = + "mkdir -pv $out\n" + concatStringsSep "\n" ( mapAttrsToList (name: value: "install -v -D -m${value.mode} ${value.source} $out/${value.target}" -- cgit v1.2.3 From 550d0e81c96103ba90c6ea477270c5e2c7e9b711 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 18 Jan 2017 09:25:19 +0100 Subject: systemd: handle missing service directories Before it suggested to restart a service `*.service`, which is quite silly. --- modules/systemd.nix | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index de3492308a9..c703ccb08b0 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -71,16 +71,42 @@ in home.activation.reloadSystemD = '' function systemdPostReload() { - local servicesDiffFile="$(mktemp)" + local workDir + workDir="$(mktemp -d)" + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" local newUserServicePath="$newGenPath/home-files/.config/systemd/user" + local oldServiceFiles="$workDir/old-files" + local newServiceFiles="$workDir/new-files" + local servicesDiffFile="$workDir/diff-files" + + if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then + return + fi + + if [[ ! -d "$oldUserServicePath" ]]; then + touch "$oldServiceFiles" + else + find "$oldUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$oldServiceFiles" + fi + + if [[ ! -d "$newUserServicePath" ]]; then + touch "$newServiceFiles" + else + find "$newUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$newServiceFiles" + fi diff \ --new-line-format='+%L' \ --old-line-format='-%L' \ --unchanged-line-format=' %L' \ - <(basename -a $(echo "$oldUserServicePath/"*.service) | sort) \ - <(basename -a $(echo "$newUserServicePath/"*.service) | sort) \ + "$oldServiceFiles" "$newServiceFiles" \ > $servicesDiffFile local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) @@ -98,7 +124,7 @@ in fi done - rm $servicesDiffFile + rm -r $workDir local sugg="" -- cgit v1.2.3 From 35e0a339f8c14aed2c3e7230850b026befc02dc9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 20 Jan 2017 00:20:25 +0100 Subject: dunst: support dbus activation --- modules/services/dunst.nix | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 4d866cec345..a70e8d31104 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -16,20 +16,21 @@ with lib; }; config = mkIf config.services.dunst.enable { - systemd.user.services.dunst = { - Unit = { - Description = "Dunst notification daemon"; - }; + home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = + "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + systemd.user.services.dunst = { + Unit = { + Description = "Dunst notification daemon"; + Requires = "graphical-session.target"; + After = "graphical-session.target"; + }; - Service = { - # Type = "dbus"; - # BusName = "org.freedesktop.Notifications"; - ExecStart = "${pkgs.dunst}/bin/dunst"; - }; + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.dunst}/bin/dunst"; + }; }; }; } -- cgit v1.2.3 From 64d6a66324618c98643968c1457b2e87d5d8a7b0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 20 Jan 2017 19:26:52 +0100 Subject: redshift: add module This module is adapted from the Nixpkgs version. --- modules/default.nix | 1 + modules/services/redshift.nix | 124 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 modules/services/redshift.nix diff --git a/modules/default.nix b/modules/default.nix index a95870b50e4..93ce01ad852 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -25,6 +25,7 @@ let ./services/keepassx.nix ./services/network-manager-applet.nix ./services/random-background.nix + ./services/redshift.nix ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix new file mode 100644 index 00000000000..f8978613464 --- /dev/null +++ b/modules/services/redshift.nix @@ -0,0 +1,124 @@ +# Adapted from Nixpkgs. + +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.redshift; + +in { + + options.services.redshift = { + enable = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Enable Redshift to change your screen's colour temperature depending on + the time of day. + ''; + }; + + latitude = mkOption { + type = types.str; + description = '' + Your current latitude, between + -90.0 and 90.0. + ''; + }; + + longitude = mkOption { + type = types.str; + description = '' + Your current longitude, between + between -180.0 and 180.0. + ''; + }; + + temperature = { + day = mkOption { + type = types.int; + default = 5500; + description = '' + Colour temperature to use during the day, between + 1000 and 25000 K. + ''; + }; + night = mkOption { + type = types.int; + default = 3700; + description = '' + Colour temperature to use at night, between + 1000 and 25000 K. + ''; + }; + }; + + brightness = { + day = mkOption { + type = types.str; + default = "1"; + description = '' + Screen brightness to apply during the day, + between 0.1 and 1.0. + ''; + }; + night = mkOption { + type = types.str; + default = "1"; + description = '' + Screen brightness to apply during the night, + between 0.1 and 1.0. + ''; + }; + }; + + package = mkOption { + type = types.package; + default = pkgs.redshift; + defaultText = "pkgs.redshift"; + description = '' + redshift derivation to use. + ''; + }; + + extraOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "-v" "-m randr" ]; + description = '' + Additional command-line arguments to pass to + redshift. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.redshift = { + Unit = { + Description = "Redshift colour temperature adjuster"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = + let + args = [ + "-l ${cfg.latitude}:${cfg.longitude}" + "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" + "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" + ] ++ cfg.extraOptions; + in + "${cfg.package}/bin/redshift ${concatStringsSep " " args}"; + RestartSec = 3; + Restart = "always"; + }; + }; + }; + +} -- cgit v1.2.3 From deaa6d3dd4f5ed51303e7f1ab00c77295442299a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Jan 2017 12:27:50 +0100 Subject: Add configurable verbosity during activation --- home-manager/home-manager | 6 +++++- modules/activation-init.sh | 30 +++++++++++++++++++----------- modules/home-environment.nix | 13 +++++++------ modules/systemd.nix | 1 - 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 41089f872c0..39c5e1e27bb 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -76,6 +76,7 @@ function doHelp() { echo "Options" echo echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix" + echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" echo " -h Print this help" echo @@ -89,11 +90,14 @@ function doHelp() { CONFIG_FILE="$HOME/.nixpkgs/home.nix" -while getopts f:nh opt; do +while getopts f:vnh opt; do case $opt in f) CONFIG_FILE=$OPTARG ;; + v) + export VERBOSE=1 + ;; n) export DRY_RUN=1 ;; diff --git a/modules/activation-init.sh b/modules/activation-init.sh index 91ad791076d..51c35968699 100755 --- a/modules/activation-init.sh +++ b/modules/activation-init.sh @@ -29,18 +29,26 @@ setupVars echo "Starting home manager activation" +if [[ $VERBOSE ]]; then + export VERBOSE_ECHO=echo + export VERBOSE_ARG="--verbose" +else + export VERBOSE_ECHO=true + unset VERBOSE_ARG +fi + if [[ $DRY_RUN ]] ; then - echo "This is a dry run" - export DRY_RUN_CMD=echo + $VERBOSE_ECHO "This is a dry run" + export DRY_RUN_CMD=echo else - echo "This is a live run" - unset DRY_RUN_CMD + $VERBOSE_ECHO "This is a live run" + unset DRY_RUN_CMD fi -echo "Activation variables:" -echo " oldGenNum=$oldGenNum" -echo " newGenNum=$newGenNum" -echo " oldGenPath=$oldGenPath" -echo " newGenPath=$newGenPath" -echo " newGenProfilePath=$newGenProfilePath" -echo " newGenGcPath=$newGenGcPath" +$VERBOSE_ECHO "Activation variables:" +$VERBOSE_ECHO " oldGenNum=$oldGenNum" +$VERBOSE_ECHO " newGenNum=$newGenNum" +$VERBOSE_ECHO " oldGenPath=$oldGenPath" +$VERBOSE_ECHO " newGenPath=$newGenPath" +$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath" +$VERBOSE_ECHO " newGenGcPath=$newGenGcPath" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 7e3775cd326..07e9a1dfc89 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -228,8 +228,8 @@ in for sourcePath in "$@" ; do relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")" targetPath="$HOME/$relativePath" - $DRY_RUN_CMD mkdir -vp "$(dirname "$targetPath")" - $DRY_RUN_CMD ln -vsf "$sourcePath" "$targetPath" + $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" + $DRY_RUN_CMD ln -sf $VERBOSE_ARG "$sourcePath" "$targetPath" done ''; @@ -245,8 +245,9 @@ in echo " exists" else echo " gone (deleting)" - $DRY_RUN_CMD rm -v "$targetPath" - $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty -v -p "$(dirname "$targetPath")" + $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" + $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \ + $VERBOSE_ARG -p "$(dirname "$targetPath")" fi done ''; @@ -274,8 +275,8 @@ in } if [[ "$oldGenPath" != "$newGenPath" ]] ; then - $DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenProfilePath" - $DRY_RUN_CMD ln -Tsfv "$newGenPath" "$newGenGcPath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" linkNewGen cleanOldGen else diff --git a/modules/systemd.nix b/modules/systemd.nix index c703ccb08b0..57c819e01fd 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -119,7 +119,6 @@ in && ! cmp --quiet \ "$oldUserServicePath/$f" \ "$newUserServicePath/$f" ; then - echo "Adding '$f' to restart list"; toRestart+=("$f") fi done -- cgit v1.2.3 From 10031e16bfd2fe6eb622fbf6aa683006b55542aa Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Jan 2017 12:28:27 +0100 Subject: gnome-terminal: rename activation command --- modules/programs/gnome-terminal.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index 6d483b90da0..ca5513cd73a 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -177,7 +177,7 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.gnome3.gnome_terminal ]; - home.activation.gnome-terminal = + home.activation.gnomeTerminal = let sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); dconfPath = "/org/gnome/terminal/legacy/"; -- cgit v1.2.3 From 11ef3873cd47ce0781a41af2f23c5f6c1e9880d9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 28 Jan 2017 18:29:27 +0100 Subject: xsession: always source `~/.profile` It seems to be pretty standard to do this so always do it, not just when Bash is the session variable setter. --- modules/xsession.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index f498d51786a..f18d7e8b7b5 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -72,12 +72,9 @@ in home.file.".xsession" = { mode = "555"; text = '' - ${ - # If we want bash to set the session variables then we need - # to pull in .profile since that's where they are. - optionalString (config.home.sessionVariableSetter == "bash") - ". \"$HOME/.profile\"" - } + if [[ -e "$HOME/.profile" ]]; then + . "$HOME/.profile" + fi systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY -- cgit v1.2.3 From d8a9182187d725efc4f8cc6bd1da5d7958b62e6a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 4 Feb 2017 19:56:44 +0100 Subject: Fix configuration example in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f86fb90f3ba..dc5d60e27e3 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ enables the user gpg-agent service. First create a file `~/.nixpkgs/home.nix` containing ```nix -{ pkgs }: +{ pkgs, ... }: { home.packages = [ -- cgit v1.2.3 From 34d472886d0d91af3440f97ece54f17cc5da14e1 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 5 Feb 2017 11:51:33 +0100 Subject: home-environment: do not `nix-env -i` on dry run --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 07e9a1dfc89..5a4fb4cfc60 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -286,7 +286,7 @@ in home.activation.installPackages = '' - nix-env -i ${cfg.path} + $DRY_RUN_CMD nix-env -i ${cfg.path} ''; home.activationPackage = -- cgit v1.2.3 From 119c7b25382eae7321db13a4aded56e50f86e363 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 5 Feb 2017 12:01:49 +0100 Subject: gnome-terminal: load configuration at right time If the dconf service hasn't been installed then the configuration activation will fail. Thus, make sure the activation script is run after packages have been installed. --- modules/programs/gnome-terminal.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index ca5513cd73a..bbeab158ef5 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -182,7 +182,8 @@ in sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); dconfPath = "/org/gnome/terminal/legacy/"; in - '' + # The dconf service needs to be installed and prepared. + stringAfter [ "installPackages" ] '' if [[ $DRY_RUN ]]; then echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${sf} else -- cgit v1.2.3 From 6794efdf68941a114b79d11d92e43c34b756cc60 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 5 Feb 2017 23:00:04 +0100 Subject: home-environment: add link for current profile This link is needed to make the `delete-older-than` option for `nix-collect-garbage` work as expected. --- modules/activation-init.sh | 2 ++ modules/home-environment.nix | 1 + 2 files changed, 3 insertions(+) diff --git a/modules/activation-init.sh b/modules/activation-init.sh index 51c35968699..d92dccb8cd7 100755 --- a/modules/activation-init.sh +++ b/modules/activation-init.sh @@ -20,6 +20,7 @@ function setupVars() { oldGenPath="$(readlink -e "$gcPath/current-home")" fi + genProfilePath="$profilesPath/home-manager" newGenPath="@GENERATION_DIR@"; newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" newGenGcPath="$gcPath/current-home" @@ -52,3 +53,4 @@ $VERBOSE_ECHO " oldGenPath=$oldGenPath" $VERBOSE_ECHO " newGenPath=$newGenPath" $VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath" $VERBOSE_ECHO " newGenGcPath=$newGenGcPath" +$VERBOSE_ECHO " genProfilePath=$genProfilePath" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 5a4fb4cfc60..e3d9f23bf97 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -276,6 +276,7 @@ in if [[ "$oldGenPath" != "$newGenPath" ]] ; then $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" linkNewGen cleanOldGen -- cgit v1.2.3 From ebe01057f8832bc60c74487508ca87b8c1653918 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 9 Feb 2017 22:32:09 +0100 Subject: home-environment: reduce verbosity --- modules/home-environment.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index e3d9f23bf97..4a770a59a98 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -240,11 +240,10 @@ in for sourcePath in "$@" ; do relativePath="$(realpath --relative-to "$oldGenFiles" "$sourcePath")" targetPath="$HOME/$relativePath" - echo -n "Checking $targetPath" if [[ -f "$newGenFiles/$relativePath" ]] ; then - echo " exists" + $VERBOSE_ECHO "Checking $targetPath exists" else - echo " gone (deleting)" + echo "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \ $VERBOSE_ARG -p "$(dirname "$targetPath")" @@ -321,10 +320,10 @@ in phases = [ "installPhase" ]; installPhase = - "mkdir -pv $out\n" + + "mkdir -p $out\n" + concatStringsSep "\n" ( mapAttrsToList (name: value: - "install -v -D -m${value.mode} ${value.source} $out/${value.target}" + "install -D -m${value.mode} ${value.source} $out/${value.target}" ) cfg.file ); }; @@ -335,12 +334,12 @@ in phases = [ "installPhase" ]; installPhase = '' - install -v -D -m755 ${sf} $out/activate + install -D -m755 ${sf} $out/activate substituteInPlace $out/activate \ --subst-var-by GENERATION_DIR $out - ln -vs ${home-files} $out/home-files + ln -s ${home-files} $out/home-files ''; }; -- cgit v1.2.3 From 386d2dbd25b522410f1e4d2d6f301b2b6be1a3ca Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Sat, 11 Feb 2017 16:20:02 +0100 Subject: git: fix evaluation error on null `extraConfig` --- modules/programs/git.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 672bd7997ef..de5d9cd89e7 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -71,7 +71,7 @@ in extraConfig = mkOption { type = types.lines; - default = null; + default = ""; description = "Additional configuration to add."; }; }; -- cgit v1.2.3 From 5d49ea6d49ceed590f6c98d840d2b77284a1aca5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Feb 2017 10:02:06 +0100 Subject: git: remove default signing key It is mandatory for a user to set the signing key so it does not make sense to set a default. --- modules/programs/git.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index de5d9cd89e7..fae933d7ea6 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -13,7 +13,6 @@ let options = { key = mkOption { type = types.str; - default = null; description = "The default GPG signing key fingerprint."; }; -- cgit v1.2.3 From fa73a7f916025cfefa23ab2392d3d504b2bc467f Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Sun, 12 Feb 2017 01:18:37 +0100 Subject: home-environment: fix evaluation error on undefined `lang.base` --- modules/home-environment.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 4a770a59a98..70889eb5225 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -9,7 +9,8 @@ let languageSubModule = types.submodule { options = { base = mkOption { - type = types.str; + default = null; + type = types.nullOr types.str; description = '' The language to use unless overridden by a more specific option. ''; -- cgit v1.2.3 From ed9464258ae1d6675cd0a5ed9c0fdedadd668804 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 14 Feb 2017 18:25:30 +0100 Subject: home-manager: add command line option `-I` This options is passed on to nix-build and allows, for example, building a user environment using a custom Nixpkgs. --- home-manager/home-manager | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 39c5e1e27bb..52c4ecb417c 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -34,7 +34,13 @@ function doBuild() { exit 1 fi - nix-build --show-trace \ + local extraArgs + + for p in "${EXTRA_NIX_PATH[@]}"; do + extraArgs="$extraArgs -I $p" + done + + nix-build --show-trace $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr modulesPath "@MODULES_PATH@" \ --argstr confPath "$confFile" \ @@ -76,6 +82,7 @@ function doHelp() { echo "Options" echo echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix" + echo " -I PATH Add a path to the Nix expression search path." echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" echo " -h Print this help" @@ -89,12 +96,16 @@ function doHelp() { } CONFIG_FILE="$HOME/.nixpkgs/home.nix" +EXTRA_NIX_PATH=() -while getopts f:vnh opt; do +while getopts f:I:vnh opt; do case $opt in f) CONFIG_FILE=$OPTARG ;; + I) + EXTRA_NIX_PATH+=("$OPTARG") + ;; v) export VERBOSE=1 ;; -- cgit v1.2.3 From beba60870505f8043d9fbe67f9c9dd0d0d031fba Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Feb 2017 21:39:53 +0100 Subject: Add support for assertions and warnings --- modules/default.nix | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 93ce01ad852..ebec6c96fb5 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,8 @@ , lib ? pkgs.stdenv.lib }: +with lib; + let modules = [ @@ -33,17 +35,38 @@ let ./systemd.nix ./xresources.nix ./xsession.nix + ]; + collectFailed = cfg: + map (x: x.message) (filter (x: !x.assertion) cfg.assertions); + + showWarnings = res: + let + f = w: x: builtins.trace "warning: ${w}" x; + in + fold f res res.config.warnings; + pkgsModule = { config._module.args.pkgs = lib.mkForce pkgs; config._module.args.baseModules = modules; }; - module = lib.evalModules { - modules = [ configuration ] ++ modules ++ [ pkgsModule ]; - }; + module = showWarnings ( + let + mod = lib.evalModules { + modules = [ configuration ] ++ modules ++ [ pkgsModule ]; + }; + + failed = collectFailed mod.config; + + failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed); + in + if failed == [] + then mod + else throw "\nFailed assertions:\n${failedStr}" + ); in -- cgit v1.2.3 From a3900340e4823fa317972b7380da9aefd5615e1f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Feb 2017 21:41:05 +0100 Subject: home-environment: check files for '.' prefix Nix does not allow files whose name start with a '.' in the Nix store. This commit makes a not of this fact in the `home.file.source` option and also adds an assertion verifying that no such file is given. Closes #4 --- modules/home-environment.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 70889eb5225..69a1a38ae34 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -114,7 +114,11 @@ in source = mkOption { type = types.path; - description = "Path of the source file."; + description = '' + Path of the source file. Note, the file name must not + start with a period since Nix will not allow such + names in the Nix store. + ''; }; mode = mkOption { @@ -206,6 +210,20 @@ in }; config = { + assertions = [ + (let + badFiles = + filter (hasPrefix ".") + (map (v: baseNameOf (toString v.source)) + (attrValues cfg.file)); + badFilesStr = toString badFiles; + in + { + assertion = badFiles == []; + message = "Source file names must not start with '.': ${badFilesStr}"; + }) + ]; + home.sessionVariables = let maybeSet = name: value: -- cgit v1.2.3 From d2e8c57bd5e371da6ddab21ff37b61248bb30d1a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Feb 2017 21:49:12 +0100 Subject: home-manager: Use --show-trace only when verbose --- home-manager/home-manager | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 52c4ecb417c..a027a9f026c 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -40,7 +40,11 @@ function doBuild() { extraArgs="$extraArgs -I $p" done - nix-build --show-trace $extraArgs \ + if [[ $VERBOSE ]]; then + extraArgs="$extraArgs --show-trace" + fi + + nix-build $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr modulesPath "@MODULES_PATH@" \ --argstr confPath "$confFile" \ -- cgit v1.2.3 From ee9bc66f691f45f9acec293198ba0255c3ef84b2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Feb 2017 21:55:07 +0100 Subject: home-environment: show full file path in error The file name alone may be misleading. --- modules/home-environment.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 69a1a38ae34..92305d144bd 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -213,8 +213,8 @@ in assertions = [ (let badFiles = - filter (hasPrefix ".") - (map (v: baseNameOf (toString v.source)) + filter (f: hasPrefix "." (baseNameOf f)) + (map (v: toString v.source) (attrValues cfg.file)); badFilesStr = toString badFiles; in -- cgit v1.2.3 From 207c3498251b3a85f537dadbb7d7d04ddae885cf Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 10 Mar 2017 23:56:43 +0100 Subject: home-environment: allow directory as home file Fixes issue #5. --- modules/home-environment.nix | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 92305d144bd..e492b8d5ece 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -115,9 +115,11 @@ in source = mkOption { type = types.path; description = '' - Path of the source file. Note, the file name must not - start with a period since Nix will not allow such - names in the Nix store. + Path of the source file. The file name must not start + with a period since Nix will not allow such names in + the Nix store. + + This may refer to a directory. ''; }; @@ -245,10 +247,10 @@ in newGenFiles="$1" shift for sourcePath in "$@" ; do - relativePath="$(realpath --relative-to "$newGenFiles" "$sourcePath")" + relativePath="''${sourcePath#$newGenFiles/}" targetPath="$HOME/$relativePath" $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" - $DRY_RUN_CMD ln -sf $VERBOSE_ARG "$sourcePath" "$targetPath" + $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" done ''; @@ -257,9 +259,9 @@ in oldGenFiles="$2" shift 2 for sourcePath in "$@" ; do - relativePath="$(realpath --relative-to "$oldGenFiles" "$sourcePath")" + relativePath="''${sourcePath#$oldGenFiles/}" targetPath="$HOME/$relativePath" - if [[ -f "$newGenFiles/$relativePath" ]] ; then + if [[ -e "$newGenFiles/$relativePath" ]] ; then $VERBOSE_ECHO "Checking $targetPath exists" else echo "Checking $targetPath gone (deleting)" @@ -274,7 +276,7 @@ in function linkNewGen() { local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 \ + find "$newGenFiles" -type f -print0 -or -type l -print0 \ | xargs -0 bash ${link} "$newGenFiles" } @@ -288,7 +290,7 @@ in local newGenFiles oldGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" oldGenFiles="$(readlink -e "$oldGenPath/home-files")" - find "$oldGenFiles" -type f -print0 \ + find "$oldGenFiles" -type f -print0 -or -type l -print0 \ | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" } @@ -341,8 +343,15 @@ in installPhase = "mkdir -p $out\n" + concatStringsSep "\n" ( - mapAttrsToList (name: value: - "install -D -m${value.mode} ${value.source} $out/${value.target}" + mapAttrsToList (n: v: + '' + if [ -d "${v.source}" ]; then + mkdir -pv "$(dirname "$out/${v.target}")" + ln -sv "${v.source}" "$out/${v.target}" + else + install -D -m${v.mode} "${v.source}" "$out/${v.target}" + fi + '' ) cfg.file ); }; -- cgit v1.2.3 From fea693ba16616890770d69b847744186f6a21930 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 25 Mar 2017 21:48:17 +0100 Subject: Use stricter Bash settings in activation script For example, with these settings Bash will complain if uninitialized variables are used. Some code has been improved to run cleanly with these settings. --- home-manager/home-manager | 2 +- modules/activation-init.sh | 8 ++++---- modules/home-environment.nix | 3 ++- modules/programs/gnome-terminal.nix | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index a027a9f026c..2344ff98652 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -40,7 +40,7 @@ function doBuild() { extraArgs="$extraArgs -I $p" done - if [[ $VERBOSE ]]; then + if [[ -v VERBOSE ]]; then extraArgs="$extraArgs --show-trace" fi diff --git a/modules/activation-init.sh b/modules/activation-init.sh index d92dccb8cd7..5ac5fdfe247 100755 --- a/modules/activation-init.sh +++ b/modules/activation-init.sh @@ -30,20 +30,20 @@ setupVars echo "Starting home manager activation" -if [[ $VERBOSE ]]; then +if [[ -v VERBOSE ]]; then export VERBOSE_ECHO=echo export VERBOSE_ARG="--verbose" else export VERBOSE_ECHO=true - unset VERBOSE_ARG + export VERBOSE_ARG="" fi -if [[ $DRY_RUN ]] ; then +if [[ -v DRY_RUN ]] ; then $VERBOSE_ECHO "This is a dry run" export DRY_RUN_CMD=echo else $VERBOSE_ECHO "This is a live run" - unset DRY_RUN_CMD + export DRY_RUN_CMD="" fi $VERBOSE_ECHO "Activation variables:" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index e492b8d5ece..cef70541a1a 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -328,7 +328,8 @@ in sf = pkgs.writeText "activation-script" '' #!${pkgs.stdenv.shell} - set -e + set -eu + set -o pipefail ${builtins.readFile ./activation-init.sh} diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index bbeab158ef5..ccb6a57bfff 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -184,7 +184,7 @@ in in # The dconf service needs to be installed and prepared. stringAfter [ "installPackages" ] '' - if [[ $DRY_RUN ]]; then + if [[ -v DRY_RUN ]]; then echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${sf} else ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} -- cgit v1.2.3 From 4f1eec818029df209ef275752cff36d6dfbb1c16 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 29 Mar 2017 00:10:30 +0200 Subject: Avoid undefined variables in activation script --- modules/activation-init.sh | 11 ++++++++--- modules/home-environment.nix | 4 ++-- modules/systemd.nix | 10 +++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/activation-init.sh b/modules/activation-init.sh index 5ac5fdfe247..a7011b9c247 100755 --- a/modules/activation-init.sh +++ b/modules/activation-init.sh @@ -47,10 +47,15 @@ else fi $VERBOSE_ECHO "Activation variables:" -$VERBOSE_ECHO " oldGenNum=$oldGenNum" -$VERBOSE_ECHO " newGenNum=$newGenNum" -$VERBOSE_ECHO " oldGenPath=$oldGenPath" +if [[ -v oldGenNum ]] ; then + $VERBOSE_ECHO " oldGenNum=$oldGenNum" + $VERBOSE_ECHO " oldGenPath=$oldGenPath" +else + $VERBOSE_ECHO " oldGenNum undefined (first run?)" + $VERBOSE_ECHO " oldGenPath undefined (first run?)" +fi $VERBOSE_ECHO " newGenPath=$newGenPath" +$VERBOSE_ECHO " newGenNum=$newGenNum" $VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath" $VERBOSE_ECHO " newGenGcPath=$newGenGcPath" $VERBOSE_ECHO " genProfilePath=$genProfilePath" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index cef70541a1a..8c3c462e987 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -281,7 +281,7 @@ in } function cleanOldGen() { - if [[ -z "$oldGenPath" ]] ; then + if [[ ! -v oldGenPath ]] ; then return fi @@ -294,7 +294,7 @@ in | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" } - if [[ "$oldGenPath" != "$newGenPath" ]] ; then + if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" diff --git a/modules/systemd.nix b/modules/systemd.nix index 57c819e01fd..293b32df1aa 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -74,17 +74,21 @@ in local workDir workDir="$(mktemp -d)" - local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" + if [[ -v oldGenPath ]] ; then + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" + fi + local newUserServicePath="$newGenPath/home-files/.config/systemd/user" local oldServiceFiles="$workDir/old-files" local newServiceFiles="$workDir/new-files" local servicesDiffFile="$workDir/diff-files" - if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ + && ! -d "$newUserServicePath" ]]; then return fi - if [[ ! -d "$oldUserServicePath" ]]; then + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then touch "$oldServiceFiles" else find "$oldUserServicePath" \ -- cgit v1.2.3 From 62a9a8fa3ced9debdaa8c760b3df6bd513c75fa7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 1 Apr 2017 23:05:36 +0200 Subject: Update README for 17.03 --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dc5d60e27e3..b5ed92b35f1 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,14 @@ So, if you already have a wonderful, painstakingly created `~/.gitconfig` it will be gone. Home Manager will _not_ attempt to backup the previous `~/.gitconfig` file. -Further, Home Manager has only ever been used on [NixOS][] version -16.09 (the stable version), it may or may not work on other Linux -distributions and NixOS versions. - -Finally, the `home-manager` tool does not support rollbacks at the -moment so if your home directory gets messed up you'll have to fix it -yourself. +Further, Home Manager targets [NixOS][] version 17.03 (the current +stable version), it may or may not work on other Linux distributions +and NixOS versions. + +Finally, the `home-manager` tool does not explicitly support rollbacks +at the moment so if your home directory gets messed up you'll have to +fix it yourself (you can attempt to run the activation script for the +desired generation). Now when your expectations have been built up and you are eager to try all this out you can go ahead and read the rest of this text. -- cgit v1.2.3 From 8fab2a5d9bb685bbf190565ea242afe670367bf4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 May 2017 00:36:39 +0200 Subject: Add basic directed acyclic graph data structure Also make use of this instead of Nixpkgs's strings-with-deps library in activation script generation. --- modules/home-environment.nix | 38 ++++++----- modules/lib/dag.nix | 124 ++++++++++++++++++++++++++++++++++++ modules/programs/gnome-terminal.nix | 10 +-- modules/systemd.nix | 3 +- 4 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 modules/lib/dag.nix diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 8c3c462e987..1e7a447305f 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: with lib; +with import ./lib/dag.nix; let @@ -241,7 +242,11 @@ in // (maybeSet "LC_TIME" cfg.language.time); - home.activation.linkGeneration = + # A dummy entry acting as a boundary between the activation + # script's "check" and the "write" phases. + home.activation.writeBoundary = dagEntryAnywhere ""; + + home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( let link = pkgs.writeText "link" '' newGenFiles="$1" @@ -303,27 +308,26 @@ in else echo "Same home files as previous generation ... doing nothing" fi - ''; + '' + ); - home.activation.installPackages = - '' - $DRY_RUN_CMD nix-env -i ${cfg.path} - ''; + home.activation.installPackages = dagEntryAfter ["writeBoundary"] '' + $DRY_RUN_CMD nix-env -i ${cfg.path} + ''; home.activationPackage = let - addHeader = n: v: - v // { - text = '' - echo Activating ${n} - ${v.text} - ''; - }; - toDepString = n: v: if isString v then noDepEntry v else v; - activationWithDeps = - mapAttrs addHeader (mapAttrs toDepString cfg.activation); + mkCmd = res: '' + echo Activating ${res.name} + ${res.data} + ''; + sortedCommands = dagTopoSort cfg.activation; activationCmds = - textClosureMap id activationWithDeps (attrNames activationWithDeps); + if sortedCommands ? result then + concatStringsSep "\n" (map mkCmd sortedCommands.result) + else + abort ("Dependency cycle in activation script: " + + builtins.toJSON sortedCommands); sf = pkgs.writeText "activation-script" '' #!${pkgs.stdenv.shell} diff --git a/modules/lib/dag.nix b/modules/lib/dag.nix new file mode 100644 index 00000000000..cb7e6f8988f --- /dev/null +++ b/modules/lib/dag.nix @@ -0,0 +1,124 @@ +# A generalization of Nixpkgs's `strings-with-deps.nix`. +# +# The main differences from the Nixpkgs version are +# +# - not specific to strings, i.e., any payload is OK, +# +# - the addition of the function `dagEntryBefore` indicating a +# "wanted by" relationship. + +with import ; +with import ; +with import ; + +rec { + + emptyDag = {}; + + isDag = dag: + let + isEntry = e: (e ? data) && (e ? after) && (e ? before); + in + builtins.isAttrs dag && all (x: x) (mapAttrsToList (n: isEntry) dag); + + # Takes an attribute set containing entries built by + # dagEntryAnywhere, dagEntryAfter, and dagEntryBefore to a + # topologically sorted list of entries. + # + # Internally this function uses the `toposort` function in + # `` and its value is accordingly. + # + # Specifically, the result on success is + # + # { result = [{name = ?; data = ?;} …] } + # + # For example + # + # nix-repl> dagTopoSort { + # a = dagEntryAnywhere "1"; + # b = dagEntryAfter ["a" "c"] "2"; + # c = dagEntryBefore ["d"] "3"; + # d = dagEntryBefore ["e"] "4"; + # e = dagEntryAnywhere "5"; + # } == { + # result = [ + # { data = "1"; name = "a"; } + # { data = "3"; name = "c"; } + # { data = "2"; name = "b"; } + # { data = "4"; name = "d"; } + # { data = "5"; name = "e"; } + # ]; + # } + # true + # + # And the result on error is + # + # { + # cycle = [ {after = ?; name = ?; data = ?} … ]; + # loops = [ {after = ?; name = ?; data = ?} … ]; + # } + # + # For example + # + # nix-repl> dagTopoSort { + # a = dagEntryAnywhere "1"; + # b = dagEntryAfter ["a" "c"] "2"; + # c = dagEntryAfter ["d"] "3"; + # d = dagEntryAfter ["b"] "4"; + # e = dagEntryAnywhere "5"; + # } == { + # cycle = [ + # { after = ["a" "c"]; data = "2"; name = "b"; } + # { after = ["d"]; data = "3"; name = "c"; } + # { after = ["b"]; data = "4"; name = "d"; } + # ]; + # loops = [ + # { after = ["a" "c"]; data = "2"; name = "b"; } + # ]; + # } == {} + # true + dagTopoSort = dag: + let + dagBefore = dag: name: + mapAttrsToList (n: v: n) ( + filterAttrs (n: v: any (a: a == name) v.before) dag + ); + normalizedDag = + mapAttrs (n: v: { + name = n; + data = v.data; + after = v.after ++ dagBefore dag n; + }) dag; + before = a: b: any (c: a.name == c) b.after; + sorted = toposort before (mapAttrsToList (n: v: v) normalizedDag); + in + if sorted ? result then + { result = map (v: { inherit (v) name data; }) sorted.result; } + else + sorted; + + # Applies a function to each element of the given DAG. + dagMap = f: dag: mapAttrs (n: v: v // { data = f n v.data; }) dag; + + # Create a DAG entry with no particular dependency information. + dagEntryAnywhere = data: { + inherit data; + before = []; + after = []; + }; + + dagEntryBetween = before: after: data: { + inherit data before after; + }; + + dagEntryAfter = after: data: { + inherit data after; + before = []; + }; + + dagEntryBefore = before: data: { + inherit data before; + after = []; + }; + +} diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index ccb6a57bfff..bbd2b392872 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: with lib; +with import ../lib/dag.nix; let @@ -177,18 +178,19 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.gnome3.gnome_terminal ]; - home.activation.gnomeTerminal = + # The dconf service needs to be installed and prepared. + home.activation.gnomeTerminal = dagEntryAfter ["installPackages"] ( let sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); dconfPath = "/org/gnome/terminal/legacy/"; in - # The dconf service needs to be installed and prepared. - stringAfter [ "installPackages" ] '' + '' if [[ -v DRY_RUN ]]; then echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${sf} else ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} fi - ''; + '' + ); }; } diff --git a/modules/systemd.nix b/modules/systemd.nix index 293b32df1aa..1e6117a12f4 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: with lib; +with import ./lib/dag.nix; let @@ -69,7 +70,7 @@ in (buildServices "timer" config.systemd.user.timers) ); - home.activation.reloadSystemD = '' + home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' function systemdPostReload() { local workDir workDir="$(mktemp -d)" -- cgit v1.2.3 From 7e58b6bb356165254f45f068649138c16d676c39 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 6 May 2017 00:35:36 +0200 Subject: home-environment: always link new and clean old generation Previously the home files were not linked if the generation hadn't changed. Unfortunately, this would mean that, if a file link was removed for some reason it would not be recreated by running a switch command. --- modules/home-environment.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 1e7a447305f..b270b1cc317 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -300,14 +300,16 @@ in } if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then + echo "Creating profile generation $newGenNum" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" - linkNewGen - cleanOldGen else - echo "Same home files as previous generation ... doing nothing" + echo "No change so reusing latest profile generation $oldGenNum" fi + + linkNewGen + cleanOldGen '' ); -- cgit v1.2.3 From 88ec7145ba065b331bfe85149d9cfcf40ac8e648 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 6 May 2017 00:44:00 +0200 Subject: home-environment: prevent overwriting existing files This should reduce the risk of overwriting an existing file in the user's home directory. A file will only be replaced if it is a link pointing to a home-manager tree inside the Nix store. If an existing file is detected an error is written indicating the file's path and the activation will terminate before any mutation occurs. Fixes #6 --- README.md | 71 +++++++++++++++++++++++++++++++------------- modules/home-environment.nix | 31 +++++++++++++++++++ 2 files changed, 81 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index b5ed92b35f1..0b946a98d2e 100644 --- a/README.md +++ b/README.md @@ -9,32 +9,23 @@ read the warning below. Words of warning ---------------- -This project is in early development! I personally use it to manage +This project is under development. I personally use it to manage several user configurations but it may fail catastrophically for you. So beware! -To configure programs and services the Home Manager must write various -things to your home directory and possibly overwrite files you have -previously created. For example, if you use Home Manager to install -and configure Git then your `~/.gitconfig` will be replaced by a link -to a configuration generated by Home Manager: - -``` -$ ls -gG ~/.gitconfig -lrwxrwxrwx 1 73 Jan 8 21:59 /home/rycee/.gitconfig -> /nix/store/pk7g12816avnxyhnkbdhqhnlzrw7fsga-home-manager-files/.gitconfig -``` - -So, if you already have a wonderful, painstakingly created -`~/.gitconfig` it will be gone. Home Manager will _not_ attempt to -backup the previous `~/.gitconfig` file. +In some cases Home Manager cannot detect whether it will overwrite a +previous manual configuration. For example, the Gnome Terminal module +will write to your dconf store and cannot tell whether a configuration +that it is about to be overwrite was from a previous Home Manager +generation or from manual configuration. -Further, Home Manager targets [NixOS][] version 17.03 (the current -stable version), it may or may not work on other Linux distributions -and NixOS versions. +Home Manager targets [NixOS][] version 17.03 (the current stable +version), it may or may not work on other Linux distributions and +NixOS versions. -Finally, the `home-manager` tool does not explicitly support rollbacks -at the moment so if your home directory gets messed up you'll have to -fix it yourself (you can attempt to run the activation script for the +Also, the `home-manager` tool does not explicitly support rollbacks at +the moment so if your home directory gets messed up you'll have to fix +it yourself (you can attempt to run the activation script for the desired generation). Now when your expectations have been built up and you are eager to try @@ -132,6 +123,44 @@ $ home-manager build which will create a `result` link to a directory containing an activation script and the generated home directory files. +File safety +----------- + +To configure programs and services the 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 +`~/.gitconfig` 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 + +``` +$ home-manager switch +… +Activating checkLinkTargets +Existing file '/home/jdoe/.gitconfig' is in the way +Please move the above files and try again +``` + [Nix]: https://nixos.org/nix/ [NixOS]: https://nixos.org/ [Nixpkgs]: https://nixos.org/nixpkgs/ diff --git a/modules/home-environment.nix b/modules/home-environment.nix index b270b1cc317..3b62b77f4e5 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -246,6 +246,37 @@ in # script's "check" and the "write" phases. home.activation.writeBoundary = dagEntryAnywhere ""; + # This verifies that the links we are about to create will not + # overwrite an existing file. + home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( + let + pattern = "-home-manager-files/"; + check = pkgs.writeText "check" '' + newGenFiles="$1" + shift + for sourcePath in "$@" ; do + relativePath="''${sourcePath#$newGenFiles/}" + targetPath="$HOME/$relativePath" + if [[ -e "$targetPath" \ + && ! "$(readlink -e "$targetPath")" =~ "${pattern}" ]] ; then + echo -e "Existing file '$targetPath' is in the way" + collision=1 + fi + done + + if [[ -v collision ]] ; then + echo -e "Please move the above files and try again" + exit 1 + fi + ''; + in + '' + newGenFiles="$(readlink -e "$newGenPath/home-files")" + find "$newGenFiles" -type f -print0 -or -type l -print0 \ + | xargs -0 bash ${check} "$newGenFiles" + '' + ); + home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( let link = pkgs.writeText "link" '' -- cgit v1.2.3 From 6e3085dc22ed23b61140be09c24963e5d3a146a0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 6 May 2017 12:50:32 +0200 Subject: Add note about using graphical services to README --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 0b946a98d2e..b339cde338b 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,40 @@ Existing file '/home/jdoe/.gitconfig' 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 = "…"; + + # … +} +``` + +in your Home Manager configuration. + [Nix]: https://nixos.org/nix/ [NixOS]: https://nixos.org/ [Nixpkgs]: https://nixos.org/nixpkgs/ -- cgit v1.2.3 From 3c69c7589a9d5a49c5ccd96926c0d761700887a3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 6 May 2017 12:51:08 +0200 Subject: xsession: make windowManager option required Also add a fairly complicated example. --- modules/xsession.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index f18d7e8b7b5..e0dff4552fe 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -14,8 +14,15 @@ in enable = mkEnableOption "X Session"; windowManager = mkOption { - default = {}; type = types.str; + example = literalExample '' + let + xmonad = pkgs.xmonad-with-packages.override { + packages = self: [ self.xmonad-contrib self.taffybar ]; + }; + in + "''${xmonad}/bin/xmonad"; + ''; description = "Path to window manager to exec."; }; -- cgit v1.2.3 From e8fb9f50cef8e79c120f257af62b457ebfc5574c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 10 May 2017 00:20:15 +0200 Subject: gnome-terminal: use `attrsOf` rather than `loaOf` Since the attribute names carry semantic meaning we should be more strict about the type. --- modules/programs/gnome-terminal.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index bbd2b392872..052962c77ee 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -169,7 +169,7 @@ in profile = mkOption { default = {}; - type = types.loaOf profileSubModule; + type = types.attrsOf profileSubModule; description = "A set of Gnome Terminal profiles."; }; }; -- cgit v1.2.3 From bce262e46e573c031feb968358ff31db77b00e71 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Mon, 8 May 2017 23:30:37 -0400 Subject: ssh: add programs.ssh module This module generates a `.ssh/config` file. This doesn't embed _all_ options for the ssh client, but the most common ones should be there. Example usage: ```nix programs.ssh = { enable = true; forwardAgent = true; controlMaster = "auto"; matchBlocks = [ { host = "something.blah.edu"; port = 1024; user = "cleague"; identitiesOnly = true; } { host = "host1 host2 host2.net host2.com"; port = 7422; hostname = "example.com"; serverAliveInterval = 60; } { host = "lucian"; forwardX11 = true; forwardX11Trusted = true; checkHostIP = false; }; }; }; ``` Each entry in `programs.ssh.matchBlocks` must contain a `host` field, which will be used for the block condition. --- modules/default.nix | 1 + modules/programs/ssh.nix | 158 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 modules/programs/ssh.nix diff --git a/modules/default.nix b/modules/default.nix index ebec6c96fb5..e1f6b652686 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -20,6 +20,7 @@ let ./programs/git.nix ./programs/gnome-terminal.nix ./programs/lesspipe.nix + ./programs/ssh.nix ./programs/texlive.nix ./services/dunst.nix ./services/gnome-keyring.nix diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix new file mode 100644 index 00000000000..9f06e8b531a --- /dev/null +++ b/modules/programs/ssh.nix @@ -0,0 +1,158 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.ssh; + + yn = flag: if flag then "yes" else "no"; + + matchBlockModule = types.submodule { + options = { + host = mkOption { + type = types.str; + example = "*.example.org"; + description = '' + The host pattern used by this conditional block. + ''; + }; + + port = mkOption { + type = types.nullOr types.int; + default = null; + description = "Specifies port number to connect on remote host."; + }; + + forwardX11 = mkOption { + type = types.bool; + default = false; + description = '' + Specifies whether X11 connections will be automatically redirected + over the secure channel and DISPLAY set. + ''; + }; + + forwardX11Trusted = mkOption { + type = types.bool; + default = false; + description = '' + Specifies whether remote X11 clients will have full access to the + original X11 display. + ''; + }; + + identitiesOnly = mkOption { + type = types.bool; + default = false; + description = '' + Specifies that ssh should only use the authentication + identity explicitly configured in the + ~/.ssh/config files or passed on the + ssh command-line, even if ssh-agent + offers more identities. + ''; + }; + + identityFile = mkOption { + type = types.nullOr types.string; + default = null; + description = '' + Specifies a file from which the user identity is read. + ''; + }; + + user = mkOption { + type = types.nullOr types.string; + default = null; + description = "Specifies the user to log in as."; + }; + + hostname = mkOption { + type = types.nullOr types.string; + default = null; + description = "Specifies the real host name to log into."; + }; + + serverAliveInterval = mkOption { + type = types.int; + default = 0; + description = + "Set timeout in seconds after which response will be requested."; + }; + + checkHostIP = mkOption { + type = types.bool; + default = true; + description = '' + Check the host IP address in the + known_hosts file. + ''; + }; + }; + }; + + matchBlockStr = cf: concatStringsSep "\n" ( + ["Host ${cf.host}"] + ++ optional (cf.port != null) " Port ${toString cf.port}" + ++ optional cf.forwardX11 " ForwardX11 yes" + ++ optional cf.forwardX11Trusted " ForwardX11Trusted yes" + ++ optional cf.identitiesOnly " IdentitiesOnly yes" + ++ optional (cf.user != null) " User ${cf.user}" + ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" + ++ optional (cf.hostname != null) " HostName ${cf.hostname}" + ++ optional (cf.serverAliveInterval != 0) + " ServerAliveInterval ${toString cf.serverAliveInterval}" + ++ optional (!cf.checkHostIP) " CheckHostIP no" + ); + +in + +{ + options.programs.ssh = { + enable = mkEnableOption "SSH client configuration"; + + forwardAgent = mkOption { + default = false; + type = types.bool; + description = '' + Whether connection to authentication agent (if any) will be forwarded + to remote machine. + ''; + }; + + controlMaster = mkOption { + default = "no"; + type = types.enum ["yes" "no" "ask" "auto" "autoask"]; + description = '' + Configure sharing of multiple sessions over a single network connection. + ''; + }; + + controlPath = mkOption { + type = types.string; + default = "~/.ssh/master-%r@%h:%p"; + description = '' + Specify path to the control socket used for connection sharing. + ''; + }; + + matchBlocks = mkOption { + type = types.listOf matchBlockModule; + default = []; + description = '' + Specify per-host settings. + ''; + }; + }; + + config = mkIf cfg.enable { + home.file.".ssh/config".text = '' + ForwardAgent ${yn cfg.forwardAgent} + ControlMaster ${cfg.controlMaster} + ControlPath ${cfg.controlPath} + + ${concatStringsSep "\n\n" (map matchBlockStr cfg.matchBlocks)} + ''; + }; +} -- cgit v1.2.3 From 961722c3a89f821caf9af7d340ca2dc8ab4c1a88 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 13 May 2017 12:08:09 +0200 Subject: ssh: add proxy command option --- modules/programs/ssh.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 9f06e8b531a..435ee5e3f20 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -89,6 +89,12 @@ let known_hosts file. ''; }; + + proxyCommand = mkOption { + type = types.nullOr types.str; + default = null; + description = "The command to use to connect to the server."; + }; }; }; @@ -104,6 +110,7 @@ let ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" ++ optional (!cf.checkHostIP) " CheckHostIP no" + ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ); in -- cgit v1.2.3 From ecf7d91d8bfcaeb44ba69d05ee0bff8a96ec2eee Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 13 May 2017 12:23:59 +0200 Subject: ssh: use `types.str` instead of `types.string` The `types.string` type is deprecated due to its surprising behavior. --- modules/programs/ssh.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 435ee5e3f20..4bf02193dc3 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -55,7 +55,7 @@ let }; identityFile = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; description = '' Specifies a file from which the user identity is read. @@ -63,13 +63,13 @@ let }; user = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; description = "Specifies the user to log in as."; }; hostname = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; description = "Specifies the real host name to log into."; }; @@ -137,7 +137,7 @@ in }; controlPath = mkOption { - type = types.string; + type = types.str; default = "~/.ssh/master-%r@%h:%p"; description = '' Specify path to the control socket used for connection sharing. -- cgit v1.2.3 From a9da4575f580778e44781bedaf5a33bd6f972219 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 May 2017 14:01:10 +0200 Subject: home-environment: run file collision check in function --- modules/home-environment.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 3b62b77f4e5..e58f9324198 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -271,9 +271,14 @@ in ''; in '' - newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${check} "$newGenFiles" + function checkNewGenCollision() { + local newGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + find "$newGenFiles" -type f -print0 -or -type l -print0 \ + | xargs -0 bash ${check} "$newGenFiles" + } + + checkNewGenCollision || exit 1 '' ); -- cgit v1.2.3 From 870d1d484d1075e8bdfcab97a815f2f997d299bd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 May 2017 14:02:15 +0200 Subject: home-manager: use strict Bash evaluation In particular, this will ensure that the whole script fails with an error code if the activation script fails during a switch. Fixes #10. --- home-manager/home-manager | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 2344ff98652..e0beb761c9a 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -1,5 +1,7 @@ #!@bash@/bin/bash +set -euo pipefail + function doBuild() { if [[ -z "$1" ]]; then echo "Need to provide path to configuration file." @@ -35,6 +37,7 @@ function doBuild() { fi local extraArgs + extraArgs="" for p in "${EXTRA_NIX_PATH[@]}"; do extraArgs="$extraArgs -I $p" -- cgit v1.2.3 From 3ee505179fd3bc6bbacd012030a3a8706f615cab Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 May 2017 16:17:38 +0200 Subject: home-environment: colorize activation output slightly --- modules/activation-init.sh | 61 ------------------------------------- modules/home-environment.nix | 12 +++++--- modules/lib-bash/activation-init.sh | 61 +++++++++++++++++++++++++++++++++++++ modules/lib-bash/color-echo.sh | 34 +++++++++++++++++++++ 4 files changed, 103 insertions(+), 65 deletions(-) delete mode 100755 modules/activation-init.sh create mode 100755 modules/lib-bash/activation-init.sh create mode 100644 modules/lib-bash/color-echo.sh diff --git a/modules/activation-init.sh b/modules/activation-init.sh deleted file mode 100755 index a7011b9c247..00000000000 --- a/modules/activation-init.sh +++ /dev/null @@ -1,61 +0,0 @@ -function setupVars() { - local profilesPath="/nix/var/nix/profiles/per-user/$USER" - local gcPath="/nix/var/nix/gcroots/per-user/$USER" - local greatestGenNum - - greatestGenNum=$( \ - find "$profilesPath" -name 'home-manager-*-link' \ - | sed 's/^.*-\([0-9]*\)-link$/\1/' \ - | sort -rn \ - | head -1) - - if [[ -n "$greatestGenNum" ]] ; then - oldGenNum=$greatestGenNum - newGenNum=$((oldGenNum + 1)) - else - newGenNum=1 - fi - - if [[ -e "$gcPath/current-home" ]] ; then - oldGenPath="$(readlink -e "$gcPath/current-home")" - fi - - genProfilePath="$profilesPath/home-manager" - newGenPath="@GENERATION_DIR@"; - newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" - newGenGcPath="$gcPath/current-home" -} - -setupVars - -echo "Starting home manager activation" - -if [[ -v VERBOSE ]]; then - export VERBOSE_ECHO=echo - export VERBOSE_ARG="--verbose" -else - export VERBOSE_ECHO=true - export VERBOSE_ARG="" -fi - -if [[ -v DRY_RUN ]] ; then - $VERBOSE_ECHO "This is a dry run" - export DRY_RUN_CMD=echo -else - $VERBOSE_ECHO "This is a live run" - export DRY_RUN_CMD="" -fi - -$VERBOSE_ECHO "Activation variables:" -if [[ -v oldGenNum ]] ; then - $VERBOSE_ECHO " oldGenNum=$oldGenNum" - $VERBOSE_ECHO " oldGenPath=$oldGenPath" -else - $VERBOSE_ECHO " oldGenNum undefined (first run?)" - $VERBOSE_ECHO " oldGenPath undefined (first run?)" -fi -$VERBOSE_ECHO " newGenPath=$newGenPath" -$VERBOSE_ECHO " newGenNum=$newGenNum" -$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath" -$VERBOSE_ECHO " newGenGcPath=$newGenGcPath" -$VERBOSE_ECHO " genProfilePath=$genProfilePath" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index e58f9324198..694a2aa02c8 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -252,6 +252,8 @@ in let pattern = "-home-manager-files/"; check = pkgs.writeText "check" '' + . ${./lib-bash/color-echo.sh} + newGenFiles="$1" shift for sourcePath in "$@" ; do @@ -259,13 +261,13 @@ in targetPath="$HOME/$relativePath" if [[ -e "$targetPath" \ && ! "$(readlink -e "$targetPath")" =~ "${pattern}" ]] ; then - echo -e "Existing file '$targetPath' is in the way" + errorEcho "Existing file '$targetPath' is in the way" collision=1 fi done if [[ -v collision ]] ; then - echo -e "Please move the above files and try again" + errorEcho "Please move the above files and try again" exit 1 fi ''; @@ -356,7 +358,7 @@ in home.activationPackage = let mkCmd = res: '' - echo Activating ${res.name} + noteEcho Activating ${res.name} ${res.data} ''; sortedCommands = dagTopoSort cfg.activation; @@ -373,7 +375,9 @@ in set -eu set -o pipefail - ${builtins.readFile ./activation-init.sh} + . ${./lib-bash/color-echo.sh} + + ${builtins.readFile ./lib-bash/activation-init.sh} ${activationCmds} ''; diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh new file mode 100755 index 00000000000..a7011b9c247 --- /dev/null +++ b/modules/lib-bash/activation-init.sh @@ -0,0 +1,61 @@ +function setupVars() { + local profilesPath="/nix/var/nix/profiles/per-user/$USER" + local gcPath="/nix/var/nix/gcroots/per-user/$USER" + local greatestGenNum + + greatestGenNum=$( \ + find "$profilesPath" -name 'home-manager-*-link' \ + | sed 's/^.*-\([0-9]*\)-link$/\1/' \ + | sort -rn \ + | head -1) + + if [[ -n "$greatestGenNum" ]] ; then + oldGenNum=$greatestGenNum + newGenNum=$((oldGenNum + 1)) + else + newGenNum=1 + fi + + if [[ -e "$gcPath/current-home" ]] ; then + oldGenPath="$(readlink -e "$gcPath/current-home")" + fi + + genProfilePath="$profilesPath/home-manager" + newGenPath="@GENERATION_DIR@"; + newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" + newGenGcPath="$gcPath/current-home" +} + +setupVars + +echo "Starting home manager activation" + +if [[ -v VERBOSE ]]; then + export VERBOSE_ECHO=echo + export VERBOSE_ARG="--verbose" +else + export VERBOSE_ECHO=true + export VERBOSE_ARG="" +fi + +if [[ -v DRY_RUN ]] ; then + $VERBOSE_ECHO "This is a dry run" + export DRY_RUN_CMD=echo +else + $VERBOSE_ECHO "This is a live run" + export DRY_RUN_CMD="" +fi + +$VERBOSE_ECHO "Activation variables:" +if [[ -v oldGenNum ]] ; then + $VERBOSE_ECHO " oldGenNum=$oldGenNum" + $VERBOSE_ECHO " oldGenPath=$oldGenPath" +else + $VERBOSE_ECHO " oldGenNum undefined (first run?)" + $VERBOSE_ECHO " oldGenPath undefined (first run?)" +fi +$VERBOSE_ECHO " newGenPath=$newGenPath" +$VERBOSE_ECHO " newGenNum=$newGenNum" +$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath" +$VERBOSE_ECHO " newGenGcPath=$newGenGcPath" +$VERBOSE_ECHO " genProfilePath=$genProfilePath" diff --git a/modules/lib-bash/color-echo.sh b/modules/lib-bash/color-echo.sh new file mode 100644 index 00000000000..e357bf70ce4 --- /dev/null +++ b/modules/lib-bash/color-echo.sh @@ -0,0 +1,34 @@ +function setupColors() { + normalColor="" + errorColor="" + warnColor="" + noteColor="" + + # Check if stdout is a terminal. + if [[ -t 1 ]]; then + # See if it supports colors. + local ncolors + ncolors=$(tput colors) + + if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then + normalColor="$(tput sgr0)" + errorColor="$(tput bold)$(tput setaf 1)" + warnColor="$(tput setaf 3)" + noteColor="$(tput bold)$(tput setaf 6)" + fi + fi +} + +setupColors + +function errorEcho() { + echo "${errorColor}$*${normalColor}" +} + +function warnEcho() { + echo "${warnColor}$*${normalColor}" +} + +function noteEcho() { + echo "${noteColor}$*${normalColor}" +} -- cgit v1.2.3 From 8c7811a213687d8a0b837ff3bee8bd5af7dec5d2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 May 2017 20:35:13 +0200 Subject: Credit original source for shell color code --- modules/lib-bash/color-echo.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lib-bash/color-echo.sh b/modules/lib-bash/color-echo.sh index e357bf70ce4..ef708b29c4d 100644 --- a/modules/lib-bash/color-echo.sh +++ b/modules/lib-bash/color-echo.sh @@ -1,3 +1,6 @@ +# The check for terminal output and color support is heavily inspired +# by https://unix.stackexchange.com/a/10065. + function setupColors() { normalColor="" errorColor="" -- cgit v1.2.3 From 02288320d035d331f78727547d53dbdc0514763e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 15 May 2017 23:50:16 +0200 Subject: home-environment: use explicit PATH in activation In the activation script we expect to use the tools provided by GNU Core Utilities and GNU Bash. This commit therefore explicitly add these first in the `PATH` environment variable. --- modules/home-environment.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 694a2aa02c8..f665833f197 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -375,6 +375,11 @@ in set -eu set -o pipefail + # This code explicitly requires GNU Core Utilities and Bash. + # We therefore need to ensure they are prioritized over any + # other similarly named tools on the system. + export PATH="${pkgs.coreutils}/bin:${pkgs.bash}/bin:$PATH" + . ${./lib-bash/color-echo.sh} ${builtins.readFile ./lib-bash/activation-init.sh} -- cgit v1.2.3 From 1a491f24f73e9dd1ef601dbbcd216c157a88fcc9 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Tue, 16 May 2017 10:09:18 -0400 Subject: home-manager: add coreutils to PATH This ensures that we use the expected version of some useful tools, such as readlink. --- home-manager/default.nix | 1 + home-manager/home-manager | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/home-manager/default.nix b/home-manager/default.nix index a037c023f92..f2b9949549b 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -28,6 +28,7 @@ pkgs.stdenv.mkDerivation { substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ + --subst-var-by coreutils "${pkgs.coreutils}" \ --subst-var-by MODULES_PATH '${modulesPath}' \ --subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}" ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index e0beb761c9a..f8fe713175c 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -1,5 +1,10 @@ #!@bash@/bin/bash +# This code explicitly requires GNU Core Utilities and we therefore +# need to ensure they are prioritized over any other similarly named +# tools on the system. +PATH=@coreutils@/bin:$PATH + set -euo pipefail function doBuild() { -- cgit v1.2.3 From f60a1ed689c45a1220eac2fe23e1fb7a9ab33a1d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 15 May 2017 23:53:49 +0200 Subject: systemd: handle non-Linux systems better This commit causes an error to be printed if running under a non-Linux system when a systemd service, target, or timer is active. It will also prevent running systemd during activation if running under a non-Linux system. --- modules/systemd.nix | 195 +++++++++++++++++++++++++++++----------------------- 1 file changed, 109 insertions(+), 86 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 1e6117a12f4..ef68b6d6441 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -5,6 +5,10 @@ with import ./lib/dag.nix; let + cfg = config.systemd.user; + + enabled = cfg.services != {} || cfg.targets != {} || cfg.timers != {}; + toSystemdIni = (import lib/generators.nix).toINI { mkKeyValue = key: value: let @@ -60,98 +64,117 @@ in }; }; - config = { - home.file = - listToAttrs ( - (buildServices "service" config.systemd.user.services) - ++ - (buildServices "target" config.systemd.user.targets) - ++ - (buildServices "timer" config.systemd.user.timers) - ); - - home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' - function systemdPostReload() { - local workDir - workDir="$(mktemp -d)" - - if [[ -v oldGenPath ]] ; then - local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" - fi - - local newUserServicePath="$newGenPath/home-files/.config/systemd/user" - local oldServiceFiles="$workDir/old-files" - local newServiceFiles="$workDir/new-files" - local servicesDiffFile="$workDir/diff-files" - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ - && ! -d "$newUserServicePath" ]]; then - return - fi - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then - touch "$oldServiceFiles" - else - find "$oldUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$oldServiceFiles" - fi - - if [[ ! -d "$newUserServicePath" ]]; then - touch "$newServiceFiles" - else - find "$newUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$newServiceFiles" - fi - - diff \ - --new-line-format='+%L' \ - --old-line-format='-%L' \ - --unchanged-line-format=' %L' \ - "$oldServiceFiles" "$newServiceFiles" \ - > $servicesDiffFile - - local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) - local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) - local -a toStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) - local -a toRestart=( ) - - for f in ''${maybeRestart[@]} ; do - if systemctl --quiet --user is-active "$f" \ - && ! cmp --quiet \ - "$oldUserServicePath/$f" \ - "$newUserServicePath/$f" ; then - toRestart+=("$f") + config = mkMerge [ + { + assertions = [ + { + assertion = enabled -> pkgs.stdenv.isLinux; + message = + let + names = concatStringsSep ", " ( + attrNames (cfg.services // cfg.targets // cfg.timers) + ); + in + "Must use Linux for modules that require systemd: " + names; + } + ]; + } + + # 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 { + home.file = + listToAttrs ( + (buildServices "service" cfg.services) + ++ + (buildServices "target" cfg.targets) + ++ + (buildServices "timer" cfg.timers) + ); + + home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' + function systemdPostReload() { + local workDir + workDir="$(mktemp -d)" + + if [[ -v oldGenPath ]] ; then + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" fi - done - rm -r $workDir + local newUserServicePath="$newGenPath/home-files/.config/systemd/user" + local oldServiceFiles="$workDir/old-files" + local newServiceFiles="$workDir/new-files" + local servicesDiffFile="$workDir/diff-files" + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ + && ! -d "$newUserServicePath" ]]; then + return + fi + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then + touch "$oldServiceFiles" + else + find "$oldUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$oldServiceFiles" + fi - local sugg="" + if [[ ! -d "$newUserServicePath" ]]; then + touch "$newServiceFiles" + else + find "$newUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$newServiceFiles" + fi - if [[ -n "''${toRestart[@]}" ]] ; then - sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" - fi + diff \ + --new-line-format='+%L' \ + --old-line-format='-%L' \ + --unchanged-line-format=' %L' \ + "$oldServiceFiles" "$newServiceFiles" \ + > $servicesDiffFile + + local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) + local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) + local -a toStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) + local -a toRestart=( ) + + for f in ''${maybeRestart[@]} ; do + if systemctl --quiet --user is-active "$f" \ + && ! cmp --quiet \ + "$oldUserServicePath/$f" \ + "$newUserServicePath/$f" ; then + toRestart+=("$f") + fi + done + + rm -r $workDir + + local sugg="" + + if [[ -n "''${toRestart[@]}" ]] ; then + sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" + fi - if [[ -n "''${toStop[@]}" ]] ; then - sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" - fi + if [[ -n "''${toStop[@]}" ]] ; then + sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" + fi - if [[ -n "''${toStart[@]}" ]] ; then - sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" - fi + if [[ -n "''${toStart[@]}" ]] ; then + sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" + fi - if [[ -n "$sugg" ]] ; then - echo "Suggested commands:" - echo -n -e "$sugg" - fi - } + if [[ -n "$sugg" ]] ; then + echo "Suggested commands:" + echo -n -e "$sugg" + fi + } - $DRY_RUN_CMD systemctl --user daemon-reload - systemdPostReload - ''; - }; + $DRY_RUN_CMD systemctl --user daemon-reload + systemdPostReload + ''; + }) + ]; } -- cgit v1.2.3 From dfb5bbddf571f0035a1a4559d4ad939b0491da0b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 17 May 2017 23:14:45 +0200 Subject: Expand installation instructions slightly In particular, mention that non-NixOS users may have to create the per-user `profiles` and `gcroots` directories. Also reformat the list a little. --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b339cde338b..1c5be43539e 100644 --- a/README.md +++ b/README.md @@ -36,15 +36,23 @@ Installation Currently the easiest way to install Home Manager is as follows: - 1. Make sure you have a working Nix installation. +1. Make sure you have a working Nix installation. If you are not + using NixOS then you may here have to run - 2. Clone the Home Manager repository into the `~/.nixpkgs` directory: + ``` + $ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER + ``` + + since Home Manager uses these directories to manage your profile + generations. On NixOS these should already be available. + +2. Clone the Home Manager repository into the `~/.nixpkgs` directory: ``` $ git clone https://github.com/rycee/home-manager ~/.nixpkgs/home-manager ``` - 3. Add Home Manager to your user's Nixpkgs, for example by adding it +3. Add Home Manager to your user's Nixpkgs, for example by adding it to the `packageOverrides` section in your `~/.nixpkgs/config.nix` file: @@ -56,7 +64,7 @@ Currently the easiest way to install Home Manager is as follows: } ``` - 4. Install the `home-manager` package: +4. Install the `home-manager` package: ``` $ nix-env -f '' -iA home-manager -- cgit v1.2.3 From a4e96843e570ffb8a0d3304113441ff8497c673e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 17 May 2017 23:26:16 +0200 Subject: More descriptive header in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c5be43539e..79fe78ad975 100644 --- a/README.md +++ b/README.md @@ -131,8 +131,8 @@ $ home-manager build which will create a `result` link to a directory containing an activation script and the generated home directory files. -File safety ------------ +Keeping your ~ safe from harm +----------------------------- To configure programs and services the Home Manager must write various things to your home directory. To prevent overwriting any existing -- cgit v1.2.3 From ff65781b843be3cfd3dfa24bbf0f4d9e533891c3 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Wed, 24 May 2017 16:55:12 -0400 Subject: info: add module This is a module for managing the GNU info directory for the user profile. See comments at the top of `modules/programs/info.nix` for further information. --- modules/default.nix | 1 + modules/programs/info.nix | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 modules/programs/info.nix diff --git a/modules/default.nix b/modules/default.nix index e1f6b652686..b14e38ac101 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -19,6 +19,7 @@ let ./programs/firefox.nix ./programs/git.nix ./programs/gnome-terminal.nix + ./programs/info.nix ./programs/lesspipe.nix ./programs/ssh.nix ./programs/texlive.nix diff --git a/modules/programs/info.nix b/modules/programs/info.nix new file mode 100644 index 00000000000..65f1e3a092e --- /dev/null +++ b/modules/programs/info.nix @@ -0,0 +1,77 @@ +# info.nix -- install texinfo, set INFOPATH, create `dir` file + +# This is a helper for the GNU info documentation system. By default, +# the `info` command (and the Info subsystem within Emacs) gives easy +# access to the info files stored system-wide, but not info files in +# your ~/.nix-profile. + +# We set $INFOPATH to include `/run/current-system/sw/share/info` and +# `~/.nix-profile/share/info` but it's not enough. Although info can +# then find files when you explicitly ask for them, it doesn't show +# them to you in the table of contents on startup. To do that requires +# a `dir` file. NixOS keeps the system-wide `dir` file up to date, but +# ignores home-installed packages. + +# So this module contains an activation script that generates the +# `dir` for your home profile. Then when you start info (and both +# `dir` files are in your $INFOPATH), it will *merge* the contents of +# the two files, showing you a unified table of contents for all +# packages. This is really nice. + +{ config, lib, pkgs, ... }: + +with lib; +with import ../lib/dag.nix; + +let + cfg = config.programs.info; + + # Indexes info files found in this location + homeInfoPath = "$HOME/.nix-profile/share/info"; + + # Installs this package -- the interactive just means that it + # includes the curses `info` program. We also use `install-info` + # from this package in the activation script. + infoPkg = pkgs.texinfoInteractive; + +in + +{ + options = { + programs.info = { + enable = mkEnableOption "GNU Info"; + + homeInfoDirLocation = mkOption { + default = "$HOME/.cache/info"; + description = '' + Directory in which to store the info dir + file within your home. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [{ + assertion = config.home.sessionVariableSetter != "pam"; + message = '' + The info module does not work with PAM as a session variable setter. + ''; + }]; + + home.sessionVariables.INFOPATH = + "${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}"; + + home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] '' + $DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}" + $DRY_RUN_CMD rm -f "${cfg.homeInfoDirLocation}/dir" + if [[ -d "${homeInfoPath}" ]]; then + find -L "${homeInfoPath}" \( -name '*.info' -o -name '*.info.gz' \) \ + -exec $DRY_RUN_CMD ${infoPkg}/bin/install-info '{}' \ + "${cfg.homeInfoDirLocation}/dir" \; + fi + ''; + + home.packages = [infoPkg]; + }; +} -- cgit v1.2.3 From 67391395ef5d2103327f35fc9182ff56754842c4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 21 May 2017 23:54:38 +0200 Subject: home-manager: use `NIX_PATH` to locate modules This removes the old argument based method that Home Manager used to find its modules by a `NIX_PATH` based method. Specifically, this adds a `home-manager` Nix path prefix that can be overridden much like with the `nixpkgs` path prefix. --- home-manager/default.nix | 4 ++-- home-manager/home-manager | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index f2b9949549b..79f3e6d0955 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -3,10 +3,10 @@ let homeManagerExpr = pkgs.writeText "home-manager.nix" '' - { pkgs ? import {}, confPath, modulesPath }: + { pkgs ? import {}, confPath }: let - env = import modulesPath { + env = import { configuration = import confPath; pkgs = pkgs; }; diff --git a/home-manager/home-manager b/home-manager/home-manager index f8fe713175c..e5111f512cf 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -41,6 +41,8 @@ function doBuild() { exit 1 fi + export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=@MODULES_PATH@" + local extraArgs extraArgs="" @@ -54,7 +56,6 @@ function doBuild() { nix-build $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ - --argstr modulesPath "@MODULES_PATH@" \ --argstr confPath "$confFile" \ -A activation-script \ -o "$output" -- cgit v1.2.3 From 0aa549f07bf752745e09f3daa09ca5b401c9f003 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 20 May 2017 23:39:54 +0200 Subject: home-manager: support `.config` configuration path This commit changes the default path of the Home Manager configuration file from `~/.nixpkgs/home.nix` to `~/.config/nixpkgs/home.nix`. The old path is still supported and will be used if the `.config` path does not exist. This aligns Home Manager with the preferred configuration directory in NixOS 17.03. Fixes #13. --- README.md | 11 +++---- home-manager/default.nix | 2 +- home-manager/home-manager | 76 +++++++++++++++++++++++++++++++---------------- 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 79fe78ad975..0db0b313224 100644 --- a/README.md +++ b/README.md @@ -46,15 +46,16 @@ Currently the easiest way to install Home Manager is as follows: since Home Manager uses these directories to manage your profile generations. On NixOS these should already be available. -2. Clone the Home Manager repository into the `~/.nixpkgs` directory: +2. Clone the Home Manager repository into the `~/.config/nixpkgs` + directory: ``` - $ git clone https://github.com/rycee/home-manager ~/.nixpkgs/home-manager + $ git clone https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager ``` 3. Add Home Manager to your user's Nixpkgs, for example by adding it - to the `packageOverrides` section in your `~/.nixpkgs/config.nix` - file: + to the `packageOverrides` section in your + `~/.config/nixpkgs/config.nix` file: ```nix { @@ -84,7 +85,7 @@ the htop and fortune packages, installs Emacs with a few extra packages enabled, installs Firefox with Adobe Flash enabled, and enables the user gpg-agent service. -First create a file `~/.nixpkgs/home.nix` containing +First create a file `~/.config/nixpkgs/home.nix` containing ```nix { pkgs, ... }: diff --git a/home-manager/default.nix b/home-manager/default.nix index 79f3e6d0955..3c4880a0150 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,4 +1,4 @@ -{ pkgs, modulesPath ? "$HOME/.nixpkgs/home-manager/modules" }: +{ pkgs, modulesPath ? "$HOME/.config/nixpkgs/home-manager/modules" }: let diff --git a/home-manager/home-manager b/home-manager/home-manager index e5111f512cf..d70eda7af8f 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -7,35 +7,61 @@ PATH=@coreutils@/bin:$PATH set -euo pipefail -function doBuild() { - if [[ -z "$1" ]]; then - echo "Need to provide path to configuration file." - exit 1 - fi +# Attempts to set the HOME_MANAGER_CONFIG global variable. +# +# If no configuration file can be found then this function will print +# an error message and exit with an error code. +function setConfigFile() { + if [[ -v HOME_MANAGER_CONFIG ]] ; then + if [[ ! -e "$HOME_MANAGER_CONFIG" ]] ; then + echo "No configure file found at $HOME_MANAGER_CONFIG" + exit 1 + fi - if [[ -z "$2" ]]; then - echo "Need to provide generation output path." - exit 1 + HOME_MANAGER_CONFIG="$(realpath "$HOME_MANAGER_CONFIG")" + return fi - if [[ -e "$2" ]]; then - echo "The output path $2 already exists." - exit 1 - fi + local confFile + for confFile in "$HOME/.config/nixpkgs/home.nix" \ + "$HOME/.nixpkgs/home.nix" ; do + if [[ -e "$confFile" ]] ; then + HOME_MANAGER_CONFIG="$confFile" + return + fi + done - local confFile output - confFile="$(realpath "$1")" + echo "No configuration file found. " \ + "Please create one at ~/.config/nixpkgs/home.nix" + exit 1 +} - if [[ $? -ne 0 ]]; then +function setHomeManagerModulesPath() { + local modulesPath + for modulesPath in "@MODULES_PATH@" \ + "$HOME/.nixpkgs/home-manager/modules" ; do + if [[ -e "$modulesPath" ]] ; then + export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath" + return + fi + done +} + +function doBuild() { + if [[ -z "$1" ]]; then + echo "Need to provide generation output path." exit 1 fi - if [[ ! -r "$confFile" ]]; then - echo "No such configuration file: $1" + if [[ -e "$1" ]]; then + echo "The output path $1 already exists." exit 1 fi - output="$(realpath "$2")" + setConfigFile + setHomeManagerModulesPath + + output="$(realpath "$1")" if [[ $? -ne 0 ]]; then exit 1 @@ -56,7 +82,7 @@ function doBuild() { nix-build $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ - --argstr confPath "$confFile" \ + --argstr confPath "$HOME_MANAGER_CONFIG" \ -A activation-script \ -o "$output" } @@ -65,7 +91,7 @@ function doSwitch() { local wrkdir wrkdir="$(mktemp -d)" - if doBuild "$1" "$wrkdir/generation" ; then + if doBuild "$wrkdir/generation" ; then "$wrkdir/generation/activate" fi @@ -94,7 +120,8 @@ function doHelp() { echo echo "Options" echo - echo " -f FILE The home configuration file. Default is ~/.nixpkgs/home.nix" + echo " -f FILE The home configuration file." + echo " Default is '~/.config/nixpkgs/home.nix'." echo " -I PATH Add a path to the Nix expression search path." echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" @@ -108,13 +135,12 @@ function doHelp() { echo " packages List all packages installed in home-manager-path" } -CONFIG_FILE="$HOME/.nixpkgs/home.nix" EXTRA_NIX_PATH=() while getopts f:I:vnh opt; do case $opt in f) - CONFIG_FILE=$OPTARG + HOME_MANAGER_CONFIG="$OPTARG" ;; I) EXTRA_NIX_PATH+=("$OPTARG") @@ -144,10 +170,10 @@ cmd="$*" case "$cmd" in build) - doBuild "$CONFIG_FILE" "result" + doBuild "result" ;; switch) - doSwitch "$CONFIG_FILE" + doSwitch ;; generations) doListGens -- cgit v1.2.3 From 8b5d19e6b7cd9fbc23d776e69963d88b3c67910b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 25 Jun 2017 16:56:54 +0200 Subject: random-background: actually use image directory option --- modules/services/random-background.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index d0412310cb5..c221740ca65 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -46,7 +46,7 @@ in Service = { Type = "oneshot"; - ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-fill %h/backgrounds/"; + ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-fill ${cfg.imageDirectory}"; IOSchedulingClass = "idle"; }; -- cgit v1.2.3 From a9343d81947e39cfbae3e4d9d39825c191587541 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Jun 2017 16:55:28 +0200 Subject: udiskie: remove taffybar requirement It should be sufficient to have a graphical session going. --- modules/services/udiskie.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index 3fb038a74aa..981400caa5f 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -13,8 +13,6 @@ with lib; systemd.user.services.udiskie = { Unit = { Description = "Udiskie mount daemon"; - Requires = [ "taffybar.service" ]; - After = [ "taffybar.service" ]; }; Service = { -- cgit v1.2.3 From acf8d4e985d1e31374a8d39239bd94cbf4fbde9f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Jun 2017 18:26:54 +0200 Subject: xsession: use systemd graphical targets The systemd targets don't allow direct startup so we create our own target for graphical sessions managed by Home Environment. --- modules/xsession.nix | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index e0dff4552fe..7f0991f1ba3 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -60,19 +60,12 @@ in }; }; - # For stuff that needs to start just before a graphical session - # starts. - systemd.user.targets.graphical-session-pre = { + # A basic graphical session target for Home Manager. + systemd.user.targets.he-graphical-session = { Unit = { - Description = "Pre-graphical session"; - }; - }; - - # A basic graphical session target. Apparently this will come - # standard in future Systemd versions. - systemd.user.targets.graphical-session = { - Unit = { - Description = "Graphical session"; + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; }; }; @@ -83,6 +76,9 @@ in . "$HOME/.profile" fi + # If there are any running services from a previous session. + systemctl --user stop graphical-session.target graphical-session-pre.target + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY systemctl --user import-environment SSH_AUTH_SOCK @@ -90,8 +86,7 @@ in systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user restart graphical-session-pre.target - systemctl --user restart graphical-session.target + systemctl --user start he-graphical-session.target ${cfg.initExtra} -- cgit v1.2.3 From 9c17c5ccbbf5626f684eecc2ce660086ac8e249c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Jun 2017 18:34:09 +0200 Subject: Clean up systemd units for all graphical services --- modules/services/dunst.nix | 4 ++-- modules/services/gnome-keyring.nix | 3 ++- modules/services/keepassx.nix | 2 ++ modules/services/network-manager-applet.nix | 2 ++ modules/services/random-background.nix | 2 ++ modules/services/redshift.nix | 2 ++ modules/services/taffybar.nix | 2 ++ modules/services/udiskie.nix | 2 ++ modules/services/xscreensaver.nix | 2 ++ modules/xsession.nix | 2 ++ 10 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index a70e8d31104..c1f29d942cf 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -22,8 +22,8 @@ with lib; systemd.user.services.dunst = { Unit = { Description = "Dunst notification daemon"; - Requires = "graphical-session.target"; - After = "graphical-session.target"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/gnome-keyring.nix b/modules/services/gnome-keyring.nix index b0edeaed478..b7097d7cd35 100644 --- a/modules/services/gnome-keyring.nix +++ b/modules/services/gnome-keyring.nix @@ -28,6 +28,7 @@ in systemd.user.services.gnome-keyring = { Unit = { Description = "GNOME Keyring"; + PartOf = [ "graphical-session-pre.target" ]; }; Service = { @@ -45,7 +46,7 @@ in }; Install = { - WantedBy = [ "graphical-session.target" ]; + WantedBy = [ "graphical-session-pre.target" ]; }; }; }; diff --git a/modules/services/keepassx.nix b/modules/services/keepassx.nix index 0ed90dd0439..ff875ee63a1 100644 --- a/modules/services/keepassx.nix +++ b/modules/services/keepassx.nix @@ -13,6 +13,8 @@ with lib; systemd.user.services.keepassx = { Unit = { Description = "KeePassX password manager"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Install = { diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index a7a90b618a5..eca5515f2d4 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -13,6 +13,8 @@ with lib; systemd.user.services.network-manager-applet = { Unit = { Description = "Network Manager applet"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Install = { diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index c221740ca65..f1b8d39d195 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -42,6 +42,8 @@ in systemd.user.services.random-background = { Unit = { Description = "Set random desktop background using feh"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index f8978613464..ba9f3b1d3ed 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -99,6 +99,8 @@ in { systemd.user.services.redshift = { Unit = { Description = "Redshift colour temperature adjuster"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Install = { diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index 87a84063483..a452295f2fe 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -27,6 +27,8 @@ in systemd.user.services.taffybar = { Unit = { Description = "Taffybar desktop bar"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index 981400caa5f..b2a2b4072f9 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -13,6 +13,8 @@ with lib; systemd.user.services.udiskie = { Unit = { Description = "Udiskie mount daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix index 0b1a4573a0f..b27e5b73ae0 100644 --- a/modules/services/xscreensaver.nix +++ b/modules/services/xscreensaver.nix @@ -13,6 +13,8 @@ with lib; systemd.user.services.xscreensaver = { Unit = { Description = "XScreenSaver"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/xsession.nix b/modules/xsession.nix index 7f0991f1ba3..6afb17ba123 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -38,6 +38,8 @@ in systemd.user.services.setxkbmap = { Unit = { Description = "Set up keyboard in X"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; Install = { -- cgit v1.2.3 From 4c85ff7ff297b784df5c2fed2f65e37e6436a385 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 29 Jun 2017 00:24:29 +0200 Subject: xsession: rename graphical session target name The `he` in `he-graphical-session` doesn't make much sense, change it to `hm` for Home Manager. --- modules/xsession.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index 6afb17ba123..0ec95ffe618 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -63,7 +63,7 @@ in }; # A basic graphical session target for Home Manager. - systemd.user.targets.he-graphical-session = { + systemd.user.targets.hm-graphical-session = { Unit = { Description = "Home Manager X session"; Requires = [ "graphical-session-pre.target" ]; @@ -88,7 +88,7 @@ in systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user start he-graphical-session.target + systemctl --user start hm-graphical-session.target ${cfg.initExtra} -- cgit v1.2.3 From 8af68388699185227295a077a4dd3a50440f5d88 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 29 Jun 2017 01:03:39 +0200 Subject: home-environment: prevent delete of non-managed files When a file has disappeared between the previous and the next generations then its symlink in `$HOME` is typically deleted. With this commit we refuse to delete the path unless we are reasonably certain it is a symlink into a Home Manager generation. --- modules/home-environment.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index f665833f197..79b4f3444ff 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -286,6 +286,8 @@ in home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( let + pattern = "-home-manager-files/"; + link = pkgs.writeText "link" '' newGenFiles="$1" shift @@ -298,6 +300,8 @@ in ''; cleanup = pkgs.writeText "cleanup" '' + . ${./lib-bash/color-echo.sh} + newGenFiles="$1" oldGenFiles="$2" shift 2 @@ -306,6 +310,8 @@ in targetPath="$HOME/$relativePath" if [[ -e "$newGenFiles/$relativePath" ]] ; then $VERBOSE_ECHO "Checking $targetPath exists" + elif [[ ! "$(readlink -e "$targetPath")" =~ "${pattern}" ]] ; then + warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." else echo "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" -- cgit v1.2.3 From acf813cadc33b339cd1d575aba44fdc283717dd7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 29 Jun 2017 01:06:08 +0200 Subject: systemd: add support for socket units --- modules/systemd.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index ef68b6d6441..edc89ab0c87 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -7,7 +7,10 @@ let cfg = config.systemd.user; - enabled = cfg.services != {} || cfg.targets != {} || cfg.timers != {}; + enabled = cfg.services != {} + || cfg.sockets != {} + || cfg.targets != {} + || cfg.timers != {}; toSystemdIni = (import lib/generators.nix).toINI { mkKeyValue = key: value: @@ -50,6 +53,12 @@ in description = "Definition of systemd per-user service units."; }; + sockets = mkOption { + default = {}; + type = types.attrs; + description = "Definition of systemd per-user sockets"; + }; + targets = mkOption { default = {}; type = types.attrs; @@ -72,7 +81,9 @@ in message = let names = concatStringsSep ", " ( - attrNames (cfg.services // cfg.targets // cfg.timers) + attrNames ( + cfg.services // cfg.sockets // cfg.targets // cfg.timers + ) ); in "Must use Linux for modules that require systemd: " + names; @@ -87,6 +98,8 @@ in listToAttrs ( (buildServices "service" cfg.services) ++ + (buildServices "socket" cfg.sockets) + ++ (buildServices "target" cfg.targets) ++ (buildServices "timer" cfg.timers) -- cgit v1.2.3 From 196db18f5bab22c431b57d6763c4b262f504ccbe Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 29 Jun 2017 23:33:28 +0200 Subject: gpg-agent: use systemd socket activation --- modules/services/gpg-agent.nix | 108 +++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 30 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 872b69b20d6..1d015397c5c 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -29,41 +29,89 @@ in }; }; - config = mkIf cfg.enable { - home.file.".gnupg/gpg-agent.conf".text = concatStringsSep "\n" ( - optional cfg.enableSshSupport - "enable-ssh-support" - ++ - optional (cfg.defaultCacheTtl != null) - "default-cache-ttl ${toString cfg.defaultCacheTtl}" - ); - - home.sessionVariables = - optionalAttrs cfg.enableSshSupport { - SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"; - }; + config = mkIf cfg.enable (mkMerge [ + { + home.file.".gnupg/gpg-agent.conf".text = concatStringsSep "\n" ( + optional cfg.enableSshSupport + "enable-ssh-support" + ++ + optional (cfg.defaultCacheTtl != null) + "default-cache-ttl ${toString cfg.defaultCacheTtl}" + ); + + home.sessionVariables = + optionalAttrs cfg.enableSshSupport { + SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"; + }; + + programs.bash.initExtra = '' + GPG_TTY="$(tty)" + export GPG_TTY + gpg-connect-agent updatestartuptty /bye > /dev/null + ''; + } - programs.bash.initExtra = '' - GPG_TTY="$(tty)" - export GPG_TTY - gpg-connect-agent updatestartuptty /bye > /dev/null - ''; + # The systemd units below are direct translations of the + # descriptions in the + # + # ${pkgs.gnupg}/share/doc/gnupg/examples/systemd-user + # + # directory. + { + systemd.user.services.gpg-agent = { + Unit = { + Description = "GnuPG cryptographic agent and passphrase cache"; + Documentation = "man:gpg-agent(1)"; + Requires = "gpg-agent.socket"; + After = "gpg-agent.socket"; + # This is a socket-activated service: + RefuseManualStart = true; + }; - systemd.user.services.gpg-agent = { - Unit = { - Description = "GnuPG private key agent"; - IgnoreOnIsolate = true; + Service = { + ExecStart = "${pkgs.gnupg}/bin/gpg-agent --supervised"; + ExecReload = "${pkgs.gnupg}/bin/gpgconf --reload gpg-agent"; + }; }; - Service = { - Type = "forking"; - ExecStart = "${pkgs.gnupg}/bin/gpg-agent --daemon"; - Restart = "on-abort"; + systemd.user.sockets.gpg-agent = { + Unit = { + Description = "GnuPG cryptographic agent and passphrase cache"; + Documentation = "man:gpg-agent(1)"; + }; + + Socket = { + ListenStream = "%t/gnupg/S.gpg-agent"; + FileDescriptorName = "std"; + SocketMode = "0600"; + DirectoryMode = "0700"; + }; + + Install = { + WantedBy = [ "sockets.target" ]; + }; }; + } - Install = { - WantedBy = [ "default.target" ]; + (mkIf cfg.enableSshSupport { + systemd.user.sockets.gpg-agent-ssh = { + Unit = { + Description = "GnuPG cryptographic agent (ssh-agent emulation)"; + Documentation = "man:gpg-agent(1) man:ssh-add(1) man:ssh-agent(1) man:ssh(1)"; + }; + + Socket = { + ListenStream = "%t/gnupg/S.gpg-agent.ssh"; + FileDescriptorName = "ssh"; + Service = "gpg-agent.service"; + SocketMode = "0600"; + DirectoryMode = "0700"; + }; + + Install = { + WantedBy = [ "sockets.target" ]; + }; }; - }; - }; + }) + ]); } -- cgit v1.2.3 From e274fc732b141c9afd8f924d581153e14f929444 Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Fri, 30 Jun 2017 22:45:09 +0200 Subject: browserpass: add module (#16) * browserpass: add module * apply some review requests * browserpass: update to 1.0.5 * browserpass: install from Nixpkgs using `home.file` --- modules/default.nix | 1 + modules/programs/browserpass.nix | 80 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 modules/programs/browserpass.nix diff --git a/modules/default.nix b/modules/default.nix index b14e38ac101..9d9947892db 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -14,6 +14,7 @@ let ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix + ./programs/browserpass.nix ./programs/eclipse.nix ./programs/emacs.nix ./programs/firefox.nix diff --git a/modules/programs/browserpass.nix b/modules/programs/browserpass.nix new file mode 100644 index 00000000000..deb29b64d58 --- /dev/null +++ b/modules/programs/browserpass.nix @@ -0,0 +1,80 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + browsers = [ + "chrome" + "chromium" + "firefox" + "vivaldi" + ]; +in { + options = { + programs.browserpass = { + enable = mkEnableOption "the browserpass extension host application"; + + browsers = mkOption { + type = types.listOf (types.enum browsers); + default = browsers; + example = [ "firefox" ]; + description = "Which browsers to install browserpass for"; + }; + }; + }; + + config = mkIf config.programs.browserpass.enable { + home.file = builtins.concatLists (with pkgs.stdenv; map (x: + if x == "chrome" then + let dir = if isDarwin + then "Library/Application Support/Google/Chrome/NativeMessagingHosts" + else ".config/google-chrome/NativeMessagingHosts"; + in [ + { + target = "${dir}/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-host.json"; + } + { + target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-policy.json"; + } + ] + else if x == "chromium" then + let dir = if isDarwin + then "Library/Application Support/Chromium/NativeMessagingHosts" + else ".config/chromium/NativeMessagingHosts"; + in [ + { + target = "${dir}/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-host.json"; + } + { + target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-policy.json"; + } + ] + else if x == "firefox" then + [ { + target = (if isDarwin + then "Library/Application Support/Mozilla/NativeMessagingHosts" + else ".mozilla/native-messaging-hosts") + + "/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/lib/mozilla/native-messaging-hosts/com.dannyvankooten.browserpass.json"; + } ] + else if x == "vivaldi" then + let dir = if isDarwin + then "Library/Application Support/Vivaldi/NativeMessagingHosts" + else ".config/vivaldi/NativeMessagingHosts"; + in [ + { + target = "${dir}/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-host.json"; + } + { + target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + source = "${pkgs.browserpass}/etc/chrome-policy.json"; + } + ] + else throw "unknown browser ${x}") config.programs.browserpass.browsers); + }; +} -- cgit v1.2.3 From 89dc8c200488be358ca3f48b1b56641667f14c92 Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Thu, 6 Jul 2017 18:31:40 +0200 Subject: home-environment: fix `home.activation.checkLinkTargets` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem ------- We resolve symlinks from inside `/nix/store/HASH-home-manager-files` into the nix store as `/nix/store/HASH-DRVNAME` which does not match the pattern. This happened to me because I pull in some repos in via `home.file`. The `home-manager-files` derivation links to the repo's derivation in the nix store. For example: let nanorcs = fetchFromGitHub { owner = "scopatz"; repo = "nanorc"; … }; in [ { target = ".nano"; source = nanorcs; } { target = ".nanorc"; source = "${nanorcs}/nanorc"; } ] Solution -------- Call `readlink` without `-e` to obtain only the first redirection from `~` to `/nix/store/HASH-home-manager-files`. --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 79b4f3444ff..cf4c49c5c5c 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -260,7 +260,7 @@ in relativePath="''${sourcePath#$newGenFiles/}" targetPath="$HOME/$relativePath" if [[ -e "$targetPath" \ - && ! "$(readlink -e "$targetPath")" =~ "${pattern}" ]] ; then + && ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then errorEcho "Existing file '$targetPath' is in the way" collision=1 fi -- cgit v1.2.3 From 98c7b23178df174ee36c6b643d2b865644604ca5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 11 Jul 2017 19:48:49 +0200 Subject: home-manager: remove unnecessary variable setting The `NIX_PATH` variable is set by the `setHomeManagerModulesPath` function so it is unnecessary to set it again. --- home-manager/home-manager | 2 -- 1 file changed, 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index d70eda7af8f..cdc68cf2546 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -67,8 +67,6 @@ function doBuild() { exit 1 fi - export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=@MODULES_PATH@" - local extraArgs extraArgs="" -- cgit v1.2.3 From 28d3f746146a66dbd64816b8638deaa83199302f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 11 Jul 2017 19:50:29 +0200 Subject: home-manager: allow a user-defined third module path The user-defined path will be used if present, otherwise the two "fallback" defaults (in `.nixpkgs` and `.config/nixpkgs`) will be used. --- home-manager/default.nix | 12 ++++++++++-- home-manager/home-manager | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index 3c4880a0150..b2c137b0684 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,4 +1,10 @@ -{ pkgs, modulesPath ? "$HOME/.config/nixpkgs/home-manager/modules" }: +{ pkgs + + # Extra path to the Home Manager modules. If set then this path will + # be tried before `$HOME/.config/nixpkgs/home-manager/modules` and + # `$HOME/.nixpkgs/home-manager/modules`. +, modulesPath ? null +}: let @@ -16,6 +22,8 @@ let } ''; + modulesPathStr = if modulesPath == null then "" else modulesPath; + in pkgs.stdenv.mkDerivation { @@ -29,7 +37,7 @@ pkgs.stdenv.mkDerivation { substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ --subst-var-by coreutils "${pkgs.coreutils}" \ - --subst-var-by MODULES_PATH '${modulesPath}' \ + --subst-var-by MODULES_PATH '${modulesPathStr}' \ --subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}" ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index cdc68cf2546..6f8e4f60d83 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -39,6 +39,7 @@ function setConfigFile() { function setHomeManagerModulesPath() { local modulesPath for modulesPath in "@MODULES_PATH@" \ + "$HOME/.config/nixpkgs/home-manager/modules" \ "$HOME/.nixpkgs/home-manager/modules" ; do if [[ -e "$modulesPath" ]] ; then export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath" -- cgit v1.2.3 From 7a18a0fb348393a4d4cb9aaff39626d63351edc3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 11 Jul 2017 19:55:30 +0200 Subject: home-manager: add module This module is a module to install and configure the home-manager tool. By managing the home-manager tool through the Home Manager module system it will be installed/updated on configuration activation. --- modules/default.nix | 1 + modules/programs/home-manager.nix | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 modules/programs/home-manager.nix diff --git a/modules/default.nix b/modules/default.nix index 9d9947892db..219aa7baee8 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -20,6 +20,7 @@ let ./programs/firefox.nix ./programs/git.nix ./programs/gnome-terminal.nix + ./programs/home-manager.nix ./programs/info.nix ./programs/lesspipe.nix ./programs/ssh.nix diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix new file mode 100644 index 00000000000..09c662ac08d --- /dev/null +++ b/modules/programs/home-manager.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.home-manager; + +in + +{ + options = { + programs.home-manager = { + enable = mkEnableOption "Home Manager"; + + modulesPath = mkOption { + type = types.nullOr types.str; + default = null; + example = "$HOME/devel/home-manager/modules"; + description = '' + The default path to use for Home Manager modules. If this + path does not exist then + $HOME/.config/nixpkgs/home-manager/modules + and $HOME/.nixpkgs/home-manager/modules + will be attempted. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (import ../../home-manager { + inherit pkgs; + inherit (cfg) modulesPath; + }) + ]; + }; +} -- cgit v1.2.3 From dd5061d73bacf62b56325d74efa9b261d3930bfd Mon Sep 17 00:00:00 2001 From: Utku Demir Date: Mon, 17 Jul 2017 08:10:15 +0000 Subject: Add syncthing service --- modules/default.nix | 1 + modules/services/syncthing.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 modules/services/syncthing.nix diff --git a/modules/default.nix b/modules/default.nix index 219aa7baee8..97db96b953c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -32,6 +32,7 @@ let ./services/network-manager-applet.nix ./services/random-background.nix ./services/redshift.nix + ./services/syncthing.nix ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix new file mode 100644 index 00000000000..3a6bf023e86 --- /dev/null +++ b/modules/services/syncthing.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.syncthing = { + enable = mkEnableOption "Syncthing"; + }; + }; + + config = mkIf config.services.syncthing.enable { + systemd.user.services.syncthing = { + Unit = { + Description = "Syncthing"; + After = [ "network.target" ]; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + + Service = { + ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser"; + }; + }; + }; +} -- cgit v1.2.3 From cdb2bec909cfdd808765778b3d8c447e4133b8c3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 18 Jul 2017 13:49:02 +0200 Subject: syncthing: expand service description This models the user service on the upstream systemd file. --- modules/services/syncthing.nix | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 3a6bf023e86..5da3a8cf06c 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -5,24 +5,28 @@ with lib; { options = { services.syncthing = { - enable = mkEnableOption "Syncthing"; + enable = mkEnableOption "Syncthing continuous file synchronization"; }; }; config = mkIf config.services.syncthing.enable { systemd.user.services.syncthing = { - Unit = { - Description = "Syncthing"; - After = [ "network.target" ]; - }; + Unit = { + Description = "Syncthing - Open Source Continuous File Synchronization"; + Documentation = "man:syncthing(1)"; + After = [ "network.target" ]; + }; - Install = { - WantedBy = [ "default.target" ]; - }; + Service = { + ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; + Restart = "on-failure"; + SuccessExitStatus = [ 3 4 ]; + RestartForceExitStatus = [ 3 4 ]; + }; - Service = { - ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser"; - }; + Install = { + WantedBy = [ "default.target" ]; + }; }; }; } -- cgit v1.2.3 From 2e257f40e68ed1730c43fff1e8a010f47f4cb072 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 19 Jul 2017 00:12:34 +0200 Subject: home-manager: remove manually installed home-manager If the `home-manager` module is enabled then check if the `home-manager` package is installed using `nix-env -i` and if so then it is automatically uninstalled before the new package environment, which includes home-manager, is installed. --- modules/programs/home-manager.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 09c662ac08d..413f566875a 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: with lib; +with import ../lib/dag.nix; let @@ -35,5 +36,17 @@ in inherit (cfg) modulesPath; }) ]; + + # Uninstall manually installed home-manager, if such exists. + # Without this a file collision error will be printed. + home.activation.uninstallHomeManager = + dagEntryBetween [ "installPackages" ] [ "writeBoundary" ] '' + if nix-env -q | grep -q '^home-manager$' ; then + $DRY_RUN_CMD nix-env -e home-manager + + echo "You can now remove the 'home-manager' entry in" + echo "'~/.config/nixpkgs/config.nix', if you want." + fi + ''; }; } -- cgit v1.2.3 From dba14bfe90949003056786d50589014fbf4233ce Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 21 Jul 2017 21:10:32 +0200 Subject: manual: fix man pages build on unstable NixOS --- modules/manual.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/manual.nix b/modules/manual.nix index 0a947914460..4736726f3ca 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -60,9 +60,19 @@ in }; config = mkIf config.manual.manpages.enable { - # To fix error during manpage build. - meta.doc = builtins.toFile "nothingness" ""; - home.packages = [ homeEnvironmentManPages ]; }; + + # To fix error during manpage build. + meta.doc = builtins.toFile "nothingness" '' + + this is just to make the docs compile + + + + ''; } -- cgit v1.2.3 From 5862a05fb1cc0de5d6c48ea4d709c2fca8050689 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 22 Jul 2017 00:18:31 +0200 Subject: home-environment: avoid harmless but scary error message --- modules/home-environment.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index cf4c49c5c5c..f659bcb3f7e 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -315,8 +315,17 @@ in else echo "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" - $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \ - $VERBOSE_ARG -p "$(dirname "$targetPath")" + targetDir="$(dirname "$targetPath")" + + # Recursively remove the containing directory. We only + # do this if the containing folder is not $HOME since + # running rmdir on $HOME will result in a harmless but + # unpleasant error message. + if [[ "$targetDir" != "$HOME" ]] ; then + $DRY_RUN_CMD rmdir $VERBOSE_ARG \ + -p --ignore-fail-on-non-empty \ + "$targetDir" + fi fi done ''; -- cgit v1.2.3 From d807a5c31428138d9d992b835f28db48582149c6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 22 Jul 2017 00:23:36 +0200 Subject: home-environment: fix cleanup of user replaced directories We must only follow the symbolic link once (i.e., not use the `-e` option) since otherwise the pattern will not match when `home.file.xyz.source` is a directory. --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index f659bcb3f7e..6596a1162c9 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -310,7 +310,7 @@ in targetPath="$HOME/$relativePath" if [[ -e "$newGenFiles/$relativePath" ]] ; then $VERBOSE_ECHO "Checking $targetPath exists" - elif [[ ! "$(readlink -e "$targetPath")" =~ "${pattern}" ]] ; then + elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." else echo "Checking $targetPath gone (deleting)" -- cgit v1.2.3 From 3778a69fbe5a618c96aef987a0f0ff056c7fa5ca Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 24 Jul 2017 07:47:59 +0200 Subject: htop: add module --- modules/default.nix | 1 + modules/programs/htop.nix | 331 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 modules/programs/htop.nix diff --git a/modules/default.nix b/modules/default.nix index 97db96b953c..0b163c7d282 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -21,6 +21,7 @@ let ./programs/git.nix ./programs/gnome-terminal.nix ./programs/home-manager.nix + ./programs/htop.nix ./programs/info.nix ./programs/lesspipe.nix ./programs/ssh.nix diff --git a/modules/programs/htop.nix b/modules/programs/htop.nix new file mode 100644 index 00000000000..b0f1a237d1f --- /dev/null +++ b/modules/programs/htop.nix @@ -0,0 +1,331 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.htop; + + list = xs: concatMapStrings (x: "${toString x} ") xs; + + bool = b: if b then "1" else "0"; + + fields = { + PID = 0; + COMM = 1; + STATE = 2; + PPID = 3; + PGRP = 4; + SESSION = 5; + TTY_NR = 6; + TPGID = 7; + MINFLT = 9; + MAJFLT = 11; + PRIORITY = 17; + NICE = 18; + STARTTIME = 20; + PROCESSOR = 37; + M_SIZE = 38; + M_RESIDENT = 39; + ST_UID = 45; + PERCENT_CPU = 46; + PERCENT_MEM = 47; + USER = 48; + TIME = 49; + NLWP = 50; + TGID = 51; + CMINFLT = 10; + CMAJFLT = 12; + UTIME = 13; + STIME = 14; + CUTIME = 15; + CSTIME = 16; + M_SHARE = 40; + M_TRS = 41; + M_DRS = 42; + M_LRS = 43; + M_DT = 44; + CTID = 99; + VPID = 100; + VXID = 102; + RCHAR = 102; + WCHAR = 103; + SYSCR = 104; + SYSCW = 105; + RBYTES = 106; + WBYTES = 107; + CNCLWB = 108; + IO_READ_RATE = 109; + IO_WRITE_RATE = 110; + IO_RATE = 111; + CGROUP = 112; + OOM = 113; + IO_PRIORITY = 114; + }; + + # Mapping from names to defaults + meters = { + Clock = 2; + LoadAverage = 2; + Load = 2; + Memory = 1; + Swap = 1; + Tasks = 2; + Uptime = 2; + Battery = 2; + Hostname = 2; + AllCPUs = 1; + AllCPUs2 = 1; + LeftCPUs = 1; + RightCPUs = 1; + LeftCPUs2 = 1; + RightCPUs2 = 1; + Blank = 2; + CPU = 1; + "CPU(1)"= 1; + "CPU(2)" = 1; + "CPU(3)" = 1; + "CPU(4)" = 1; + }; + + singleMeterType = types.either (types.enum (attrNames meters)) (types.submodule { + options = { + kind = mkOption { + type = types.enum (attrNames meters); + example = "AllCPUs"; + description = "What kind of meter."; + }; + + mode = mkOption { + type = types.enum [ 1 2 3 4 ]; + example = 2; + description = "Which mode the meter should use, one of 1(Bar) 2(Text) 3(Graph) 4(LED)."; + }; + }; + }); + + # Converts the meter to an attribute set if it isn't already + meterStandard = m: if builtins.isString m then { + kind = m; + mode = meters.${m}; + } else m; + + + meterType = types.submodule { + options = { + left = mkOption { + description = "Meters shown in the left header."; + default = [ "AllCPUs" "Memory" "Swap" ]; + example = [ + "Memory" + "LeftCPUs2" + "RightCPUs2" + { kind = "CPU"; mode = 3; } + ]; + type = types.listOf singleMeterType; + }; + right = mkOption { + description = "Meters shown in the right header."; + default = [ "Tasks" "LoadAverage" "Uptime" ]; + example = [ + { kind = "Clock"; mode = 4; } + "Uptime" + "Tasks" + ]; + type = types.listOf singleMeterType; + }; + }; + }; +in +{ + options.programs.htop = { + enable = mkEnableOption "htop"; + + fields = mkOption { + type = types.listOf (types.enum (attrNames fields)); + default = [ "PID" "USER" "PRIORITY" "NICE" "M_SIZE" "M_RESIDENT" "M_SHARE" "STATE" "PERCENT_CPU" "PERCENT_MEM" "TIME" "COMM" ]; + example = [ "PID" "USER" "PRIORITY" "PERCENT_CPU" "M_RESIDENT" "PERCENT_MEM" "TIME" "COMM" ]; + description = "Active fields shown in the table."; + }; + + sortKey = mkOption { + type = types.enum (attrNames fields); + default = "PERCENT_CPU"; + example = "TIME"; + description = "Which field to use for sorting."; + }; + + sortDescending = mkOption { + type = types.bool; + default = true; + description = "Whether to sort descending or not."; + }; + + hideThreads = mkOption { + type = types.bool; + default = false; + description = "Hide threads."; + }; + + hideKernelThreads = mkOption { + type = types.bool; + default = true; + description = "Hide kernel threads."; + }; + + hideUserlandThreads = mkOption { + type = types.bool; + default = false; + description = "Hide userland process threads."; + }; + + shadowOtherUsers = mkOption { + type = types.bool; + default = false; + description = "Shadow other users' processes."; + }; + + showThreadNames = mkOption { + type = types.bool; + default = false; + description = "Show custom thread names."; + }; + + showProgramPath = mkOption { + type = types.bool; + default = true; + description = "Show program path."; + }; + + highlightBaseName = mkOption { + type = types.bool; + default = false; + description = "Highlight program basename."; + }; + + highlightMegabytes = mkOption { + type = types.bool; + default = true; + description = "Highlight large numbers in memory counters."; + }; + + highlightThreads = mkOption { + type = types.bool; + default = true; + description = "Display threads in a different color."; + }; + + treeView = mkOption { + type = types.bool; + default = false; + description = "Tree view."; + }; + + headerMargin = mkOption { + type = types.bool; + default = true; + description = "Leave a margin around header."; + }; + + detailedCpuTime = mkOption { + type = types.bool; + default = false; + description = "Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)."; + }; + + cpuCountFromZero = mkOption { + type = types.bool; + default = false; + description = "Count CPUs from 0 instead of 1."; + }; + + updateProcessNames = mkOption { + type = types.bool; + default = false; + description = "Update process names on every refresh."; + }; + + accountGuestInCpuMeter = mkOption { + type = types.bool; + default = false; + description = "Add guest time in CPU meter percentage."; + }; + + colorScheme = mkOption { + type = types.enum [ 0 1 2 3 4 5 6 ]; + default = 0; + example = 6; + description = "Which color scheme to use."; + }; + + delay = mkOption { + type = types.int; + default = 15; + example = 2; + description = "Set the delay between updates, in tenths of seconds."; + }; + + meters = mkOption { + description = "Meters shown in the header."; + default = { + left = [ "AllCPUs" "Memory" "Swap" ]; + right = [ "Tasks" "LoadAverage" "Uptime" ]; + }; + example = { + left = [ + "Memory" + "CPU" + "LeftCPUs2" + "RightCPUs2" + { kind = "CPU"; mode = 3; } + ]; + right = [ + { kind = "Clock"; mode = 4; } + "Uptime" + "Tasks" + "LoadAverage" + { kind = "Battery"; mode = 1; } + ]; + }; + type = meterType; + }; + + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.htop ]; + + home.file.".config/htop/htoprc".text = let + leftMeters = map (m: (meterStandard m).kind) cfg.meters.left; + leftModes = map (m: (meterStandard m).mode) cfg.meters.left; + rightMeters = map (m: (meterStandard m).kind) cfg.meters.right; + rightModes = map (m: (meterStandard m).mode) cfg.meters.right; + in '' + # This file is regenerated by home-manager + # when options are changed in the config + fields=${list (map (n: fields.${n}) cfg.fields)} + sort_key=${toString (fields.${cfg.sortKey})} + sort_direction=${bool cfg.sortDescending} + hide_threads=${bool cfg.hideThreads} + hide_kernel_threads=${bool cfg.hideKernelThreads} + hide_userland_threads=${bool cfg.hideUserlandThreads} + shadow_other_users=${bool cfg.shadowOtherUsers} + show_thread_names=${bool cfg.showThreadNames} + show_program_path=${bool cfg.showProgramPath} + highlight_base_name=${bool cfg.highlightBaseName} + highlight_megabytes=${bool cfg.highlightMegabytes} + highlight_threads=${bool cfg.highlightThreads} + tree_view=${bool cfg.treeView} + header_margin=${bool cfg.headerMargin} + detailed_cpu_time=${bool cfg.detailedCpuTime} + cpu_count_from_zero=${bool cfg.cpuCountFromZero} + update_process_names=${bool cfg.updateProcessNames} + account_guest_in_cpu_meter=${bool cfg.accountGuestInCpuMeter} + color_scheme=${toString cfg.colorScheme} + delay=${toString cfg.delay} + left_meters=${list leftMeters} + left_meter_modes=${list leftModes} + right_meters=${list rightMeters} + right_meter_modes=${list rightModes} + ''; + }; +} -- cgit v1.2.3 From be432c8654493005838d1d4614206f071ba4e534 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 29 Jul 2017 17:47:18 +0200 Subject: ssh: add control persist option --- modules/programs/ssh.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 4bf02193dc3..e166f49b515 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -144,6 +144,15 @@ in ''; }; + controlPersist = mkOption { + type = types.str; + default = "no"; + example = "10m"; + description = '' + Whether control socket should remain open in the background. + ''; + }; + matchBlocks = mkOption { type = types.listOf matchBlockModule; default = []; @@ -158,6 +167,7 @@ in ForwardAgent ${yn cfg.forwardAgent} ControlMaster ${cfg.controlMaster} ControlPath ${cfg.controlPath} + ControlPersist ${cfg.controlPersist} ${concatStringsSep "\n\n" (map matchBlockStr cfg.matchBlocks)} ''; -- cgit v1.2.3 From 1d24e96074ac8c4c787c556fc3fa0fd7ff4a25ca Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 24 Jul 2017 20:44:58 +0200 Subject: htop: use types.coercedTo --- modules/programs/htop.nix | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/modules/programs/htop.nix b/modules/programs/htop.nix index b0f1a237d1f..10235ccdad5 100644 --- a/modules/programs/htop.nix +++ b/modules/programs/htop.nix @@ -87,28 +87,24 @@ let "CPU(4)" = 1; }; - singleMeterType = types.either (types.enum (attrNames meters)) (types.submodule { - options = { - kind = mkOption { - type = types.enum (attrNames meters); - example = "AllCPUs"; - description = "What kind of meter."; - }; - - mode = mkOption { - type = types.enum [ 1 2 3 4 ]; - example = 2; - description = "Which mode the meter should use, one of 1(Bar) 2(Text) 3(Graph) 4(LED)."; + singleMeterType = types.coercedTo + (types.enum (attrNames meters)) + (m: { kind = m; mode = meters.${m}; }) + (types.submodule { + options = { + kind = mkOption { + type = types.enum (attrNames meters); + example = "AllCPUs"; + description = "What kind of meter."; + }; + + mode = mkOption { + type = types.enum [ 1 2 3 4 ]; + example = 2; + description = "Which mode the meter should use, one of 1(Bar) 2(Text) 3(Graph) 4(LED)."; + }; }; - }; - }); - - # Converts the meter to an attribute set if it isn't already - meterStandard = m: if builtins.isString m then { - kind = m; - mode = meters.${m}; - } else m; - + }); meterType = types.submodule { options = { @@ -295,10 +291,10 @@ in home.packages = [ pkgs.htop ]; home.file.".config/htop/htoprc".text = let - leftMeters = map (m: (meterStandard m).kind) cfg.meters.left; - leftModes = map (m: (meterStandard m).mode) cfg.meters.left; - rightMeters = map (m: (meterStandard m).kind) cfg.meters.right; - rightModes = map (m: (meterStandard m).mode) cfg.meters.right; + leftMeters = map (m: m.kind) cfg.meters.left; + leftModes = map (m: m.mode) cfg.meters.left; + rightMeters = map (m: m.kind) cfg.meters.right; + rightModes = map (m: m.mode) cfg.meters.right; in '' # This file is regenerated by home-manager # when options are changed in the config -- cgit v1.2.3 From cde8e02bf268f86c5ec894a088b2bb5f03b9f59d Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Tue, 15 Aug 2017 13:54:33 +0200 Subject: zsh: add module --- modules/default.nix | 1 + modules/home-environment.nix | 2 +- modules/programs/zsh.nix | 102 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 modules/programs/zsh.nix diff --git a/modules/default.nix b/modules/default.nix index 0b163c7d282..4206fa9389c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -26,6 +26,7 @@ let ./programs/lesspipe.nix ./programs/ssh.nix ./programs/texlive.nix + ./programs/zsh.nix ./services/dunst.nix ./services/gnome-keyring.nix ./services/gpg-agent.nix diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 6596a1162c9..bd2fb6ffa22 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -165,7 +165,7 @@ in home.sessionVariableSetter = mkOption { default = "bash"; - type = types.enum [ "pam" "bash" ]; + type = types.enum [ "pam" "bash" "zsh" ]; example = "pam"; description = '' Identifies the module that should set the session variables. diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix new file mode 100644 index 00000000000..b0c528e573e --- /dev/null +++ b/modules/programs/zsh.nix @@ -0,0 +1,102 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.zsh; + +in + +{ + options = { + programs.zsh = { + enable = mkEnableOption "Z shell (Zsh)"; + + historySize = mkOption { + type = types.int; + default = 10000; + description = "Number of history lines to keep."; + }; + + shellAliases = mkOption { + default = {}; + example = { ll = "ls -l"; ".." = "cd .."; }; + description = '' + An attribute set that maps aliases (the top level attribute names in + this option) to command strings or directly to build outputs. + ''; + type = types.attrs; + }; + + enableCompletion = mkOption { + default = true; + description = '' + Enable zsh completion. + ''; + type = types.bool; + }; + + enableAutosuggestions = mkOption { + default = false; + description = '' + Enable zsh autosuggestions + ''; + }; + + profileExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zprofile."; + }; + + initExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zshrc."; + }; + }; + }; + + config = ( + let + aliasesStr = concatStringsSep "\n" ( + mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + ); + + export = n: v: "export ${n}=\"${toString v}\""; + exportIfNonNull = n: v: optionalString (v != null) (export n v); + exportIfNonEmpty = n: v: optionalString (v != "") (export n v); + + histControlStr = concatStringsSep ":" cfg.historyControl; + histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; + + envVarsStr = concatStringsSep "\n" ( + mapAttrsToList export config.home.sessionVariables + ); + in mkIf cfg.enable { + home.packages = [ pkgs.zsh ] + ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; + + home.file.".zprofile".text = '' + ${optionalString (config.home.sessionVariableSetter == "zsh") + envVarsStr} + + ${cfg.profileExtra} + ''; + + home.file.".zshrc".text = '' + ${export "HISTSIZE" cfg.historySize} + + ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} + ${optionalString (cfg.enableAutosuggestions) + "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" + } + + ${aliasesStr} + + ${cfg.initExtra} + ''; + } + ); +} -- cgit v1.2.3 From 3ef56576d35d2ba245295443c4998cb51ea3e87b Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 16 Aug 2017 14:15:53 +0200 Subject: oh-my-zsh: add module --- modules/default.nix | 1 + modules/programs/oh-my-zsh.nix | 63 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 modules/programs/oh-my-zsh.nix diff --git a/modules/default.nix b/modules/default.nix index 4206fa9389c..aae9b2d50a3 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -24,6 +24,7 @@ let ./programs/htop.nix ./programs/info.nix ./programs/lesspipe.nix + ./programs/oh-my-zsh.nix ./programs/ssh.nix ./programs/texlive.nix ./programs/zsh.nix diff --git a/modules/programs/oh-my-zsh.nix b/modules/programs/oh-my-zsh.nix new file mode 100644 index 00000000000..654c68e1be5 --- /dev/null +++ b/modules/programs/oh-my-zsh.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.zsh.oh-my-zsh; + +in + +{ + options = { + programs.zsh.oh-my-zsh = { + enable = mkEnableOption "oh-my-zsh"; + + plugins = mkOption { + default = []; + example = [ "git" "sudo" ]; + type = types.listOf types.str; + description = '' + List of oh-my-zsh plugins + ''; + }; + + custom = mkOption { + default = ""; + type = types.str; + example = "$HOME/my_customizations"; + description = '' + Path to a custom oh-my-zsh package to override config of oh-my-zsh. + See: https://github.com/robbyrussell/oh-my-zsh/wiki/Customization + ''; + }; + + theme = mkOption { + default = ""; + example = "robbyrussell"; + type = types.str; + description = '' + Name of the theme to be used by oh-my-zsh. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.oh-my-zsh ]; + programs.zsh.initExtra = with pkgs; '' + # oh-my-zsh configuration generated by NixOS + export ZSH=${oh-my-zsh}/share/oh-my-zsh + ${optionalString (cfg.plugins != []) + "plugins=(${concatStringsSep " " cfg.plugins})" + } + ${optionalString (cfg.custom != "") + "ZSH_CUSTOM=\"${cfg.custom}\"" + } + ${optionalString (cfg.theme != "") + "ZSH_THEME=\"${cfg.theme}\"" + } + source $ZSH/oh-my-zsh.sh + ''; + }; +} -- cgit v1.2.3 From ffbc7e723d78f479256828102c9eb367831982f1 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:27 +0200 Subject: home-manager: add config file attribute --- home-manager/default.nix | 8 ++++++-- home-manager/home-manager | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index b2c137b0684..979f9aa8040 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -9,11 +9,15 @@ let homeManagerExpr = pkgs.writeText "home-manager.nix" '' - { pkgs ? import {}, confPath }: + { pkgs ? import {}, confPath, confAttr }: let env = import { - configuration = import confPath; + configuration = + let + conf = import confPath; + in + if confAttr == "" then conf else conf.''${confAttr}; pkgs = pkgs; }; in diff --git a/home-manager/home-manager b/home-manager/home-manager index 6f8e4f60d83..d6d17053e25 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -82,6 +82,7 @@ function doBuild() { nix-build $extraArgs \ "@HOME_MANAGER_EXPR_PATH@" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ + --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ -A activation-script \ -o "$output" } @@ -121,6 +122,8 @@ function doHelp() { echo echo " -f FILE The home configuration file." echo " Default is '~/.config/nixpkgs/home.nix'." + echo " -A ATTRIBUTE Optional attribute that selects a configuration" + echo " expression in the configuration file." echo " -I PATH Add a path to the Nix expression search path." echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" @@ -135,8 +138,9 @@ function doHelp() { } EXTRA_NIX_PATH=() +HOME_MANAGER_CONFIG_ATTRIBUTE="" -while getopts f:I:vnh opt; do +while getopts f:I:A:vnh opt; do case $opt in f) HOME_MANAGER_CONFIG="$OPTARG" @@ -144,6 +148,9 @@ while getopts f:I:vnh opt; do I) EXTRA_NIX_PATH+=("$OPTARG") ;; + A) + HOME_MANAGER_CONFIG_ATTRIBUTE="$OPTARG" + ;; v) export VERBOSE=1 ;; -- cgit v1.2.3 From a9d9fb5d75b57fd9932aeab957c6b938fb6e41a2 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:25 +0200 Subject: home-manager: exit with an error on build failure Because 'set -e' has no effect on commands that run in an if condition, the script was always exiting with no error when 'doBuild' failed. As a bonus, $wrkdir is now always removed after building. --- home-manager/home-manager | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index d6d17053e25..f599d9008d3 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -91,11 +91,13 @@ function doSwitch() { local wrkdir wrkdir="$(mktemp -d)" - if doBuild "$wrkdir/generation" ; then - "$wrkdir/generation/activate" - fi + local exitCode=0 + doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1 + # Because the previous command never fails, the script keeps running and + # $wrkdir is always removed. rm -r "$wrkdir" + return $exitCode } function doListGens() { -- cgit v1.2.3 From 02a501705a11f14ddc21a215c01ed3c1c16a007c Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:26 +0200 Subject: home-manager: show full script path on activation error Run the activation script in its original nix-store location so that Bash error messages show the real script location instead of 'wrkdir', which gets deleted right after the script exits. --- home-manager/home-manager | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index f599d9008d3..45fe0e1cba6 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -91,8 +91,9 @@ function doSwitch() { local wrkdir wrkdir="$(mktemp -d)" + local generation local exitCode=0 - doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1 + generation=$(doBuild "$wrkdir/result") && $generation/activate || exitCode=1 # Because the previous command never fails, the script keeps running and # $wrkdir is always removed. -- cgit v1.2.3 From 910cdc0537d7ed3482a77e89756de36ddfccd300 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 21 Aug 2017 14:13:03 +0200 Subject: zsh: use .zshenv for env vars --- modules/programs/zsh.nix | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index b0c528e573e..34c93963c5a 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -44,12 +44,6 @@ in ''; }; - profileExtra = mkOption { - default = ""; - type = types.lines; - description = "Extra commands that should be added to .zprofile."; - }; - initExtra = mkOption { default = ""; type = types.lines; @@ -78,11 +72,9 @@ in home.packages = [ pkgs.zsh ] ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; - home.file.".zprofile".text = '' + home.file.".zshenv".text = '' ${optionalString (config.home.sessionVariableSetter == "zsh") envVarsStr} - - ${cfg.profileExtra} ''; home.file.".zshrc".text = '' -- cgit v1.2.3 From da5b7bea788cef236785d7d3b9b88c5df7dd0a66 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Sat, 19 Aug 2017 09:49:05 +0200 Subject: home-environment: fix error when deleting empty directories With --ignore-fail-on-non-empty, non-emptiness is the only failure that gets ignored by rmdir. In the case that rmdir reaches $HOME and considers deleting it, it will detect insufficient permissions and subsequently exit with an error, even if $HOME is not empty. Prevent this by calling rmdir with a relative path that excludes $HOME. --- modules/home-environment.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index bd2fb6ffa22..e88ea95d433 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -315,16 +315,20 @@ in else echo "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" - targetDir="$(dirname "$targetPath")" - # Recursively remove the containing directory. We only - # do this if the containing folder is not $HOME since - # running rmdir on $HOME will result in a harmless but - # unpleasant error message. - if [[ "$targetDir" != "$HOME" ]] ; then + # Recursively delete empty parent directories. + targetDir="$(dirname "$relativePath")" + if [[ "$targetDir" != "." ]] ; then + pushd "$HOME" > /dev/null + + # Call rmdir with a relative path excluding $HOME. + # Otherwise, it might try to delete $HOME and exit + # with a permission error. $DRY_RUN_CMD rmdir $VERBOSE_ARG \ -p --ignore-fail-on-non-empty \ "$targetDir" + + popd > /dev/null fi fi done -- cgit v1.2.3 From 1eee82272a78a2110050768575eb0c6fdbccec4a Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:28 +0200 Subject: home-environment: only notify about path deletion on verbose output --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index e88ea95d433..f9dd55418b3 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -313,7 +313,7 @@ in elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." else - echo "Checking $targetPath gone (deleting)" + $VERBOSE_ECHO "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" # Recursively delete empty parent directories. -- cgit v1.2.3 From 3dba6fc95c2f3a3a34ffaf674c36191ba559cf1a Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:29 +0200 Subject: home-environment: replace superfluous spaces in debug messages --- modules/home-environment.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index f9dd55418b3..50401e0f0fb 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -309,11 +309,11 @@ in relativePath="''${sourcePath#$oldGenFiles/}" targetPath="$HOME/$relativePath" if [[ -e "$newGenFiles/$relativePath" ]] ; then - $VERBOSE_ECHO "Checking $targetPath exists" + $VERBOSE_ECHO "Checking $targetPath: exists" elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." else - $VERBOSE_ECHO "Checking $targetPath gone (deleting)" + $VERBOSE_ECHO "Checking $targetPath: gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" # Recursively delete empty parent directories. -- cgit v1.2.3 From 5c098dc7ad2e8584b8799fd14dc79a40b86bae07 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:30 +0200 Subject: lib-bash: always print message announcing a dry run --- modules/lib-bash/activation-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index a7011b9c247..1239e18e2a6 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -39,7 +39,7 @@ else fi if [[ -v DRY_RUN ]] ; then - $VERBOSE_ECHO "This is a dry run" + echo "This is a dry run" export DRY_RUN_CMD=echo else $VERBOSE_ECHO "This is a live run" -- cgit v1.2.3 From 42f5d4404d9b938f13016cb2ba0851a9154bb4b3 Mon Sep 17 00:00:00 2001 From: Richard Yang Date: Tue, 22 Aug 2017 04:43:03 +0000 Subject: home-environment: use relative latest profile link Using a relative path prevents the latest version from being garbage collected. --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 50401e0f0fb..12317e36ec4 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -359,7 +359,7 @@ in if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then echo "Creating profile generation $newGenNum" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" - $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG $(basename "$newGenProfilePath") "$genProfilePath" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" else echo "No change so reusing latest profile generation $oldGenNum" -- cgit v1.2.3 From 42ae135d38bfeae8a5fdd5f80dbc2b1aec54d177 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 21 Aug 2017 15:01:36 +0200 Subject: gpg-agent: add zsh support --- modules/services/gpg-agent.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 1d015397c5c..03affd217f9 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -6,6 +6,12 @@ let cfg = config.services.gpg-agent; + gpgInitStr = '' + GPG_TTY="$(tty)" + export GPG_TTY + gpg-connect-agent updatestartuptty /bye > /dev/null + ''; + in { @@ -44,11 +50,8 @@ in SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"; }; - programs.bash.initExtra = '' - GPG_TTY="$(tty)" - export GPG_TTY - gpg-connect-agent updatestartuptty /bye > /dev/null - ''; + programs.bash.initExtra = gpgInitStr; + programs.zsh.initExtra = gpgInitStr; } # The systemd units below are direct translations of the -- cgit v1.2.3 From 286d67878503cf05cb5d5d06660f59a1549ded09 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Wed, 23 Aug 2017 17:43:46 +0200 Subject: systemd: don't fail on activation when services changed The diff command exits with status 1 when detecting differences. Because of 'set -e', this caused the activation to fail. --- modules/systemd.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index edc89ab0c87..b68034b702c 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -147,7 +147,7 @@ in --old-line-format='-%L' \ --unchanged-line-format=' %L' \ "$oldServiceFiles" "$newServiceFiles" \ - > $servicesDiffFile + > $servicesDiffFile || true local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) -- cgit v1.2.3 From c3be4c462907df02ff71a7f5d5cb1c6c4413cf8d Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 23 Aug 2017 16:10:41 +0200 Subject: termite: add module --- modules/default.nix | 1 + modules/programs/termite.nix | 364 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 365 insertions(+) create mode 100644 modules/programs/termite.nix diff --git a/modules/default.nix b/modules/default.nix index aae9b2d50a3..111525bc5d6 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -26,6 +26,7 @@ let ./programs/lesspipe.nix ./programs/oh-my-zsh.nix ./programs/ssh.nix + ./programs/termite.nix ./programs/texlive.nix ./programs/zsh.nix ./services/dunst.nix diff --git a/modules/programs/termite.nix b/modules/programs/termite.nix new file mode 100644 index 00000000000..1e4ee671cde --- /dev/null +++ b/modules/programs/termite.nix @@ -0,0 +1,364 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.termite; + +in + +{ + options = { + programs.termite = { + enable = mkEnableOption "Termite VTE-based terminal"; + + allowBold = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Allow the output of bold characters when the bold escape sequence appears. + ''; + }; + + audibleBell = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Have the terminal beep on the terminal bell."; + }; + + clickableUrl = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Auto-detected URLs can be clicked on to open them in your browser. + Only enabled if a browser is configured or detected. + ''; + }; + + dynamicTitle = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Settings dynamic title allows the terminal and the shell to + update the terminal's title. + ''; + }; + + fullscreen = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Enables entering fullscreen mode by pressing F11."; + }; + + mouseAutohide = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Automatically hide the mouse pointer when you start typing."; + }; + + scrollOnOutput = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Scroll to the bottom when the shell generates output."; + }; + + scrollOnKeystroke = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Scroll to the bottom automatically when a key is pressed."; + }; + + searchWrap = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Search from top again when you hit the bottom."; + }; + + urgentOnBell = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Sets the window as urgent on the terminal bell."; + }; + + font = mkOption { + default = null; + example = "Monospace 12"; + type = types.nullOr types.str; + description = "The font description for the terminal's font."; + }; + + geometry = mkOption { + default = null; + example = "640x480"; + type = types.nullOr types.str; + description = "The default window geometry for new terminal windows."; + }; + + iconName = mkOption { + default = null; + example = "terminal"; + type = types.nullOr types.str; + description = "The name of the icon to be used for the terminal process."; + }; + + scrollbackLines = mkOption { + default = null; + example = 10000; + type = types.nullOr types.int; + description = "Set the number of lines to limit the terminal's scrollback."; + }; + + browser = mkOption { + default = null; + type = types.nullOr types.str; + example = "${pkgs.xdg_utils}/xdg-open"; + description = '' + Set the default browser for opening links. If its not set, $BROWSER is read. + If that's not set, url hints will be disabled. + ''; + }; + + cursorBlink = mkOption { + default = null; + example = "system"; + type = types.nullOr (types.enum [ "system" "on" "off" ]); + description = '' + Specify the how the terminal's cursor should behave. + Accepts system to respect the gtk global configuration, + on and off to explicitly enable or disable them. + ''; + }; + + cursorShape = mkOption { + default = null; + example = "block"; + type = types.nullOr (types.enum [ "block" "underline" "ibeam" ]); + description = '' + Specify how the cursor should look. Accepts block, ibeam and underline. + ''; + }; + + filterUnmatchedUrls = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Whether to hide url hints not matching input in url hints mode."; + }; + + modifyOtherKeys = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Emit escape sequences for extra keys, + like the modifyOtherKeys resource for xterm(1). + ''; + }; + + sizeHints = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Enable size hints. Locks the terminal resizing + to increments of the terminal's cell size. + Requires a window manager that respects scroll hints. + ''; + }; + + scrollbar = mkOption { + default = null; + type = types.nullOr (types.enum [ "off" "left" "right" ]); + description = "Scroll to the bottom when the shell generates output."; + }; + + backgroundColor = mkOption { + default = null; + example = "rgba(63, 63, 63, 0.8)"; + type = types.nullOr types.str; + description = "Background color value."; + }; + + cursorColor = mkOption { + default = null; + example = "#dcdccc"; + type = types.nullOr types.str; + description = "Cursor color value."; + }; + + cursorForegroundColor = mkOption { + default = null; + example = "#dcdccc"; + type = types.nullOr types.str; + description = "Cursor foreground color value."; + }; + + foregroundColor = mkOption { + default = null; + example = "#dcdccc"; + type = types.nullOr types.str; + description = "Foreground color value."; + }; + + foregroundBoldColor = mkOption { + default = null; + example = "#ffffff"; + type = types.nullOr types.str; + description = "Foreground bold color value."; + }; + + highlightColor = mkOption { + default = null; + example = "#2f2f2f"; + type = types.nullOr types.str; + description = "highlight color value."; + }; + + hintsActiveBackgroundColor = mkOption { + default = null; + example = "#3f3f3f"; + type = types.nullOr types.str; + description = "Hints active background color value."; + }; + + hintsActiveForegroundColor = mkOption { + default = null; + example = "#e68080"; + type = types.nullOr types.str; + description = "Hints active foreground color value."; + }; + + hintsBackgroundColor = mkOption { + default = null; + example = "#3f3f3f"; + type = types.nullOr types.str; + description = "Hints background color value."; + }; + + hintsForegroundColor = mkOption { + default = null; + example = "#dcdccc"; + type = types.nullOr types.str; + description = "Hints foreground color value."; + }; + + hintsBorderColor = mkOption { + default = null; + example = "#3f3f3f"; + type = types.nullOr types.str; + description = "Hints border color value."; + }; + + hintsBorderWidth = mkOption { + default = null; + example = "0.5"; + type = types.nullOr types.str; + description = "Hints border width."; + }; + + hintsFont = mkOption { + default = null; + example = "Monospace 12"; + type = types.nullOr types.str; + description = "The font description for the hints font."; + }; + + hintsPadding = mkOption { + default = null; + example = 2; + type = types.nullOr types.int; + description = "Hints padding."; + }; + + hintsRoundness = mkOption { + default = null; + example = "0.2"; + type = types.nullOr types.str; + description = "Hints roundness."; + }; + + optionsExtra = mkOption { + default = ""; + example = "fullscreen = true"; + type = types.lines; + description = "Extra options that should be added to [options] section."; + }; + + colorsExtra = mkOption { + default = ""; + example = '' + color0 = #3f3f3f + color1 = #705050 + color2 = #60b48a + ''; + type = types.lines; + description = "Extra colors options that should be added to [colors] section."; + }; + + hintsExtra = mkOption { + default = ""; + example = "border = #3f3f3f"; + type = types.lines; + description = "Extra hints options that should be added to [hints] section."; + }; + }; + }; + + config = ( + let + boolToString = v: if v then "true" else "false"; + optionalBoolean = name: val: lib.optionalString (val != null) "${name} = ${boolToString val}"; + optionalInteger = name: val: lib.optionalString (val != null) "${name} = ${toString val}"; + optionalString = name: val: lib.optionalString (val != null) "${name} = ${val}"; + in mkIf cfg.enable { + home.packages = [ pkgs.termite ]; + home.file.".config/termite/config".text = '' + [options] + ${optionalBoolean "allow_bold" cfg.allowBold} + ${optionalBoolean "audible_bell" cfg.audibleBell} + ${optionalString "browser" cfg.browser} + ${optionalBoolean "clickable_url" cfg.clickableUrl} + ${optionalString "cursor_blink" cfg.cursorBlink} + ${optionalString "cursor_shape" cfg.cursorShape} + ${optionalBoolean "dynamic_title" cfg.dynamicTitle} + ${optionalBoolean "filter_unmatched_urls" cfg.filterUnmatchedUrls} + ${optionalString "font" cfg.font} + ${optionalBoolean "fullscreen" cfg.fullscreen} + ${optionalString "geometry" cfg.geometry} + ${optionalString "icon_name" cfg.iconName} + ${optionalBoolean "modify_other_keys" cfg.modifyOtherKeys} + ${optionalBoolean "mouse_autohide" cfg.mouseAutohide} + ${optionalBoolean "scroll_on_keystroke" cfg.scrollOnKeystroke} + ${optionalBoolean "scroll_on_output" cfg.scrollOnOutput} + ${optionalInteger "scrollback_lines" cfg.scrollbackLines} + ${optionalString "scrollbar" cfg.scrollbar} + ${optionalBoolean "search_wrap" cfg.searchWrap} + ${optionalBoolean "size_hints" cfg.sizeHints} + ${optionalBoolean "urgent_on_bell" cfg.urgentOnBell} + + ${cfg.optionsExtra} + + [colors] + ${optionalString "background" cfg.backgroundColor} + ${optionalString "cursor" cfg.cursorColor} + ${optionalString "cursor_foreground" cfg.cursorForegroundColor} + ${optionalString "foreground" cfg.foregroundColor} + ${optionalString "foregroundBold" cfg.foregroundBoldColor} + ${optionalString "highlight" cfg.highlightColor} + + ${cfg.colorsExtra} + + [hints] + ${optionalString "active_background" cfg.hintsActiveBackgroundColor} + ${optionalString "active_foreground" cfg.hintsActiveForegroundColor} + ${optionalString "background" cfg.hintsBackgroundColor} + ${optionalString "border" cfg.hintsBorderColor} + ${optionalInteger "border_width" cfg.hintsBorderWidth} + ${optionalString "font" cfg.hintsFont} + ${optionalString "foreground" cfg.hintsForegroundColor} + ${optionalInteger "padding" cfg.hintsPadding} + ${optionalInteger "roundness" cfg.hintsRoundness} + + ${cfg.hintsExtra} + ''; + } + ); +} -- cgit v1.2.3 From fed112e497323ddb089aad79ab85a9a60a503942 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 24 Aug 2017 01:03:01 +0200 Subject: git: simplify submodule slightly --- modules/programs/git.nix | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index fae933d7ea6..eeab16abd77 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -8,29 +8,27 @@ let toINI = (import ../lib/generators.nix).toINI {}; - signModule = types.submodule ( - { ... }: { - options = { - key = mkOption { - type = types.str; - description = "The default GPG signing key fingerprint."; - }; + signModule = types.submodule { + options = { + key = mkOption { + type = types.str; + description = "The default GPG signing key fingerprint."; + }; - signByDefault = mkOption { - type = types.bool; - default = false; - description = "Whether commits should be signed by default."; - }; + signByDefault = mkOption { + type = types.bool; + default = false; + description = "Whether commits should be signed by default."; + }; - gpgPath = mkOption { - type = types.str; - default = "${pkgs.gnupg}/bin/gpg2"; - defaultText = "\${pkgs.gnupg}/bin/gpg2"; - description = "Path to GnuPG binary to use."; - }; + gpgPath = mkOption { + type = types.str; + default = "${pkgs.gnupg}/bin/gpg2"; + defaultText = "\${pkgs.gnupg}/bin/gpg2"; + description = "Path to GnuPG binary to use."; }; - } - ); + }; + }; in -- cgit v1.2.3 From bd914d49f1b87fca43ae37ff1beb3ca5e24624b3 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 23 Aug 2017 12:51:54 +0200 Subject: zsh: add history submodule --- modules/programs/zsh.nix | 63 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 34c93963c5a..8526c71dcc9 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -6,6 +6,37 @@ let cfg = config.programs.zsh; + historyModule = types.submodule { + options = { + size = mkOption { + type = types.int; + default = 10000; + description = "Number of history lines to keep."; + }; + + path = mkOption { + type = types.str; + default = "$HOME/.zsh_history"; + description = "History file location"; + }; + + ignoreDups = mkOption { + type = types.bool; + default = true; + description = '' + Do not enter command lines into the history list + if they are duplicates of the previous event. + ''; + }; + + share = mkOption { + type = types.bool; + default = true; + description = "Share command history between zsh sessions."; + }; + }; + }; + in { @@ -13,12 +44,6 @@ in programs.zsh = { enable = mkEnableOption "Z shell (Zsh)"; - historySize = mkOption { - type = types.int; - default = 10000; - description = "Number of history lines to keep."; - }; - shellAliases = mkOption { default = {}; example = { ll = "ls -l"; ".." = "cd .."; }; @@ -31,17 +56,19 @@ in enableCompletion = mkOption { default = true; - description = '' - Enable zsh completion. - ''; + description = "Enable zsh completion."; type = types.bool; }; enableAutosuggestions = mkOption { default = false; - description = '' - Enable zsh autosuggestions - ''; + description = "Enable zsh autosuggestions"; + }; + + history = mkOption { + type = historyModule; + default = {}; + description = "Options related to commands history configuration."; }; initExtra = mkOption { @@ -59,11 +86,6 @@ in ); export = n: v: "export ${n}=\"${toString v}\""; - exportIfNonNull = n: v: optionalString (v != null) (export n v); - exportIfNonEmpty = n: v: optionalString (v != "") (export n v); - - histControlStr = concatStringsSep ":" cfg.historyControl; - histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; envVarsStr = concatStringsSep "\n" ( mapAttrsToList export config.home.sessionVariables @@ -78,7 +100,12 @@ in ''; home.file.".zshrc".text = '' - ${export "HISTSIZE" cfg.historySize} + ${export "HISTSIZE" cfg.history.size} + ${export "HISTFILE" cfg.history.path} + + setopt HIST_FCNTL_LOCK + ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS + ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} ${optionalString (cfg.enableAutosuggestions) -- cgit v1.2.3 From 7218c4544328176afe897ccce88960ad289872de Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 23 Aug 2017 13:05:49 +0200 Subject: zsh: add completions to fpath --- modules/programs/zsh.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 8526c71dcc9..b8f203ee916 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -107,6 +107,11 @@ in ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY + # Tell zsh how to find installed completions + for p in ''${(z)NIX_PROFILES}; do + fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions) + done + ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} ${optionalString (cfg.enableAutosuggestions) "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" -- cgit v1.2.3 From 1678548353ec2aaa59e4fd57ca5019c3b3057d64 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 23 Aug 2017 13:06:19 +0200 Subject: zsh: set HELPDIR --- modules/programs/zsh.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index b8f203ee916..32f30aaf9df 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -112,6 +112,8 @@ in fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions) done + HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" + ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} ${optionalString (cfg.enableAutosuggestions) "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" -- cgit v1.2.3 From a30751464acd50a47a40da66de486d851762f63f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 26 Aug 2017 12:10:14 +0200 Subject: info: use XDG_CACHE_HOME if defined --- modules/programs/info.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 65f1e3a092e..3042331c937 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -42,7 +42,7 @@ in enable = mkEnableOption "GNU Info"; homeInfoDirLocation = mkOption { - default = "$HOME/.cache/info"; + default = "\${XDG_CACHE_HOME:-$HOME/.cache}/info"; description = '' Directory in which to store the info dir file within your home. -- cgit v1.2.3 From 85a71a3923cdf1b482c8a1d5b617e017dbefc974 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 23 Aug 2017 12:53:41 +0200 Subject: oh-my-zsh: set `ZSH_CACHE_DIR` --- modules/programs/oh-my-zsh.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/programs/oh-my-zsh.nix b/modules/programs/oh-my-zsh.nix index 654c68e1be5..fc2692a3246 100644 --- a/modules/programs/oh-my-zsh.nix +++ b/modules/programs/oh-my-zsh.nix @@ -45,9 +45,12 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.oh-my-zsh ]; + programs.zsh.initExtra = with pkgs; '' # oh-my-zsh configuration generated by NixOS export ZSH=${oh-my-zsh}/share/oh-my-zsh + export ZSH_CACHE_DIR=''${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh + ${optionalString (cfg.plugins != []) "plugins=(${concatStringsSep " " cfg.plugins})" } -- cgit v1.2.3 From 3bcd9d747b102b825bdf218245652eb763045d6c Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 26 Aug 2017 16:00:55 +0200 Subject: owncloud-client: add module --- modules/default.nix | 1 + modules/services/owncloud-client.nix | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 modules/services/owncloud-client.nix diff --git a/modules/default.nix b/modules/default.nix index 111525bc5d6..a3ecb41c7a7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -34,6 +34,7 @@ let ./services/gpg-agent.nix ./services/keepassx.nix ./services/network-manager-applet.nix + ./services/owncloud-client.nix ./services/random-background.nix ./services/redshift.nix ./services/syncthing.nix diff --git a/modules/services/owncloud-client.nix b/modules/services/owncloud-client.nix new file mode 100644 index 00000000000..e168ab11197 --- /dev/null +++ b/modules/services/owncloud-client.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.owncloud-client = { + enable = mkEnableOption "Owncloud Client"; + }; + }; + + config = mkIf config.services.owncloud-client.enable { + systemd.user.services.owncloud-client = { + Unit = { + Description = "Owncloud Client"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.owncloud-client}/bin/owncloud"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From e561beab449aebbf30bba34c2294f359c23cbc8d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 00:13:26 +0200 Subject: home-environment: include home path in generation directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Technically not necessary but it was a bit silly to leave out this important directory from the generation directory. This also makes it more convenient to browse the installed packages after a `home-manager build`. --- modules/home-environment.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 12317e36ec4..5db2fbd6f42 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -439,6 +439,7 @@ in --subst-var-by GENERATION_DIR $out ln -s ${home-files} $out/home-files + ln -s ${cfg.path} $out/home-path ''; }; -- cgit v1.2.3 From 2245b0ac94978c259bb054b49f0e45433af411c4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 12:55:30 +0200 Subject: home-manager: simplify use of nix-build output There is no need to specify an out link when switching to a new generation since nix-build prints the store path on standard output. Similarly, when just building a generation we specify no out link since nix-build will use "result" by default. --- home-manager/home-manager | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 45fe0e1cba6..1874143ad91 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -49,27 +49,11 @@ function setHomeManagerModulesPath() { } function doBuild() { - if [[ -z "$1" ]]; then - echo "Need to provide generation output path." - exit 1 - fi - - if [[ -e "$1" ]]; then - echo "The output path $1 already exists." - exit 1 - fi - setConfigFile setHomeManagerModulesPath - output="$(realpath "$1")" - - if [[ $? -ne 0 ]]; then - exit 1 - fi - local extraArgs - extraArgs="" + extraArgs="$1" for p in "${EXTRA_NIX_PATH[@]}"; do extraArgs="$extraArgs -I $p" @@ -83,21 +67,15 @@ function doBuild() { "@HOME_MANAGER_EXPR_PATH@" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ - -A activation-script \ - -o "$output" + -A activation-script } function doSwitch() { - local wrkdir - wrkdir="$(mktemp -d)" - local generation local exitCode=0 - generation=$(doBuild "$wrkdir/result") && $generation/activate || exitCode=1 - # Because the previous command never fails, the script keeps running and - # $wrkdir is always removed. - rm -r "$wrkdir" + generation=$(doBuild "--no-out-link") && $generation/activate || exitCode=1 + return $exitCode } @@ -179,7 +157,7 @@ cmd="$*" case "$cmd" in build) - doBuild "result" + doBuild "" ;; switch) doSwitch -- cgit v1.2.3 From b4fff6b9b7c393ee588e52caf3a6d685852d9c04 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 13:04:39 +0200 Subject: home-manager: minor attribute rename The "activation-script" attribute doesn't actually point directly at the activation script. Renamed the attribute to be more descriptive. --- home-manager/default.nix | 2 +- home-manager/home-manager | 2 +- modules/default.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index 979f9aa8040..e517ee9ec8f 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -22,7 +22,7 @@ let }; in { - inherit (env) activation-script; + inherit (env) activationPackage; } ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index 1874143ad91..78b9749be09 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -67,7 +67,7 @@ function doBuild() { "@HOME_MANAGER_EXPR_PATH@" \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ - -A activation-script + -A activationPackage } function doSwitch() { diff --git a/modules/default.nix b/modules/default.nix index a3ecb41c7a7..67955aa1b6c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -83,6 +83,6 @@ in { inherit (module) options config; - activation-script = module.config.home.activationPackage; + activationPackage = module.config.home.activationPackage; home-path = module.config.home.path; } -- cgit v1.2.3 From 4a17d8ef970b7ab9cf99100d06f6734af3ea64cd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 13:13:43 +0200 Subject: home-manager: remove unused attribute --- modules/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/default.nix b/modules/default.nix index 67955aa1b6c..c79799b9a55 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -84,5 +84,4 @@ in inherit (module) options config; activationPackage = module.config.home.activationPackage; - home-path = module.config.home.path; } -- cgit v1.2.3 From 1445673e18a76c4477e57f46236c8c9e0eb5f3d4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 17:13:06 +0200 Subject: home-manager: temporarily re-add attribute --- modules/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/default.nix b/modules/default.nix index c79799b9a55..dd9a82bdbe7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -84,4 +84,5 @@ in inherit (module) options config; activationPackage = module.config.home.activationPackage; + activation-script = module.config.home.activationPackage; } -- cgit v1.2.3 From 125deafc8440fbfa5a6d8aa51207e24a1241384e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 27 Aug 2017 17:44:00 +0200 Subject: home-manager: add explanatory comment --- modules/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/default.nix b/modules/default.nix index dd9a82bdbe7..31451d6f8d4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -84,5 +84,7 @@ in inherit (module) options config; activationPackage = module.config.home.activationPackage; + + # For backwards compatibility. Please use activationPackage instead. activation-script = module.config.home.activationPackage; } -- cgit v1.2.3 From e9ca4305a6bf8727f347c57b65883d2e1e1a5070 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 28 Aug 2017 11:37:34 +0200 Subject: home-manager: move Nix code to own file --- home-manager/default.nix | 20 +------------------- home-manager/home-manager.nix | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 home-manager/home-manager.nix diff --git a/home-manager/default.nix b/home-manager/default.nix index e517ee9ec8f..a5853961792 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -8,24 +8,6 @@ let - homeManagerExpr = pkgs.writeText "home-manager.nix" '' - { pkgs ? import {}, confPath, confAttr }: - - let - env = import { - configuration = - let - conf = import confPath; - in - if confAttr == "" then conf else conf.''${confAttr}; - pkgs = pkgs; - }; - in - { - inherit (env) activationPackage; - } - ''; - modulesPathStr = if modulesPath == null then "" else modulesPath; in @@ -42,7 +24,7 @@ pkgs.stdenv.mkDerivation { --subst-var-by bash "${pkgs.bash}" \ --subst-var-by coreutils "${pkgs.coreutils}" \ --subst-var-by MODULES_PATH '${modulesPathStr}' \ - --subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}" + --subst-var-by HOME_MANAGER_EXPR_PATH "${./home-manager.nix}" ''; meta = with pkgs.stdenv.lib; { diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix new file mode 100644 index 00000000000..34ce49ace3f --- /dev/null +++ b/home-manager/home-manager.nix @@ -0,0 +1,15 @@ +{ pkgs ? import {}, confPath, confAttr }: + +let + env = import { + configuration = + let + conf = import confPath; + in + if confAttr == "" then conf else conf.''${confAttr}; + pkgs = pkgs; + }; +in + { + inherit (env) activationPackage; + } -- cgit v1.2.3 From 5eff7f38df0c4f8708db16260bc447306ca42d63 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 28 Aug 2017 15:23:45 +0200 Subject: home-manager: remove escaping The Nix code that was extracted to its own file erroneously included escaping of "${". --- home-manager/home-manager.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix index 34ce49ace3f..f356b5a0c02 100644 --- a/home-manager/home-manager.nix +++ b/home-manager/home-manager.nix @@ -6,7 +6,7 @@ let let conf = import confPath; in - if confAttr == "" then conf else conf.''${confAttr}; + if confAttr == "" then conf else conf.${confAttr}; pkgs = pkgs; }; in -- cgit v1.2.3 From 2c5151726c508173a08981055b112635e6f0bc57 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 28 Aug 2017 16:33:22 +0200 Subject: vim: add module --- modules/default.nix | 1 + modules/programs/vim.nix | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 modules/programs/vim.nix diff --git a/modules/default.nix b/modules/default.nix index 31451d6f8d4..f180423bd08 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -28,6 +28,7 @@ let ./programs/ssh.nix ./programs/termite.nix ./programs/texlive.nix + ./programs/vim.nix ./programs/zsh.nix ./services/dunst.nix ./services/gnome-keyring.nix diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix new file mode 100644 index 00000000000..e019751a309 --- /dev/null +++ b/modules/programs/vim.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.vim; + defaultPlugins = [ "sensible" ]; + +in + +{ + options = { + programs.vim = { + enable = mkEnableOption "Vim"; + + lineNumbers = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether to show line numbers."; + }; + + tabSize = mkOption { + type = types.nullOr types.int; + default = null; + example = 4; + description = "Set tab size and shift width to a specified number of spaces."; + }; + + plugins = mkOption { + type = types.listOf types.str; + default = defaultPlugins; + example = [ "YankRing" ]; + description = '' + List of vim plugins to install. + For supported plugins see: https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/vim-plugins/vim-plugin-names + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + set nocompatible + set nobackup + ''; + description = "Custom .vimrc lines"; + }; + }; + }; + + config = ( + let + optionalBoolean = name: val: optionalString (val != null) (if val then "set ${name}" else "unset ${name}"); + optionalInteger = name: val: optionalString (val != null) "set ${name}=${toString val}"; + customRC = '' + ${optionalBoolean "number" cfg.lineNumbers} + ${optionalInteger "tabstop" cfg.tabSize} + ${optionalInteger "shiftwidth" cfg.tabSize} + + ${cfg.extraConfig} + ''; + + vim = pkgs.vim_configurable.customize { + name = "vim"; + vimrcConfig.customRC = customRC; + vimrcConfig.vam.knownPlugins = pkgs.vimPlugins; + vimrcConfig.vam.pluginDictionaries = [ + { names = defaultPlugins ++ cfg.plugins; } + ]; + }; + + in mkIf cfg.enable { + home.packages = [ vim ]; + } + ); +} -- cgit v1.2.3 From 6611c1609933316cd5e0d6785aa5ccb8b80deff6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 1 Sep 2017 10:24:01 +0200 Subject: home-manager: print errors to stderr --- home-manager/home-manager | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 78b9749be09..2fbf057f873 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -7,6 +7,10 @@ PATH=@coreutils@/bin:$PATH set -euo pipefail +function errorEcho() { + >&2 echo "$*" +} + # Attempts to set the HOME_MANAGER_CONFIG global variable. # # If no configuration file can be found then this function will print @@ -14,7 +18,7 @@ set -euo pipefail function setConfigFile() { if [[ -v HOME_MANAGER_CONFIG ]] ; then if [[ ! -e "$HOME_MANAGER_CONFIG" ]] ; then - echo "No configure file found at $HOME_MANAGER_CONFIG" + errorEcho "No configure file found at $HOME_MANAGER_CONFIG" exit 1 fi @@ -31,7 +35,7 @@ function setConfigFile() { fi done - echo "No configuration file found. " \ + errorEcho "No configuration file found." \ "Please create one at ~/.config/nixpkgs/home.nix" exit 1 } @@ -92,7 +96,7 @@ function doListPackages() { if [[ -n "$outPath" ]] ; then nix-store -q --references "$outPath" | sed 's/[^-]*-//' else - echo "No home-manager packages seem to be installed." + errorEcho "No home-manager packages seem to be installed." fi } @@ -143,7 +147,7 @@ while getopts f:I:A:vnh opt; do exit 0 ;; *) - echo "Unknown option -$OPTARG" >&2 + errorEcho "Unknown option -$OPTARG" doHelp >&2 exit 1 ;; @@ -172,7 +176,7 @@ case "$cmd" in doHelp ;; *) - echo "Unknown command: $cmd" + errorEcho "Unknown command: $cmd" doHelp >&2 exit 1 ;; -- cgit v1.2.3 From 721f924e151d5c2195ac55c5af39485023cb7b94 Mon Sep 17 00:00:00 2001 From: Jean Potier Date: Sun, 3 Sep 2017 18:24:26 +0200 Subject: zsh: remove search for installed completions 1. It slows down the initial start: it takes around 2s at first launch, and around 0.25s for the following launches; 2. It seems to be redundant since just installing zsh package gives working completions with correct $fpath set. --- modules/programs/zsh.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 32f30aaf9df..be9eb3c735f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -107,11 +107,6 @@ in ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY - # Tell zsh how to find installed completions - for p in ''${(z)NIX_PROFILES}; do - fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions) - done - HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} -- cgit v1.2.3 From f5289c546e82507537b42f7b26eba2731966cb60 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 4 Sep 2017 16:35:23 +0200 Subject: feh: add module --- modules/default.nix | 1 + modules/programs/feh.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 modules/programs/feh.nix diff --git a/modules/default.nix b/modules/default.nix index f180423bd08..a6dc6848fcd 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -17,6 +17,7 @@ let ./programs/browserpass.nix ./programs/eclipse.nix ./programs/emacs.nix + ./programs/feh.nix ./programs/firefox.nix ./programs/git.nix ./programs/gnome-terminal.nix diff --git a/modules/programs/feh.nix b/modules/programs/feh.nix new file mode 100644 index 00000000000..1ca83ca8121 --- /dev/null +++ b/modules/programs/feh.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.feh; + + disableBinding = func: key: func; + enableBinding = func: key: "${func} ${key}"; + +in + +{ + options.programs.feh = { + enable = mkEnableOption "feh - a fast and light image viewer"; + + keybindings = mkOption { + default = {}; + type = types.attrs; + example = { zoom_in = "plus"; zoom_out = "minus"; }; + description = '' + Set keybindings. + See for + default bindings and available commands. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.feh ]; + + home.file.".config/feh/keys".text = '' + # Disable default keybindings + ${concatStringsSep "\n" (mapAttrsToList disableBinding cfg.keybindings)} + + # Enable new keybindings + ${concatStringsSep "\n" (mapAttrsToList enableBinding cfg.keybindings)} + ''; + }; +} -- cgit v1.2.3 From 39fc16954b48ab2d59015c3615c71919e80bae7e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 4 Sep 2017 22:19:56 +0200 Subject: home-manager: make sure switch generation is GC root Using `--no-out-link` is convenient but it does not set up a GC root, so an unfortunately timed GC could remove the generation before activation completes. Many thanks to @nonsequitur for noting this problem. --- home-manager/home-manager | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 2fbf057f873..8e0bd40c2d5 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -77,8 +77,18 @@ function doBuild() { function doSwitch() { local generation local exitCode=0 - - generation=$(doBuild "--no-out-link") && $generation/activate || exitCode=1 + local wrkdir + + # Build the generation and run the activate script. Note, we + # specify an output link si that it is treated as a GC root. This + # prevents an unfortunately timed GC from removing the generation + # before activation completes. + wrkdir="$(mktemp -d)" + generation=$(doBuild "-o $wrkdir/result") && $generation/activate || exitCode=1 + + # Because the previous command never fails, the script keeps + # running and $wrkdir is always removed. + rm -r "$wrkdir" return $exitCode } -- cgit v1.2.3 From ab0338f6ae372ff6891a6df143fd753bcbb24f71 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 12 Jul 2017 00:35:59 +0200 Subject: news: add module This new module adds a "news" feature to Home Manager. See #52. Many thanks to @nonsequitur and @uvNikita for suggestions and improvements. --- modules/default.nix | 1 + modules/misc/news.nix | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 modules/misc/news.nix diff --git a/modules/default.nix b/modules/default.nix index a6dc6848fcd..7add9dc3b5a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -11,6 +11,7 @@ let ./home-environment.nix ./manual.nix ./misc/gtk.nix + ./misc/news.nix ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix new file mode 100644 index 00000000000..3bb9ce80ba8 --- /dev/null +++ b/modules/misc/news.nix @@ -0,0 +1,146 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.news; + + entryModule = types.submodule ({ config, ... }: { + options = { + id = mkOption { + internal = true; + type = types.str; + description = '' + A unique entry identifier. By default it is a base16 + formatted hash of the entry message. + ''; + }; + + time = mkOption { + internal = true; + type = types.str; + example = "2017-07-10T21:55:04+00:00"; + description = '' + News entry time stamp in ISO-8601 format. Must be in UTC + (ending in '+00:00'). + ''; + }; + + condition = mkOption { + internal = true; + default = true; + description = "Whether the news entry should be active."; + }; + + message = mkOption { + internal = true; + type = types.str; + description = "The news entry content."; + }; + }; + + config = { + id = mkDefault (builtins.hashString "sha256" config.message); + }; + }); + +in + +{ + options = { + news = { + display = mkOption { + type = types.enum [ "silent" "notify" "show" ]; + default = "notify"; + description = '' + How unread and relevant news should be presented when + running home-manager build and + home-manager switch. + + + + The options are + + + + silent + + + Do not print anything during build or switch. The + home-manager news command still + works for viewing the entries. + + + + + notify + + + The number of unread and relevant news entries will be + printed to standard output. The home-manager + news command can later be used to view the + entries. + + + + + show + + + A pager showing unread news entries is opened. + + + + + ''; + }; + + entries = mkOption { + internal = true; + type = types.listOf entryModule; + default = []; + description = "News entries."; + }; + }; + }; + + config = { + news.entries = [ + { + time = "2017-09-01T10:56:28+00:00"; + message = '' + Hello! This is a news entry and it represents an + experimental new feature of Home Manager. The idea is to + inform you when something of importance happens in Home + Manager or its modules. + + We will try to not disturb you about the same news more than + once so the next time you run + + home-manager switch + + or + + home-manager build + + it should not notify you about this text again. + + News items may be conditional and will then only show if the + condition holds, for example if they are relevant to your + configuration. + + If you want to see all relevant news then please use the + + home-manager news + + command. + + Since this is an experimental feature any positive or + negative feedback would be greatly appreciated. For example, + by commenting in https://git.io/v5BJL. + ''; + } + ]; + }; +} -- cgit v1.2.3 From 9c1b3735b402346533449efc741f191d6ef578dd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 26 Aug 2017 22:24:40 +0200 Subject: home-manager: add news sub-command This command allows the user to examine the news items generated by the news module. See #52. Many thanks to @nonsequitur and @uvNikita for suggestions and improvements. --- home-manager/default.nix | 1 + home-manager/home-manager | 121 +++++++++++++++++++++++++++++++++++++----- home-manager/home-manager.nix | 76 +++++++++++++++++++++++++- modules/default.nix | 10 ++++ 4 files changed, 195 insertions(+), 13 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index a5853961792..bb09886913a 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -23,6 +23,7 @@ pkgs.stdenv.mkDerivation { substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ --subst-var-by coreutils "${pkgs.coreutils}" \ + --subst-var-by less "${pkgs.less}" \ --subst-var-by MODULES_PATH '${modulesPathStr}' \ --subst-var-by HOME_MANAGER_EXPR_PATH "${./home-manager.nix}" ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index 8e0bd40c2d5..4722d41a2f8 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -3,12 +3,12 @@ # This code explicitly requires GNU Core Utilities and we therefore # need to ensure they are prioritized over any other similarly named # tools on the system. -PATH=@coreutils@/bin:$PATH +PATH=@coreutils@/bin:@less@/bin${PATH:+:}$PATH set -euo pipefail function errorEcho() { - >&2 echo "$*" + echo $* >&2 } # Attempts to set the HOME_MANAGER_CONFIG global variable. @@ -52,12 +52,11 @@ function setHomeManagerModulesPath() { done } -function doBuild() { +function doBuildAttr() { setConfigFile setHomeManagerModulesPath - local extraArgs - extraArgs="$1" + local extraArgs="$*" for p in "${EXTRA_NIX_PATH[@]}"; do extraArgs="$extraArgs -I $p" @@ -67,11 +66,53 @@ function doBuild() { extraArgs="$extraArgs --show-trace" fi - nix-build $extraArgs \ - "@HOME_MANAGER_EXPR_PATH@" \ - --argstr confPath "$HOME_MANAGER_CONFIG" \ - --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" \ - -A activationPackage + nix-build \ + "@HOME_MANAGER_EXPR_PATH@" \ + $extraArgs \ + --argstr confPath "$HOME_MANAGER_CONFIG" \ + --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" +} + +function presentNews() { + local infoFile + infoFile=$(doBuildNews -A newsInfo) || return 1 + + # shellcheck source=/dev/null + . "$infoFile" + + if [[ $newsNumUnread -eq 0 ]]; then + return + elif [[ "$newsDisplay" == "silent" ]]; then + return + elif [[ "$newsDisplay" == "notify" ]]; then + local msg + if [[ $newsNumUnread -eq 1 ]]; then + msg="There is an unread and relevant news item.\n" + msg+="Read it by running the command '$(basename "$0") news'." + else + msg="There are $newsNumUnread unread and relevant news items.\n" + msg+="Read them by running the command '$(basename "$0") news'." + fi + + # Not actually an error but here stdout is reserved for + # nix-build output. + errorEcho + errorEcho -e "$msg" + errorEcho + + if [[ -v DISPLAY ]] && type -P notify-send > /dev/null; then + notify-send "Home Manager" "$msg" + fi + elif [[ "$newsDisplay" == "show" ]]; then + doShowNews --unread + else + errorEcho "Unknown 'news.display' setting '$newsDisplay'." + fi +} + +function doBuild() { + doBuildAttr -A activationPackage + presentNews } function doSwitch() { @@ -84,12 +125,17 @@ function doSwitch() { # prevents an unfortunately timed GC from removing the generation # before activation completes. wrkdir="$(mktemp -d)" - generation=$(doBuild "-o $wrkdir/result") && $generation/activate || exitCode=1 + generation=$(doBuildAttr -o "$wrkdir/result" -A activationPackage) \ + && $generation/activate || exitCode=1 # Because the previous command never fails, the script keeps # running and $wrkdir is always removed. rm -r "$wrkdir" + if [[ $exitCode -eq 0 ]]; then + presentNews + fi + return $exitCode } @@ -110,6 +156,53 @@ function doListPackages() { fi } +function newsReadIdsFile() { + local dataDir="${XDG_DATA_HOME:-$HOME/.local/share}/home-manager" + local path="$dataDir/news-read-ids" + + # If the path doesn't exist then we should create it, otherwise + # Nix will error out when we attempt to use builtins.readFile. + if [[ ! -f "$path" ]]; then + mkdir -p "$dataDir" + touch "$path" + fi + + echo "$path" +} + +function doBuildNews() { + doBuildAttr "$*" \ + --no-out-link \ + --arg check false \ + --argstr newsReadIdsFile "$(newsReadIdsFile)" +} + +function doShowNews() { + local infoFile + infoFile=$(doBuildNews -A newsInfo) || return 1 + + # shellcheck source=/dev/null + . "$infoFile" + + case $1 in + --all) + ${PAGER:-less} "$newsFileAll" + ;; + --unread) + ${PAGER:-less} "$newsFileUnread" + ;; + *) + errorEcho "Unknown argument $1" + return 1 + esac + + if [[ -s "$newsUnreadIdsFile" ]]; then + local newsReadIdsFile + newsReadIdsFile="$(newsReadIdsFile)" + cat "$newsUnreadIdsFile" >> "$newsReadIdsFile" + fi +} + function doHelp() { echo "Usage: $0 [OPTION] COMMAND" echo @@ -130,6 +223,7 @@ function doHelp() { echo " switch Build and activate configuration" echo " generations List all home environment generations" echo " packages List all packages installed in home-manager-path" + echo " news Show news entries in a pager" } EXTRA_NIX_PATH=() @@ -171,7 +265,7 @@ cmd="$*" case "$cmd" in build) - doBuild "" + doBuild ;; switch) doSwitch @@ -182,6 +276,9 @@ case "$cmd" in packages) doListPackages ;; + news) + doShowNews --all + ;; help|--help) doHelp ;; diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix index f356b5a0c02..a6c9259f874 100644 --- a/home-manager/home-manager.nix +++ b/home-manager/home-manager.nix @@ -1,6 +1,14 @@ -{ pkgs ? import {}, confPath, confAttr }: +{ pkgs ? import {} +, confPath +, confAttr +, check ? true +, newsReadIdsFile ? null +}: + +with pkgs.lib; let + env = import { configuration = let @@ -8,8 +16,74 @@ let in if confAttr == "" then conf else conf.${confAttr}; pkgs = pkgs; + check = check; }; + + newsReadIds = + if newsReadIdsFile == null + then {} + else + let + ids = splitString "\n" (fileContents newsReadIdsFile); + in + builtins.listToAttrs (map (id: { name = id; value = null; }) ids); + + newsIsRead = entry: builtins.hasAttr entry.id newsReadIds; + + newsFiltered = + let + pred = entry: entry.condition && ! newsIsRead entry; + in + filter pred env.newsEntries; + + newsNumUnread = length newsFiltered; + + newsFileUnread = pkgs.writeText "news-unread.txt" ( + concatMapStringsSep "\n\n" (entry: + let + time = replaceStrings ["T"] [" "] (removeSuffix "+00:00" entry.time); + in + '' + * ${time} + + ${replaceStrings ["\n"] ["\n "] entry.message} + '' + ) newsFiltered + ); + + newsFileAll = pkgs.writeText "news-all.txt" ( + concatMapStringsSep "\n\n" (entry: + let + flag = if newsIsRead entry then "read" else "unread"; + time = replaceStrings ["T"] [" "] (removeSuffix "+00:00" entry.time); + in + '' + * ${time} [${flag}] + + ${replaceStrings ["\n"] ["\n "] entry.message} + '' + ) env.newsEntries + ); + + # File where each line corresponds to an unread news entry + # identifier. If non-empty then the file ends in "\n". + newsUnreadIdsFile = pkgs.writeText "news-unread-ids" ( + let + text = concatMapStringsSep "\n" (entry: entry.id) newsFiltered; + in + text + optionalString (text != "") "\n" + ); + + newsInfo = pkgs.writeText "news-info.sh" '' + local newsNumUnread=${toString newsNumUnread} + local newsDisplay="${env.newsDisplay}" + local newsFileAll="${newsFileAll}" + local newsFileUnread="${newsFileUnread}" + local newsUnreadIdsFile="${newsUnreadIdsFile}" + ''; + in { inherit (env) activationPackage; + inherit newsInfo; } diff --git a/modules/default.nix b/modules/default.nix index 7add9dc3b5a..9137fa384e1 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,6 +1,9 @@ { configuration , pkgs , lib ? pkgs.stdenv.lib + + # Whether to check that each option has a matching declaration. +, check ? true }: with lib; @@ -64,6 +67,7 @@ let pkgsModule = { config._module.args.pkgs = lib.mkForce pkgs; config._module.args.baseModules = modules; + config._module.check = check; }; module = showWarnings ( @@ -90,4 +94,10 @@ in # For backwards compatibility. Please use activationPackage instead. activation-script = module.config.home.activationPackage; + + newsDisplay = module.config.news.display; + newsEntries = + sort (a: b: a.time > b.time) ( + filter (a: a.condition) module.config.news.entries + ); } -- cgit v1.2.3 From ad1eee7aa549c3294f48379e82b40e7f69036a6f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 6 Sep 2017 23:44:58 +0200 Subject: home-manager: minor news build cleanups - Rename the build function. - Specify the built attribute in the build function. - Make the news build silent. --- home-manager/home-manager | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 4722d41a2f8..329dd8d5cbe 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -75,7 +75,7 @@ function doBuildAttr() { function presentNews() { local infoFile - infoFile=$(doBuildNews -A newsInfo) || return 1 + infoFile=$(buildNews) || return 1 # shellcheck source=/dev/null . "$infoFile" @@ -170,8 +170,15 @@ function newsReadIdsFile() { echo "$path" } -function doBuildNews() { - doBuildAttr "$*" \ +# Builds news meta information to be sourced into this script. +# +# Note, we suppress build output to remove unnecessary verbosity. We +# also use "no out link" to avoid the need for a build directory +# (although this exposes the risk of GC removing the result before we +# manage to source it). +function buildNews() { + doBuildAttr --quiet \ + --attr newsInfo \ --no-out-link \ --arg check false \ --argstr newsReadIdsFile "$(newsReadIdsFile)" @@ -179,7 +186,7 @@ function doBuildNews() { function doShowNews() { local infoFile - infoFile=$(doBuildNews -A newsInfo) || return 1 + infoFile=$(buildNews) || return 1 # shellcheck source=/dev/null . "$infoFile" -- cgit v1.2.3 From 07b4228988711fd4a23547fa7a9bc78f56254135 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 15 Jun 2017 18:11:49 +0200 Subject: README: add instructions for `release-17.03` branch (cherry picked from commit 46f03380923f923237c0530e6ca425e90dc226cd) --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0db0b313224..e98923e267d 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwrite was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] version 17.03 (the current stable -version), it may or may not work on other Linux distributions and -NixOS versions. +Home Manager targets [NixOS][] unstable and NixOS version 17.03 (the +current stable version), it may or may not work on other Linux +distributions and NixOS versions. Also, the `home-manager` tool does not explicitly support rollbacks at the moment so if your home directory gets messed up you'll have to fix @@ -50,9 +50,18 @@ Currently the easiest way to install Home Manager is as follows: directory: ``` - $ git clone https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager + $ git clone -b master https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager ``` + or + + ``` + $ git clone -b release-17.03 https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager + ``` + + depending on whether you are tracking Nixpkgs unstable or version + 17.03. + 3. Add Home Manager to your user's Nixpkgs, for example by adding it to the `packageOverrides` section in your `~/.config/nixpkgs/config.nix` file: -- cgit v1.2.3 From cda222d2ec652e870676d40fbf0c91ab90ce37e0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 9 Sep 2017 17:14:07 +0200 Subject: home-manager: present news even if assertion failed --- home-manager/home-manager | 24 +++++++++++++++++------- modules/default.nix | 17 ++++++++--------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 329dd8d5cbe..97166d6f99b 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -73,9 +73,10 @@ function doBuildAttr() { --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" } +# Presents news to the user. Takes as argument the path to a "news +# info" file as generated by `buildNews`. function presentNews() { - local infoFile - infoFile=$(buildNews) || return 1 + local infoFile="$1" # shellcheck source=/dev/null . "$infoFile" @@ -111,11 +112,22 @@ function presentNews() { } function doBuild() { - doBuildAttr -A activationPackage - presentNews + local newsInfo + newsInfo=$(buildNews) + + local exitCode + doBuildAttr -A activationPackage \ + && exitCode=0 || exitCode=1 + + presentNews "$newsInfo" + + return $exitCode } function doSwitch() { + local newsInfo + newsInfo=$(buildNews) + local generation local exitCode=0 local wrkdir @@ -132,9 +144,7 @@ function doSwitch() { # running and $wrkdir is always removed. rm -r "$wrkdir" - if [[ $exitCode -eq 0 ]]; then - presentNews - fi + presentNews "$newsInfo" return $exitCode } diff --git a/modules/default.nix b/modules/default.nix index 9137fa384e1..c5fc9bcbc38 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -70,18 +70,17 @@ let config._module.check = check; }; + rawModule = lib.evalModules { + modules = [ configuration ] ++ modules ++ [ pkgsModule ]; + }; + module = showWarnings ( let - mod = lib.evalModules { - modules = [ configuration ] ++ modules ++ [ pkgsModule ]; - }; - - failed = collectFailed mod.config; - + failed = collectFailed rawModule.config; failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed); in if failed == [] - then mod + then rawModule else throw "\nFailed assertions:\n${failedStr}" ); @@ -95,9 +94,9 @@ in # For backwards compatibility. Please use activationPackage instead. activation-script = module.config.home.activationPackage; - newsDisplay = module.config.news.display; + newsDisplay = rawModule.config.news.display; newsEntries = sort (a: b: a.time > b.time) ( - filter (a: a.condition) module.config.news.entries + filter (a: a.condition) rawModule.config.news.entries ); } -- cgit v1.2.3 From fc1d4f5362656f161af10be1eba6c68357b66f03 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sun, 10 Sep 2017 13:59:59 +0200 Subject: ssh: allow attrset matchBlock --- modules/programs/ssh.nix | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index e166f49b515..3f1d35db935 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -8,7 +8,7 @@ let yn = flag: if flag then "yes" else "no"; - matchBlockModule = types.submodule { + matchBlockModule = types.submodule ({ name, ... }: { options = { host = mkOption { type = types.str; @@ -96,7 +96,9 @@ let description = "The command to use to connect to the server."; }; }; - }; + + config.host = mkDefault name; + }); matchBlockStr = cf: concatStringsSep "\n" ( ["Host ${cf.host}"] @@ -154,10 +156,27 @@ in }; matchBlocks = mkOption { - type = types.listOf matchBlockModule; + type = types.loaOf matchBlockModule; default = []; + example = literalExample '' + { + "john.example.com" = { + hostname = "example.com"; + user = "john"; + }; + foo = { + hostname = "example.com"; + identityFile = "/home/john/.ssh/foo_rsa"; + }; + }; + ''; description = '' - Specify per-host settings. + Specify per-host settings. Note, if the order of rules matter + then this must be a list. See + + ssh_config + 5 + . ''; }; }; @@ -169,7 +188,9 @@ in ControlPath ${cfg.controlPath} ControlPersist ${cfg.controlPersist} - ${concatStringsSep "\n\n" (map matchBlockStr cfg.matchBlocks)} + ${concatStringsSep "\n\n" ( + map matchBlockStr ( + builtins.attrValues cfg.matchBlocks))} ''; }; } -- cgit v1.2.3 From 258bc85b9ce191bb32d551b1a5391ddb6dad7ba3 Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Mon, 4 Sep 2017 16:39:14 +0200 Subject: zsh: add plugins submodule To pass compinit security checks, plugins are liked into ~/zsh/plugins folder. This also solves issues with a slow start up, see https://github.com/rycee/home-manager/pull/56#issuecomment-328057513. --- modules/misc/news.nix | 9 +++++ modules/programs/zsh.nix | 91 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3bb9ce80ba8..9a77dee87d1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -107,6 +107,15 @@ in config = { news.entries = [ + { + time = "2017-09-10T22:15:19+00:00"; + condition = config.programs.zsh.enable; + message = '' + Home Manager now offers its own minimal zsh plugin manager + under the 'programs.zsh.plugins' option path. By statically + sourcing your plugins it achieves no startup overhead. + ''; + } { time = "2017-09-01T10:56:28+00:00"; message = '' diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index be9eb3c735f..26de2b44972 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -37,6 +37,36 @@ let }; }; + pluginModule = types.submodule ({ config, ... }: { + options = { + src = mkOption { + type = types.path; + description = '' + Path to the plugin folder. + + Will be added to fpath and PATH. + ''; + }; + + name = mkOption { + type = types.str; + description = '' + The name of the plugin. + + Don't forget to add + if the script name does not follow convention. + ''; + }; + + file = mkOption { + type = types.str; + description = "The plugin script to source."; + }; + }; + + config.file = mkDefault "${config.name}.plugin.zsh"; + }); + in { @@ -74,13 +104,43 @@ in initExtra = mkOption { default = ""; type = types.lines; - description = "Extra commands that should be added to .zshrc."; + description = "Extra commands that should be added to .zshrc."; + }; + + plugins = mkOption { + type = types.listOf pluginModule; + default = []; + example = literalExample '' + [ + { + # will source zsh-autosuggestions.plugin.zsh + name = "zsh-autosuggestions"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-autosuggestions"; + rev = "v0.4.0"; + sha256 = "0z6i9wjjklb4lvr7zjhbphibsyx51psv50gm07mbb0kj9058j6kc"; + }; + } + { + name = "enhancd"; + file = "init.sh"; + src = pkgs.fetchFromGitHub { + owner = "b4b4r07"; + repo = "enhancd"; + rev = "v2.2.1"; + sha256 = "0iqa9j09fwm6nj5rpip87x3hnvbbz9w9ajgm6wkrd5fls8fn8i5g"; + }; + } + ] + ''; + description = "Plugins to source in .zshrc."; }; }; }; - config = ( - let + config = mkMerge [ + (let aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases ); @@ -109,15 +169,34 @@ in HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" - ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} + ${concatStrings (map (plugin: '' + path+="$HOME/.zsh/plugins/${plugin.name}" + fpath+="$HOME/.zsh/plugins/${plugin.name}" + '') cfg.plugins)} + + ${optionalString cfg.enableCompletion "autoload -U compinit && compinit"} ${optionalString (cfg.enableAutosuggestions) "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } + ${concatStrings (map (plugin: '' + source "$HOME/.zsh/plugins/${plugin.name}/${plugin.file}" + '') cfg.plugins)} + ${aliasesStr} ${cfg.initExtra} ''; - } - ); + }) + (mkIf (cfg.plugins != []) { + # Many plugins require compinit to be called + # but allow the user to opt out. + programs.zsh.enableCompletion = mkDefault true; + + home.file = map (plugin: { + target = ".zsh/plugins/${plugin.name}"; + source = plugin.src; + }) cfg.plugins; + }) + ]; } -- cgit v1.2.3 From 29d5f5d7601b0a3ae84ca7a214c9cd90137f4e16 Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Thu, 7 Sep 2017 23:57:13 +0200 Subject: zsh: fix double compinit slowdown with oh-my-zsh Integrate oh-my-zsh into zsh module to be able to control invocation order. --- modules/default.nix | 1 - modules/programs/oh-my-zsh.nix | 66 ---------------------------------------- modules/programs/zsh.nix | 68 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 modules/programs/oh-my-zsh.nix diff --git a/modules/default.nix b/modules/default.nix index c5fc9bcbc38..67e855a36b9 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -29,7 +29,6 @@ let ./programs/htop.nix ./programs/info.nix ./programs/lesspipe.nix - ./programs/oh-my-zsh.nix ./programs/ssh.nix ./programs/termite.nix ./programs/texlive.nix diff --git a/modules/programs/oh-my-zsh.nix b/modules/programs/oh-my-zsh.nix deleted file mode 100644 index fc2692a3246..00000000000 --- a/modules/programs/oh-my-zsh.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = config.programs.zsh.oh-my-zsh; - -in - -{ - options = { - programs.zsh.oh-my-zsh = { - enable = mkEnableOption "oh-my-zsh"; - - plugins = mkOption { - default = []; - example = [ "git" "sudo" ]; - type = types.listOf types.str; - description = '' - List of oh-my-zsh plugins - ''; - }; - - custom = mkOption { - default = ""; - type = types.str; - example = "$HOME/my_customizations"; - description = '' - Path to a custom oh-my-zsh package to override config of oh-my-zsh. - See: https://github.com/robbyrussell/oh-my-zsh/wiki/Customization - ''; - }; - - theme = mkOption { - default = ""; - example = "robbyrussell"; - type = types.str; - description = '' - Name of the theme to be used by oh-my-zsh. - ''; - }; - }; - }; - - config = mkIf cfg.enable { - home.packages = [ pkgs.oh-my-zsh ]; - - programs.zsh.initExtra = with pkgs; '' - # oh-my-zsh configuration generated by NixOS - export ZSH=${oh-my-zsh}/share/oh-my-zsh - export ZSH_CACHE_DIR=''${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh - - ${optionalString (cfg.plugins != []) - "plugins=(${concatStringsSep " " cfg.plugins})" - } - ${optionalString (cfg.custom != "") - "ZSH_CUSTOM=\"${cfg.custom}\"" - } - ${optionalString (cfg.theme != "") - "ZSH_THEME=\"${cfg.theme}\"" - } - source $ZSH/oh-my-zsh.sh - ''; - }; -} diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 26de2b44972..ab9d226b4a4 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -67,6 +67,40 @@ let config.file = mkDefault "${config.name}.plugin.zsh"; }); + ohMyZshModule = types.submodule { + options = { + enable = mkEnableOption "oh-my-zsh"; + + plugins = mkOption { + default = []; + example = [ "git" "sudo" ]; + type = types.listOf types.str; + description = '' + List of oh-my-zsh plugins + ''; + }; + + custom = mkOption { + default = ""; + type = types.str; + example = "$HOME/my_customizations"; + description = '' + Path to a custom oh-my-zsh package to override config of oh-my-zsh. + See: https://github.com/robbyrussell/oh-my-zsh/wiki/Customization + ''; + }; + + theme = mkOption { + default = ""; + example = "robbyrussell"; + type = types.str; + description = '' + Name of the theme to be used by oh-my-zsh. + ''; + }; + }; + }; + in { @@ -136,6 +170,12 @@ in ''; description = "Plugins to source in .zshrc."; }; + + oh-my-zsh = mkOption { + type = ohMyZshModule; + default = {}; + description = "Options to configure oh-my-zsh."; + }; }; }; @@ -151,8 +191,9 @@ in mapAttrsToList export config.home.sessionVariables ); in mkIf cfg.enable { - home.packages = [ pkgs.zsh ] - ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; + home.packages = with pkgs; [ zsh ] + ++ optional cfg.enableCompletion nix-zsh-completions + ++ optional cfg.oh-my-zsh.enable oh-my-zsh; home.file.".zshenv".text = '' ${optionalString (config.home.sessionVariableSetter == "zsh") @@ -179,6 +220,23 @@ in "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } + ${optionalString cfg.oh-my-zsh.enable '' + # oh-my-zsh configuration generated by NixOS + export ZSH=${pkgs.oh-my-zsh}/share/oh-my-zsh + export ZSH_CACHE_DIR=''${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh + + ${optionalString (cfg.oh-my-zsh.plugins != []) + "plugins=(${concatStringsSep " " cfg.oh-my-zsh.plugins})" + } + ${optionalString (cfg.oh-my-zsh.custom != "") + "ZSH_CUSTOM=\"${cfg.oh-my-zsh.custom}\"" + } + ${optionalString (cfg.oh-my-zsh.theme != "") + "ZSH_THEME=\"${cfg.oh-my-zsh.theme}\"" + } + source $ZSH/oh-my-zsh.sh + ''} + ${concatStrings (map (plugin: '' source "$HOME/.zsh/plugins/${plugin.name}/${plugin.file}" '') cfg.plugins)} @@ -188,6 +246,12 @@ in ${cfg.initExtra} ''; }) + (mkIf cfg.oh-my-zsh.enable { + # Oh-My-Zsh calls compinit during initialization, + # calling it twice causes sight start up slowdown + # as all $fpath entries will be traversed again. + programs.zsh.enableCompletion = mkForce false; + }) (mkIf (cfg.plugins != []) { # Many plugins require compinit to be called # but allow the user to opt out. -- cgit v1.2.3 From 379e2c694b9cb3f9a26e9620a36fb018f0b4ca21 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 7 Sep 2017 22:21:00 +0200 Subject: zsh: move aliases definitions after initExtra Same motivation as in https://github.com/NixOS/nixpkgs/pull/28378. zsh.initExtra parameter can be used by external modules which can redefine user aliases. This change will give user-defined aliases the highest priority. --- modules/misc/news.nix | 13 +++++++++++++ modules/programs/zsh.nix | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 9a77dee87d1..0fdb660490f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -107,6 +107,19 @@ in config = { news.entries = [ + { + time = "2017-09-12T13:11:48+00:00"; + condition = ( + config.programs.zsh.enable && + config.programs.zsh.shellAliases != {} + ); + message = '' + Aliases defined in 'programs.zsh.shellAliases' + are now have the highest priority. Such aliases will + not be redefined by the code in 'programs.zsh.initExtra' + or any external plugins. + ''; + } { time = "2017-09-10T22:15:19+00:00"; condition = config.programs.zsh.enable; diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index ab9d226b4a4..24c5e098e97 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -241,9 +241,9 @@ in source "$HOME/.zsh/plugins/${plugin.name}/${plugin.file}" '') cfg.plugins)} - ${aliasesStr} - ${cfg.initExtra} + + ${aliasesStr} ''; }) (mkIf cfg.oh-my-zsh.enable { -- cgit v1.2.3 From c7edde6ca47d5090ec25aae4e2f76bfacb0319b5 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Tue, 5 Sep 2017 14:21:57 +0200 Subject: zsh: add user nix-profile dir to fpath Fixes zsh plugins installed to nix user profile via nixpkgs. --- modules/programs/zsh.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 24c5e098e97..b6c2bc3a370 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -208,6 +208,9 @@ in ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY + fpath+="$HOME/.nix-profile/share/zsh/site-functions" + fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" + HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" ${concatStrings (map (plugin: '' -- cgit v1.2.3 From 6a8e8e92a7d666f4b462dd0a84cae604c72dd0e5 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Tue, 12 Sep 2017 16:26:52 +0200 Subject: blueman-applet: add module --- modules/default.nix | 1 + modules/misc/news.nix | 6 ++++++ modules/services/blueman-applet.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 modules/services/blueman-applet.nix diff --git a/modules/default.nix b/modules/default.nix index 67e855a36b9..03ab0764b93 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -34,6 +34,7 @@ let ./programs/texlive.nix ./programs/vim.nix ./programs/zsh.nix + ./services/blueman-applet.nix ./services/dunst.nix ./services/gnome-keyring.nix ./services/gpg-agent.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0fdb660490f..13735b45e5b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -107,6 +107,12 @@ in config = { news.entries = [ + { + time = "2017-09-12T14:22:18+00:00"; + message = '' + A new service is available: 'services.blueman-applet'. + ''; + } { time = "2017-09-12T13:11:48+00:00"; condition = ( diff --git a/modules/services/blueman-applet.nix b/modules/services/blueman-applet.nix new file mode 100644 index 00000000000..d8e58385c70 --- /dev/null +++ b/modules/services/blueman-applet.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.blueman-applet = { + enable = mkEnableOption "Blueman applet"; + }; + }; + + config = mkIf config.services.blueman-applet.enable { + systemd.user.services.blueman-applet = { + Unit = { + Description = "Blueman applet"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.blueman}/bin/blueman-applet"; + }; + }; + }; +} -- cgit v1.2.3 From f47084968dc7be2f4eeb77872cd9fe3bf8243998 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 12 Sep 2017 18:08:44 +0200 Subject: news: minor cleanup This puts entries in chronological order and adds a comment describing how to get a suitable time stamp. --- modules/misc/news.nix | 65 +++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 13735b45e5b..43baa1b4e45 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -106,35 +106,13 @@ in }; config = { + # Add news entries in chronological order (i.e., latest time + # should be at the bottom of the list). The time should be + # formatted as given in the output of + # + # date --iso-8601=second --universal + # news.entries = [ - { - time = "2017-09-12T14:22:18+00:00"; - message = '' - A new service is available: 'services.blueman-applet'. - ''; - } - { - time = "2017-09-12T13:11:48+00:00"; - condition = ( - config.programs.zsh.enable && - config.programs.zsh.shellAliases != {} - ); - message = '' - Aliases defined in 'programs.zsh.shellAliases' - are now have the highest priority. Such aliases will - not be redefined by the code in 'programs.zsh.initExtra' - or any external plugins. - ''; - } - { - time = "2017-09-10T22:15:19+00:00"; - condition = config.programs.zsh.enable; - message = '' - Home Manager now offers its own minimal zsh plugin manager - under the 'programs.zsh.plugins' option path. By statically - sourcing your plugins it achieves no startup overhead. - ''; - } { time = "2017-09-01T10:56:28+00:00"; message = '' @@ -169,6 +147,37 @@ in by commenting in https://git.io/v5BJL. ''; } + + { + time = "2017-09-10T22:15:19+00:00"; + condition = config.programs.zsh.enable; + message = '' + Home Manager now offers its own minimal zsh plugin manager + under the 'programs.zsh.plugins' option path. By statically + sourcing your plugins it achieves no startup overhead. + ''; + } + + { + time = "2017-09-12T13:11:48+00:00"; + condition = ( + config.programs.zsh.enable && + config.programs.zsh.shellAliases != {} + ); + message = '' + Aliases defined in 'programs.zsh.shellAliases' + are now have the highest priority. Such aliases will + not be redefined by the code in 'programs.zsh.initExtra' + or any external plugins. + ''; + } + + { + time = "2017-09-12T14:22:18+00:00"; + message = '' + A new service is available: 'services.blueman-applet'. + ''; + } ]; }; } -- cgit v1.2.3 From aa69598b5742024ebaee0c861585269f77ef1a5f Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 13 Sep 2017 13:31:10 +0200 Subject: compton: add module --- modules/default.nix | 1 + modules/misc/news.nix | 7 +++++++ modules/services/compton.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 modules/services/compton.nix diff --git a/modules/default.nix b/modules/default.nix index 03ab0764b93..115a144cf98 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -35,6 +35,7 @@ let ./programs/vim.nix ./programs/zsh.nix ./services/blueman-applet.nix + ./services/compton.nix ./services/dunst.nix ./services/gnome-keyring.nix ./services/gpg-agent.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 43baa1b4e45..791dc06105d 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -178,6 +178,13 @@ in A new service is available: 'services.blueman-applet'. ''; } + + { + time = "2017-09-13T11:30:22+00:00"; + message = '' + A new service is available: 'services.compton'. + ''; + } ]; }; } diff --git a/modules/services/compton.nix b/modules/services/compton.nix new file mode 100644 index 00000000000..e1c349971db --- /dev/null +++ b/modules/services/compton.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.compton = { + enable = mkEnableOption "Compton X11 compositor"; + }; + }; + + config = mkIf config.services.compton.enable { + systemd.user.services.compton = { + Unit = { + Description = "Compton X11 compositor"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.compton}/bin/compton"; + }; + }; + }; +} -- cgit v1.2.3 From 6ecf9e091c53d592edeb202378a5b5c920dfde55 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 13 Sep 2017 15:19:49 +0200 Subject: home-environment: fail if a home.file is outside $HOME --- modules/home-environment.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 5db2fbd6f42..db4a9847a08 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -416,11 +416,19 @@ in concatStringsSep "\n" ( mapAttrsToList (n: v: '' + target="$(realpath -m "$out/${v.target}")" + + # Target file must be within $HOME. + if [[ ! "$target" =~ "$out" ]] ; then + echo "Error installing file '${v.target}' outside \$HOME" >&2 + exit 1 + fi + if [ -d "${v.source}" ]; then mkdir -pv "$(dirname "$out/${v.target}")" - ln -sv "${v.source}" "$out/${v.target}" + ln -sv "${v.source}" "$target" else - install -D -m${v.mode} "${v.source}" "$out/${v.target}" + install -D -m${v.mode} "${v.source}" "$target" fi '' ) cfg.file -- cgit v1.2.3 From cab9237d954ebf91b85f0388c35c47cd56674f10 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 8 Sep 2017 22:26:30 +0200 Subject: Add initial CONTRIBUTING file --- CONTRIBUTING.md | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..feda8dedb06 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,127 @@ +Contributing +============ + +Thanks for wanting to contribute to Home Manager! These are some +guidelines to make the process as smooth as possible for both you and +the Home Manager developers. + +If you are only looking to report a problem then it is sufficient to +read through the following section on reporting issues. If you instead +want to directly contribute improvements and additions then please +have a look at everything here. + +Reporting an issue +------------------ + +If you notice a problem with Home Manager and want to report it then +have a look among the already [open issues][], if you find one +matching yours then feel free to comment on it to add any additional +information you may have. + +If no matching issue exists then go to the [new issue][] page and +write a description of your problem. Include as much information as +you can, ideally also include relevant excerpts from your Home Manager +configuration. + +Contributing code +----------------- + +If you want to contribute code to improve Home Manager then please +follow these guidelines. + +### Fork and create a pull request ### + +If you have not previously forked Home Manager then you need to do +that first. Have a look at GitHub's "[Fork A Repo][]" for instructions +on how to do this. + +Once you have a fork of Home Manager you should create a branch +starting at the most recent `master`. Give your branch a reasonably +descriptive name. Perform your changes on this branch and when you are +happy with the result push the branch to GitHub and +[create a pull request][]. + +### Commits ### + +The commits in your pull request should be reasonably self-contained, +that is, each commit should make sense in isolation. In particular, +you will be asked to amend any commit that introduces syntax errors or +similar problems even if they are fixed in a later commit. + +The commit messages should follow the format + + {component}: {description} + + {long description} + +where `{component}` refers to the code component (or module) your +change affects, `{description}` is a brief description of your change, +and `{long description}` is an optional clarifying description. Note, +`{description}` should start with a lower case letter. As a rare +exception, if there is no clear component, or your change affects many +components, then the `{component}` part is optional. + +When adding a new module, say `foo.nix`, we use the fixed commit +format `foo: add module`. You can, of course, still include a long +description if you wish. + +In addition to the above commit message guidelines, try to follow the +[seven rules][] as much as possible. + +### News ### + +Home Manager includes a system for presenting news to the user. When +making a change you, therefore, have the option to also include an +associated news entry. In general, a news entry should only be added +for truly noteworthy news. For example, a bug fix or new option does +generally not need a news entry. + +If you do have a change worthy of a news entry then please add one in +[`news.nix`][] but you should follow some basic guidelines: + +- The entry timestamp should be in ISO-8601 format having "+00:00" as + time zone. For example, "2017-09-13T17:10:14+00:00". A suitable + timestamp can be produced by the command + + date --iso-8601=second --universal + +- The entry condition should be as specific as possible. For example, + if you are changing or deprecating a specific option then you could + restrict the news to those users who actually use this option. + +- Wrap the news message so that it will fit in the typical terminal, + that is, at most 80 characters wide. Ideally a bit less. + +- Unlike commit messages, news will be read without any connection to + the Home Manager source code. It is therefore important to make the + message understandable in isolation and to those who do not have + knowledge of the Home Manager internals. To this end it should be + written in more descriptive, prose like way. + +- If you refer to an option then write its full attribute path. That + is, instead of writing + + > The option 'foo' has been deprecated, please use 'bar' instead. + + it should read + + > The option 'services.myservice.foo' has been deprecated, please + > use 'services.myservice.bar' instead. + +- A new module, say `foo.nix`, should always include a news entry + (without any condition) that has a message along the lines of + + > A new service is available: 'services.foo'. + + or + + > A new program configuration is available: 'program.foo'. + + depending on the type of module. + +[open issues]: https://github.com/rycee/home-manager/issues +[new issue]: https://github.com/rycee/home-manager/issues/new +[Fork A Repo]: https://help.github.com/articles/fork-a-repo/ +[create a pull request]: https://help.github.com/articles/creating-a-pull-request/ +[seven rules]: https://chris.beams.io/posts/git-commit/#seven-rules +[`news.nix`]: https://github.com/rycee/home-manager/blob/master/modules/misc/news.nix -- cgit v1.2.3 From de5f902487dceed61dff462b53767cc139567a7e Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 12 Sep 2017 20:01:02 +0200 Subject: zsh: add custom dotDir parameter --- modules/programs/zsh.nix | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index b6c2bc3a370..958494b533f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -6,6 +6,12 @@ let cfg = config.programs.zsh; + relToDotDir = file: (optionalString (cfg.dotDir != null) (cfg.dotDir + "/")) + file; + + pluginsDir = if cfg.dotDir != null then + relToDotDir "plugins" else ".zsh/plugins"; + + historyModule = types.submodule { options = { size = mkOption { @@ -16,7 +22,8 @@ let path = mkOption { type = types.str; - default = "$HOME/.zsh_history"; + default = relToDotDir ".zsh_history"; + defaultText = ".zsh_history"; # Manual fails to build without this description = "History file location"; }; @@ -108,6 +115,17 @@ in programs.zsh = { enable = mkEnableOption "Z shell (Zsh)"; + dotDir = mkOption { + default = null; + example = ".config/zsh"; + description = '' + Directory where the zsh configuration and more should be located, + relative to the users home directory. The default is the home + directory. + ''; + type = types.nullOr types.str; + }; + shellAliases = mkOption { default = {}; example = { ll = "ls -l"; ".." = "cd .."; }; @@ -190,19 +208,25 @@ in envVarsStr = concatStringsSep "\n" ( mapAttrsToList export config.home.sessionVariables ); + + zdotdir = if cfg.dotDir == null then null else "$HOME/" + cfg.dotDir; in mkIf cfg.enable { home.packages = with pkgs; [ zsh ] ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; + home.sessionVariables.${if cfg.dotDir != null then "ZDOTDIR" else null} = zdotdir; + home.file.".zshenv".text = '' ${optionalString (config.home.sessionVariableSetter == "zsh") envVarsStr} + ${optionalString (cfg.dotDir != null && config.home.sessionVariableSetter != "zsh") + (export "ZDOTDIR" zdotdir)} ''; - home.file.".zshrc".text = '' + home.file."${relToDotDir ".zshrc"}".text = '' ${export "HISTSIZE" cfg.history.size} - ${export "HISTFILE" cfg.history.path} + ${export "HISTFILE" ("$HOME/" + cfg.history.path)} setopt HIST_FCNTL_LOCK ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS @@ -214,12 +238,12 @@ in HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" ${concatStrings (map (plugin: '' - path+="$HOME/.zsh/plugins/${plugin.name}" - fpath+="$HOME/.zsh/plugins/${plugin.name}" + path+="$HOME/${pluginsDir}/${plugin.name}" + fpath+="$HOME/${pluginsDir}/${plugin.name}" '') cfg.plugins)} ${optionalString cfg.enableCompletion "autoload -U compinit && compinit"} - ${optionalString (cfg.enableAutosuggestions) + ${optionalString cfg.enableAutosuggestions "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } @@ -241,7 +265,7 @@ in ''} ${concatStrings (map (plugin: '' - source "$HOME/.zsh/plugins/${plugin.name}/${plugin.file}" + source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" '') cfg.plugins)} ${cfg.initExtra} @@ -261,7 +285,7 @@ in programs.zsh.enableCompletion = mkDefault true; home.file = map (plugin: { - target = ".zsh/plugins/${plugin.name}"; + target = "${pluginsDir}/${plugin.name}"; source = plugin.src; }) cfg.plugins; }) -- cgit v1.2.3 From e4deffcbe8f71c51585507d878d7a9fbd2fe91e5 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sun, 17 Sep 2017 17:27:26 +0200 Subject: vim: add package option This adds a readonly package option which will be set to the resulting configured vim package, so it can be refered to by other configuration. An example would be home.sessionVariables.EDITOR = config.programs.vim.package + "/bin/vim". --- modules/programs/vim.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index e019751a309..e246c21fdf9 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -46,6 +46,12 @@ in ''; description = "Custom .vimrc lines"; }; + + package = mkOption { + type = types.package; + description = "Resulting customized vim package"; + readOnly = true; + }; }; }; @@ -71,7 +77,8 @@ in }; in mkIf cfg.enable { - home.packages = [ vim ]; + programs.vim.package = vim; + home.packages = [ cfg.package ]; } ); } -- cgit v1.2.3 From 76e0e09aca244fdbe54a5604a1fa4f26ff5a051b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 19 Sep 2017 23:32:01 +0200 Subject: emacs: allow custom Emacs package --- modules/programs/emacs.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 22a4ed4349e..35f03911032 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -6,6 +6,10 @@ let cfg = config.programs.emacs; + # Copied from all-packages.nix. + emacsPackages = pkgs.emacsPackagesNgGen cfg.package; + emacsWithPackages = emacsPackages.emacsWithPackages; + in { @@ -13,6 +17,14 @@ in programs.emacs = { enable = mkEnableOption "Emacs"; + package = mkOption { + type = types.package; + default = pkgs.emacs; + defaultText = "pkgs.emacs"; + example = literalExample "pkgs.emacs25-nox"; + description = "The Emacs package to use."; + }; + extraPackages = mkOption { default = self: []; example = literalExample '' @@ -24,6 +36,6 @@ in }; config = mkIf cfg.enable { - home.packages = [ (pkgs.emacsWithPackages cfg.extraPackages) ]; + home.packages = [ (emacsWithPackages cfg.extraPackages) ]; }; } -- cgit v1.2.3 From 3e4f7228a0b3185c142dcffcb689c705dc228fd1 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 20 Sep 2017 16:50:49 +0200 Subject: screen-locker: add module --- modules/default.nix | 1 + modules/misc/news.nix | 7 +++++ modules/services/screen-locker.nix | 59 ++++++++++++++++++++++++++++++++++++++ modules/xsession.nix | 1 + 4 files changed, 68 insertions(+) create mode 100644 modules/services/screen-locker.nix diff --git a/modules/default.nix b/modules/default.nix index 115a144cf98..cb3b9f14f98 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -44,6 +44,7 @@ let ./services/owncloud-client.nix ./services/random-background.nix ./services/redshift.nix + ./services/screen-locker.nix ./services/syncthing.nix ./services/taffybar.nix ./services/tahoe-lafs.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 791dc06105d..17747fb79a8 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -185,6 +185,13 @@ in A new service is available: 'services.compton'. ''; } + + { + time = "2017-09-20T14:47:14+00:00"; + message = '' + A new service is available: 'services.screen-locker'. + ''; + } ]; }; } diff --git a/modules/services/screen-locker.nix b/modules/services/screen-locker.nix new file mode 100644 index 00000000000..291416564b9 --- /dev/null +++ b/modules/services/screen-locker.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.screen-locker; + +in { + + options.services.screen-locker = { + enable = mkEnableOption "screen locker for X session"; + + lockCmd = mkOption { + type = types.str; + description = "Locker command to run."; + example = "\${pkgs.i3lock}/bin/i3lock -n -c 000000"; + }; + + inactiveInterval = mkOption { + type = types.int; + default = 10; + description = '' + Inactive time interval in minutes after which session will be locked. + The minimum is 1 minute, and the maximum is 1 hour. + See . + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.xautolock-session = { + Unit = { + Description = "xautolock, session locker service"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = '' + ${pkgs.xautolock}/bin/xautolock \ + -detectsleep \ + -time ${toString cfg.inactiveInterval} \ + -locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID' + ''; + }; + }; + + # xss-lock will run specified screen locker when the session is locked via loginctl + # can't be started as a systemd service, + # see https://bitbucket.org/raymonad/xss-lock/issues/13/allow-operation-as-systemd-user-unit + xsession.initExtra = "${pkgs.xss-lock}/bin/xss-lock -- ${cfg.lockCmd} &"; + }; + +} diff --git a/modules/xsession.nix b/modules/xsession.nix index 0ec95ffe618..89979796c2d 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -87,6 +87,7 @@ in systemctl --user import-environment XAUTHORITY systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user import-environment XDG_SESSION_ID systemctl --user start hm-graphical-session.target -- cgit v1.2.3 From 61042c76065b7ff99d840e1be78c4cf5b011bcab Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Sep 2017 13:18:33 +0200 Subject: lib: use generators from Nixpkgs --- modules/lib/generators.nix | 93 ------------------------------------- modules/misc/gtk.nix | 2 +- modules/programs/git.nix | 5 +- modules/programs/gnome-terminal.nix | 9 ++-- modules/systemd.nix | 2 +- 5 files changed, 9 insertions(+), 102 deletions(-) delete mode 100644 modules/lib/generators.nix diff --git a/modules/lib/generators.nix b/modules/lib/generators.nix deleted file mode 100644 index 4190703e236..00000000000 --- a/modules/lib/generators.nix +++ /dev/null @@ -1,93 +0,0 @@ -/* Functions that generate widespread file - * formats from nix data structures. - * - * They all follow a similar interface: - * generator { config-attrs } data - * - * Tests can be found in ./tests.nix - * Documentation in the manual, #sec-generators - */ -with import ; -let - libStr = import ; - libAttr = import ; - - flipMapAttrs = flip libAttr.mapAttrs; -in - -rec { - - /* Generate a line of key k and value v, separated by - * character sep. If sep appears in k, it is escaped. - * Helper for synaxes with different separators. - * - * mkKeyValueDefault ":" "f:oo" "bar" - * > "f\:oo:bar" - */ - mkKeyValueDefault = sep: k: v: - "${libStr.escape [sep] k}${sep}${toString v}"; - - - /* Generate a key-value-style config file from an attrset. - * - * mkKeyValue is the same as in toINI. - */ - toKeyValue = { - mkKeyValue ? mkKeyValueDefault "=" - }: attrs: - let mkLine = k: v: mkKeyValue k v + "\n"; - in libStr.concatStrings (libAttr.mapAttrsToList mkLine attrs); - - - /* Generate an INI-style config file from an - * attrset of sections to an attrset of key-value pairs. - * - * generators.toINI {} { - * foo = { hi = "${pkgs.hello}"; ciao = "bar"; }; - * baz = { "also, integers" = 42; }; - * } - * - *> [baz] - *> also, integers=42 - *> - *> [foo] - *> ciao=bar - *> hi=/nix/store/y93qql1p5ggfnaqjjqhxcw0vqw95rlz0-hello-2.10 - * - * The mk* configuration attributes can generically change - * the way sections and key-value strings are generated. - * - * For more examples see the test cases in ./tests.nix. - */ - toINI = { - # apply transformations (e.g. escapes) to section names - mkSectionName ? (name: libStr.escape [ "[" "]" ] name), - # format a setting line from key and value - mkKeyValue ? mkKeyValueDefault "=" - }: attrsOfAttrs: - let - # map function to string for each key val - mapAttrsToStringsSep = sep: mapFn: attrs: - libStr.concatStringsSep sep - (libAttr.mapAttrsToList mapFn attrs); - mkSection = sectName: sectValues: '' - [${mkSectionName sectName}] - '' + toKeyValue { inherit mkKeyValue; } sectValues; - in - # map input to ini sections - mapAttrsToStringsSep "\n" mkSection attrsOfAttrs; - - - /* Generates JSON from an arbitrary (non-function) value. - * For more information see the documentation of the builtin. - */ - toJSON = {}: builtins.toJSON; - - - /* YAML has been a strict superset of JSON since 1.2, so we - * use toJSON. Before it only had a few differences referring - * to implicit typing rules, so it should work with older - * parsers as well. - */ - toYAML = {}@args: toJSON args; -} diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index ab58ead6b38..1d667339170 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -8,7 +8,7 @@ let cfg2 = config.gtk.gtk2; cfg3 = config.gtk.gtk3; - toGtk3Ini = (import ../lib/generators.nix).toINI { + toGtk3Ini = generators.toINI { mkKeyValue = key: value: let value' = diff --git a/modules/programs/git.nix b/modules/programs/git.nix index eeab16abd77..28d1168d00d 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -6,8 +6,6 @@ let cfg = config.programs.git; - toINI = (import ../lib/generators.nix).toINI {}; - signModule = types.submodule { options = { key = mkOption { @@ -93,7 +91,8 @@ in { home.packages = [ cfg.package ]; - home.file.".gitconfig".text = toINI ini + "\n" + cfg.extraConfig; + home.file.".gitconfig".text = + generators.toINI {} ini + "\n" + cfg.extraConfig; } ); } diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index 052962c77ee..dc8990a965c 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -90,7 +90,7 @@ let } ); - toINI = (import ../lib/generators.nix).toINI { mkKeyValue = mkIniKeyValue; }; + toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; mkIniKeyValue = key: value: let @@ -181,14 +181,15 @@ in # The dconf service needs to be installed and prepared. home.activation.gnomeTerminal = dagEntryAfter ["installPackages"] ( let - sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg)); + iniText = toDconfIni (buildIniSet cfg); + iniFile = pkgs.writeText "gnome-terminal.ini" iniText; dconfPath = "/org/gnome/terminal/legacy/"; in '' if [[ -v DRY_RUN ]]; then - echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${sf} + echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} else - ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf} + ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} fi '' ); diff --git a/modules/systemd.nix b/modules/systemd.nix index b68034b702c..6ca8e217b34 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -12,7 +12,7 @@ let || cfg.targets != {} || cfg.timers != {}; - toSystemdIni = (import lib/generators.nix).toINI { + toSystemdIni = generators.toINI { mkKeyValue = key: value: let value' = -- cgit v1.2.3 From 742d1889c52583968f062ac3ba2b82b63e166662 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Sep 2017 13:19:29 +0200 Subject: lib: make dag.nix take `lib` as argument --- modules/home-environment.nix | 2 +- modules/lib/dag.nix | 6 +++--- modules/programs/gnome-terminal.nix | 2 +- modules/programs/home-manager.nix | 2 +- modules/programs/info.nix | 2 +- modules/systemd.nix | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index db4a9847a08..24c1a40c328 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: with lib; -with import ./lib/dag.nix; +with import ./lib/dag.nix { inherit lib; }; let diff --git a/modules/lib/dag.nix b/modules/lib/dag.nix index cb7e6f8988f..535dec35ad4 100644 --- a/modules/lib/dag.nix +++ b/modules/lib/dag.nix @@ -7,9 +7,9 @@ # - the addition of the function `dagEntryBefore` indicating a # "wanted by" relationship. -with import ; -with import ; -with import ; +{ lib }: + +with lib; rec { diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index dc8990a965c..ee9db93b18e 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix; +with import ../lib/dag.nix { inherit lib; }; let diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 413f566875a..a8950a74d04 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix; +with import ../lib/dag.nix { inherit lib; }; let diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 3042331c937..3671c5c4292 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -21,7 +21,7 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix; +with import ../lib/dag.nix { inherit lib; }; let cfg = config.programs.info; diff --git a/modules/systemd.nix b/modules/systemd.nix index 6ca8e217b34..57017a66865 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: with lib; -with import ./lib/dag.nix; +with import ./lib/dag.nix { inherit lib; }; let -- cgit v1.2.3 From 82c5aa82d2bb289c8ab104aab5b80b41ab77cc17 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 21 Sep 2017 10:23:23 +0200 Subject: readme: add man page info --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e98923e267d..7ad6136654f 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,13 @@ $ home-manager build which will create a `result` link to a directory containing an activation script and the generated home directory files. +To see available configuration options with descriptions +and usage examples run + +``` +$ man home-configuration.nix +``` + Keeping your ~ safe from harm ----------------------------- -- cgit v1.2.3 From db55e596d2010025882f3f6067a886bff0ddbae8 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 18 Sep 2017 00:26:42 +0200 Subject: zsh: refine module - fix part of zsh config being built even though cfg.enable is false - fix .zshenv sourcing when ZDOTDIR already set and some other minor adjustments --- modules/programs/zsh.nix | 62 ++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 958494b533f..dd0f986abda 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -11,6 +11,19 @@ let pluginsDir = if cfg.dotDir != null then relToDotDir "plugins" else ".zsh/plugins"; + export = n: v: "export ${n}=\"${toString v}\""; + + toEnvVarsStr = vars: concatStringsSep "\n" ( + mapAttrsToList export vars + ); + + envVarsStr = toEnvVarsStr config.home.sessionVariables; + + aliasesStr = concatStringsSep "\n" ( + mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + ); + + zdotdir = "$HOME/" + cfg.dotDir; historyModule = types.submodule { options = { @@ -197,32 +210,12 @@ in }; }; - config = mkMerge [ - (let - aliasesStr = concatStringsSep "\n" ( - mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases - ); - - export = n: v: "export ${n}=\"${toString v}\""; - - envVarsStr = concatStringsSep "\n" ( - mapAttrsToList export config.home.sessionVariables - ); - - zdotdir = if cfg.dotDir == null then null else "$HOME/" + cfg.dotDir; - in mkIf cfg.enable { + config = mkIf cfg.enable (mkMerge [ + { home.packages = with pkgs; [ zsh ] ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; - home.sessionVariables.${if cfg.dotDir != null then "ZDOTDIR" else null} = zdotdir; - - home.file.".zshenv".text = '' - ${optionalString (config.home.sessionVariableSetter == "zsh") - envVarsStr} - ${optionalString (cfg.dotDir != null && config.home.sessionVariableSetter != "zsh") - (export "ZDOTDIR" zdotdir)} - ''; home.file."${relToDotDir ".zshrc"}".text = '' ${export "HISTSIZE" cfg.history.size} @@ -272,6 +265,29 @@ in ${aliasesStr} ''; + } + (mkIf (cfg.dotDir != null) { + home.sessionVariables.ZDOTDIR = zdotdir; + }) + (mkIf (config.home.sessionVariableSetter == "zsh" && cfg.dotDir == null) { + home.file.".zshenv".text = '' + ${envVarsStr} + ''; + }) + (mkIf (config.home.sessionVariableSetter == "zsh" && cfg.dotDir != null) { + # When dotDir is set, only use ~/.zshenv to export ZDOTDIR, + # $ZDOTDIR/.zshenv for the rest. This is so that if ZDOTDIR happens to be + # already set correctly (by e.g. spawning a zsh inside a zsh), all env + # vars still get exported + home.file.".zshenv".text = '' + ${export "ZDOTDIR" zdotdir} + source ${zdotdir}/.zshenv + ''; + + home.file."${relToDotDir ".zshenv"}".text = '' + ${toEnvVarsStr + (builtins.removeAttrs config.home.sessionVariables [ "ZDOTDIR" ])} + ''; }) (mkIf cfg.oh-my-zsh.enable { # Oh-My-Zsh calls compinit during initialization, @@ -289,5 +305,5 @@ in source = plugin.src; }) cfg.plugins; }) - ]; + ]); } -- cgit v1.2.3 From 0f096f9ad40f2fb055f4b696f16450d7487cd895 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 21 Sep 2017 14:45:20 +0200 Subject: git: change extraConfig from lines to attrs --- modules/misc/news.nix | 28 ++++++++++++++++++++++++++ modules/programs/git.nix | 51 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 17747fb79a8..eef664b6ff2 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -192,6 +192,34 @@ in A new service is available: 'services.screen-locker'. ''; } + + { + time = "2017-09-22T12:09:01+00:00"; + condition = isString config.programs.git.extraConfig; + message = '' + The 'programs.git.extraConfig' parameter now accepts + attributes instead of strings which allows more flexible + configuration. + + The string parameter type will be deprecated in the future, + please change your configuration file accordingly. + + For example, if your configuration includes + + programs.git.extraConfig = ''' + [core] + editor = vim + '''; + + then you can now change it to + + programs.git.extraConfig = { + core = { + editor = "vim"; + }; + }; + ''; + } ]; }; } diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 28d1168d00d..1616dcb4a78 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -65,34 +65,51 @@ in }; extraConfig = mkOption { - type = types.lines; - default = ""; + type = types.either types.attrs types.lines; + default = {}; description = "Additional configuration to add."; }; + + iniContent = mkOption { + type = types.attrsOf types.attrs; + internal = true; + }; }; }; config = mkIf cfg.enable ( - let - ini = { - user = { + mkMerge [ + { + home.packages = [ cfg.package ]; + + programs.git.iniContent.user = { name = cfg.userName; email = cfg.userEmail; - } // optionalAttrs (cfg.signing != null) { - signingKey = cfg.signing.key; }; - } // optionalAttrs (cfg.signing != null) { - commit.gpgSign = cfg.signing.signByDefault; - gpg.program = cfg.signing.gpgPath; - } // optionalAttrs (cfg.aliases != {}) { - alias = cfg.aliases; - }; - in - { - home.packages = [ cfg.package ]; home.file.".gitconfig".text = - generators.toINI {} ini + "\n" + cfg.extraConfig; + generators.toINI {} cfg.iniContent; } + + (mkIf (cfg.signing != null) { + programs.git.iniContent = { + user.signingKey = cfg.signing.key; + commit.gpgSign = cfg.signing.signByDefault; + gpg.program = cfg.signing.gpgPath; + }; + }) + + (mkIf (cfg.aliases != {}) { + programs.git.iniContent.alias = cfg.aliases; + }) + + (mkIf (lib.isAttrs cfg.extraConfig) { + programs.git.iniContent = cfg.extraConfig; + }) + + (mkIf (lib.isString cfg.extraConfig) { + home.file.".gitconfig".text = cfg.extraConfig; + }) + ] ); } -- cgit v1.2.3 From bf9b9026d9b8b060332b19f7d120da1ae6a3380f Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 22 Sep 2017 22:42:37 +0200 Subject: compton: extend module --- modules/services/compton.nix | 206 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 200 insertions(+), 6 deletions(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index e1c349971db..f425db8ab06 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -1,15 +1,207 @@ { config, lib, pkgs, ... }: with lib; +with builtins; -{ - options = { - services.compton = { - enable = mkEnableOption "Compton X11 compositor"; +let + + cfg = config.services.compton; + + configFile = pkgs.writeText "compton.conf" + (optionalString cfg.fade '' + # fading + fading = true; + fade-delta = ${toString cfg.fadeDelta}; + fade-in-step = ${elemAt cfg.fadeSteps 0}; + fade-out-step = ${elemAt cfg.fadeSteps 1}; + fade-exclude = ${toJSON cfg.fadeExclude}; + '' + + optionalString cfg.shadow '' + + # shadows + shadow = true; + shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)}; + shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; + shadow-opacity = ${cfg.shadowOpacity}; + shadow-exclude = ${toJSON cfg.shadowExclude}; + '' + '' + # opacity + active-opacity = ${cfg.activeOpacity}; + inactive-opacity = ${cfg.inactiveOpacity}; + menu-opacity = ${cfg.menuOpacity}; + + # other options + backend = ${toJSON cfg.backend}; + vsync = ${toJSON cfg.vSync}; + refresh-rate = ${toString cfg.refreshRate}; + '' + cfg.extraOptions); + +in { + + options.services.compton = { + enable = mkEnableOption "Compton X11 compositor"; + + fade = mkOption { + type = types.bool; + default = false; + description = '' + Fade windows in and out. + ''; + }; + + fadeDelta = mkOption { + type = types.int; + default = 10; + example = 5; + description = '' + Time between fade animation step (in ms). + ''; + }; + + fadeSteps = mkOption { + type = types.listOf types.str; + default = [ "0.028" "0.03" ]; + example = [ "0.04" "0.04" ]; + description = '' + Opacity change between fade steps (in and out). + ''; + }; + + fadeExclude = mkOption { + type = types.listOf types.str; + default = []; + example = [ + "window_type *= 'menu'" + "name ~= 'Firefox$'" + "focused = 1" + ]; + description = '' + List of conditions of windows that should not be faded. + See compton(1) man page for more examples. + ''; + }; + + shadow = mkOption { + type = types.bool; + default = false; + description = '' + Draw window shadows. + ''; + }; + + shadowOffsets = mkOption { + type = types.listOf types.int; + default = [ (-15) (-15) ]; + example = [ (-10) (-15) ]; + description = '' + Left and right offset for shadows (in pixels). + ''; + }; + + shadowOpacity = mkOption { + type = types.str; + default = "0.75"; + example = "0.8"; + description = '' + Window shadows opacity (number in range 0 - 1). + ''; + }; + + shadowExclude = mkOption { + type = types.listOf types.str; + default = []; + example = [ + "window_type *= 'menu'" + "name ~= 'Firefox$'" + "focused = 1" + ]; + description = '' + List of conditions of windows that should have no shadow. + See compton(1) man page for more examples. + ''; + }; + + activeOpacity = mkOption { + type = types.str; + default = "1.0"; + example = "0.8"; + description = '' + Opacity of active windows. + ''; + }; + + inactiveOpacity = mkOption { + type = types.str; + default = "1.0"; + example = "0.8"; + description = '' + Opacity of inactive windows. + ''; + }; + + menuOpacity = mkOption { + type = types.str; + default = "1.0"; + example = "0.8"; + description = '' + Opacity of dropdown and popup menu. + ''; + }; + + backend = mkOption { + type = types.str; + default = "glx"; + description = '' + Backend to use: glx or xrender. + ''; + }; + + vSync = mkOption { + type = types.str; + default = "none"; + example = "opengl-swc"; + description = '' + Enable vertical synchronization using the specified method. + See compton(1) man page available methods. + ''; + }; + + refreshRate = mkOption { + type = types.int; + default = 0; + example = 60; + description = '' + Screen refresh rate (0 = automatically detect). + ''; + }; + + package = mkOption { + type = types.package; + default = pkgs.compton; + defaultText = "pkgs.compton"; + example = literalExample "pkgs.compton"; + description = '' + Compton derivation to use. + ''; + }; + + extraOptions = mkOption { + type = types.str; + default = ""; + example = '' + unredir-if-possible = true; + dbe = true; + ''; + description = '' + Additional Compton configuration. + ''; }; }; - config = mkIf config.services.compton.enable { + config = mkIf cfg.enable { + + home.packages = [ cfg.package ]; + systemd.user.services.compton = { Unit = { Description = "Compton X11 compositor"; @@ -22,7 +214,9 @@ with lib; }; Service = { - ExecStart = "${pkgs.compton}/bin/compton"; + ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; + Restart = "always"; + RestartSec = 3; }; }; }; -- cgit v1.2.3 From a8e08d14bbc08137cf12c79818ad6f381ded287d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 26 Sep 2017 23:40:31 +0200 Subject: Mark rycee as maintainer for a bunch of modules --- modules/home-environment.nix | 2 ++ modules/manual.nix | 25 ++++++++++++++----------- modules/misc/gtk.nix | 2 ++ modules/misc/news.nix | 2 ++ modules/misc/pam.nix | 2 ++ modules/programs/bash.nix | 2 ++ modules/programs/beets.nix | 2 ++ modules/programs/eclipse.nix | 2 ++ modules/programs/emacs.nix | 2 ++ modules/programs/firefox.nix | 2 ++ modules/programs/git.nix | 2 ++ modules/programs/gnome-terminal.nix | 2 ++ modules/programs/home-manager.nix | 2 ++ modules/programs/lesspipe.nix | 2 ++ modules/programs/ssh.nix | 2 ++ modules/programs/texlive.nix | 2 ++ modules/services/dunst.nix | 2 ++ modules/services/gnome-keyring.nix | 2 ++ modules/services/gpg-agent.nix | 2 ++ modules/services/keepassx.nix | 2 ++ modules/services/network-manager-applet.nix | 2 ++ modules/services/random-background.nix | 2 ++ modules/services/redshift.nix | 5 ++++- modules/services/syncthing.nix | 2 ++ modules/services/taffybar.nix | 2 ++ modules/services/tahoe-lafs.nix | 2 ++ modules/services/udiskie.nix | 2 ++ modules/services/xscreensaver.nix | 2 ++ modules/systemd.nix | 2 ++ modules/xresources.nix | 2 ++ modules/xsession.nix | 2 ++ 31 files changed, 76 insertions(+), 12 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 24c1a40c328..8b6a6cfa8a8 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -93,6 +93,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { home.file = mkOption { description = "Attribute set of files to link into the user home."; diff --git a/modules/manual.nix b/modules/manual.nix index 4736726f3ca..636b184c308 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -64,15 +64,18 @@ in }; # To fix error during manpage build. - meta.doc = builtins.toFile "nothingness" '' - - this is just to make the docs compile - - - - ''; + meta = { + maintainers = [ maintainers.rycee ]; + doc = builtins.toFile "nothingness" '' + + this is just to make the docs compile + + + + ''; + }; } diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 1d667339170..a95e8d6e27f 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -30,6 +30,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { gtk = { enable = mkEnableOption "GTK 2/3 configuration"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index eef664b6ff2..b52b2b2cdc3 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -48,6 +48,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { news = { display = mkOption { diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index 89040aa841c..3bd0f292561 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = {}; config = mkIf (homeCfg.sessionVariableSetter == "pam") { diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index a8004580d8a..25929abfa77 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.bash = { enable = mkEnableOption "GNU Bourne-Again SHell"; diff --git a/modules/programs/beets.nix b/modules/programs/beets.nix index df9495ef267..34aa04608d3 100644 --- a/modules/programs/beets.nix +++ b/modules/programs/beets.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.beets = { settings = mkOption { diff --git a/modules/programs/eclipse.nix b/modules/programs/eclipse.nix index e9d4c060287..092db23f4ed 100644 --- a/modules/programs/eclipse.nix +++ b/modules/programs/eclipse.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.eclipse = { enable = mkEnableOption "Eclipse"; diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 35f03911032..a056866a85c 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -13,6 +13,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.emacs = { enable = mkEnableOption "Emacs"; diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index befacec24b5..50a43cfe7ba 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.firefox = { enable = mkEnableOption "Firefox"; diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 1616dcb4a78..c8dab199ce1 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -31,6 +31,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.git = { enable = mkEnableOption "Git"; diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index ee9db93b18e..a10914ad6d8 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -157,6 +157,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.gnome-terminal = { enable = mkEnableOption "Gnome Terminal"; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index a8950a74d04..2b211b85b7a 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -10,6 +10,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.home-manager = { enable = mkEnableOption "Home Manager"; diff --git a/modules/programs/lesspipe.nix b/modules/programs/lesspipe.nix index d250f535ad8..a7a51ffe2a2 100644 --- a/modules/programs/lesspipe.nix +++ b/modules/programs/lesspipe.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.lesspipe = { enable = mkEnableOption "lesspipe preprocessor for less"; diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 3f1d35db935..b2017818c76 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -118,6 +118,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options.programs.ssh = { enable = mkEnableOption "SSH client configuration"; diff --git a/modules/programs/texlive.nix b/modules/programs/texlive.nix index afa8f7012c8..1d944cef13a 100644 --- a/modules/programs/texlive.nix +++ b/modules/programs/texlive.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { programs.texlive = { enable = mkEnableOption "Texlive"; diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index c1f29d942cf..659425b116c 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.dunst = { enable = mkEnableOption "the dunst notification daemon"; diff --git a/modules/services/gnome-keyring.nix b/modules/services/gnome-keyring.nix index b7097d7cd35..4ca6c7cacf2 100644 --- a/modules/services/gnome-keyring.nix +++ b/modules/services/gnome-keyring.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { services.gnome-keyring = { enable = mkEnableOption "GNOME Keyring"; diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 03affd217f9..4f1dd5f2d34 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -15,6 +15,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { services.gpg-agent = { enable = mkEnableOption "GnuPG private key agent"; diff --git a/modules/services/keepassx.nix b/modules/services/keepassx.nix index ff875ee63a1..ad791786f05 100644 --- a/modules/services/keepassx.nix +++ b/modules/services/keepassx.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.keepassx = { enable = mkEnableOption "the KeePassX password manager"; diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index eca5515f2d4..6fd50575a1f 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.network-manager-applet = { enable = mkEnableOption "the Network Manager applet"; diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index f1b8d39d195..4f0a4c43121 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { services.random-background = { enable = mkEnableOption "random desktop background"; diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index ba9f3b1d3ed..9bf66f8946f 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -8,7 +8,10 @@ let cfg = config.services.redshift; -in { +in + +{ + meta.maintainers = [ maintainers.rycee ]; options.services.redshift = { enable = mkOption { diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 5da3a8cf06c..f722208d1a3 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.syncthing = { enable = mkEnableOption "Syncthing continuous file synchronization"; diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index a452295f2fe..b8a642408e1 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { services.taffybar = { enable = mkEnableOption "Taffybar"; diff --git a/modules/services/tahoe-lafs.nix b/modules/services/tahoe-lafs.nix index 8d12b03e2bc..bb7be8d7db9 100644 --- a/modules/services/tahoe-lafs.nix +++ b/modules/services/tahoe-lafs.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.tahoe-lafs = { enable = mkEnableOption "Tahoe-LAFS"; diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index b2a2b4072f9..a9451c325f0 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.udiskie = { enable = mkEnableOption "Udiskie mount daemon"; diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix index b27e5b73ae0..e500c5d85a6 100644 --- a/modules/services/xscreensaver.nix +++ b/modules/services/xscreensaver.nix @@ -3,6 +3,8 @@ with lib; { + meta.maintainers = [ maintainers.rycee ]; + options = { services.xscreensaver = { enable = mkEnableOption "XScreenSaver"; diff --git a/modules/systemd.nix b/modules/systemd.nix index 57017a66865..d77c0076ad9 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -45,6 +45,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { systemd.user = { services = mkOption { diff --git a/modules/xresources.nix b/modules/xresources.nix index abeed0c1fc2..8608438065f 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -17,6 +17,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { xresources.properties = mkOption { type = types.nullOr types.attrs; diff --git a/modules/xsession.nix b/modules/xsession.nix index 89979796c2d..6a3c589effc 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -9,6 +9,8 @@ let in { + meta.maintainers = [ maintainers.rycee ]; + options = { xsession = { enable = mkEnableOption "X Session"; -- cgit v1.2.3 From 393274d142d1729682cbd420bcbccb2329f639b4 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Tue, 26 Sep 2017 08:39:56 +0200 Subject: command-not-found: add module --- modules/default.nix | 1 + modules/misc/news.nix | 10 ++++ .../command-not-found/command-not-found.nix | 57 ++++++++++++++++++++++ .../command-not-found/command-not-found.pl | 44 +++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 modules/programs/command-not-found/command-not-found.nix create mode 100644 modules/programs/command-not-found/command-not-found.pl diff --git a/modules/default.nix b/modules/default.nix index cb3b9f14f98..1c569ef6bdb 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -19,6 +19,7 @@ let ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix + ./programs/command-not-found/command-not-found.nix ./programs/eclipse.nix ./programs/emacs.nix ./programs/feh.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b52b2b2cdc3..70b320d2a8f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -222,6 +222,16 @@ in }; ''; } + + { + time = "2017-09-27T07:28:54+00:00"; + message = '' + A new program module is available: 'programs.command-not-found'. + + Note, this differs from the NixOS system command-not-found + tool in that NIX_AUTO_INSTALL is not supported. + ''; + } ]; }; } diff --git a/modules/programs/command-not-found/command-not-found.nix b/modules/programs/command-not-found/command-not-found.nix new file mode 100644 index 00000000000..0053fe36ad7 --- /dev/null +++ b/modules/programs/command-not-found/command-not-found.nix @@ -0,0 +1,57 @@ +# Adapted from Nixpkgs. + +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.command-not-found; + commandNotFound = pkgs.substituteAll { + name = "command-not-found"; + dir = "bin"; + src = ./command-not-found.pl; + isExecutable = true; + inherit (pkgs) perl; + inherit (cfg) dbPath; + perlFlags = concatStrings (map (path: "-I ${path}/lib/perl5/site_perl ") + [ pkgs.perlPackages.DBI pkgs.perlPackages.DBDSQLite pkgs.perlPackages.StringShellQuote ]); + }; + + shInit = commandNotFoundHandlerName: '' + # This function is called whenever a command is not found. + ${commandNotFoundHandlerName}() { + local p=${commandNotFound}/bin/command-not-found + if [ -x $p -a -f ${cfg.dbPath} ]; then + # Run the helper program. + $p "$@" + else + echo "$1: command not found" >&2 + return 127 + fi + } + ''; + +in + +{ + options.programs.command-not-found = { + enable = mkEnableOption "command-not-found hook for interactive shell"; + + dbPath = mkOption { + default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ; + description = '' + Absolute path to programs.sqlite. By + default this file will be provided by your channel + (nixexprs.tar.xz). + ''; + type = types.path; + }; + }; + + config = mkIf cfg.enable { + programs.bash.initExtra = shInit "command_not_found_handle"; + programs.zsh.initExtra = shInit "command_not_found_handler"; + + home.packages = [ commandNotFound ]; + }; +} diff --git a/modules/programs/command-not-found/command-not-found.pl b/modules/programs/command-not-found/command-not-found.pl new file mode 100644 index 00000000000..997dfec649b --- /dev/null +++ b/modules/programs/command-not-found/command-not-found.pl @@ -0,0 +1,44 @@ +#! @perl@/bin/perl -w @perlFlags@ + +use strict; +use DBI; +use DBD::SQLite; +use String::ShellQuote; +use Config; + +my $program = $ARGV[0]; + +my $dbPath = "@dbPath@"; + +my $dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "") + or die "cannot open database `$dbPath'"; +$dbh->{RaiseError} = 0; +$dbh->{PrintError} = 0; + +my $system = $ENV{"NIX_SYSTEM"} // $Config{myarchname}; + +my $res = $dbh->selectall_arrayref( + "select package from Programs where system = ? and name = ?", + { Slice => {} }, $system, $program); + +if (!defined $res || scalar @$res == 0) { + print STDERR "$program: command not found\n"; +} elsif (scalar @$res == 1) { + my $package = @$res[0]->{package}; + if ($ENV{"NIX_AUTO_RUN"} // "") { + exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV)); + } else { + print STDERR <{package}\n" foreach @$res; +} + +exit 127; -- cgit v1.2.3 From 34428fc7090744481e2328ddfda466596e875775 Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Mon, 25 Sep 2017 13:14:51 +0100 Subject: Add overlay and instructions for using it --- README.md | 15 +++++---------- modules/programs/home-manager.nix | 4 ++-- overlay.nix | 3 +++ 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 overlay.nix diff --git a/README.md b/README.md index 7ad6136654f..32960e91a6f 100644 --- a/README.md +++ b/README.md @@ -62,16 +62,11 @@ Currently the easiest way to install Home Manager is as follows: depending on whether you are tracking Nixpkgs unstable or version 17.03. -3. Add Home Manager to your user's Nixpkgs, for example by adding it - to the `packageOverrides` section in your - `~/.config/nixpkgs/config.nix` file: - - ```nix - { - packageOverrides = pkgs: rec { - home-manager = import ./home-manager { inherit pkgs; }; - }; - } +3. Add Home Manager to your user's Nixpkgs, for example by symlinking the + overlay to `~/.config/nixpkgs/overlays`: + + ```console + $ ln -s ~/.config/nixpkgs/home-manager/overlay.nix ~/.config/nixpkgs/overlays/home-manager.nix ``` 4. Install the `home-manager` package: diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 2b211b85b7a..ad7278a12f0 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -46,8 +46,8 @@ in if nix-env -q | grep -q '^home-manager$' ; then $DRY_RUN_CMD nix-env -e home-manager - echo "You can now remove the 'home-manager' entry in" - echo "'~/.config/nixpkgs/config.nix', if you want." + echo "You can now remove the 'home-manager' packageOverride" + echo "or overlay in '~/.config/nixpkgs/', if you want." fi ''; }; diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 00000000000..6c64fa6b191 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,3 @@ +self: super: { + home-manager = import ./home-manager { pkgs = super; }; +} -- cgit v1.2.3 From e1bceb2adb046d56b437d6c2c48fc717b0b028e3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 27 Sep 2017 13:29:32 +0200 Subject: readme: add 'console' syntax highlighting --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 32960e91a6f..cb0517ba253 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Currently the easiest way to install Home Manager is as follows: 1. Make sure you have a working Nix installation. If you are not using NixOS then you may here have to run - ``` + ```console $ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER ``` @@ -49,13 +49,13 @@ Currently the easiest way to install Home Manager is as follows: 2. Clone the Home Manager repository into the `~/.config/nixpkgs` directory: - ``` + ```console $ git clone -b master https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager ``` or - ``` + ```console $ git clone -b release-17.03 https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager ``` @@ -71,7 +71,7 @@ Currently the easiest way to install Home Manager is as follows: 4. Install the `home-manager` package: - ``` + ```console $ nix-env -f '' -iA home-manager installing ‘home-manager’ ``` @@ -123,13 +123,13 @@ First create a file `~/.config/nixpkgs/home.nix` containing To activate this configuration you can then run -``` +```console $ home-manager switch ``` or if you are not feeling so lucky, -``` +```console $ home-manager build ``` @@ -139,7 +139,7 @@ activation script and the generated home directory files. To see available configuration options with descriptions and usage examples run -``` +```console $ man home-configuration.nix ``` @@ -173,7 +173,7 @@ For example, suppose you have a wonderful, painstakingly created to your configuration. Attempting to switch to the generation will then result in -``` +```console $ home-manager switch … Activating checkLinkTargets -- cgit v1.2.3 From e9deaf2ca5b414de4c5ed156fb801f05011f617a Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 28 Sep 2017 14:41:35 +0200 Subject: rofi: add module --- modules/default.nix | 1 + modules/misc/news.nix | 6 ++ modules/programs/rofi.nix | 260 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 267 insertions(+) create mode 100644 modules/programs/rofi.nix diff --git a/modules/default.nix b/modules/default.nix index 1c569ef6bdb..a9d3552f2ca 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -30,6 +30,7 @@ let ./programs/htop.nix ./programs/info.nix ./programs/lesspipe.nix + ./programs/rofi.nix ./programs/ssh.nix ./programs/termite.nix ./programs/texlive.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 70b320d2a8f..db2aee3479e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -232,6 +232,12 @@ in tool in that NIX_AUTO_INSTALL is not supported. ''; } + { + time = "2017-09-28T12:39:36+00:00"; + message = '' + A new program module is available: 'programs.rofi'; + ''; + } ]; }; } diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix new file mode 100644 index 00000000000..0194a3d56fd --- /dev/null +++ b/modules/programs/rofi.nix @@ -0,0 +1,260 @@ +{ config, lib, pkgs, ... }: + +with lib; +with builtins; + +let + + cfg = config.programs.rofi; + + colorOption = description: mkOption { + type = types.string; + description = description; + }; + + rowColorSubmodule = types.submodule { + options = { + background = colorOption "Background color"; + foreground = colorOption "Foreground color"; + backgroundAlt = colorOption "Alternative background color"; + highlight = mkOption { + type = types.submodule { + options = { + background = colorOption "Highlight background color"; + foreground = colorOption "Highlight foreground color"; + }; + }; + description = "Color settings for highlighted row."; + }; + }; + }; + + windowColorSubmodule = types.submodule { + options = { + background = colorOption "Window background color"; + border = colorOption "Window border color"; + separator = colorOption "Separator color"; + }; + }; + + colorsSubmodule = types.submodule { + options = { + window = mkOption { + default = null; + type = windowColorSubmodule; + description = "Window color settings."; + }; + rows = mkOption { + default = null; + type = types.submodule { + options = { + normal = mkOption { + default = null; + type = types.nullOr rowColorSubmodule; + description = "Normal row color settings."; + }; + active = mkOption { + default = null; + type = types.nullOr rowColorSubmodule; + description = "Active row color settings."; + }; + urgent = mkOption { + default = null; + type = types.nullOr rowColorSubmodule; + description = "Urgent row color settings."; + }; + }; + }; + description = "Rows color settings."; + }; + }; + }; + + valueToString = value: + if isBool value + then (if value then "true" else "else") + else toString value; + + windowColorsToString = window: concatStringsSep ", " (with window; [ + background + border + separator + ]); + + rowsColorsToString = rows: '' + ${optionalString + (rows.normal != null) + (setOption "color-normal" (rowColorsToString rows.normal))} + ${optionalString + (rows.active != null) + (setOption "color-active" (rowColorsToString rows.active))} + ${optionalString + (rows.urgent != null) + (setOption "color-urgent" (rowColorsToString rows.urgent))} + ''; + + rowColorsToString = row: concatStringsSep ", " (with row; [ + background + foreground + backgroundAlt + highlight.background + highlight.foreground + ]); + + setOption = name: value: + optionalString (value != null) "rofi.${name}: ${valueToString value}"; + + setColorScheme = colors: optionalString (colors != null) '' + ${optionalString + (colors.window != null) + setOption "color-window" (windowColorsToString colors.window)} + ${optionalString + (colors.rows != null) + (rowsColorsToString colors.rows)} + ''; + +in + +{ + options.programs.rofi = { + enable = mkEnableOption "Rofi: A window switcher, application launcher and dmenu replacement"; + + width = mkOption { + default = null; + type = types.nullOr types.int; + description = "Window width"; + example = 100; + }; + + lines = mkOption { + default = null; + type = types.nullOr types.int; + description = "Number of lines"; + example = 10; + }; + + borderWidth = mkOption { + default = null; + type = types.nullOr types.int; + description = "Border width"; + example = 1; + }; + + rowHeight = mkOption { + default = null; + type = types.nullOr types.int; + description = "Row height (in chars)"; + example = 1; + }; + + padding = mkOption { + default = null; + type = types.nullOr types.int; + description = "Padding"; + example = 400; + }; + + font = mkOption { + default = null; + type = types.nullOr types.string; + example = "Droid Sans Mono 14"; + description = "Font to use"; + }; + + scrollbar = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Whether to show a scrollbar."; + }; + + terminal = mkOption { + default = null; + type = types.nullOr types.string; + description = '' + Path to the terminal which will be used to run console applications + ''; + example = "\${pkgs.gnome3.gnome_terminal}/bin/gnome-terminal"; + }; + + separator = mkOption { + default = null; + type = types.nullOr (types.enum [ "none" "dash" "solid" ]); + description = "Separator style"; + example = "solid"; + }; + + cycle = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Whether to cycle through the results list"; + }; + + colors = mkOption { + default = null; + type = types.nullOr colorsSubmodule; + description = '' + Color scheme settings. + Colors can be specified in CSS color formats. + ''; + example = literalExample '' + colors = { + window = { + background = "argb:583a4c54"; + border = "argb:582a373e"; + separator = "#c3c6c8"; + }; + + rows = { + normal = { + background = "argb:58455a64"; + foreground = "#fafbfc"; + backgroundAlt = "argb:58455a64"; + highlight = { + background = "#00bcd4"; + foreground = "#fafbfc"; + }; + }; + }; + }; + ''; + }; + + configPath = mkOption { + default = ".config/rofi/config"; + type = types.string; + description = "Path where to put generated configuration file."; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = "Additional configuration to add."; + }; + + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.rofi ]; + + home.file."${cfg.configPath}".text = '' + ${setOption "width" cfg.width} + ${setOption "lines" cfg.lines} + ${setOption "font" cfg.font} + ${setOption "bw" cfg.borderWidth} + ${setOption "eh" cfg.rowHeight} + ${setOption "padding" cfg.padding} + ${setOption "separator-style" cfg.separator} + ${setOption "hide-scrollbar" ( + if (cfg.scrollbar != null) + then (! cfg.scrollbar) + else cfg.scrollbar + )} + ${setOption "terminal" cfg.terminal} + ${setOption "cycle" cfg.cycle} + + ${setColorScheme cfg.colors} + + ${cfg.extraConfig} + ''; + }; +} -- cgit v1.2.3 From bcff7274f432868e03736e7654d3a742912c4b1a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 30 Sep 2017 12:10:52 +0200 Subject: vim, zsh: use DocBook links in description --- modules/programs/vim.nix | 4 ++-- modules/programs/zsh.nix | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index e246c21fdf9..b96adeacbc5 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -32,8 +32,8 @@ in default = defaultPlugins; example = [ "YankRing" ]; description = '' - List of vim plugins to install. - For supported plugins see: https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/vim-plugins/vim-plugin-names + List of vim plugins to install. For supported plugins see: + . ''; }; diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index dd0f986abda..c7ad7702311 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -105,8 +105,9 @@ let type = types.str; example = "$HOME/my_customizations"; description = '' - Path to a custom oh-my-zsh package to override config of oh-my-zsh. - See: https://github.com/robbyrussell/oh-my-zsh/wiki/Customization + Path to a custom oh-my-zsh package to override config of + oh-my-zsh. See + for more information. ''; }; -- cgit v1.2.3 From 23d3539fcbfea31f739905f4713dd39d79a32a79 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 23 Sep 2017 00:34:25 +0200 Subject: xsession: deprecate `xsession.windowManager` The intention is for the `xsession.windowManager` option to be available for full modules in the future. The option `xsession.windowManager.command` should now be used to specify the window manager startup command. --- modules/misc/news.nix | 17 +++++ modules/xsession.nix | 172 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 120 insertions(+), 69 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index db2aee3479e..025f69c0ef4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -232,12 +232,29 @@ in tool in that NIX_AUTO_INSTALL is not supported. ''; } + { time = "2017-09-28T12:39:36+00:00"; message = '' A new program module is available: 'programs.rofi'; ''; } + + { + time = "2017-09-28T21:39:45+00:00"; + condition = + config.xsession.enable + && config.xsession.windowManager.usesDeprecated; + message = '' + The 'xsession.windowManager' option is now deprecated, + please use 'xsession.windowManager.command' instead. + + This change was made to prepare for window manager modules + under the 'xsession.windowManager' namespace. For example, + 'xsession.windowManager.xmonad' and + 'xsession.windowManager.i3'. + ''; + } ]; }; } diff --git a/modules/xsession.nix b/modules/xsession.nix index 6a3c589effc..4899ad2ea76 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -6,6 +6,32 @@ let cfg = config.xsession; + # Hack to support xsession.windowManager.command option. + wmBaseModule = { + options = { + command = mkOption { + type = types.str; + example = literalExample '' + let + xmonad = pkgs.xmonad-with-packages.override { + packages = self: [ self.xmonad-contrib self.taffybar ]; + }; + in + "''${xmonad}/bin/xmonad"; + ''; + description = '' + Window manager start command. + ''; + }; + + usesDeprecated = mkOption { + internal = true; + type = types.bool; + default = false; + }; + }; + }; + in { @@ -16,16 +42,15 @@ in enable = mkEnableOption "X Session"; windowManager = mkOption { - type = types.str; - example = literalExample '' - let - xmonad = pkgs.xmonad-with-packages.override { - packages = self: [ self.xmonad-contrib self.taffybar ]; - }; - in - "''${xmonad}/bin/xmonad"; + type = + types.coercedTo + types.str + (command: { inherit command; usesDeprecated = true; }) + (types.submodule wmBaseModule); + description = '' + Window manager start command. DEPRECATED: Use + xsession.windowManager.command instead. ''; - description = "Path to window manager to exec."; }; initExtra = mkOption { @@ -36,75 +61,84 @@ in }; }; - config = mkIf cfg.enable { - systemd.user.services.setxkbmap = { - Unit = { - Description = "Set up keyboard in X"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - ExecStart = - let - args = concatStringsSep " " ( - [ - "-layout '${config.home.keyboard.layout}'" - "-variant '${config.home.keyboard.variant}'" - ] ++ - (map (v: "-option '${v}'") config.home.keyboard.options) - ); - in - "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.windowManager.usesDeprecated { + warnings = [ + ("xsession.windowManager is deprecated, " + + "please use xsession.windowManager.command") + ]; + }) + + { + systemd.user.services.setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; }; - }; - # A basic graphical session target for Home Manager. - systemd.user.targets.hm-graphical-session = { - Unit = { - Description = "Home Manager X session"; - Requires = [ "graphical-session-pre.target" ]; - BindsTo = [ "graphical-session.target" ]; + # A basic graphical session target for Home Manager. + systemd.user.targets.hm-graphical-session = { + Unit = { + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; + }; }; - }; - home.file.".xsession" = { - mode = "555"; - text = '' - if [[ -e "$HOME/.profile" ]]; then - . "$HOME/.profile" - fi + home.file.".xsession" = { + mode = "555"; + text = '' + if [[ -e "$HOME/.profile" ]]; then + . "$HOME/.profile" + fi - # If there are any running services from a previous session. - systemctl --user stop graphical-session.target graphical-session-pre.target + # If there are any running services from a previous session. + systemctl --user stop graphical-session.target graphical-session-pre.target - systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS - systemctl --user import-environment DISPLAY - systemctl --user import-environment SSH_AUTH_SOCK - systemctl --user import-environment XAUTHORITY - systemctl --user import-environment XDG_DATA_DIRS - systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user import-environment XDG_SESSION_ID + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS + systemctl --user import-environment DISPLAY + systemctl --user import-environment SSH_AUTH_SOCK + systemctl --user import-environment XAUTHORITY + systemctl --user import-environment XDG_DATA_DIRS + systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user import-environment XDG_SESSION_ID - systemctl --user start hm-graphical-session.target + systemctl --user start hm-graphical-session.target - ${cfg.initExtra} + ${cfg.initExtra} - ${cfg.windowManager} + ${cfg.windowManager.command} - systemctl --user stop graphical-session.target - systemctl --user stop graphical-session-pre.target + systemctl --user stop graphical-session.target + systemctl --user stop graphical-session-pre.target - # Wait until the units actually stop. - while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do - sleep 0.5 - done - ''; - }; - }; + # Wait until the units actually stop. + while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do + sleep 0.5 + done + ''; + }; + } + ]); } -- cgit v1.2.3 From aa974c0dc3a27c2d68a9777a6554f67be5a80fdd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Sep 2017 00:15:08 +0200 Subject: vim: add option `programs.vim.settings` This option gathers basic Vim options into a single place. The idea is to allow many options without making the Home Manager documentation too verbose. This also deprecates the options `programs.vim.lineNumbers` and `programs.vim.tabSize`. Fixes #69. --- modules/misc/news.nix | 19 ++++++++ modules/programs/vim.nix | 115 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 122 insertions(+), 12 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 025f69c0ef4..3c30587015d 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -255,6 +255,25 @@ in 'xsession.windowManager.i3'. ''; } + + { + time = "2017-09-30T09:44:18+00:00"; + condition = with config.programs.vim; + enable && (tabSize != null || lineNumbers != null); + message = '' + The options 'programs.vim.tabSize' and 'programs.vim.lineNumbers' have + been deprecated and will be removed in the near future. + + The new and preferred way to configure tab size and line numbers is to + use the more general 'programs.vim.settings' option. Specifically, + instead of + + - 'programs.vim.lineNumbers' use 'programs.vim.settings.number', and + + - 'programs.vim.tabSize' use 'programs.vim.settings.tabstop' and + 'programs.vim.settings.shiftwidth'. + ''; + } ]; }; } diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index b96adeacbc5..8f94301607f 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -7,6 +7,36 @@ let cfg = config.programs.vim; defaultPlugins = [ "sensible" ]; + knownSettings = { + background = types.enum [ "dark" "light" ]; + expandtab = types.bool; + history = types.int; + number = types.bool; + relativenumber = types.bool; + shiftwidth = types.int; + tabstop = types.int; + }; + + vimSettingsType = types.submodule { + options = + let + opt = name: type: mkOption { + type = types.nullOr type; + default = null; + visible = false; + }; + in + mapAttrs opt knownSettings; + }; + + setExpr = name: value: + let + v = + if isBool value then (if value then "" else "no") + name + else name + "=" + toString value; + in + optionalString (value != null) ("set " + v); + in { @@ -17,14 +47,22 @@ in lineNumbers = mkOption { type = types.nullOr types.bool; default = null; - description = "Whether to show line numbers."; + description = '' + Whether to show line numbers. DEPRECATED: Use + programs.vim.settings.number. + ''; }; tabSize = mkOption { type = types.nullOr types.int; - default = null; + default = null; example = 4; - description = "Set tab size and shift width to a specified number of spaces."; + description = '' + Set tab size and shift width to a specified number of + spaces. DEPRECATED: Use + programs.vim.settings.tabstop and + programs.vim.settings.shiftwidth. + ''; }; plugins = mkOption { @@ -37,6 +75,38 @@ in ''; }; + settings = mkOption { + type = vimSettingsType; + default = {}; + example = literalExample '' + { + expandtab = true; + history = 1000; + background = "dark"; + } + ''; + description = '' + At attribute set of Vim settings. The attribute names and + corresponding values must be among the following supported + options. + + + ${concatStringsSep "\n" ( + mapAttrsToList (n: v: '' + + ${n} + ${v.description} + + '') knownSettings + )} + + + See the Vim documentation for detailed descriptions of these + options. Note, use extraConfig to + manually set any options not listed above. + ''; + }; + extraConfig = mkOption { type = types.lines; default = ""; @@ -57,12 +127,11 @@ in config = ( let - optionalBoolean = name: val: optionalString (val != null) (if val then "set ${name}" else "unset ${name}"); - optionalInteger = name: val: optionalString (val != null) "set ${name}=${toString val}"; customRC = '' - ${optionalBoolean "number" cfg.lineNumbers} - ${optionalInteger "tabstop" cfg.tabSize} - ${optionalInteger "shiftwidth" cfg.tabSize} + ${concatStringsSep "\n" ( + filter (v: v != "") ( + mapAttrsToList setExpr ( + builtins.intersectAttrs knownSettings cfg.settings)))} ${cfg.extraConfig} ''; @@ -76,9 +145,31 @@ in ]; }; - in mkIf cfg.enable { - programs.vim.package = vim; - home.packages = [ cfg.package ]; - } + in mkIf cfg.enable (mkMerge [ + { + programs.vim.package = vim; + home.packages = [ cfg.package ]; + } + + (mkIf (cfg.lineNumbers != null) { + warnings = [ + ("'programs.vim.lineNumbers' is deprecated, " + + "use 'programs.vim.settings.number'") + ]; + + programs.vim.settings.number = cfg.lineNumbers; + }) + + (mkIf (cfg.tabSize != null) { + warnings = [ + ("'programs.vim.tabSize' is deprecated, use " + + "'programs.vim.settings.tabstop' and " + + "'programs.vim.settings.shiftwidth'") + ]; + + programs.vim.settings.tabstop = cfg.tabSize; + programs.vim.settings.shiftwidth = cfg.tabSize; + }) + ]) ); } -- cgit v1.2.3 From 52256d7a73f5849014014451d28935b810ee03f4 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 30 Sep 2017 14:14:07 +0200 Subject: rofi: add fullscreen option --- modules/programs/rofi.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 0194a3d56fd..9391b2d0927 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -158,7 +158,7 @@ in default = null; type = types.nullOr types.string; example = "Droid Sans Mono 14"; - description = "Font to use"; + description = "Font to use."; }; scrollbar = mkOption { @@ -186,7 +186,13 @@ in cycle = mkOption { default = null; type = types.nullOr types.bool; - description = "Whether to cycle through the results list"; + description = "Whether to cycle through the results list."; + }; + + fullscreen = mkOption { + default = null; + type = types.nullOr types.bool; + description = "Whether to run rofi fullscreen."; }; colors = mkOption { @@ -251,6 +257,7 @@ in )} ${setOption "terminal" cfg.terminal} ${setOption "cycle" cfg.cycle} + ${setOption "fullscreen" cfg.fullscreen} ${setColorScheme cfg.colors} -- cgit v1.2.3 From e4c359d8b9b2cdb3b9b1bec4f75567ba6e6bf969 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 2 Oct 2017 13:25:31 +0200 Subject: udiskie: add a few configuration options The new options allow some control over automounting, notifications, and the tray icon. This commit also changes the defaults to automatically mount new devices, udiskie was previously told not to automount. The change in behavior is to closer match the default options. --- modules/misc/news.nix | 14 +++++++++++ modules/services/udiskie.nix | 59 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3c30587015d..5bbb6fa7065 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -274,6 +274,20 @@ in 'programs.vim.settings.shiftwidth'. ''; } + + { + time = "2017-10-02T11:15:03+00:00"; + condition = config.services.udiskie.enable; + message = '' + The udiskie service now defaults to automatically mounting + new devices. Previous behavior was to not automatically + mount. To restore this previous behavior add + + services.udiskie.automount = false; + + to your Home Manager configuration. + ''; + } ]; }; } diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index a9451c325f0..e4d4f527915 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -2,25 +2,78 @@ with lib; +let + + cfg = config.services.udiskie; + + commandArgs = + concatStringsSep " " ( + map (opt: "-" + opt) [ + (if cfg.automount then "a" else "A") + (if cfg.notify then "n" else "N") + ({ always = "t"; auto = "s"; never = "T"; }.${cfg.tray}) + ] + ); + +in + { meta.maintainers = [ maintainers.rycee ]; options = { services.udiskie = { - enable = mkEnableOption "Udiskie mount daemon"; + enable = mkEnableOption "udiskie mount daemon"; + + automount = mkOption { + type = types.bool; + default = true; + description = "Whether to automatically mount new devices."; + }; + + notify = mkOption { + type = types.bool; + default = true; + description = "Whether to show pop-up notifications."; + }; + + tray = mkOption { + type = types.enum [ "always" "auto" "never" ]; + default = "auto"; + description = '' + Whether to display tray icon. + + The options are + + + always + Always show tray icon. + + + auto + + Show tray icon only when there is a device available. + + + + never + Never show tray icon. + + + ''; + }; }; }; config = mkIf config.services.udiskie.enable { systemd.user.services.udiskie = { Unit = { - Description = "Udiskie mount daemon"; + Description = "udiskie mount daemon"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; }; Service = { - ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 -A -n -s"; + ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 ${commandArgs}"; }; Install = { -- cgit v1.2.3 From fb5dbe13c24b4ae09d908389804ba559a6a152da Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 4 Oct 2017 00:24:59 +0200 Subject: readme: minor fixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb0517ba253..e0da6b240b4 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ $ man home-configuration.nix Keeping your ~ safe from harm ----------------------------- -To configure programs and services the Home Manager must write various +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 @@ -207,7 +207,7 @@ in your system configuration and # … xsession.enable = true; - xsession.windowManager = "…"; + xsession.windowManager.command = "…"; # … } -- cgit v1.2.3 From 9c859d26553aebe56bb669f275af04cc1dbc4af5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 29 Sep 2017 00:15:57 +0200 Subject: xmonad: add module Adapted from #78 and originally authored by Infinisil. --- modules/misc/news.nix | 7 +++ modules/services/window-managers/xmonad.nix | 86 +++++++++++++++++++++++++++++ modules/xsession.nix | 35 +++++++++++- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 modules/services/window-managers/xmonad.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 5bbb6fa7065..613cc595cf9 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -288,6 +288,13 @@ in to your Home Manager configuration. ''; } + + { + time = "2017-10-04T18:36:07+00:00"; + message = '' + A new module is available: 'xsession.windowManager.xmonad'. + ''; + } ]; }; } diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix new file mode 100644 index 00000000000..8105612c8c6 --- /dev/null +++ b/modules/services/window-managers/xmonad.nix @@ -0,0 +1,86 @@ +{ pkgs }: { config, lib, ... }: + +with lib; + +let + + cfg = config.xmonad; + + xmonad = pkgs.xmonad-with-packages.override { + ghcWithPackages = cfg.haskellPackages.ghcWithPackages; + packages = self: + cfg.extraPackages self + ++ optionals cfg.enableContribAndExtras [ + self.xmonad-contrib self.xmonad-extras + ]; + }; + +in + +{ + options = { + xmonad = { + enable = mkEnableOption "xmonad window manager"; + + haskellPackages = mkOption { + default = pkgs.haskellPackages; + defaultText = "pkgs.haskellPackages"; + example = literalExample "pkgs.haskell.packages.ghc784"; + description = '' + The haskellPackages used to build xmonad + and other packages. This can be used to change the GHC + version used to build xmonad and the packages listed in + extraPackages. + ''; + }; + + extraPackages = mkOption { + default = self: []; + defaultText = "self: []"; + example = literalExample '' + haskellPackages: [ + haskellPackages.xmonad-contrib + haskellPackages.monad-logger + ] + ''; + description = '' + Extra packages available to GHC when rebuilding xmonad. The + value must be a function which receives the attribute set + defined in haskellPackages as the sole + argument. + ''; + }; + + enableContribAndExtras = mkOption { + default = false; + type = types.bool; + description = "Enable xmonad-{contrib,extras} in xmonad."; + }; + + config = mkOption { + type = types.nullOr types.path; + default = null; + example = literalExample '' + pkgs.writeText "xmonad.hs" ''' + import XMonad + main = xmonad defaultConfig + { terminal = "urxvt" + , modMask = mod4Mask + , borderWidth = 3 + } + ''' + ''; + description = '' + The configuration file to be used for xmonad. This must be + an absolute path or null in which case + ~/.xmonad/xmonad.hs will not be managed + by Home Manager. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + command = "${xmonad}/bin/xmonad"; + }; +} diff --git a/modules/xsession.nix b/modules/xsession.nix index 4899ad2ea76..5c9ee777881 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: with lib; +with import ./lib/dag.nix { inherit lib; }; let @@ -32,6 +33,10 @@ let }; }; + xmonadModule = import ./services/window-managers/xmonad.nix { + inherit pkgs; + }; + in { @@ -46,7 +51,7 @@ in types.coercedTo types.str (command: { inherit command; usesDeprecated = true; }) - (types.submodule wmBaseModule); + (types.submodule [ wmBaseModule xmonadModule ]); description = '' Window manager start command. DEPRECATED: Use xsession.windowManager.command instead. @@ -69,6 +74,34 @@ in ]; }) + # Hack to support xsession.windowManager as a string. Once that is + # removed this code should go back into the xmonad.nix file. + (mkIf (cfg.windowManager.xmonad.enable + && cfg.windowManager.xmonad.config != null) { + home.file.".xmonad/xmonad.hs".source = cfg.windowManager.xmonad.config; + + home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] '' + if ! cmp --quiet \ + "${cfg.windowManager.xmonad.config}" \ + "$HOME/.xmonad/xmonad.hs"; then + xmonadChanged=1 + fi + ''; + + home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] '' + if [[ -v xmonadChanged ]]; then + echo "Recompiling xmonad" + ${cfg.windowManager.command} --recompile + + # Attempt to restart xmonad if X is running. + if [[ -v DISPLAY ]] ; then + echo "Restarting xmonad" + ${cfg.windowManager.command} --restart + fi + fi + ''; + }) + { systemd.user.services.setxkbmap = { Unit = { -- cgit v1.2.3 From 01d46a17513d015f936b1f9ccf7dc54a7dc422de Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 4 Oct 2017 20:45:20 +0200 Subject: readme: current NixOS stable is version 17.09 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0da6b240b4..eb373c67fac 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwrite was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] unstable and NixOS version 17.03 (the +Home Manager targets [NixOS][] unstable and NixOS version 17.09 (the current stable version), it may or may not work on other Linux distributions and NixOS versions. @@ -56,11 +56,11 @@ Currently the easiest way to install Home Manager is as follows: or ```console - $ git clone -b release-17.03 https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager + $ git clone -b release-17.09 https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager ``` depending on whether you are tracking Nixpkgs unstable or version - 17.03. + 17.09. 3. Add Home Manager to your user's Nixpkgs, for example by symlinking the overlay to `~/.config/nixpkgs/overlays`: -- cgit v1.2.3 From 3aca8a938c36e49787e53b58cfa74214f407da40 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 5 Oct 2017 19:54:09 +0200 Subject: gpg-agent: use full path to `gpg-connect-agent` --- modules/services/gpg-agent.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 4f1dd5f2d34..9f4a9b5414e 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -9,7 +9,7 @@ let gpgInitStr = '' GPG_TTY="$(tty)" export GPG_TTY - gpg-connect-agent updatestartuptty /bye > /dev/null + ${pkgs.gnupg}/bin/gpg-connect-agent updatestartuptty /bye > /dev/null ''; in -- cgit v1.2.3 From 469caa1a1405b22a849f60280ca4bdaec2f3289b Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 5 Oct 2017 15:55:37 +0200 Subject: polybar: add module --- modules/default.nix | 1 + modules/misc/news.nix | 7 +++ modules/services/polybar.nix | 139 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 modules/services/polybar.nix diff --git a/modules/default.nix b/modules/default.nix index a9d3552f2ca..ab7b1065ed9 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -44,6 +44,7 @@ let ./services/keepassx.nix ./services/network-manager-applet.nix ./services/owncloud-client.nix + ./services/polybar.nix ./services/random-background.nix ./services/redshift.nix ./services/screen-locker.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 613cc595cf9..ebda61cf829 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -295,6 +295,13 @@ in A new module is available: 'xsession.windowManager.xmonad'. ''; } + + { + time = "2017-10-06T08:21:43+00:00"; + message = '' + A new service is available: 'services.polybar'. + ''; + } ]; }; } diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix new file mode 100644 index 00000000000..29f268ff2b2 --- /dev/null +++ b/modules/services/polybar.nix @@ -0,0 +1,139 @@ +{ config, lib, pkgs, ... }: + +with lib; +with import ../lib/dag.nix { inherit lib; }; + +let + + cfg = config.services.polybar; + + configFile = pkgs.writeText "polybar.conf" + (generators.toINI {} cfg.config + "\n" + cfg.extraConfig); + + script = '' + #!${pkgs.stdenv.shell} + + ${cfg.script} + ''; + +in + +{ + options = { + services.polybar = { + enable = mkEnableOption "Polybar status bar"; + + package = mkOption { + type = types.package; + default = pkgs.polybar; + defaultText = "pkgs.polybar"; + description = "Polybar package to install."; + example = literalExample '' + pkgs.polybar.override { + i3GapsSupport = true; + alsaSupport = true; + iwSupport = true; + githubSupport = true; + } + ''; + }; + + config = mkOption { + type = types.coercedTo + types.path + (p: { "section/base" = { include-file = "${p}"; }; }) + (types.attrsOf types.attrs); + description = '' + Polybar configuration. Can be either path to a file, or set of attibutes + that will be used to create the final configuration. + ''; + default = {}; + example = literalExample '' + { + "bar/top" = { + monitor = "\''${env:MONITOR:eDP1}"; + width = "100%"; + height = "3%"; + radius = 0; + modules-center = "date"; + }; + + "module/date" = { + type = "internal/date"; + internal = 5; + date = "%d.%m.%y"; + time = "%H:%M"; + label = "%time% %date%"; + }; + } + ''; + }; + + extraConfig = mkOption { + type = types.lines; + description = "Additional configuration to add."; + default = ""; + example = '' + [module/date] + type = internal/date + interval = 5 + date = "%d.%m.%y" + time = %H:%M + format-prefix-foreground = \''${colors.foreground-alt} + label = %time% %date% + ''; + }; + + script = mkOption { + type = types.lines; + description = '' + This script will be used to start the polybars. + Set all necessary environment variables here and start all bars. + It can be assumed that polybar executable is in the PATH. + + Note, this script must start all bars in the background and then terminate. + ''; + example = "polybar bar &"; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + home.file.".config/polybar/config".source = configFile; + + systemd.user.services.polybar = { + Unit = { + Description = "Polybar status bar"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "forking"; + Environment = "PATH=${cfg.package}/bin"; + ExecStart = ''${pkgs.writeScriptBin "polybar-start" script}/bin/polybar-start''; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + + home.activation.checkPolybar = dagEntryBefore [ "linkGeneration" ] '' + if ! cmp --quiet \ + "${configFile}" \ + "$HOME/.config/polybar/config"; then + polybarChanged=1 + fi + ''; + + home.activation.applyPolybar = dagEntryAfter [ "reloadSystemD" ] '' + if [[ -v polybarChanged && -v DISPLAY ]]; then + echo "Restarting polybar" + systemctl --user restart polybar.service + fi + ''; + }; + +} -- cgit v1.2.3 From 9eb48312c7090a661fd7ca423669b6ceb2b883de Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 9 Oct 2017 14:21:43 +0200 Subject: polybar: enclose strings in double quotes This fixes the case when there are trailing spaces in string values which can be used for elements padding. --- modules/services/polybar.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 29f268ff2b2..351626f8bb8 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -7,8 +7,19 @@ let cfg = config.services.polybar; + toPolybarIni = generators.toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "true" else "false") + else if isString value then "\"${value}\"" + else toString value; + in + "${key}=${value'}"; + }; + configFile = pkgs.writeText "polybar.conf" - (generators.toINI {} cfg.config + "\n" + cfg.extraConfig); + (toPolybarIni cfg.config + "\n" + cfg.extraConfig); script = '' #!${pkgs.stdenv.shell} -- cgit v1.2.3 From 420a3f4a01f58ac6d504435b1641106cb59588c1 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 9 Oct 2017 14:39:56 +0200 Subject: vim: add more vim settings New settings: copyindent, hidden, ignorecase, modeline, smartcase. --- modules/programs/vim.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index 8f94301607f..c77c0d45d30 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -9,11 +9,16 @@ let knownSettings = { background = types.enum [ "dark" "light" ]; + copyindent = types.bool; expandtab = types.bool; + hidden = types.bool; history = types.int; + ignorecase = types.bool; + modeline = types.bool; number = types.bool; relativenumber = types.bool; shiftwidth = types.int; + smartcase = types.bool; tabstop = types.int; }; -- cgit v1.2.3 From 3160c0384370f7a8dc340cf341c67066daf9c81e Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 9 Oct 2017 11:20:12 +0200 Subject: dunst: implement settings parameter --- modules/services/dunst.nix | 74 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 659425b116c..22a7d216340 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -2,6 +2,22 @@ with lib; +let + + cfg = config.services.dunst; + toDunstIni = generators.toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "yes" else "no") + else if isString value then "\"${value}\"" + else toString value; + in + "${key}=${value'}"; + }; + +in + { meta.maintainers = [ maintainers.rycee ]; @@ -10,29 +26,53 @@ with lib; enable = mkEnableOption "the dunst notification daemon"; settings = mkOption { - type = types.attrs; + type = types.attrsOf types.attrs; default = {}; description = "Configuration written to ~/.config/dunstrc"; + example = literalExample '' + { + global = { + geometry = "300x5-30+50"; + transparency = 10; + frame_color = "#eceff1"; + font = "Droid Sans 9"; + }; + + urgency_normal = { + background = "#37474f"; + foreground = "#eceff1"; + timeout = 10; + }; + }; + ''; }; }; }; - config = mkIf config.services.dunst.enable { - home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = - "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; + config = mkIf cfg.enable ( + mkMerge [ + { + home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = + "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; - systemd.user.services.dunst = { - Unit = { - Description = "Dunst notification daemon"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + systemd.user.services.dunst = { + Unit = { + Description = "Dunst notification daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Service = { - Type = "dbus"; - BusName = "org.freedesktop.Notifications"; - ExecStart = "${pkgs.dunst}/bin/dunst"; - }; - }; - }; + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.dunst}/bin/dunst"; + }; + }; + } + + (mkIf (cfg.settings != {}) { + home.file.".config/dunst/dunstrc".text = toDunstIni cfg.settings; + }) + ] + ); } -- cgit v1.2.3 From 3f430627df846b8f1787ea8c28a90bcdc6fb6469 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 9 Oct 2017 18:37:57 +0200 Subject: fontconfig: add module --- modules/default.nix | 1 + modules/misc/fontconfig.nix | 41 +++++++++++++++++++++++++++++++++++++++++ modules/misc/news.nix | 15 +++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 modules/misc/fontconfig.nix diff --git a/modules/default.nix b/modules/default.nix index ab7b1065ed9..d43831ee770 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -13,6 +13,7 @@ let modules = [ ./home-environment.nix ./manual.nix + ./misc/fontconfig.nix ./misc/gtk.nix ./misc/news.nix ./misc/pam.nix diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix new file mode 100644 index 00000000000..aab29b67d43 --- /dev/null +++ b/modules/misc/fontconfig.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.fonts.fontconfig; + +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + fonts.fontconfig = { + enableProfileFonts = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Configure fontconfig to discover fonts installed through + home.packages and + nix-env. + + Note, this is only necessary on non-NixOS systems. + ''; + }; + }; + }; + + config = mkIf cfg.enableProfileFonts { + home.file.".config/fontconfig/conf.d/10-nix-profile-fonts.conf".text = '' + + + + ~/.nix-profile/lib/X11/fonts + ~/.nix-profile/share/fonts + + ''; + }; +} diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ebda61cf829..f0a41d7c143 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -302,6 +302,21 @@ in A new service is available: 'services.polybar'. ''; } + + { + time = "2017-10-09T16:38:34+00:00"; + message = '' + A new module is available: 'fonts.fontconfig'. + + In particular, the Boolean option + + fonts.fontconfig.enableProfileFonts + + was added for those who do not use NixOS and want to install + font packages using 'nix-env' or 'home.packages'. If you are + using NixOS then you do not need to enable this option. + ''; + } ]; }; } -- cgit v1.2.3 From 7e6f3364bcf0a0ec838aa4853f550a9a7b5ed027 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 11 Oct 2017 13:05:47 +0200 Subject: blueman-applet: add note about required system service --- modules/services/blueman-applet.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/services/blueman-applet.nix b/modules/services/blueman-applet.nix index d8e58385c70..186dc7454f9 100644 --- a/modules/services/blueman-applet.nix +++ b/modules/services/blueman-applet.nix @@ -5,7 +5,15 @@ with lib; { options = { services.blueman-applet = { - enable = mkEnableOption "Blueman applet"; + enable = mkEnableOption '' + Blueman applet. + + Note, for the applet to work, 'blueman' package should also be installed system-wide + since it requires running 'blueman-mechanism' service activated via dbus. + You can add it to the dbus packages in system configuration: + + services.dbus.packages = [ pkgs.blueman ]; + ''; }; }; -- cgit v1.2.3 From 691eea9b4507778334cfb48913964c659d3560de Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 12 Oct 2017 13:20:23 +0200 Subject: zsh: add sessionVariables option --- modules/misc/news.nix | 11 +++++++++++ modules/programs/zsh.nix | 40 ++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f0a41d7c143..18c7f9a8f57 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -317,6 +317,17 @@ in using NixOS then you do not need to enable this option. ''; } + + { + time = "2017-10-12T11:21:45+00:00"; + condition = config.programs.zsh.enable; + message = '' + A new option in zsh module is available: 'programs.zsh.sessionVariables'. + + This option can be used to set zsh specific session variables which + will be set only on zsh launch. + ''; + } ]; }; } diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index c7ad7702311..aed6fd40180 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -17,7 +17,11 @@ let mapAttrsToList export vars ); - envVarsStr = toEnvVarsStr config.home.sessionVariables; + envVars = cfg.sessionVariables // ( + if config.home.sessionVariableSetter == "zsh" then config.home.sessionVariables else {} + ); + + envVarsStr = toEnvVarsStr envVars; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases @@ -36,7 +40,7 @@ let path = mkOption { type = types.str; default = relToDotDir ".zsh_history"; - defaultText = ".zsh_history"; # Manual fails to build without this + defaultText = ".zsh_history"; description = "History file location"; }; @@ -167,6 +171,15 @@ in description = "Options related to commands history configuration."; }; + sessionVariables = mkOption { + default = {}; + type = types.attrs; + example = { ZSH_CACHE_DIR = "$HOME/.cache/zsh"; }; + description = '' + Environment variables that will be set for zsh session. + ''; + }; + initExtra = mkOption { default = ""; type = types.lines; @@ -217,6 +230,9 @@ in ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; + home.file."${relToDotDir ".zshenv"}".text = '' + ${envVarsStr} + ''; home.file."${relToDotDir ".zshrc"}".text = '' ${export "HISTSIZE" cfg.history.size} @@ -268,27 +284,15 @@ in ''; } (mkIf (cfg.dotDir != null) { - home.sessionVariables.ZDOTDIR = zdotdir; - }) - (mkIf (config.home.sessionVariableSetter == "zsh" && cfg.dotDir == null) { - home.file.".zshenv".text = '' - ${envVarsStr} - ''; - }) - (mkIf (config.home.sessionVariableSetter == "zsh" && cfg.dotDir != null) { - # When dotDir is set, only use ~/.zshenv to export ZDOTDIR, - # $ZDOTDIR/.zshenv for the rest. This is so that if ZDOTDIR happens to be + programs.zsh.sessionVariables.ZDOTDIR = zdotdir; + + # When dotDir is set, only use ~/.zshenv to source ZDOTDIR/.zshenv, + # This is so that if ZDOTDIR happens to be # already set correctly (by e.g. spawning a zsh inside a zsh), all env # vars still get exported home.file.".zshenv".text = '' - ${export "ZDOTDIR" zdotdir} source ${zdotdir}/.zshenv ''; - - home.file."${relToDotDir ".zshenv"}".text = '' - ${toEnvVarsStr - (builtins.removeAttrs config.home.sessionVariables [ "ZDOTDIR" ])} - ''; }) (mkIf cfg.oh-my-zsh.enable { # Oh-My-Zsh calls compinit during initialization, -- cgit v1.2.3 From 12ebf21be523eaf6db1f19b5a6b9304e99540961 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 12 Oct 2017 15:06:51 +0200 Subject: bash: add sessionVariables option --- modules/programs/bash.nix | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 25929abfa77..dce7969f5c6 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -64,6 +64,15 @@ in description = "Shell options to set."; }; + sessionVariables = mkOption { + default = {}; + type = types.attrs; + example = { MAILCHECK = 30; }; + description = '' + Environment variables that will be set for the Bash session. + ''; + }; + shellAliases = mkOption { default = {}; example = { ll = "ls -l"; ".." = "cd .."; }; @@ -112,8 +121,16 @@ in histControlStr = concatStringsSep ":" cfg.historyControl; histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; + # If Bash is the session variable setter then this is the + # attribute set of global session variables, otherwise it is an + # empty set. + globalEnvVars = + optionalAttrs + (config.home.sessionVariableSetter == "bash") + config.home.sessionVariables; + envVarsStr = concatStringsSep "\n" ( - mapAttrsToList export config.home.sessionVariables + mapAttrsToList export (cfg.sessionVariables // globalEnvVars) ); in mkIf cfg.enable { home.file.".bash_profile".text = '' @@ -129,8 +146,7 @@ in home.file.".profile".text = '' # -*- mode: sh -*- - ${optionalString (config.home.sessionVariableSetter == "bash") - envVarsStr} + ${envVarsStr} ${cfg.profileExtra} ''; -- cgit v1.2.3 From ee7f2413edf40f323fff76c876304ceca87931f9 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 13 Oct 2017 16:34:02 +0200 Subject: zsh: use new option to set internal session vars --- modules/programs/zsh.nix | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index aed6fd40180..d9ee7ab18c8 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -230,14 +230,16 @@ in ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; + programs.zsh.sessionVariables = { + HISTSIZE = cfg.history.size; + HISTFILE = "$HOME/" + cfg.history.path; + }; + home.file."${relToDotDir ".zshenv"}".text = '' ${envVarsStr} ''; home.file."${relToDotDir ".zshrc"}".text = '' - ${export "HISTSIZE" cfg.history.size} - ${export "HISTFILE" ("$HOME/" + cfg.history.path)} - setopt HIST_FCNTL_LOCK ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY @@ -259,9 +261,6 @@ in ${optionalString cfg.oh-my-zsh.enable '' # oh-my-zsh configuration generated by NixOS - export ZSH=${pkgs.oh-my-zsh}/share/oh-my-zsh - export ZSH_CACHE_DIR=''${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh - ${optionalString (cfg.oh-my-zsh.plugins != []) "plugins=(${concatStringsSep " " cfg.oh-my-zsh.plugins})" } @@ -283,6 +282,14 @@ in ${aliasesStr} ''; } + + (mkIf cfg.oh-my-zsh.enable { + programs.zsh.sessionVariables = { + ZSH = "${pkgs.oh-my-zsh}/share/oh-my-zsh"; + ZSH_CACHE_DIR = "\${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"; + }; + }) + (mkIf (cfg.dotDir != null) { programs.zsh.sessionVariables.ZDOTDIR = zdotdir; @@ -294,12 +301,14 @@ in source ${zdotdir}/.zshenv ''; }) + (mkIf cfg.oh-my-zsh.enable { # Oh-My-Zsh calls compinit during initialization, # calling it twice causes sight start up slowdown # as all $fpath entries will be traversed again. programs.zsh.enableCompletion = mkForce false; }) + (mkIf (cfg.plugins != []) { # Many plugins require compinit to be called # but allow the user to opt out. -- cgit v1.2.3 From c07fa70d58738eb28cfb84c089cccc8de96783e8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Oct 2017 15:58:34 +0200 Subject: home-environment: add option `home.extraOutputsToInstall` --- modules/home-environment.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 8b6a6cfa8a8..9b900ef0cdf 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -187,6 +187,17 @@ in description = "The set of packages to appear in the user environment."; }; + home.extraOutputsToInstall = mkOption { + type = types.listOf types.str; + default = []; + example = [ "doc" "info" "devdoc" ]; + description = '' + List of additional package outputs of the packages + home.packages that should be installed into + the user environment. + ''; + }; + home.path = mkOption { internal = true; description = "The derivation installing the user packages."; @@ -457,6 +468,7 @@ in name = "home-manager-path"; paths = cfg.packages; + inherit (cfg) extraOutputsToInstall; meta = { description = "Environment of packages installed through home-manager"; -- cgit v1.2.3 From 3632478b8d91a56711b0434707e0982ec8688d88 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Oct 2017 16:01:41 +0200 Subject: man: add module --- modules/default.nix | 1 + modules/misc/news.nix | 10 ++++++++++ modules/programs/man.nix | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 modules/programs/man.nix diff --git a/modules/default.nix b/modules/default.nix index d43831ee770..1b1d97a6fc8 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -31,6 +31,7 @@ let ./programs/htop.nix ./programs/info.nix ./programs/lesspipe.nix + ./programs/man.nix ./programs/rofi.nix ./programs/ssh.nix ./programs/termite.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 18c7f9a8f57..c7be03c8589 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -328,6 +328,16 @@ in will be set only on zsh launch. ''; } + + { + time = "2017-10-15T13:59:47+00:00"; + message = '' + A new module is available: 'programs.man'. + + This module is enabled by default and makes sure that manual + pages are installed for packages in 'home.packages'. + ''; + } ]; }; } diff --git a/modules/programs/man.nix b/modules/programs/man.nix new file mode 100644 index 00000000000..702b8932ded --- /dev/null +++ b/modules/programs/man.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + programs.man.enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable manual pages and the man + command. This also includes "man" outputs of all + home.packages. + ''; + }; + }; + + config = mkIf config.programs.man.enable { + home.packages = [ pkgs.man-db ]; + home.extraOutputsToInstall = [ "man" ]; + }; +} -- cgit v1.2.3 From 067293613460ed38709ebe8008780df67bb937ae Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 15 Oct 2017 16:03:35 +0200 Subject: info: add "info" to extra outputs to install --- modules/programs/info.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 3671c5c4292..c3b4b5942e7 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -24,6 +24,7 @@ with lib; with import ../lib/dag.nix { inherit lib; }; let + cfg = config.programs.info; # Indexes info files found in this location @@ -72,6 +73,8 @@ in fi ''; - home.packages = [infoPkg]; + home.packages = [ infoPkg ]; + + home.extraOutputsToInstall = [ "info" ]; }; } -- cgit v1.2.3 From f0a1d69f509d463df907cd02547d18596aff3e68 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 5 Oct 2017 21:38:46 +0200 Subject: Separate home files module from home-environment.nix --- modules/default.nix | 1 + modules/files.nix | 237 +++++++++++++++++++++++++++++++++++++++++++ modules/home-environment.nix | 217 +-------------------------------------- 3 files changed, 239 insertions(+), 216 deletions(-) create mode 100644 modules/files.nix diff --git a/modules/default.nix b/modules/default.nix index 1b1d97a6fc8..a87299472c0 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -12,6 +12,7 @@ let modules = [ ./home-environment.nix + ./files.nix ./manual.nix ./misc/fontconfig.nix ./misc/gtk.nix diff --git a/modules/files.nix b/modules/files.nix new file mode 100644 index 00000000000..19def8b561b --- /dev/null +++ b/modules/files.nix @@ -0,0 +1,237 @@ +{ pkgs, config, lib, ... }: + +with lib; +with import ./lib/dag.nix { inherit lib; }; + +let + + cfg = config.home.file; + +in + +{ + options = { + home.file = mkOption { + description = "Attribute set of files to link into the user home."; + default = {}; + type = types.loaOf (types.submodule ( + { name, config, ... }: { + options = { + target = mkOption { + type = types.str; + description = '' + Path to target file relative to HOME. + ''; + }; + + text = mkOption { + default = null; + type = types.nullOr types.lines; + description = "Text of the file."; + }; + + source = mkOption { + type = types.path; + description = '' + Path of the source file. The file name must not start + with a period since Nix will not allow such names in + the Nix store. + + This may refer to a directory. + ''; + }; + + mode = mkOption { + type = types.str; + default = "444"; + description = "The permissions to apply to the file."; + }; + }; + + config = { + target = mkDefault name; + source = mkIf (config.text != null) ( + let name' = "user-etc-" + baseNameOf name; + in mkDefault (pkgs.writeText name' config.text) + ); + }; + }) + ); + }; + + home-files = mkOption { + type = types.package; + internal = true; + description = "Package to contain all home files"; + }; + }; + + config = { + assertions = [ + (let + badFiles = + filter (f: hasPrefix "." (baseNameOf f)) + (map (v: toString v.source) + (attrValues cfg)); + badFilesStr = toString badFiles; + in + { + assertion = badFiles == []; + message = "Source file names must not start with '.': ${badFilesStr}"; + }) + ]; + + # This verifies that the links we are about to create will not + # overwrite an existing file. + home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( + let + pattern = "-home-manager-files/"; + check = pkgs.writeText "check" '' + . ${./lib-bash/color-echo.sh} + + newGenFiles="$1" + shift + for sourcePath in "$@" ; do + relativePath="''${sourcePath#$newGenFiles/}" + targetPath="$HOME/$relativePath" + if [[ -e "$targetPath" \ + && ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then + errorEcho "Existing file '$targetPath' is in the way" + collision=1 + fi + done + + if [[ -v collision ]] ; then + errorEcho "Please move the above files and try again" + exit 1 + fi + ''; + in + '' + function checkNewGenCollision() { + local newGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + find "$newGenFiles" -type f -print0 -or -type l -print0 \ + | xargs -0 bash ${check} "$newGenFiles" + } + + checkNewGenCollision || exit 1 + '' + ); + + home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( + let + pattern = "-home-manager-files/"; + + link = pkgs.writeText "link" '' + newGenFiles="$1" + shift + for sourcePath in "$@" ; do + relativePath="''${sourcePath#$newGenFiles/}" + targetPath="$HOME/$relativePath" + $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" + $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" + done + ''; + + cleanup = pkgs.writeText "cleanup" '' + . ${./lib-bash/color-echo.sh} + + newGenFiles="$1" + oldGenFiles="$2" + shift 2 + for sourcePath in "$@" ; do + relativePath="''${sourcePath#$oldGenFiles/}" + targetPath="$HOME/$relativePath" + if [[ -e "$newGenFiles/$relativePath" ]] ; then + $VERBOSE_ECHO "Checking $targetPath: exists" + elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then + warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." + else + $VERBOSE_ECHO "Checking $targetPath: gone (deleting)" + $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" + + # Recursively delete empty parent directories. + targetDir="$(dirname "$relativePath")" + if [[ "$targetDir" != "." ]] ; then + pushd "$HOME" > /dev/null + + # Call rmdir with a relative path excluding $HOME. + # Otherwise, it might try to delete $HOME and exit + # with a permission error. + $DRY_RUN_CMD rmdir $VERBOSE_ARG \ + -p --ignore-fail-on-non-empty \ + "$targetDir" + + popd > /dev/null + fi + fi + done + ''; + in + '' + function linkNewGen() { + local newGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + find "$newGenFiles" -type f -print0 -or -type l -print0 \ + | xargs -0 bash ${link} "$newGenFiles" + } + + function cleanOldGen() { + if [[ ! -v oldGenPath ]] ; then + return + fi + + echo "Cleaning up orphan links from $HOME" + + local newGenFiles oldGenFiles + newGenFiles="$(readlink -e "$newGenPath/home-files")" + oldGenFiles="$(readlink -e "$oldGenPath/home-files")" + find "$oldGenFiles" -type f -print0 -or -type l -print0 \ + | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" + } + + if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then + echo "Creating profile generation $newGenNum" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG $(basename "$newGenProfilePath") "$genProfilePath" + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" + else + echo "No change so reusing latest profile generation $oldGenNum" + fi + + linkNewGen + cleanOldGen + '' + ); + + home-files = pkgs.stdenv.mkDerivation { + name = "home-manager-files"; + + phases = [ "installPhase" ]; + + installPhase = + "mkdir -p $out\n" + + concatStringsSep "\n" ( + mapAttrsToList (n: v: + '' + target="$(realpath -m "$out/${v.target}")" + + # Target file must be within $HOME. + if [[ ! "$target" =~ "$out" ]] ; then + echo "Error installing file '${v.target}' outside \$HOME" >&2 + exit 1 + fi + + if [ -d "${v.source}" ]; then + mkdir -pv "$(dirname "$out/${v.target}")" + ln -sv "${v.source}" "$target" + else + install -D -m${v.mode} "${v.source}" "$target" + fi + '' + ) cfg + ); + }; + }; +} diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 9b900ef0cdf..2026e7d4ba9 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -96,54 +96,6 @@ in meta.maintainers = [ maintainers.rycee ]; options = { - home.file = mkOption { - description = "Attribute set of files to link into the user home."; - default = {}; - type = types.loaOf (types.submodule ( - { name, config, ... }: { - options = { - target = mkOption { - type = types.str; - description = '' - Path to target file relative to HOME. - ''; - }; - - text = mkOption { - default = null; - type = types.nullOr types.lines; - description = "Text of the file."; - }; - - source = mkOption { - type = types.path; - description = '' - Path of the source file. The file name must not start - with a period since Nix will not allow such names in - the Nix store. - - This may refer to a directory. - ''; - }; - - mode = mkOption { - type = types.str; - default = "444"; - description = "The permissions to apply to the file."; - }; - }; - - config = { - target = mkDefault name; - source = mkIf (config.text != null) ( - let name' = "user-etc-" + baseNameOf name; - in mkDefault (pkgs.writeText name' config.text) - ); - }; - }) - ); - }; - home.language = mkOption { type = languageSubModule; default = {}; @@ -226,20 +178,6 @@ in }; config = { - assertions = [ - (let - badFiles = - filter (f: hasPrefix "." (baseNameOf f)) - (map (v: toString v.source) - (attrValues cfg.file)); - badFilesStr = toString badFiles; - in - { - assertion = badFiles == []; - message = "Source file names must not start with '.': ${badFilesStr}"; - }) - ]; - home.sessionVariables = let maybeSet = name: value: @@ -259,130 +197,6 @@ in # script's "check" and the "write" phases. home.activation.writeBoundary = dagEntryAnywhere ""; - # This verifies that the links we are about to create will not - # overwrite an existing file. - home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( - let - pattern = "-home-manager-files/"; - check = pkgs.writeText "check" '' - . ${./lib-bash/color-echo.sh} - - newGenFiles="$1" - shift - for sourcePath in "$@" ; do - relativePath="''${sourcePath#$newGenFiles/}" - targetPath="$HOME/$relativePath" - if [[ -e "$targetPath" \ - && ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then - errorEcho "Existing file '$targetPath' is in the way" - collision=1 - fi - done - - if [[ -v collision ]] ; then - errorEcho "Please move the above files and try again" - exit 1 - fi - ''; - in - '' - function checkNewGenCollision() { - local newGenFiles - newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${check} "$newGenFiles" - } - - checkNewGenCollision || exit 1 - '' - ); - - home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( - let - pattern = "-home-manager-files/"; - - link = pkgs.writeText "link" '' - newGenFiles="$1" - shift - for sourcePath in "$@" ; do - relativePath="''${sourcePath#$newGenFiles/}" - targetPath="$HOME/$relativePath" - $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" - $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" - done - ''; - - cleanup = pkgs.writeText "cleanup" '' - . ${./lib-bash/color-echo.sh} - - newGenFiles="$1" - oldGenFiles="$2" - shift 2 - for sourcePath in "$@" ; do - relativePath="''${sourcePath#$oldGenFiles/}" - targetPath="$HOME/$relativePath" - if [[ -e "$newGenFiles/$relativePath" ]] ; then - $VERBOSE_ECHO "Checking $targetPath: exists" - elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then - warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." - else - $VERBOSE_ECHO "Checking $targetPath: gone (deleting)" - $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" - - # Recursively delete empty parent directories. - targetDir="$(dirname "$relativePath")" - if [[ "$targetDir" != "." ]] ; then - pushd "$HOME" > /dev/null - - # Call rmdir with a relative path excluding $HOME. - # Otherwise, it might try to delete $HOME and exit - # with a permission error. - $DRY_RUN_CMD rmdir $VERBOSE_ARG \ - -p --ignore-fail-on-non-empty \ - "$targetDir" - - popd > /dev/null - fi - fi - done - ''; - in - '' - function linkNewGen() { - local newGenFiles - newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${link} "$newGenFiles" - } - - function cleanOldGen() { - if [[ ! -v oldGenPath ]] ; then - return - fi - - echo "Cleaning up orphan links from $HOME" - - local newGenFiles oldGenFiles - newGenFiles="$(readlink -e "$newGenPath/home-files")" - oldGenFiles="$(readlink -e "$oldGenPath/home-files")" - find "$oldGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" - } - - if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then - echo "Creating profile generation $newGenNum" - $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" - $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG $(basename "$newGenProfilePath") "$genProfilePath" - $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath" - else - echo "No change so reusing latest profile generation $oldGenNum" - fi - - linkNewGen - cleanOldGen - '' - ); - home.activation.installPackages = dagEntryAfter ["writeBoundary"] '' $DRY_RUN_CMD nix-env -i ${cfg.path} ''; @@ -418,35 +232,6 @@ in ${activationCmds} ''; - - home-files = pkgs.stdenv.mkDerivation { - name = "home-manager-files"; - - phases = [ "installPhase" ]; - - installPhase = - "mkdir -p $out\n" + - concatStringsSep "\n" ( - mapAttrsToList (n: v: - '' - target="$(realpath -m "$out/${v.target}")" - - # Target file must be within $HOME. - if [[ ! "$target" =~ "$out" ]] ; then - echo "Error installing file '${v.target}' outside \$HOME" >&2 - exit 1 - fi - - if [ -d "${v.source}" ]; then - mkdir -pv "$(dirname "$out/${v.target}")" - ln -sv "${v.source}" "$target" - else - install -D -m${v.mode} "${v.source}" "$target" - fi - '' - ) cfg.file - ); - }; in pkgs.stdenv.mkDerivation { name = "home-manager-generation"; @@ -459,7 +244,7 @@ in substituteInPlace $out/activate \ --subst-var-by GENERATION_DIR $out - ln -s ${home-files} $out/home-files + ln -s ${config.home-files} $out/home-files ln -s ${cfg.path} $out/home-path ''; }; -- cgit v1.2.3 From 3bc3b34d9715a2750f2a7b7880eb532260ec6dde Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 6 Oct 2017 00:15:22 +0200 Subject: home-environment: add username and homeDirectory options --- modules/home-environment.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 2026e7d4ba9..38049290f55 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -96,6 +96,20 @@ in meta.maintainers = [ maintainers.rycee ]; options = { + home.username = mkOption { + type = types.str; + defaultText = "$USER"; + readOnly = true; + description = "The user's username"; + }; + + home.homeDirectory = mkOption { + type = types.path; + defaultText = "$HOME"; + readOnly = true; + description = "The user's home directory"; + }; + home.language = mkOption { type = languageSubModule; default = {}; @@ -178,6 +192,20 @@ in }; config = { + assertions = [ + { + assertion = config.home.username != ""; + message = "Username could not be determined"; + } + { + assertion = config.home.homeDirectory != ""; + message = "Home directory could not be determined"; + } + ]; + + home.username = mkDefault (builtins.getEnv "USER"); + home.homeDirectory = mkDefault (builtins.getEnv "HOME"); + home.sessionVariables = let maybeSet = name: value: -- cgit v1.2.3 From d81276607c338f319e3e3d959e7eef185e39229c Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 6 Oct 2017 00:19:03 +0200 Subject: files: support absolute home directory path --- modules/files.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/files.nix b/modules/files.nix index 19def8b561b..bd2c61250be 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -6,6 +6,7 @@ with import ./lib/dag.nix { inherit lib; }; let cfg = config.home.file; + homeDirectory = config.home.homeDirectory; in @@ -19,6 +20,7 @@ in options = { target = mkOption { type = types.str; + apply = removePrefix (homeDirectory + "/"); description = '' Path to target file relative to HOME. ''; -- cgit v1.2.3 From bc40ab378c25998b25145fbe7296c9b42e9ac8bb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Oct 2017 18:40:34 +0200 Subject: home-manager: add license field --- home-manager/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home-manager/default.nix b/home-manager/default.nix index bb09886913a..de1982fae5b 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -32,5 +32,6 @@ pkgs.stdenv.mkDerivation { description = "A user environment configurator"; maintainers = [ maintainers.rycee ]; platforms = platforms.linux; + license = licenses.mit; }; } -- cgit v1.2.3 From 335cffe9a9c5be616d542b9b7a0487d930bb99d9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 18 Oct 2017 00:33:31 +0200 Subject: man: install `man`, not `man-db` This may help with installing on Darwin. --- modules/programs/man.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/man.nix b/modules/programs/man.nix index 702b8932ded..0ed376780d4 100644 --- a/modules/programs/man.nix +++ b/modules/programs/man.nix @@ -16,7 +16,7 @@ with lib; }; config = mkIf config.programs.man.enable { - home.packages = [ pkgs.man-db ]; + home.packages = [ pkgs.man ]; home.extraOutputsToInstall = [ "man" ]; }; } -- cgit v1.2.3 From 2ff8c12bf96b40c2639057f2a89ec12aad369fe0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 18 Oct 2017 00:45:29 +0200 Subject: home-manager: change platforms to `unix` --- home-manager/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index de1982fae5b..5fed40554f7 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -31,7 +31,7 @@ pkgs.stdenv.mkDerivation { meta = with pkgs.stdenv.lib; { description = "A user environment configurator"; maintainers = [ maintainers.rycee ]; - platforms = platforms.linux; + platforms = platforms.unix; license = licenses.mit; }; } -- cgit v1.2.3 From c144580c98b24bd7074ad1a88a1a34296f3895d7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 19 Oct 2017 11:43:41 +0200 Subject: xsession: warn about windowManager option removal --- modules/misc/news.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c7be03c8589..0c899ad600e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -338,6 +338,19 @@ in pages are installed for packages in 'home.packages'. ''; } + + { + time = "2017-10-19T09:33:10+00:00"; + condition = + config.xsession.enable + && config.xsession.windowManager.usesDeprecated; + message = '' + The 'xsession.windowManager' option is deprecated and will + be removed on October 31, 2017. To avoid evaluation errors + you must change to using 'xsession.windowManager.command' + before that date. + ''; + } ]; }; } -- cgit v1.2.3 From b9f49cee45c1fce22244ab5ff7819f07d785dac3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 19 Oct 2017 22:42:35 +0200 Subject: home-environment: use makeBinPath for activation PATH --- modules/home-environment.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 38049290f55..1ea6988137b 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -243,16 +243,20 @@ in abort ("Dependency cycle in activation script: " + builtins.toJSON sortedCommands); + # Programs that always should be available on the activation + # script's PATH. + activationBinPaths = lib.makeBinPath [ + pkgs.bash + pkgs.coreutils + ]; + sf = pkgs.writeText "activation-script" '' #!${pkgs.stdenv.shell} set -eu set -o pipefail - # This code explicitly requires GNU Core Utilities and Bash. - # We therefore need to ensure they are prioritized over any - # other similarly named tools on the system. - export PATH="${pkgs.coreutils}/bin:${pkgs.bash}/bin:$PATH" + export PATH="${activationBinPaths}:$PATH" . ${./lib-bash/color-echo.sh} -- cgit v1.2.3 From 30b9d7f00ee5fb3a443682f0db3a17e12ab8ee59 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 20 Oct 2017 14:02:05 +0200 Subject: Use only tools from Nixpkgs in activation script Note, we still pull in the user's `PATH` in case the user has defined their own activation blocks that depend on additional tools. Eventually this will be deprecated and removed. See #99. --- modules/home-environment.nix | 6 ++++++ modules/misc/news.nix | 19 +++++++++++++++++++ modules/programs/info.nix | 4 ++++ modules/services/polybar.nix | 2 +- modules/systemd.nix | 15 +++++++++++++-- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 1ea6988137b..da0cc68e9b9 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -248,6 +248,12 @@ in activationBinPaths = lib.makeBinPath [ pkgs.bash pkgs.coreutils + pkgs.diffutils # For `cmp` and `diff`. + pkgs.findutils + pkgs.gnugrep + pkgs.gnused + pkgs.ncurses # For `tput`. + pkgs.nix ]; sf = pkgs.writeText "activation-script" '' diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0c899ad600e..f14248ecb87 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -351,6 +351,25 @@ in before that date. ''; } + + { + time = "2017-10-20T12:15:27+00:00"; + condition = with config.systemd.user; + services != {} || sockets != {} || targets != {} || timers != {}; + message = '' + Home Manager's interaction with systemd is now done using + 'systemctl' from Nixpkgs, not the 'systemctl' in '$PATH'. + + If you are using a distribution whose systemd is + incompatible with the version in Nixpkgs then you can + override this behavior by adding + + systemd.user.systemctlPath = "/usr/bin/systemctl" + + to your configuration. Home Manager will then use your + chosen version. + ''; + } ]; }; } diff --git a/modules/programs/info.nix b/modules/programs/info.nix index c3b4b5942e7..5f75ec927a2 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -64,6 +64,8 @@ in "${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}"; home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] '' + oPATH=$PATH + export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH" $DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}" $DRY_RUN_CMD rm -f "${cfg.homeInfoDirLocation}/dir" if [[ -d "${homeInfoPath}" ]]; then @@ -71,6 +73,8 @@ in -exec $DRY_RUN_CMD ${infoPkg}/bin/install-info '{}' \ "${cfg.homeInfoDirLocation}/dir" \; fi + export PATH="$oPATH" + unset oPATH ''; home.packages = [ infoPkg ]; diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 351626f8bb8..8e92b4afffa 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -142,7 +142,7 @@ in home.activation.applyPolybar = dagEntryAfter [ "reloadSystemD" ] '' if [[ -v polybarChanged && -v DISPLAY ]]; then echo "Restarting polybar" - systemctl --user restart polybar.service + ${config.systemd.user.systemctlPath} --user restart polybar.service fi ''; }; diff --git a/modules/systemd.nix b/modules/systemd.nix index d77c0076ad9..066304773f8 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -49,6 +49,17 @@ in options = { systemd.user = { + systemctlPath = mkOption { + default = "${pkgs.systemd}/bin/systemctl"; + defaultText = "\${pkgs.systemd}/bin/systemctl"; + type = types.str; + description = '' + Absolute path to the systemctl tool. This + option may need to be set if running Home Manager on a + non-NixOS distribution. + ''; + }; + services = mkOption { default = {}; type = types.attrs; @@ -157,7 +168,7 @@ in local -a toRestart=( ) for f in ''${maybeRestart[@]} ; do - if systemctl --quiet --user is-active "$f" \ + if ${cfg.systemctlPath} --quiet --user is-active "$f" \ && ! cmp --quiet \ "$oldUserServicePath/$f" \ "$newUserServicePath/$f" ; then @@ -187,7 +198,7 @@ in fi } - $DRY_RUN_CMD systemctl --user daemon-reload + $DRY_RUN_CMD ${cfg.systemctlPath} --user daemon-reload systemdPostReload ''; }) -- cgit v1.2.3 From 0f43d5df6a3511dc05028a2790aa37619d0a2d34 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 20 Oct 2017 21:10:44 +0200 Subject: home-environment: add extraBuilderCommands option --- modules/home-environment.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index da0cc68e9b9..892c20cc806 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -189,6 +189,15 @@ in type = types.package; description = "The package containing the complete activation script."; }; + + home.extraBuilderCommands = mkOption { + type = types.lines; + default = ""; + internal = true; + description = '' + Extra commands to run in the Home Manager generation builder. + ''; + }; }; config = { @@ -284,6 +293,8 @@ in ln -s ${config.home-files} $out/home-files ln -s ${cfg.path} $out/home-path + + ${cfg.extraBuilderCommands} ''; }; -- cgit v1.2.3 From b78b2b6b35bc87a032334cb8ef0cbf30fed64ad6 Mon Sep 17 00:00:00 2001 From: pasqui23 Date: Thu, 12 Oct 2017 01:16:33 +0200 Subject: firefox: add enableIcedTea option --- modules/programs/firefox.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 50a43cfe7ba..d51849e4033 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -33,6 +33,12 @@ in default = false; description = "Whether to enable the unfree Google Talk plugin."; }; + + enableIcedTea = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the Java applet plugin."; + }; }; }; @@ -46,6 +52,7 @@ in fcfg = setAttrByPath [browserName] { enableAdobeFlash = cfg.enableAdobeFlash; enableGoogleTalkPlugin = cfg.enableGoogleTalk; + icedtea = cfg.enableIcedTea; }; wrapper = pkgs.wrapFirefox.override { -- cgit v1.2.3 From 3346c7f455d34a3b7c704ceff8000a74960aa86d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Oct 2017 14:37:30 +0200 Subject: xsession: prepare for session in `~/.xprofile` This works around the way NixOS starts up the systemd graphical session target. --- modules/xsession.nix | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index 5c9ee777881..dde0a7fe6b4 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -58,6 +58,12 @@ in ''; }; + profileExtra = mkOption { + type = types.lines; + default = ""; + description = "Extra shell commands to run before session start."; + }; + initExtra = mkOption { type = types.lines; default = ""; @@ -139,14 +145,14 @@ in }; }; - home.file.".xsession" = { - mode = "555"; - text = '' + home.file.".xprofile".text = '' if [[ -e "$HOME/.profile" ]]; then . "$HOME/.profile" fi # If there are any running services from a previous session. + # Need to run this in xprofile because the NixOS xsession + # script starts up graphical-session.target. systemctl --user stop graphical-session.target graphical-session-pre.target systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS @@ -157,6 +163,19 @@ in systemctl --user import-environment XDG_RUNTIME_DIR systemctl --user import-environment XDG_SESSION_ID + ${cfg.profileExtra} + + export HM_XPROFILE_SOURCED=1 + ''; + + home.file.".xsession" = { + mode = "555"; + text = '' + if [[ ! -v HM_XPROFILE_SOURCED ]]; then + . ~/.xprofile + fi + unset HM_XPROFILE_SOURCED + systemctl --user start hm-graphical-session.target ${cfg.initExtra} -- cgit v1.2.3 From 5605e46acbe06f82fe9392559ce201fa9de2e0a6 Mon Sep 17 00:00:00 2001 From: Ruben Maher Date: Sun, 22 Oct 2017 13:54:32 +1030 Subject: home-manager: fix typo --- home-manager/home-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 97166d6f99b..55c717eea1e 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -18,7 +18,7 @@ function errorEcho() { function setConfigFile() { if [[ -v HOME_MANAGER_CONFIG ]] ; then if [[ ! -e "$HOME_MANAGER_CONFIG" ]] ; then - errorEcho "No configure file found at $HOME_MANAGER_CONFIG" + errorEcho "No configuration file found at $HOME_MANAGER_CONFIG" exit 1 fi -- cgit v1.2.3 From bf3a8c63838c998e06e6825ac80f1a9a7f735a57 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Oct 2017 20:51:28 +0200 Subject: home-manager: point to project root Before this path would point to the modules path. Using the project root instead makes it possible to set `` to point to a downloadable archive of Home Manager. This should make it significantly easier to install and keep Home Manager up to date. To match this change we also deprecate the Home Manager option programs.home-manager.modulesPath and instead ask users to use programs.home-manager.path --- default.nix | 16 ++++++++++++++-- home-manager/default.nix | 13 ++++++------- home-manager/home-manager | 18 +++++++++--------- home-manager/home-manager.nix | 2 +- modules/misc/news.nix | 40 +++++++++++++++++++++++++++++++++++++++ modules/programs/home-manager.nix | 28 +++++++++++++++++++++++++-- 6 files changed, 96 insertions(+), 21 deletions(-) diff --git a/default.nix b/default.nix index d9024779c74..b9eedd47041 100644 --- a/default.nix +++ b/default.nix @@ -1,2 +1,14 @@ -# Simply defer to the home-manager script derivation. -import ./home-manager +{ pkgs ? import {} }: + +rec { + home-manager = import ./home-manager { + inherit pkgs; + path = ./.; + }; + + install = + pkgs.runCommand + "home-manager-install" + { propagatedBuildInputs = [ home-manager ]; } + ""; +} diff --git a/home-manager/default.nix b/home-manager/default.nix index 5fed40554f7..943d61e81b2 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,14 +1,14 @@ { pkgs - # Extra path to the Home Manager modules. If set then this path will - # be tried before `$HOME/.config/nixpkgs/home-manager/modules` and - # `$HOME/.nixpkgs/home-manager/modules`. -, modulesPath ? null + # Extra path to Home Manager. If set then this path will be tried + # before `$HOME/.config/nixpkgs/home-manager` and + # `$HOME/.nixpkgs/home-manager`. +, path ? null }: let - modulesPathStr = if modulesPath == null then "" else modulesPath; + pathStr = if path == null then "" else path; in @@ -24,8 +24,7 @@ pkgs.stdenv.mkDerivation { --subst-var-by bash "${pkgs.bash}" \ --subst-var-by coreutils "${pkgs.coreutils}" \ --subst-var-by less "${pkgs.less}" \ - --subst-var-by MODULES_PATH '${modulesPathStr}' \ - --subst-var-by HOME_MANAGER_EXPR_PATH "${./home-manager.nix}" + --subst-var-by HOME_MANAGER_PATH '${pathStr}' ''; meta = with pkgs.stdenv.lib; { diff --git a/home-manager/home-manager b/home-manager/home-manager index 55c717eea1e..6bfc46e6606 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -40,13 +40,13 @@ function setConfigFile() { exit 1 } -function setHomeManagerModulesPath() { - local modulesPath - for modulesPath in "@MODULES_PATH@" \ - "$HOME/.config/nixpkgs/home-manager/modules" \ - "$HOME/.nixpkgs/home-manager/modules" ; do - if [[ -e "$modulesPath" ]] ; then - export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath" +function setHomeManagerNixPath() { + local path + for path in "@HOME_MANAGER_PATH@" \ + "$HOME/.config/nixpkgs/home-manager" \ + "$HOME/.nixpkgs/home-manager" ; do + if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then + export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path" return fi done @@ -54,7 +54,7 @@ function setHomeManagerModulesPath() { function doBuildAttr() { setConfigFile - setHomeManagerModulesPath + setHomeManagerNixPath local extraArgs="$*" @@ -67,7 +67,7 @@ function doBuildAttr() { fi nix-build \ - "@HOME_MANAGER_EXPR_PATH@" \ + "" \ $extraArgs \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix index a6c9259f874..206a1bcefa3 100644 --- a/home-manager/home-manager.nix +++ b/home-manager/home-manager.nix @@ -9,7 +9,7 @@ with pkgs.lib; let - env = import { + env = import { configuration = let conf = import confPath; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f14248ecb87..b17b0454257 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -370,6 +370,46 @@ in chosen version. ''; } + + { + time = "2017-10-23T22:54:33+00:00"; + condition = config.programs.home-manager.modulesPath != null; + message = '' + The 'programs.home-manager.modulesPath' option is now + deprecated and will be removed on November 24, 2017. Please + use the option 'programs.home-manager.path' instead. + ''; + } + + { + time = "2017-10-23T23:10:29+00:00"; + condition = !config.programs.home-manager.enable; + message = '' + Unfortunately, due to some internal restructuring it is no + longer possible to install the home-manager command when + having + + home-manager = import ./home-manager { inherit pkgs; }; + + in the '~/.config/nixpkgs/config.nix' package override + section. Attempting to use the above override will now + result in the error "cannot coerce a set to a string". + + To resolve this please delete the override from the + 'config.nix' file and either link the Home Manager overlay + + $ ln -s ~/.config/nixpkgs/home-manager/overlay.nix \ + ~/.config/nixpkgs/overlays/home-manager.nix + + or add + + programs.home-manager.enable = true; + + to your Home Manager configuration. The latter is + recommended as the home-manager tool then is updated + automatically whenever you do a switch. + ''; + } ]; }; } diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index ad7278a12f0..2fac0bce353 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -16,6 +16,19 @@ in programs.home-manager = { enable = mkEnableOption "Home Manager"; + path = mkOption { + type = types.nullOr types.str; + default = null; + example = "$HOME/devel/home-manager"; + description = '' + The default path to use for Home Manager. If this path does + not exist then + $HOME/.config/nixpkgs/home-manager and + $HOME/.nixpkgs/home-manager will be + attempted. + ''; + }; + modulesPath = mkOption { type = types.nullOr types.str; default = null; @@ -25,17 +38,28 @@ in path does not exist then $HOME/.config/nixpkgs/home-manager/modules and $HOME/.nixpkgs/home-manager/modules - will be attempted. + will be attempted. DEPRECATED: Use + programs.home-manager.path instead. ''; }; }; }; config = mkIf cfg.enable { + assertions = [{ + assertion = cfg.path == null || cfg.modulesPath == null; + message = "Cannot simultaneously use " + + "'programs.home-manager.path' and " + + "'programs.home-manager.modulesPath'."; + }]; + home.packages = [ (import ../../home-manager { inherit pkgs; - inherit (cfg) modulesPath; + path = + if cfg.modulesPath != null + then "$(dirname ${cfg.modulesPath})" + else cfg.path; }) ]; -- cgit v1.2.3 From df84c466c18b8e8d7c2b69254bb015fc56196457 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 23 Oct 2017 14:01:38 +0200 Subject: readme: update installation instructions Also clean up usage section slightly. --- README.md | 59 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index eb373c67fac..5b2d88429e9 100644 --- a/README.md +++ b/README.md @@ -46,50 +46,62 @@ Currently the easiest way to install Home Manager is as follows: since Home Manager uses these directories to manage your profile generations. On NixOS these should already be available. -2. Clone the Home Manager repository into the `~/.config/nixpkgs` - directory: +2. Assign a temporary variable holding the URL to the appropriate + archive. Typically this is ```console - $ git clone -b master https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager + $ HM_PATH=https://github.com/rycee/home-manager/archive/master.tar.gz ``` or ```console - $ git clone -b release-17.09 https://github.com/rycee/home-manager ~/.config/nixpkgs/home-manager + $ HM_PATH=https://github.com/rycee/home-manager/archive/release-17.09.tar.gz ``` - depending on whether you are tracking Nixpkgs unstable or version - 17.09. + depending on whether you follow Nixpkgs unstable or version 17.09. -3. Add Home Manager to your user's Nixpkgs, for example by symlinking the - overlay to `~/.config/nixpkgs/overlays`: +2. Create an initial Home Manager configuration file: ```console - $ ln -s ~/.config/nixpkgs/home-manager/overlay.nix ~/.config/nixpkgs/overlays/home-manager.nix + $ cat > ~/.config/nixpkgs/home.nix <' -iA home-manager - installing ‘home-manager’ + $ nix-shell $HM_PATH -A install --run 'home-manager switch' ``` + Home Manager should now be active and available in your user + environment. + +Note, because the `HM_PATH` variable above points to the live Home +Manager repository you will automatically get updates whenever you +build a new generation. If you dislike automatic updates then perform +a Git clone of the desired branch and set `programs.home-manager.path` +to the absolute path of your clone. + Usage ----- -The `home-manager` package installs a tool that is conveniently called -`home-manager`. This tool can apply configurations to your home +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 set up a very simple configuration that installs -the htop and fortune packages, installs Emacs with a few extra -packages enabled, installs Firefox with Adobe Flash enabled, and -enables the user gpg-agent service. +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 Adobe +Flash enabled, and enable the user gpg-agent service. -First create a file `~/.config/nixpkgs/home.nix` containing +To satisfy the above setup we should elaborate the +`~/.config/nixpkgs/home.nix` file as follows: ```nix { pkgs, ... }: @@ -118,6 +130,11 @@ First create a file `~/.config/nixpkgs/home.nix` containing defaultCacheTtl = 1800; enableSshSupport = true; }; + + programs.home-manager = { + enable = true; + path = "…"; + }; } ``` @@ -136,8 +153,8 @@ $ home-manager build which will create a `result` link to a directory containing an activation script and the generated home directory files. -To see available configuration options with descriptions -and usage examples run +To see available configuration options with descriptions and usage +examples run ```console $ man home-configuration.nix -- cgit v1.2.3 From 7417d8e86e9b1bfa47482f29604315f5ec2696bf Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 20 Oct 2017 23:22:47 +0200 Subject: nixpkgs: add module --- modules/default.nix | 6 ++- modules/misc/news.nix | 12 +++++ modules/misc/nixpkgs.nix | 119 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 modules/misc/nixpkgs.nix diff --git a/modules/default.nix b/modules/default.nix index a87299472c0..4cba27ffb69 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -11,12 +11,13 @@ with lib; let modules = [ - ./home-environment.nix ./files.nix + ./home-environment.nix ./manual.nix ./misc/fontconfig.nix ./misc/gtk.nix ./misc/news.nix + ./misc/nixpkgs.nix ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix @@ -73,9 +74,10 @@ let fold f res res.config.warnings; pkgsModule = { - config._module.args.pkgs = lib.mkForce pkgs; config._module.args.baseModules = modules; + config._module.args.pkgs = lib.mkDefault pkgs; config._module.check = check; + config.nixpkgs.system = mkDefault pkgs.system; }; rawModule = lib.evalModules { diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b17b0454257..dc546ed0681 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -410,6 +410,18 @@ in automatically whenever you do a switch. ''; } + + { + time = "2017-10-23T23:26:17+00:00"; + message = '' + A new module is available: 'nixpkgs'. + + Like the identically named NixOS module, this allows you to + set Nixpkgs options and define Nixpkgs overlays. Note, the + changes you make here will not automatically apply to Nix + commands run outside Home Manager. + ''; + } ]; }; } diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix new file mode 100644 index 00000000000..d86e2fd1c07 --- /dev/null +++ b/modules/misc/nixpkgs.nix @@ -0,0 +1,119 @@ +# Adapted from Nixpkgs. + +{ config, lib, pkgs, ... }: + +with lib; + +let + + isConfig = x: + builtins.isAttrs x || builtins.isFunction x; + + optCall = f: x: + if builtins.isFunction f + then f x + else f; + + mergeConfig = lhs_: rhs_: + let + lhs = optCall lhs_ { inherit pkgs; }; + rhs = optCall rhs_ { inherit pkgs; }; + in + lhs // rhs // + optionalAttrs (lhs ? packageOverrides) { + packageOverrides = pkgs: + optCall lhs.packageOverrides pkgs // + optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; + } // + optionalAttrs (lhs ? perlPackageOverrides) { + perlPackageOverrides = pkgs: + optCall lhs.perlPackageOverrides pkgs // + optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; + }; + + configType = mkOptionType { + name = "nixpkgs-config"; + description = "nixpkgs config"; + check = traceValIfNot isConfig; + merge = args: fold (def: mergeConfig def.value) {}; + }; + + overlayType = mkOptionType { + name = "nixpkgs-overlay"; + description = "nixpkgs overlay"; + check = builtins.isFunction; + merge = lib.mergeOneOption; + }; + + _pkgs = import ( + filterAttrs (n: v: v != null) config.nixpkgs + ); + +in + +{ + options.nixpkgs = { + config = mkOption { + default = null; + example = { allowBroken = true; }; + type = types.nullOr configType; + description = '' + The configuration of the Nix Packages collection. (For + details, see the Nixpkgs documentation.) It allows you to set + package configuration options. + + If null, then configuration is taken from + the fallback location, for example, + ~/.config/nixpkgs/config.nix. + ''; + }; + + overlays = mkOption { + default = null; + example = literalExample + '' + [ (self: super: { + openssh = super.openssh.override { + hpnSupport = true; + withKerberos = true; + kerberos = self.libkrb5; + }; + }; + ) ] + ''; + type = types.nullOr (types.listOf overlayType); + description = '' + List of overlays to use with the Nix Packages collection. (For + details, see the Nixpkgs documentation.) It allows you to + override packages globally. This is a function that takes as + an argument the original Nixpkgs. The + first argument should be used for finding dependencies, and + the second should be used for overriding recipes. + + If null, then the overlays are taken from + the fallback location, for example, + ~/.config/nixpkgs/overlays. + ''; + }; + + system = mkOption { + type = types.str; + example = "i686-linux"; + internal = true; + description = '' + Specifies the Nix platform type for which the user environment + should be built. If unset, it defaults to the platform type of + your host system. Specifying this option is useful when doing + distributed multi-platform deployment, or when building + virtual machines. + ''; + }; + }; + + config = { + _module.args = { + pkgs = _pkgs; + pkgs_i686 = _pkgs.pkgsi686Linux; + }; + }; +} -- cgit v1.2.3 From 35775b3bc58c727a395bdc6c93050b410e6929c8 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 24 Oct 2017 12:41:28 +0200 Subject: fix typo --- home-manager/home-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 6bfc46e6606..1a5676e5079 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -133,7 +133,7 @@ function doSwitch() { local wrkdir # Build the generation and run the activate script. Note, we - # specify an output link si that it is treated as a GC root. This + # specify an output link so that it is treated as a GC root. This # prevents an unfortunately timed GC from removing the generation # before activation completes. wrkdir="$(mktemp -d)" -- cgit v1.2.3 From a4c0fead1f93ca11125afe7a2b16154569057480 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 29 Oct 2017 01:21:40 +0200 Subject: files: be less verbose when linking a directory --- modules/files.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index bd2c61250be..e294f97f011 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -226,8 +226,8 @@ in fi if [ -d "${v.source}" ]; then - mkdir -pv "$(dirname "$out/${v.target}")" - ln -sv "${v.source}" "$target" + mkdir -p "$(dirname "$out/${v.target}")" + ln -s "${v.source}" "$target" else install -D -m${v.mode} "${v.source}" "$target" fi -- cgit v1.2.3 From efb5256d280429bd0536342928c01ae718b91119 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 28 Oct 2017 23:01:42 +0200 Subject: home-manager: use XDG configuration directory --- home-manager/home-manager | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 1a5676e5079..d3ef4dfcbb0 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -26,8 +26,9 @@ function setConfigFile() { return fi + local defaultConfFile="${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" local confFile - for confFile in "$HOME/.config/nixpkgs/home.nix" \ + for confFile in "$defaultConfFile" \ "$HOME/.nixpkgs/home.nix" ; do if [[ -e "$confFile" ]] ; then HOME_MANAGER_CONFIG="$confFile" @@ -36,14 +37,14 @@ function setConfigFile() { done errorEcho "No configuration file found." \ - "Please create one at ~/.config/nixpkgs/home.nix" + "Please create one at $defaultConfFile" exit 1 } function setHomeManagerNixPath() { local path for path in "@HOME_MANAGER_PATH@" \ - "$HOME/.config/nixpkgs/home-manager" \ + "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" \ "$HOME/.nixpkgs/home-manager" ; do if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path" -- cgit v1.2.3 From 54a9058ee0bba8eddb60183b525150de467243b7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 17 Oct 2017 15:50:55 +0200 Subject: xdg: add module When enabled this module will cause Home Manager to manage the user environment XDG variables. When disabled, then Home Manager will use the XDG variables taken from the user environment. --- modules/default.nix | 1 + modules/misc/xdg.nix | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 modules/misc/xdg.nix diff --git a/modules/default.nix b/modules/default.nix index 4cba27ffb69..9b6ad758d19 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -19,6 +19,7 @@ let ./misc/news.nix ./misc/nixpkgs.nix ./misc/pam.nix + ./misc/xdg.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix new file mode 100644 index 00000000000..941d51ed8f5 --- /dev/null +++ b/modules/misc/xdg.nix @@ -0,0 +1,138 @@ +{ options, config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xdg; + + fileType = basePath: (types.loaOf (types.submodule ( + { name, config, ... }: { + options = { + target = mkOption { + type = types.str; + apply = p: "${cfg.configHome}/${p}"; + description = '' + Path to target file relative to ${basePath}. + ''; + }; + + text = mkOption { + default = null; + type = types.nullOr types.lines; + description = "Text of the file."; + }; + + source = mkOption { + type = types.path; + description = '' + Path of the source file. The file name must not start + with a period since Nix will not allow such names in + the Nix store. + + This may refer to a directory. + ''; + }; + + executable = mkOption { + type = types.bool; + default = false; + description = "Whether the file should be executable."; + }; + }; + + config = { + target = mkDefault name; + source = mkIf (config.text != null) ( + let + file = pkgs.writeTextFile { + inherit (config) text executable; + name = "user-etc-" + baseNameOf name; + }; + in + mkDefault file + ); + }; + } + ))); + + defaultCacheHome = "${config.home.homeDirectory}/.cache"; + defaultConfigHome = "${config.home.homeDirectory}/.config"; + defaultDataHome = "${config.home.homeDirectory}/.local/share"; + + getXdgDir = name: fallback: + let + value = builtins.getEnv name; + in + if value != "" then value else fallback; + +in + +{ + options.xdg = { + enable = mkEnableOption "management of XDG base directories"; + + cacheHome = mkOption { + type = types.path; + defaultText = "~/.cache"; + description = '' + Absolute path to directory holding application caches. + ''; + }; + + configFile = mkOption { + type = fileType "xdg.configHome"; + default = {}; + description = '' + Attribute set of files to link into the user's XDG + configuration home. + ''; + }; + + configHome = mkOption { + type = types.path; + defaultText = "~/.config"; + description = '' + Absolute path to directory holding application configurations. + ''; + }; + + dataHome = mkOption { + type = types.path; + defaultText = "~/.local/share"; + description = '' + Absolute path to directory holding application data. + ''; + }; + }; + + config = mkMerge [ + (mkIf cfg.enable { + xdg.cacheHome = mkDefault defaultCacheHome; + xdg.configHome = mkDefault defaultConfigHome; + xdg.dataHome = mkDefault defaultDataHome; + + home.sessionVariables = { + XDG_CACHE_HOME = cfg.cacheHome; + XDG_CONFIG_HOME = cfg.configHome; + XDG_DATA_HOME = cfg.dataHome; + }; + }) + + (mkIf (!cfg.enable) { + xdg.cacheHome = getXdgDir "XDG_CACHE_HOME" defaultCacheHome; + xdg.configHome = getXdgDir "XDG_CONFIG_HOME" defaultConfigHome; + xdg.dataHome = getXdgDir "XDG_DATA_HOME" defaultDataHome; + }) + + { + home.file = + let + f = n: v: { + inherit (v) source target; + mode = if v.executable then "777" else "444"; + }; + in mapAttrsToList f cfg.configFile; + } + ]; +} -- cgit v1.2.3 From d70715a635461e77d4426ed50e363a12066fe0a9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 24 Oct 2017 18:30:35 +0200 Subject: use `xdg.configFile` for files in XDG config home --- modules/misc/fontconfig.nix | 2 +- modules/misc/gtk.nix | 4 ++-- modules/programs/beets.nix | 2 +- modules/programs/feh.nix | 2 +- modules/programs/htop.nix | 2 +- modules/programs/termite.nix | 2 +- modules/services/dunst.nix | 2 +- modules/services/polybar.nix | 2 +- modules/systemd.nix | 6 +++--- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index aab29b67d43..e76e135eb6d 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -29,7 +29,7 @@ in }; config = mkIf cfg.enableProfileFonts { - home.file.".config/fontconfig/conf.d/10-nix-profile-fonts.conf".text = '' + xdg.configFile."fontconfig/conf.d/10-nix-profile-fonts.conf".text = '' diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index a95e8d6e27f..f0fc8b1aea7 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -124,10 +124,10 @@ in mapAttrsToList formatGtk2Option ini ) + "\n" + cfg2.extraConfig; - home.file.".config/gtk-3.0/settings.ini".text = + xdg.configFile."gtk-3.0/settings.ini".text = toGtk3Ini { Settings = ini // cfg3.extraConfig; }; - home.file.".config/gtk-3.0/gtk.css".text = cfg3.extraCss; + xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; } ); } diff --git a/modules/programs/beets.nix b/modules/programs/beets.nix index 34aa04608d3..40e06a6b389 100644 --- a/modules/programs/beets.nix +++ b/modules/programs/beets.nix @@ -27,7 +27,7 @@ in config = mkIf (cfg.settings != {}) { home.packages = [ pkgs.beets ]; - home.file.".config/beets/config.yaml".text = + xdg.configFile."beets/config.yaml".text = builtins.toJSON config.programs.beets.settings; }; } diff --git a/modules/programs/feh.nix b/modules/programs/feh.nix index 1ca83ca8121..12d828ec583 100644 --- a/modules/programs/feh.nix +++ b/modules/programs/feh.nix @@ -30,7 +30,7 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.feh ]; - home.file.".config/feh/keys".text = '' + xdg.configFile."feh/keys".text = '' # Disable default keybindings ${concatStringsSep "\n" (mapAttrsToList disableBinding cfg.keybindings)} diff --git a/modules/programs/htop.nix b/modules/programs/htop.nix index 10235ccdad5..d700c4855fe 100644 --- a/modules/programs/htop.nix +++ b/modules/programs/htop.nix @@ -290,7 +290,7 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.htop ]; - home.file.".config/htop/htoprc".text = let + xdg.configFile."htop/htoprc".text = let leftMeters = map (m: m.kind) cfg.meters.left; leftModes = map (m: m.mode) cfg.meters.left; rightMeters = map (m: m.kind) cfg.meters.right; diff --git a/modules/programs/termite.nix b/modules/programs/termite.nix index 1e4ee671cde..ce047b8fdbf 100644 --- a/modules/programs/termite.nix +++ b/modules/programs/termite.nix @@ -310,7 +310,7 @@ in optionalString = name: val: lib.optionalString (val != null) "${name} = ${val}"; in mkIf cfg.enable { home.packages = [ pkgs.termite ]; - home.file.".config/termite/config".text = '' + xdg.configFile."termite/config".text = '' [options] ${optionalBoolean "allow_bold" cfg.allowBold} ${optionalBoolean "audible_bell" cfg.audibleBell} diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 22a7d216340..a2f5dae9f92 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -71,7 +71,7 @@ in } (mkIf (cfg.settings != {}) { - home.file.".config/dunst/dunstrc".text = toDunstIni cfg.settings; + xdg.configFile."dunst/dunstrc".text = toDunstIni cfg.settings; }) ] ); diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 8e92b4afffa..2e24f2a94e5 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -111,7 +111,7 @@ in config = mkIf cfg.enable { home.packages = [ cfg.package ]; - home.file.".config/polybar/config".source = configFile; + xdg.configFile."polybar/config".source = configFile; systemd.user.services.polybar = { Unit = { diff --git a/modules/systemd.nix b/modules/systemd.nix index 066304773f8..8ee2db65985 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -28,12 +28,12 @@ let wantedBy = target: { - name = ".config/systemd/user/${target}.wants/${name}.${style}"; + name = "systemd/user/${target}.wants/${name}.${style}"; value = { inherit source; }; }; in singleton { - name = ".config/systemd/user/${name}.${style}"; + name = "systemd/user/${name}.${style}"; value = { inherit source; }; } ++ @@ -107,7 +107,7 @@ 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 { - home.file = + xdg.configFile = listToAttrs ( (buildServices "service" cfg.services) ++ -- cgit v1.2.3 From 3a95ff7435d4ae624fbee4db51d064b4eae4bbc0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 29 Oct 2017 01:48:32 +0200 Subject: xdg: add news entry --- modules/misc/news.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index dc546ed0681..eb25444ea0f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -422,6 +422,31 @@ in commands run outside Home Manager. ''; } + + { + time = "2017-10-28T23:39:55+00:00"; + message = '' + A new module is available: 'xdg'. + + If enabled, this module allows configuration of the XDG base + directory paths. + + Whether the module is enabled or not, it also offers the + option 'xdg.configFile', which acts much like 'home.file' + except the target path is relative to the XDG configuration + directory. That is, unless `XDG_CONFIG_HOME` is configured + otherwise, the assignment + + xdg.configFile.hello.text = "hello world"; + + will result in a file '$HOME/.config/hello'. + + Most modules in Home Manager that previously were hard coded + to write configuration to '$HOME/.config' now use this + option and will therefore honor the XDG configuration + directory. + ''; + } ]; }; } -- cgit v1.2.3 From 268d027770a853ca21ff695755ab05c0349817ef Mon Sep 17 00:00:00 2001 From: Ruben Maher Date: Fri, 27 Oct 2017 08:41:56 +1030 Subject: modules/home-manager: fix syntax error Fixes the error error: syntax error, unexpected $undefined, expecting IND_STR or DOLLAR_CURLY or IND_STRING_CLOSE, at .../home-manager/modules/programs/home-manager.nix:70:47 --- modules/programs/home-manager.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 2fac0bce353..0d6d5f00cc5 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -67,7 +67,7 @@ in # Without this a file collision error will be printed. home.activation.uninstallHomeManager = dagEntryBetween [ "installPackages" ] [ "writeBoundary" ] '' - if nix-env -q | grep -q '^home-manager$' ; then + if nix-env -q | grep -q "^home-manager$" ; then $DRY_RUN_CMD nix-env -e home-manager echo "You can now remove the 'home-manager' packageOverride" -- cgit v1.2.3 From 1213578eb7f7a4031f82046cb3a1c84fa18fe5a0 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 30 Oct 2017 13:45:06 +0100 Subject: zsh: turn fpath into a set Forcing fpath to contain unique values increases startup speed by eliminating extra work of processing duplicated folders. In addition, it increases startup time when zsh is enabled in both system and home configuration due to having the same fpath value between different compinit calls. Fixes https://github.com/rycee/home-manager/issues/108. --- modules/programs/zsh.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index d9ee7ab18c8..d945012c088 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -236,6 +236,7 @@ in }; home.file."${relToDotDir ".zshenv"}".text = '' + typeset -U fpath ${envVarsStr} ''; -- cgit v1.2.3 From 82d6aa0c97220b1398cd46824fa61c7c2a09dd18 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Oct 2017 12:26:39 +0100 Subject: xdg: fix use of base path --- modules/misc/xdg.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 941d51ed8f5..8dcf1fba4be 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -6,14 +6,14 @@ let cfg = config.xdg; - fileType = basePath: (types.loaOf (types.submodule ( + fileType = basePathDesc: basePath: (types.loaOf (types.submodule ( { name, config, ... }: { options = { target = mkOption { type = types.str; - apply = p: "${cfg.configHome}/${p}"; + apply = p: "${basePath}/${p}"; description = '' - Path to target file relative to ${basePath}. + Path to target file relative to ${basePathDesc}. ''; }; @@ -81,7 +81,7 @@ in }; configFile = mkOption { - type = fileType "xdg.configHome"; + type = fileType "xdg.configHome" cfg.configHome; default = {}; description = '' Attribute set of files to link into the user's XDG -- cgit v1.2.3 From 78a14245821060f633057e731906ffacf7e5b7e0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Oct 2017 14:05:54 +0100 Subject: xsession: remove `xsession.windowManager` option This removes the deprecated use of `xsession.windowManager` as a string. This commit also adjusts the xmonad module to become a full module. I.e., the backwards compatibility hack was removed. --- modules/default.nix | 1 + modules/misc/news.nix | 29 ---- modules/services/window-managers/xmonad.nix | 38 ++++- modules/xsession.nix | 229 ++++++++++------------------ 4 files changed, 115 insertions(+), 182 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 9b6ad758d19..c10a4cb5d35 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -57,6 +57,7 @@ let ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix + ./services/window-managers/xmonad.nix ./services/xscreensaver.nix ./systemd.nix ./xresources.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index eb25444ea0f..e2bceb92c83 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -240,22 +240,6 @@ in ''; } - { - time = "2017-09-28T21:39:45+00:00"; - condition = - config.xsession.enable - && config.xsession.windowManager.usesDeprecated; - message = '' - The 'xsession.windowManager' option is now deprecated, - please use 'xsession.windowManager.command' instead. - - This change was made to prepare for window manager modules - under the 'xsession.windowManager' namespace. For example, - 'xsession.windowManager.xmonad' and - 'xsession.windowManager.i3'. - ''; - } - { time = "2017-09-30T09:44:18+00:00"; condition = with config.programs.vim; @@ -339,19 +323,6 @@ in ''; } - { - time = "2017-10-19T09:33:10+00:00"; - condition = - config.xsession.enable - && config.xsession.windowManager.usesDeprecated; - message = '' - The 'xsession.windowManager' option is deprecated and will - be removed on October 31, 2017. To avoid evaluation errors - you must change to using 'xsession.windowManager.command' - before that date. - ''; - } - { time = "2017-10-20T12:15:27+00:00"; condition = with config.systemd.user; diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 8105612c8c6..d512cde076a 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -1,10 +1,11 @@ -{ pkgs }: { config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; +with import ../../lib/dag.nix { inherit lib; }; let - cfg = config.xmonad; + cfg = config.xsession.windowManager.xmonad; xmonad = pkgs.xmonad-with-packages.override { ghcWithPackages = cfg.haskellPackages.ghcWithPackages; @@ -19,7 +20,7 @@ in { options = { - xmonad = { + xsession.windowManager.xmonad = { enable = mkEnableOption "xmonad window manager"; haskellPackages = mkOption { @@ -80,7 +81,32 @@ in }; }; - config = mkIf cfg.enable { - command = "${xmonad}/bin/xmonad"; - }; + config = mkIf cfg.enable (mkMerge [ + { + xsession.windowManager.command = "${xmonad}/bin/xmonad"; + } + + (mkIf (cfg.config != null) { + home.file.".xmonad/xmonad.hs".source = cfg.config; + + home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] '' + if ! cmp --quiet "${cfg.config}" "$HOME/.xmonad/xmonad.hs"; then + xmonadChanged=1 + fi + ''; + + home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] '' + if [[ -v xmonadChanged ]]; then + echo "Recompiling xmonad" + ${config.xsession.windowManager.command} --recompile + + # Attempt to restart xmonad if X is running. + if [[ -v DISPLAY ]] ; then + echo "Restarting xmonad" + ${config.xsession.windowManager.command} --restart + fi + fi + ''; + }) + ]); } diff --git a/modules/xsession.nix b/modules/xsession.nix index dde0a7fe6b4..d51bb6b4852 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -1,16 +1,21 @@ { config, lib, pkgs, ... }: with lib; -with import ./lib/dag.nix { inherit lib; }; let cfg = config.xsession; - # Hack to support xsession.windowManager.command option. - wmBaseModule = { - options = { - command = mkOption { +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + xsession = { + enable = mkEnableOption "X Session"; + + windowManager.command = mkOption { type = types.str; example = literalExample '' let @@ -25,39 +30,6 @@ let ''; }; - usesDeprecated = mkOption { - internal = true; - type = types.bool; - default = false; - }; - }; - }; - - xmonadModule = import ./services/window-managers/xmonad.nix { - inherit pkgs; - }; - -in - -{ - meta.maintainers = [ maintainers.rycee ]; - - options = { - xsession = { - enable = mkEnableOption "X Session"; - - windowManager = mkOption { - type = - types.coercedTo - types.str - (command: { inherit command; usesDeprecated = true; }) - (types.submodule [ wmBaseModule xmonadModule ]); - description = '' - Window manager start command. DEPRECATED: Use - xsession.windowManager.command instead. - ''; - }; - profileExtra = mkOption { type = types.lines; default = ""; @@ -72,125 +44,88 @@ in }; }; - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.windowManager.usesDeprecated { - warnings = [ - ("xsession.windowManager is deprecated, " - + "please use xsession.windowManager.command") - ]; - }) - - # Hack to support xsession.windowManager as a string. Once that is - # removed this code should go back into the xmonad.nix file. - (mkIf (cfg.windowManager.xmonad.enable - && cfg.windowManager.xmonad.config != null) { - home.file.".xmonad/xmonad.hs".source = cfg.windowManager.xmonad.config; - - home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] '' - if ! cmp --quiet \ - "${cfg.windowManager.xmonad.config}" \ - "$HOME/.xmonad/xmonad.hs"; then - xmonadChanged=1 - fi - ''; - - home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] '' - if [[ -v xmonadChanged ]]; then - echo "Recompiling xmonad" - ${cfg.windowManager.command} --recompile - - # Attempt to restart xmonad if X is running. - if [[ -v DISPLAY ]] ; then - echo "Restarting xmonad" - ${cfg.windowManager.command} --restart - fi - fi - ''; - }) - - { - systemd.user.services.setxkbmap = { - Unit = { - Description = "Set up keyboard in X"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - ExecStart = - let - args = concatStringsSep " " ( - [ - "-layout '${config.home.keyboard.layout}'" - "-variant '${config.home.keyboard.variant}'" - ] ++ - (map (v: "-option '${v}'") config.home.keyboard.options) - ); - in - "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; - }; + config = mkIf cfg.enable { + systemd.user.services.setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; - # A basic graphical session target for Home Manager. - systemd.user.targets.hm-graphical-session = { - Unit = { - Description = "Home Manager X session"; - Requires = [ "graphical-session-pre.target" ]; - BindsTo = [ "graphical-session.target" ]; - }; + Install = { + WantedBy = [ "graphical-session.target" ]; }; - home.file.".xprofile".text = '' - if [[ -e "$HOME/.profile" ]]; then - . "$HOME/.profile" - fi - - # If there are any running services from a previous session. - # Need to run this in xprofile because the NixOS xsession - # script starts up graphical-session.target. - systemctl --user stop graphical-session.target graphical-session-pre.target - - systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS - systemctl --user import-environment DISPLAY - systemctl --user import-environment SSH_AUTH_SOCK - systemctl --user import-environment XAUTHORITY - systemctl --user import-environment XDG_DATA_DIRS - systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user import-environment XDG_SESSION_ID + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; + }; - ${cfg.profileExtra} + # A basic graphical session target for Home Manager. + systemd.user.targets.hm-graphical-session = { + Unit = { + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; + }; + }; - export HM_XPROFILE_SOURCED=1 - ''; + home.file.".xprofile".text = '' + if [[ -e "$HOME/.profile" ]]; then + . "$HOME/.profile" + fi - home.file.".xsession" = { - mode = "555"; - text = '' - if [[ ! -v HM_XPROFILE_SOURCED ]]; then - . ~/.xprofile - fi - unset HM_XPROFILE_SOURCED + # If there are any running services from a previous session. + # Need to run this in xprofile because the NixOS xsession + # script starts up graphical-session.target. + systemctl --user stop graphical-session.target graphical-session-pre.target + + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS + systemctl --user import-environment DISPLAY + systemctl --user import-environment SSH_AUTH_SOCK + systemctl --user import-environment XAUTHORITY + systemctl --user import-environment XDG_DATA_DIRS + systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user import-environment XDG_SESSION_ID + + ${cfg.profileExtra} + + export HM_XPROFILE_SOURCED=1 + ''; + + home.file.".xsession" = { + mode = "555"; + text = '' + if [[ ! -v HM_XPROFILE_SOURCED ]]; then + . ~/.xprofile + fi + unset HM_XPROFILE_SOURCED - systemctl --user start hm-graphical-session.target + systemctl --user start hm-graphical-session.target - ${cfg.initExtra} + ${cfg.initExtra} - ${cfg.windowManager.command} + ${cfg.windowManager.command} - systemctl --user stop graphical-session.target - systemctl --user stop graphical-session-pre.target + systemctl --user stop graphical-session.target + systemctl --user stop graphical-session-pre.target - # Wait until the units actually stop. - while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do - sleep 0.5 - done - ''; - }; - } - ]); + # Wait until the units actually stop. + while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do + sleep 0.5 + done + ''; + }; + }; } -- cgit v1.2.3 From 467b774d13ec47e623524d20acd7b19e30927480 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 22 Sep 2017 23:52:26 +0200 Subject: i3: add module --- modules/default.nix | 1 + modules/misc/news.nix | 7 + modules/services/window-managers/i3.nix | 576 ++++++++++++++++++++++++++++++++ 3 files changed, 584 insertions(+) create mode 100644 modules/services/window-managers/i3.nix diff --git a/modules/default.nix b/modules/default.nix index c10a4cb5d35..f82cfdbbcd6 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -57,6 +57,7 @@ let ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix + ./services/window-managers/i3.nix ./services/window-managers/xmonad.nix ./services/xscreensaver.nix ./systemd.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e2bceb92c83..ac969f160b6 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -418,6 +418,13 @@ in directory. ''; } + + { + time = "2017-10-31T11:46:07+00:00"; + message = '' + A new window manager module is available: 'xsession.windowManager.i3'. + ''; + } ]; }; } diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix new file mode 100644 index 00000000000..d224c4a4f08 --- /dev/null +++ b/modules/services/window-managers/i3.nix @@ -0,0 +1,576 @@ +{ config, lib, pkgs, ... }: + +with lib; +with import ../../lib/dag.nix { inherit lib; }; + +let + + cfg = config.xsession.windowManager.i3; + + startupModule = types.submodule { + options = { + command = mkOption { + type = types.string; + description = "Command that will be executed on startup."; + }; + + always = mkOption { + type = types.bool; + default = false; + description = "Whether to run command on each i3 restart."; + }; + + workspace = mkOption { + type = types.nullOr types.string; + default = null; + description = "Launch application on a particular workspace."; + }; + }; + }; + + colorSetModule = types.submodule { + options = { + border = mkOption { + type = types.string; + visible = false; + }; + + childBorder = mkOption { + type = types.string; + visible = false; + }; + + background = mkOption { + type = types.string; + visible = false; + }; + + text = mkOption { + type = types.string; + visible = false; + }; + + indicator = mkOption { + type = types.string; + visible = false; + }; + }; + }; + + barModule = types.submodule { + options = { + mode = mkOption { + type = types.enum [ "dock" "hide" "invisible" ]; + default = "dock"; + description = "Bar visibility mode."; + }; + + hiddenState = mkOption { + type = types.enum [ "hide" "show" ]; + default = "hide"; + description = "The default bar mode when 'bar.mode' == 'hide'."; + }; + + position = mkOption { + type = types.enum [ "top" "bottom" ]; + default = "bottom"; + description = "The edge of the screen i3bar should show up."; + }; + + workspaceButtons = mkOption { + type = types.bool; + default = true; + description = "Whether workspace buttons should be shown or not."; + }; + + statusCommand = mkOption { + type = types.string; + default = "${pkgs.i3status}/bin/i3status"; + description = "Command that will be used to get status lines."; + }; + + }; + }; + + criteriaModule = types.attrs; + + configModule = types.submodule { + options = { + fonts = mkOption { + type = types.listOf types.string; + default = ["monospace 8"]; + description = '' + Font list used for window titles. Only FreeType fonts are supported. + The order here is improtant (e.g. icons font should go before the one used for text). + ''; + example = [ "FontAwesome 10" "Terminus 10" ]; + }; + + window = mkOption { + type = types.submodule { + options = { + titlebar = mkOption { + type = types.bool; + default = cfg.package != pkgs.i3-gaps; + defaultText = "xsession.windowManager.i3.package != nixpkgs.i3-gaps (titlebar should be disabled for i3-gaps)"; + description = "Whether to show window titlebars."; + }; + + border = mkOption { + type = types.int; + default = 2; + description = "Window border width."; + }; + }; + }; + default = {}; + description = "Window titlebar and border settings."; + }; + + floating = mkOption { + type = types.submodule { + options = { + titlebar = mkOption { + type = types.bool; + default = cfg.package != pkgs.i3-gaps; + defaultText = "xsession.windowManager.i3.package != nixpkgs.i3-gaps (titlebar should be disabled for i3-gaps)"; + description = "Whether to show floating window titlebars."; + }; + + border = mkOption { + type = types.int; + default = 2; + description = "Floating windows border width."; + }; + + modifier = mkOption { + type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ]; + default = "Mod1"; + description = "Modifier key that can be used to drag floating windows."; + example = "Mod4"; + }; + + criteria = mkOption { + type = types.listOf criteriaModule; + default = []; + description = "List of criteria for windows that should be opened in a floating mode."; + example = [ "title='Steam - Update News'" "class='Pavucontrol'" ]; + }; + }; + }; + default = {}; + description = "Floating window settings."; + }; + + focus = mkOption { + type = types.submodule { + options = { + newWindow = mkOption { + type =types.enum [ "smart" "urgent" "focus" "none" ]; + default = "smart"; + description = '' + This option modifies focus behavior on new window activation. + + See + ''; + example = "none"; + }; + + followMouse = mkOption { + type = types.bool; + default = true; + description = "Whether focus should follow the mouse."; + }; + + forceWrapping = mkOption { + type = types.bool; + default = false; + description = '' + Whether to force focus wrapping in tabbed or stacked container. + + See + ''; + }; + }; + }; + default = {}; + description = "Focus related settings."; + }; + + assigns = mkOption { + type = types.attrsOf (types.listOf criteriaModule); + default = {}; + description = '' + An attribute set that assignes applications to workspaces based + on criteria. + ''; + example = literalExample '' + { + "1: web" = [{ class = "^Firefox$"; }]; + "0: extra" = [{ class = "^Firefox$"; window_role = "About"; }]; + } + ''; + }; + + keybindings = mkOption { + type = types.attrs; + default = { + "Mod1+Return" = "exec i3-sensible-terminal"; + "Mod1+Shift+q" = "kill"; + "Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + + "Mod1+Left" = "focus left"; + "Mod1+Down" = "focus down"; + "Mod1+Up" = "focus up"; + "Mod1+Right" = "focus right"; + + "Mod1+h" = "split h"; + "Mod1+v" = "split v"; + "Mod1+f" = "fullscreen toggle"; + + "Mod1+s" = "layout stacking"; + "Mod1+w" = "layout tabbed"; + "Mod1+e" = "layout toggle split"; + + "Mod1+Shift+space" = "floating toggle"; + + "Mod1+1" = "workspace 1"; + "Mod1+2" = "workspace 2"; + "Mod1+3" = "workspace 3"; + "Mod1+4" = "workspace 4"; + "Mod1+5" = "workspace 5"; + "Mod1+6" = "workspace 6"; + "Mod1+7" = "workspace 7"; + "Mod1+8" = "workspace 8"; + "Mod1+9" = "workspace 9"; + + "Mod1+Shift+1" = "move container to workspace 1"; + "Mod1+Shift+2" = "move container to workspace 2"; + "Mod1+Shift+3" = "move container to workspace 3"; + "Mod1+Shift+4" = "move container to workspace 4"; + "Mod1+Shift+5" = "move container to workspace 5"; + "Mod1+Shift+6" = "move container to workspace 6"; + "Mod1+Shift+7" = "move container to workspace 7"; + "Mod1+Shift+8" = "move container to workspace 8"; + "Mod1+Shift+9" = "move container to workspace 9"; + + "Mod1+Shift+c" = "reload"; + "Mod1+Shift+r" = "restart"; + "Mod1+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; + + "Mod1+r" = "mode resize"; + }; + defaultText = "Default i3 keybindings."; + description = '' + An attribute set that assignes keypress to an action. + Only basic keybinding is supported (bindsym keycomb action), + for more advanced setup use 'i3.extraConfig'. + ''; + example = literalExample '' + { + "Mod1+Return" = "exec i3-sensible-terminal"; + "Mod1+Shift+q" = "kill"; + "Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + } + ''; + }; + + colors = mkOption { + type = types.submodule { + options = { + background = mkOption { + type = types.string; + default = "#ffffff"; + description = '' + Background color of the window. Only applications which do not cover + the whole area expose the color. + ''; + }; + + focused = mkOption { + type = colorSetModule; + default = { + border = "#4c7899"; background = "#285577"; text = "#ffffff"; + indicator = "#2e9ef4"; childBorder = "#285577"; + }; + description = "A window which currently has the focus."; + }; + + focusedInactive = mkOption { + type = colorSetModule; + default = { + border = "#333333"; background = "#5f676a"; text = "#ffffff"; + indicator = "#484e50"; childBorder = "#5f676a"; + }; + description = '' + A window which is the focused one of its container, + but it does not have the focus at the moment. + ''; + }; + + unfocused = mkOption { + type = colorSetModule; + default = { + border = "#333333"; background = "#222222"; text = "#888888"; + indicator = "#292d2e"; childBorder = "#222222"; + }; + description = "A window which is not focused."; + }; + + urgent = mkOption { + type = colorSetModule; + default = { + border = "#2f343a"; background = "#900000"; text = "#ffffff"; + indicator = "#900000"; childBorder = "#900000"; + }; + description = "A window which has its urgency hint activated."; + }; + + placeholder = mkOption { + type = colorSetModule; + default = { + border = "#000000"; background = "#0c0c0c"; text = "#ffffff"; + indicator = "#000000"; childBorder = "#0c0c0c"; + }; + description = '' + Background and text color are used to draw placeholder window + contents (when restoring layouts). Border and indicator are ignored. + ''; + }; + }; + }; + default = {}; + description = '' + Color settings. All color classes can be specified using submodules + with 'border', 'background', 'text', 'indicator' and 'childBorder' fields + and RGB color hex-codes as values. See default values for the reference. + Note that 'i3.config.colors.background' parameter takes a single RGB value. + + See . + ''; + }; + + modes = mkOption { + type = types.attrsOf types.attrs; + default = { + resize = { + "Left" = "resize shrink width 10 px or 10 ppt"; + "Down" = "resize grow height 10 px or 10 ppt"; + "Up" = "resize shrink height 10 px or 10 ppt"; + "Right" = "resize grow width 10 px or 10 ppt"; + "Escape" = "mode default"; + }; + }; + description = '' + An attribute set that defines binding modes and keybindings + inside them + + Only basic keybinding is supported (bindsym keycomb action), + for more advanced setup use 'i3.extraConfig'. + ''; + }; + + bars = mkOption { + type = types.listOf barModule; + default = [{}]; + description = '' + i3 bars settings blocks. Set to empty list to remove bars completely. + ''; + }; + + startup = mkOption { + type = types.listOf startupModule; + default = []; + description = '' + Commands that should be executed at startup. + + See . + ''; + example = literalExample '' + [ + { command = "systemctl --user restart polybar"; always = true; } + { command = "dropbox start"; } + { command = "firefox"; workspace = "1: web"; } + ]; + ''; + }; + + gaps = mkOption { + type = types.nullOr (types.submodule { + options = { + inner = mkOption { + type = types.nullOr types.int; + default = null; + description = "Inner gaps value."; + example = 12; + }; + + outer = mkOption { + type = types.nullOr types.int; + default = null; + description = "Outer gaps value."; + example = 5; + }; + + smartGaps = mkOption { + type = types.bool; + default = false; + description = '' + This option controls whether to disable all gaps (outer and inner) + on workspace with a single container. + ''; + example = true; + }; + + smartBorders = mkOption { + type = types.enum [ "on" "off" "no_gaps" ]; + default = null; + description = '' + This option controls whether to disable container borders on + workspace with a single container. + ''; + example = true; + }; + }; + }); + default = null; + description = '' + i3gaps related settings. + Note that i3-gaps package should be set for this options to take effect. + ''; + }; + }; + }; + + keybindingsStr = keybindings: concatStringsSep "\n" ( + mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings + ); + + colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; + + criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]"; + + modeStr = name: keybindings: '' + mode "${name}" { + ${keybindingsStr keybindings} + } + ''; + + assignStr = workspace: criteria: concatStringsSep "\n" ( + map (c: "assign ${criteriaStr c} ${workspace}") criteria + ); + + barStr = { mode, hiddenState, position, workspaceButtons, statusCommand, ... }: '' + bar { + mode ${mode} + hidden_state ${hiddenState} + position ${position} + status_command ${statusCommand} + workspace_buttons ${if workspaceButtons then "yes" else "no"} + } + ''; + + gapsStr = with cfg.config.gaps; '' + ${optionalString (inner != null) "gaps inner ${toString inner}"} + ${optionalString (outer != null) "gaps outer ${toString outer}"} + ${optionalString smartGaps "smart_gaps on"} + ${optionalString (smartBorders != "off") "smart_borders ${smartBorders}"} + ''; + + floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable"; + + startupEntryStr = { command, always, workspace, ... }: '' + ${if always then "exec_always" else "exec"} --no-startup-id ${ + if (workspace == null) then + command + else + "i3-msg 'workspace ${workspace}; exec ${command}'" + } + ''; + + configFile = pkgs.writeText "i3.conf" ((if cfg.config != null then with cfg.config; '' + font pango:${concatStringsSep ", " fonts} + floating_modifier ${floating.modifier} + new_window ${if window.titlebar then "normal" else "pixel"} ${toString window.border} + new_float ${if floating.titlebar then "normal" else "pixel"} ${toString floating.border} + force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"} + focus_follows_mouse ${if focus.followMouse then "yes" else "no"} + focus_on_window_activation ${focus.newWindow} + + client.focused ${colorSetStr colors.focused} + client.focused_inactive ${colorSetStr colors.focusedInactive} + client.unfocused ${colorSetStr colors.unfocused} + client.urgent ${colorSetStr colors.urgent} + client.placeholder ${colorSetStr colors.placeholder} + client.background ${colors.background} + + ${keybindingsStr keybindings} + ${concatStringsSep "\n" (mapAttrsToList modeStr modes)} + ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} + ${concatStringsSep "\n" (map barStr bars)} + ${optionalString (gaps != null) gapsStr} + ${concatStringsSep "\n" (map floatingCriteriaStr floating.criteria)} + ${concatStringsSep "\n" (map startupEntryStr startup)} + '' else "") + "\n" + cfg.extraConfig); + +in + +{ + options = { + xsession.windowManager.i3 = { + enable = mkEnableOption "i3 window manager."; + + package = mkOption { + type = types.package; + default = pkgs.i3; + defaultText = "pkgs.i3"; + example = "pkgs.i3-gaps"; + description = '' + i3 package to use. + If 'i3.config.gaps' settings are specified, 'pkgs.i3-gaps' will be set as a default package. + ''; + }; + + config = mkOption { + type = types.nullOr configModule; + default = {}; + description = "i3 configuration options."; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Extra configuration lines to add to ~/.config/i3/config."; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { + home.packages = [ cfg.package ]; + xsession.windowManager.command = "${cfg.package}/bin/i3"; + home.file.".config/i3/config".source = configFile; + + home.activation.checkI3 = dagEntryBefore [ "linkGeneration" ] '' + if ! cmp --quiet \ + "${configFile}" \ + "$HOME/.config/i3/config"; then + i3Changed=1 + fi + ''; + + home.activation.reloadI3 = dagEntryAfter [ "linkGeneration" ] '' + if [[ -v i3Changed && -v DISPLAY ]]; then + echo "Reloading i3" + ${cfg.package}/bin/i3-msg reload 1>/dev/null + fi + ''; + } + + (mkIf (cfg.config != null) { + xsession.windowManager.i3.package = mkDefault ( + if (cfg.config.gaps != null) then pkgs.i3-gaps else pkgs.i3 + ); + }) + ]); +} -- cgit v1.2.3 From d2572315ca14f225ff3b41c03b0c0b670dffa3a8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 1 Nov 2017 09:50:58 +0100 Subject: i3: use XDG configuration directory Fixes #111. --- modules/services/window-managers/i3.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index d224c4a4f08..608e94546e6 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -549,12 +549,12 @@ in { home.packages = [ cfg.package ]; xsession.windowManager.command = "${cfg.package}/bin/i3"; - home.file.".config/i3/config".source = configFile; + xdg.configFile."i3/config".source = configFile; home.activation.checkI3 = dagEntryBefore [ "linkGeneration" ] '' if ! cmp --quiet \ "${configFile}" \ - "$HOME/.config/i3/config"; then + "${config.xdg.configHome}/i3/config"; then i3Changed=1 fi ''; -- cgit v1.2.3 From bfb5a678d20c774417760a97556f08043674ac66 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 2 Nov 2017 10:32:25 +0100 Subject: modules/home-manager: add warning about `modulesPath` --- modules/programs/home-manager.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 0d6d5f00cc5..724a19ae3da 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -46,6 +46,11 @@ in }; config = mkIf cfg.enable { + warnings = mkIf (cfg.modulesPath != null) [ + ("'programs.home-manager.modulesPath' is deprecated, " + + "please use 'programs.home-manager.path") + ]; + assertions = [{ assertion = cfg.path == null || cfg.modulesPath == null; message = "Cannot simultaneously use " -- cgit v1.2.3 From fa4f9197eeb5d0c881d646f02f58cf0c2c7b1aff Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 2 Nov 2017 11:19:12 +0100 Subject: home-manager: avoid import to improve error messages When using `import` to inject the configuration into the module system we lose the location in error messages, i.e., it just says ``'`. --- home-manager/home-manager.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix index 206a1bcefa3..a4b3c44390f 100644 --- a/home-manager/home-manager.nix +++ b/home-manager/home-manager.nix @@ -11,10 +11,9 @@ let env = import { configuration = - let - conf = import confPath; - in - if confAttr == "" then conf else conf.${confAttr}; + if confAttr == "" + then confPath + else (import confPath).${confAttr}; pkgs = pkgs; check = check; }; -- cgit v1.2.3 From b4f5b5556ff7627a09b73b86a4d07147aead9f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Str=C3=B6mkvist?= Date: Tue, 31 Oct 2017 18:12:46 +0100 Subject: zsh: Add options for remaining config files `profileExtra`, `loginExtra` and `logoutExtra` for `zprofile`, `zlogin`, and `zlogout` respectively --- modules/programs/zsh.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index d945012c088..a088b332a0f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -186,6 +186,24 @@ in description = "Extra commands that should be added to .zshrc."; }; + profileExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zprofile."; + }; + + loginExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zlogin."; + }; + + logoutExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zlogout."; + }; + plugins = mkOption { type = types.listOf pluginModule; default = []; @@ -291,6 +309,18 @@ in }; }) + (mkIf (cfg.profileExtra != "") { + home.file."${relToDotDir ".zprofile"}".text = cfg.profileExtra; + }) + + (mkIf (cfg.loginExtra != "") { + home.file."${relToDotDir ".zlogin"}".text = cfg.loginExtra; + }) + + (mkIf (cfg.logoutExtra != "") { + home.file."${relToDotDir ".zlogout"}".text = cfg.logoutExtra; + }) + (mkIf (cfg.dotDir != null) { programs.zsh.sessionVariables.ZDOTDIR = zdotdir; -- cgit v1.2.3 From 14083a085771ef218cef5f4b5df4c95b65e6e319 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 5 Nov 2017 19:31:07 +0100 Subject: home-manager: refuse build if CWD is read-only This produces a clearer error message than produced by Nix. Fixes #116. --- home-manager/home-manager | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index d3ef4dfcbb0..7161f17111b 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -113,6 +113,11 @@ function presentNews() { } function doBuild() { + if [[ ! -w . ]]; then + errorEcho "Cannot run build in read-only directory"; + return 1 + fi + local newsInfo newsInfo=$(buildNews) -- cgit v1.2.3 From 676f5c4b3117be7dbe24cc0beacc070b982decfb Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:42 +0100 Subject: files: allow arbitrary paths as home file names By sanitizing the home file name in the derivation name, the home file name is no longer exposed to the naming restrictions for nix store paths. For example, it is now possible to define home files with spaces in their names without providing a target or source attribute. --- modules/files.nix | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index e294f97f011..71b940d20d6 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -6,8 +6,31 @@ with import ./lib/dag.nix { inherit lib; }; let cfg = config.home.file; + homeDirectory = config.home.homeDirectory; + # Figures out a valid Nix store name for the given path. + storeFileName = path: + let + # All characters that are considered safe. Note "-" is not + # included to avoid "-" followed by digit being interpreted as a + # version. + safeChars = + [ "+" "." "_" "?" "=" ] + ++ lowerChars + ++ upperChars + ++ stringToCharacters "0123456789"; + + empties = l: genList (x: "") (length l); + + unsafeInName = stringToCharacters ( + replaceStrings safeChars (empties safeChars) path + ); + + safeName = replaceStrings unsafeInName (empties unsafeInName) path; + in + "home_file_" + safeName; + in { @@ -53,8 +76,7 @@ in config = { target = mkDefault name; source = mkIf (config.text != null) ( - let name' = "user-etc-" + baseNameOf name; - in mkDefault (pkgs.writeText name' config.text) + mkDefault (pkgs.writeText (storeFileName name) config.text) ); }; }) -- cgit v1.2.3 From ccb291ce66ccecb9532015860c383c0e7ebe33ac Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:44 +0100 Subject: files: add option 'executable' This also deprecates the `home.file..mode` option, which is misleading because the Nix store only allows modes 'r--' and 'r-x'. --- modules/files.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++------ modules/misc/news.nix | 17 +++++++++++++++++ modules/misc/xdg.nix | 8 +------- modules/xsession.nix | 2 +- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 71b940d20d6..011f685e35b 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -67,16 +67,34 @@ in }; mode = mkOption { - type = types.str; - default = "444"; - description = "The permissions to apply to the file."; + type = types.nullOr types.str; + default = null; + description = '' + The permissions to apply to the file. + + DEPRECATED: use home.file.<name?>.executable + instead. + ''; + }; + + executable = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Set the execute bit. If null, defaults to the mode + of the source file or to false + for files created through the text option. + ''; }; }; config = { target = mkDefault name; source = mkIf (config.text != null) ( - mkDefault (pkgs.writeText (storeFileName name) config.text) + mkDefault (pkgs.writeTextFile { + inherit (config) executable text; + name = storeFileName name; + }) ); }; }) @@ -105,6 +123,19 @@ in }) ]; + warnings = + let + badFiles = + map (f: f.target) + (filter (f: f.mode != null) + (attrValues cfg)); + badFilesStr = toString badFiles; + in + mkIf (badFiles != []) [ + ("The 'mode' field is deprecated for 'home.file', " + + "use 'executable' instead: ${badFilesStr}") + ]; + # This verifies that the links we are about to create will not # overwrite an existing file. home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( @@ -238,7 +269,15 @@ in "mkdir -p $out\n" + concatStringsSep "\n" ( mapAttrsToList (n: v: - '' + let + mode = + if v.mode != null + then v.mode + else + if v.executable != null + then (if v.executable then "+x" else "-x") + else "+r"; # Acts as a no-op. + in '' target="$(realpath -m "$out/${v.target}")" # Target file must be within $HOME. @@ -251,7 +290,7 @@ in mkdir -p "$(dirname "$out/${v.target}")" ln -s "${v.source}" "$target" else - install -D -m${v.mode} "${v.source}" "$target" + install -D -m${mode} "${v.source}" "$target" fi '' ) cfg diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ac969f160b6..44b9d7f59ad 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -425,6 +425,23 @@ in A new window manager module is available: 'xsession.windowManager.i3'. ''; } + + { + time = "2017-11-06T13:23:17+00:00"; + condition = any (f: f.mode != null) (attrValues config.home.file); + message = '' + The + + home.file..mode + + option is now deprecated. Please use + + home.file..executable + + instead. The 'mode' option will be completely removed + December 6, 2017. + ''; + } ]; }; } diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 8dcf1fba4be..7dd5f456d38 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -126,13 +126,7 @@ in }) { - home.file = - let - f = n: v: { - inherit (v) source target; - mode = if v.executable then "777" else "444"; - }; - in mapAttrsToList f cfg.configFile; + home.file = cfg.configFile; } ]; } diff --git a/modules/xsession.nix b/modules/xsession.nix index d51bb6b4852..9f06e76beb2 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -105,7 +105,7 @@ in ''; home.file.".xsession" = { - mode = "555"; + executable = true; text = '' if [[ ! -v HM_XPROFILE_SOURCED ]]; then . ~/.xprofile -- cgit v1.2.3 From 811bc1b8e514e46da7de5ab250c94b9a31657157 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:47 +0100 Subject: files: extract common variable Also improve the pattern used to determine whether a symlink target points to a Home Manager file path. --- modules/files.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 011f685e35b..8871aa1a23c 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -31,6 +31,10 @@ let in "home_file_" + safeName; + # A symbolic link whose target path matches this pattern will be + # considered part of a Home Manager generation. + homeFilePattern = "${builtins.storeDir}/*-home-manager-files/*"; + in { @@ -140,7 +144,6 @@ in # overwrite an existing file. home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( let - pattern = "-home-manager-files/"; check = pkgs.writeText "check" '' . ${./lib-bash/color-echo.sh} @@ -150,7 +153,7 @@ in relativePath="''${sourcePath#$newGenFiles/}" targetPath="$HOME/$relativePath" if [[ -e "$targetPath" \ - && ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then + && ! "$(readlink "$targetPath")" == ${homeFilePattern} ]] ; then errorEcho "Existing file '$targetPath' is in the way" collision=1 fi @@ -176,8 +179,6 @@ in home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( let - pattern = "-home-manager-files/"; - link = pkgs.writeText "link" '' newGenFiles="$1" shift @@ -200,7 +201,7 @@ in targetPath="$HOME/$relativePath" if [[ -e "$newGenFiles/$relativePath" ]] ; then $VERBOSE_ECHO "Checking $targetPath: exists" - elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then + elif [[ ! "$(readlink "$targetPath")" == ${homeFilePattern} ]] ; then warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete." else $VERBOSE_ECHO "Checking $targetPath: gone (deleting)" -- cgit v1.2.3 From f04cc227a6b41c7d9775d5b9749dc8a99c844dc3 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:48 +0100 Subject: home-environment: clean up activation script creation --- modules/home-environment.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 892c20cc806..932f33f00cf 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -265,7 +265,7 @@ in pkgs.nix ]; - sf = pkgs.writeText "activation-script" '' + activationScript = pkgs.writeScript "activation-script" '' #!${pkgs.stdenv.shell} set -eu @@ -286,7 +286,9 @@ in phases = [ "installPhase" ]; installPhase = '' - install -D -m755 ${sf} $out/activate + mkdir -p $out + + cp ${activationScript} $out/activate substituteInPlace $out/activate \ --subst-var-by GENERATION_DIR $out -- cgit v1.2.3 From b8ddb1179662624652eefdeab5cdcaf3f352a248 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:49 +0100 Subject: use `buildCommand` for single phase builds --- home-manager/default.nix | 4 +--- modules/files.nix | 4 +--- modules/home-environment.nix | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index 943d61e81b2..394f0e7f2a5 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -15,9 +15,7 @@ in pkgs.stdenv.mkDerivation { name = "home-manager"; - phases = [ "installPhase" ]; - - installPhase = '' + buildCommand = '' install -v -D -m755 ${./home-manager} $out/bin/home-manager substituteInPlace $out/bin/home-manager \ diff --git a/modules/files.nix b/modules/files.nix index 8871aa1a23c..11d0694b5e3 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -264,9 +264,7 @@ in home-files = pkgs.stdenv.mkDerivation { name = "home-manager-files"; - phases = [ "installPhase" ]; - - installPhase = + buildCommand = "mkdir -p $out\n" + concatStringsSep "\n" ( mapAttrsToList (n: v: diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 932f33f00cf..323294a37b7 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -283,9 +283,7 @@ in pkgs.stdenv.mkDerivation { name = "home-manager-generation"; - phases = [ "installPhase" ]; - - installPhase = '' + buildCommand = '' mkdir -p $out cp ${activationScript} $out/activate -- cgit v1.2.3 From 9627fe6be63ad29f642d93218b152806bfef2c41 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 6 Nov 2017 10:28:50 +0100 Subject: files: link home files instead of copying Only copy files that need their execute bit changed or use the deprecated `mode` option. --- modules/files.nix | 75 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 11d0694b5e3..66d71510006 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -264,36 +264,57 @@ in home-files = pkgs.stdenv.mkDerivation { name = "home-manager-files"; - buildCommand = - "mkdir -p $out\n" + - concatStringsSep "\n" ( - mapAttrsToList (n: v: - let - mode = - if v.mode != null - then v.mode - else - if v.executable != null - then (if v.executable then "+x" else "-x") - else "+r"; # Acts as a no-op. - in '' - target="$(realpath -m "$out/${v.target}")" - - # Target file must be within $HOME. - if [[ ! "$target" =~ "$out" ]] ; then - echo "Error installing file '${v.target}' outside \$HOME" >&2 - exit 1 - fi + # Symlink directories and files that have the right execute bit. + # Copy files that need their execute bit changed or use the + # deprecated 'mode' option. + buildCommand = '' + mkdir -p $out + + function insertFile() { + local source="$1" + local relTarget="$2" + local executable="$3" + local mode="$4" # For backwards compatibility. + + # Figure out the real absolute path to the target. + local target + target="$(realpath -m "$out/$relTarget")" + + # Target path must be within $HOME. + if [[ ! $target =~ $out ]] ; then + echo "Error installing file '$relTarget' outside \$HOME" >&2 + exit 1 + fi - if [ -d "${v.source}" ]; then - mkdir -p "$(dirname "$out/${v.target}")" - ln -s "${v.source}" "$target" + mkdir -p "$(dirname "$target")" + if [[ -d $source ]]; then + ln -s "$source" "$target" + elif [[ $mode ]]; then + install -m "$mode" "$source" "$target" + else + [[ -x $source ]] && isExecutable=1 || isExecutable="" + if [[ $executable == symlink || $isExecutable == $executable ]]; then + ln -s "$source" "$target" + else + cp "$source" "$target" + if [[ $executable ]]; then + chmod +x "$target" else - install -D -m${mode} "${v.source}" "$target" + chmod -x "$target" fi - '' - ) cfg - ); + fi + fi + } + '' + concatStrings ( + mapAttrsToList (n: v: '' + insertFile "${v.source}" \ + "${v.target}" \ + "${if v.executable == null + then "symlink" + else builtins.toString v.executable}" \ + "${builtins.toString v.mode}" + '') cfg + ); }; }; } -- cgit v1.2.3 From 4f842d9f1b137d98ad4e6393b16b038bbab2bad2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 6 Nov 2017 10:28:54 +0100 Subject: files: extract type of `home.file` into own file --- modules/files.nix | 86 ++----------------------------------- modules/lib/file-type.nix | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 82 deletions(-) create mode 100644 modules/lib/file-type.nix diff --git a/modules/files.nix b/modules/files.nix index 66d71510006..c61560c5bdd 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -9,27 +9,9 @@ let homeDirectory = config.home.homeDirectory; - # Figures out a valid Nix store name for the given path. - storeFileName = path: - let - # All characters that are considered safe. Note "-" is not - # included to avoid "-" followed by digit being interpreted as a - # version. - safeChars = - [ "+" "." "_" "?" "=" ] - ++ lowerChars - ++ upperChars - ++ stringToCharacters "0123456789"; - - empties = l: genList (x: "") (length l); - - unsafeInName = stringToCharacters ( - replaceStrings safeChars (empties safeChars) path - ); - - safeName = replaceStrings unsafeInName (empties unsafeInName) path; - in - "home_file_" + safeName; + fileType = (import lib/file-type.nix { + inherit homeDirectory lib pkgs; + }).fileType; # A symbolic link whose target path matches this pattern will be # considered part of a Home Manager generation. @@ -42,67 +24,7 @@ in home.file = mkOption { description = "Attribute set of files to link into the user home."; default = {}; - type = types.loaOf (types.submodule ( - { name, config, ... }: { - options = { - target = mkOption { - type = types.str; - apply = removePrefix (homeDirectory + "/"); - description = '' - Path to target file relative to HOME. - ''; - }; - - text = mkOption { - default = null; - type = types.nullOr types.lines; - description = "Text of the file."; - }; - - source = mkOption { - type = types.path; - description = '' - Path of the source file. The file name must not start - with a period since Nix will not allow such names in - the Nix store. - - This may refer to a directory. - ''; - }; - - mode = mkOption { - type = types.nullOr types.str; - default = null; - description = '' - The permissions to apply to the file. - - DEPRECATED: use home.file.<name?>.executable - instead. - ''; - }; - - executable = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Set the execute bit. If null, defaults to the mode - of the source file or to false - for files created through the text option. - ''; - }; - }; - - config = { - target = mkDefault name; - source = mkIf (config.text != null) ( - mkDefault (pkgs.writeTextFile { - inherit (config) executable text; - name = storeFileName name; - }) - ); - }; - }) - ); + type = fileType "HOME" homeDirectory; }; home-files = mkOption { diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix new file mode 100644 index 00000000000..ebdcb774165 --- /dev/null +++ b/modules/lib/file-type.nix @@ -0,0 +1,105 @@ +{ homeDirectory, lib, pkgs }: + +with lib; + +let + + # Figures out a valid Nix store name for the given path. + storeFileName = path: + let + # All characters that are considered safe. Note "-" is not + # included to avoid "-" followed by digit being interpreted as a + # version. + safeChars = + [ "+" "." "_" "?" "=" ] + ++ lowerChars + ++ upperChars + ++ stringToCharacters "0123456789"; + + empties = l: genList (x: "") (length l); + + unsafeInName = stringToCharacters ( + replaceStrings safeChars (empties safeChars) path + ); + + safeName = replaceStrings unsafeInName (empties unsafeInName) path; + in + "home_file_" + safeName; + +in + +{ + # Constructs a type suitable for a `home.file` like option. The + # target path may be either absolute or relative, in which case it + # is relative the `basePath` argument (which itself must be an + # absolute path). + # + # Arguments: + # - basePathDesc docbook compatible description of the base path + # - basePath the file base path + fileType = basePathDesc: basePath: types.loaOf (types.submodule ( + { name, config, ... }: { + options = { + target = mkOption { + type = types.str; + apply = p: + let + absPath = if hasPrefix "/" p then p else "${basePath}/${p}"; + in + removePrefix (homeDirectory + "/") absPath; + description = '' + Path to target file relative to ${basePathDesc}. + ''; + }; + + text = mkOption { + default = null; + type = types.nullOr types.lines; + description = "Text of the file."; + }; + + source = mkOption { + type = types.path; + description = '' + Path of the source file. The file name must not start + with a period since Nix will not allow such names in + the Nix store. + + This may refer to a directory. + ''; + }; + + mode = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The permissions to apply to the file. + + DEPRECATED: use home.file.<name?>.executable + instead. + ''; + }; + + executable = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Set the execute bit. If null, defaults to the mode + of the source file or to false + for files created through the text option. + ''; + }; + }; + + config = { + target = mkDefault name; + source = mkIf (config.text != null) ( + mkDefault (pkgs.writeTextFile { + inherit (config) executable text; + name = storeFileName name; + }) + ); + }; + } + )); +} -- cgit v1.2.3 From 549deb51d6f4ac9aa8fccb16a560ad4fcef2d6bc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 6 Nov 2017 10:28:55 +0100 Subject: xdg: use `fileType` for `xdg.configFile` --- modules/misc/xdg.nix | 55 +++++----------------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 7dd5f456d38..8f47ac5dc43 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -6,55 +6,10 @@ let cfg = config.xdg; - fileType = basePathDesc: basePath: (types.loaOf (types.submodule ( - { name, config, ... }: { - options = { - target = mkOption { - type = types.str; - apply = p: "${basePath}/${p}"; - description = '' - Path to target file relative to ${basePathDesc}. - ''; - }; - - text = mkOption { - default = null; - type = types.nullOr types.lines; - description = "Text of the file."; - }; - - source = mkOption { - type = types.path; - description = '' - Path of the source file. The file name must not start - with a period since Nix will not allow such names in - the Nix store. - - This may refer to a directory. - ''; - }; - - executable = mkOption { - type = types.bool; - default = false; - description = "Whether the file should be executable."; - }; - }; - - config = { - target = mkDefault name; - source = mkIf (config.text != null) ( - let - file = pkgs.writeTextFile { - inherit (config) text executable; - name = "user-etc-" + baseNameOf name; - }; - in - mkDefault file - ); - }; - } - ))); + fileType = (import ../lib/file-type.nix { + inherit (config.home) homeDirectory; + inherit lib pkgs; + }).fileType; defaultCacheHome = "${config.home.homeDirectory}/.cache"; defaultConfigHome = "${config.home.homeDirectory}/.config"; @@ -81,7 +36,7 @@ in }; configFile = mkOption { - type = fileType "xdg.configHome" cfg.configHome; + type = fileType "xdg.configHome" cfg.configHome; default = {}; description = '' Attribute set of files to link into the user's XDG -- cgit v1.2.3 From fc3e82584bda579739f01b57e5f31adea2bce593 Mon Sep 17 00:00:00 2001 From: BjornMelgaard Date: Sun, 5 Nov 2017 23:24:42 +0200 Subject: readme: expand preconditions installation step Also fix markdown list item numbering. --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b2d88429e9..6cee3bfb894 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ Currently the easiest way to install Home Manager is as follows: since Home Manager uses these directories to manage your profile generations. On NixOS these should already be available. + Also 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`. 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. + 2. Assign a temporary variable holding the URL to the appropriate archive. Typically this is @@ -61,7 +69,7 @@ Currently the easiest way to install Home Manager is as follows: depending on whether you follow Nixpkgs unstable or version 17.09. -2. Create an initial Home Manager configuration file: +3. Create an initial Home Manager configuration file: ```console $ cat > ~/.config/nixpkgs/home.nix < Date: Tue, 7 Nov 2017 00:27:46 +0100 Subject: dunst: add option `services.dunst.iconTheme` Fixes #119 --- modules/services/dunst.nix | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index a2f5dae9f92..e5c83da2575 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -16,6 +16,35 @@ let "${key}=${value'}"; }; + themeType = types.submodule { + options = { + package = mkOption { + type = types.package; + example = literalExample "pkgs.gnome3.adwaita-icon-theme"; + description = "Package providing the theme."; + }; + + name = mkOption { + type = types.str; + example = "Adwaita"; + description = "The name of the theme within the package."; + }; + + size = mkOption { + type = types.str; + default = "32x32"; + example = "16x16"; + description = "The desired icon size."; + }; + }; + }; + + hicolorTheme = { + package = pkgs.hicolor_icon_theme; + name = "hicolor"; + size = "32x32"; + }; + in { @@ -25,6 +54,12 @@ in services.dunst = { enable = mkEnableOption "the dunst notification daemon"; + iconTheme = mkOption { + type = themeType; + default = hicolorTheme; + description = "Set the icon theme."; + }; + settings = mkOption { type = types.attrsOf types.attrs; default = {}; @@ -55,6 +90,52 @@ in home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; + services.dunst.settings.global.icon_folders = + let + useCustomTheme = + cfg.iconTheme.package != hicolorTheme.package + || cfg.iconTheme.name != hicolorTheme.name + || cfg.iconTheme.size != hicolorTheme.size; + + basePaths = [ + "/run/current-system/sw" + "${config.home.homeDirectory}/.nix-profile" + cfg.iconTheme.package + ] ++ optional useCustomTheme hicolorTheme.package; + + themes = + [ + cfg.iconTheme + ] ++ optional useCustomTheme ( + hicolorTheme // { size = cfg.iconTheme.size; } + ); + + categories = [ + "actions" + "animations" + "apps" + "categories" + "devices" + "emblems" + "emotes" + "filesystem" + "intl" + "mimetypes" + "places" + "status" + "stock" + ]; + in + concatStringsSep ":" ( + concatMap (theme: + concatMap (basePath: + map (category: + "${basePath}/share/icons/${theme.name}/${theme.size}/${category}" + ) categories + ) basePaths + ) themes + ); + systemd.user.services.dunst = { Unit = { Description = "Dunst notification daemon"; -- cgit v1.2.3 From 54043df8fbb07e34fac69d103873823c050e4a6b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 6 Nov 2017 18:00:25 +0100 Subject: files: support recursive linking of directory --- modules/files.nix | 13 +++++++++++-- modules/lib/file-type.nix | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index c61560c5bdd..42ef02d8eb8 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -186,6 +186,8 @@ in home-files = pkgs.stdenv.mkDerivation { name = "home-manager-files"; + nativeBuildInputs = [ pkgs.xlibs.lndir ]; + # Symlink directories and files that have the right execute bit. # Copy files that need their execute bit changed or use the # deprecated 'mode' option. @@ -197,6 +199,7 @@ in local relTarget="$2" local executable="$3" local mode="$4" # For backwards compatibility. + local recursive="$5" # Figure out the real absolute path to the target. local target @@ -210,7 +213,12 @@ in mkdir -p "$(dirname "$target")" if [[ -d $source ]]; then - ln -s "$source" "$target" + if [[ $recursive ]]; then + mkdir -p "$target" + lndir -silent "$source" "$target" + else + ln -s "$source" "$target" + fi elif [[ $mode ]]; then install -m "$mode" "$source" "$target" else @@ -234,7 +242,8 @@ in "${if v.executable == null then "symlink" else builtins.toString v.executable}" \ - "${builtins.toString v.mode}" + "${builtins.toString v.mode}" \ + "${builtins.toString v.recursive}" '') cfg ); }; diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index ebdcb774165..d8622d0c8ca 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -89,6 +89,23 @@ in for files created through the text option. ''; }; + + recursive = mkOption { + type = types.bool; + default = false; + description = '' + If the file source is a directory, then this option + determines whether the directory should be recursively + linked to the target location. This option has no effect + if the source is a file. + + If false (the default) then the target + will be a symbolic link to the source directory. If + true then the target will be a + directory structure matching the source's but whose leafs + are symbolic links to the files of the source directory. + ''; + }; }; config = { -- cgit v1.2.3 From f52ec0df7c00a2d3938091f3d72641d023385878 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 9 Nov 2017 17:14:37 +0100 Subject: systemd: force copying of unit files This is done by exploiting the fact that home files will be copied if the executable bit of the source file and the target file is different. This should be considered a hack until some nicer solution is found. --- modules/systemd.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 8ee2db65985..939dc832c6a 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -24,17 +24,17 @@ let buildService = style: name: serviceCfg: let - source = pkgs.writeText "${name}.${style}" (toSystemdIni serviceCfg); + source = pkgs.writeScript "${name}.${style}" (toSystemdIni serviceCfg); wantedBy = target: { name = "systemd/user/${target}.wants/${name}.${style}"; - value = { inherit source; }; + value = { inherit source; executable = false; }; }; in singleton { name = "systemd/user/${name}.${style}"; - value = { inherit source; }; + value = { inherit source; executable = false; }; } ++ map wantedBy (serviceCfg.Install.WantedBy or []); -- cgit v1.2.3 From a977c79f9fc6f32e75ea3d64561f9401213c5563 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 11 Nov 2017 00:30:53 +0100 Subject: xdg: add option 'xdg.dataFile' This allows creating files within the user's XDG data directory. --- modules/misc/xdg.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 8f47ac5dc43..3e7a3bcb51c 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -52,6 +52,15 @@ in ''; }; + dataFile = mkOption { + type = fileType "xdg.dataHome" cfg.dataHome; + default = {}; + description = '' + Attribute set of files to link into the user's XDG + data home. + ''; + }; + dataHome = mkOption { type = types.path; defaultText = "~/.local/share"; @@ -81,7 +90,7 @@ in }) { - home.file = cfg.configFile; + home.file = mkMerge [ cfg.configFile cfg.dataFile ]; } ]; } -- cgit v1.2.3 From 2b2e20da24a814e244dacc78072f3cc807076afb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 11 Nov 2017 00:31:44 +0100 Subject: dunst: use `xdg.dataFile` for D-Bus service file --- modules/services/dunst.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index e5c83da2575..e01211b579a 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -87,7 +87,7 @@ in config = mkIf cfg.enable ( mkMerge [ { - home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = + xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source = "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; services.dunst.settings.global.icon_folders = -- cgit v1.2.3 From 145aefc9d159ecd0367f887ba0234739fcd8134a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 11 Nov 2017 14:16:45 +0100 Subject: files: simplify cleanup script slightly The cleanup script now takes relative paths as arguments, not absolute paths into the old generation. This uses a GNU specific feature of find. --- modules/files.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 42ef02d8eb8..406fdcf304b 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -116,10 +116,8 @@ in . ${./lib-bash/color-echo.sh} newGenFiles="$1" - oldGenFiles="$2" - shift 2 - for sourcePath in "$@" ; do - relativePath="''${sourcePath#$oldGenFiles/}" + shift 1 + for relativePath in "$@" ; do targetPath="$HOME/$relativePath" if [[ -e "$newGenFiles/$relativePath" ]] ; then $VERBOSE_ECHO "Checking $targetPath: exists" @@ -165,8 +163,12 @@ in local newGenFiles oldGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" oldGenFiles="$(readlink -e "$oldGenPath/home-files")" - find "$oldGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" + + # Apply the cleanup script on each leaf in the old + # generation. The find command below will print the + # relative path of the entry. + find "$oldGenFiles" '(' -type f -or -type l ')' -printf '%P\0' \ + | xargs -0 bash ${cleanup} "$newGenFiles" } if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then -- cgit v1.2.3 From d7537777c3c92ce3430257a947191081237457d8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Nov 2017 00:13:29 +0100 Subject: files: improve keyword for inheriting executable bit --- modules/files.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 406fdcf304b..f2495f5b418 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -225,7 +225,7 @@ in install -m "$mode" "$source" "$target" else [[ -x $source ]] && isExecutable=1 || isExecutable="" - if [[ $executable == symlink || $isExecutable == $executable ]]; then + if [[ $executable == inherit || $isExecutable == $executable ]]; then ln -s "$source" "$target" else cp "$source" "$target" @@ -242,7 +242,7 @@ in insertFile "${v.source}" \ "${v.target}" \ "${if v.executable == null - then "symlink" + then "inherit" else builtins.toString v.executable}" \ "${builtins.toString v.mode}" \ "${builtins.toString v.recursive}" -- cgit v1.2.3 From 7a9c8730931b0d6ec13ad115cd79826f30877d88 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Nov 2017 00:49:36 +0100 Subject: files: add special handling of systemd files Unfortunately systemd derives nonsensical unit names when the unit file is a link to a link to a file. This commit ensures that any file whose target path matches the pattern `*/systemd/user/*` will be reachable with only one link hop. This also reverts f52ec0df7c00a2d3938091f3d72641d023385878, which contained a temporary fix. This commit is an improvements in that it is more explicit and also handles unit files given directly as a home file source. --- modules/files.nix | 19 +++++++++++++++++-- modules/systemd.nix | 6 +++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index f2495f5b418..45aa9965964 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -225,11 +225,26 @@ in install -m "$mode" "$source" "$target" else [[ -x $source ]] && isExecutable=1 || isExecutable="" - if [[ $executable == inherit || $isExecutable == $executable ]]; then + + # Link the file into the home file directory if possible, + # i.e., if the executable bit of the source is the same we + # expect for the target. Otherwise, we copy the file and + # set the executable bit to the expected value. + # + # Note, as a special case we always copy systemd units + # because it derives the unit name from the ultimate link + # target, which may be a store path with the hash + # included. + if [[ ($executable == inherit || $isExecutable == $executable) \ + && $relTarget != *"/systemd/user/"* ]]; then ln -s "$source" "$target" else cp "$source" "$target" - if [[ $executable ]]; then + + if [[ $executable == inherit ]]; then + # Don't change file mode if it should match the source. + : + elif [[ $executable ]]; then chmod +x "$target" else chmod -x "$target" diff --git a/modules/systemd.nix b/modules/systemd.nix index 939dc832c6a..8ee2db65985 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -24,17 +24,17 @@ let buildService = style: name: serviceCfg: let - source = pkgs.writeScript "${name}.${style}" (toSystemdIni serviceCfg); + source = pkgs.writeText "${name}.${style}" (toSystemdIni serviceCfg); wantedBy = target: { name = "systemd/user/${target}.wants/${name}.${style}"; - value = { inherit source; executable = false; }; + value = { inherit source; }; }; in singleton { name = "systemd/user/${name}.${style}"; - value = { inherit source; executable = false; }; + value = { inherit source; }; } ++ map wantedBy (serviceCfg.Install.WantedBy or []); -- cgit v1.2.3 From 356c0bf751a55878c448461d8ef1d17f43911acd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 12 Nov 2017 12:53:10 +0100 Subject: git: use XDG config directory --- modules/programs/git.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index c8dab199ce1..3c07e7999af 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -89,7 +89,7 @@ in email = cfg.userEmail; }; - home.file.".gitconfig".text = + xdg.configFile."git/config".text = generators.toINI {} cfg.iniContent; } @@ -110,7 +110,7 @@ in }) (mkIf (lib.isString cfg.extraConfig) { - home.file.".gitconfig".text = cfg.extraConfig; + xdg.configFile."git/config".text = cfg.extraConfig; }) ] ); -- cgit v1.2.3 From 187a12e90a5ddd5d587c306a55ac1162c5c7a46e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Nov 2017 13:37:59 +0100 Subject: home-manager: minor cleanup output from generations --- home-manager/home-manager | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 7161f17111b..2e3f2dd90a4 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -158,7 +158,8 @@ function doSwitch() { function doListGens() { pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null ls --color=yes -gG --sort time home-manager-*-link \ - | cut -d' ' -f 4- + | cut -d' ' -f 4- \ + | sed -E 's/home-manager-([[:digit:]]*)-link/id \1/' popd > /dev/null } -- cgit v1.2.3 From 66219f23bbb4293b4ad3377a0086c475f78b7630 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Nov 2017 14:07:41 +0100 Subject: home-manager: add 'remove-generations' command This command allows the user to immediately remove specific generations from the profiles directory. --- home-manager/home-manager | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 2e3f2dd90a4..0b13a84c510 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -163,6 +163,39 @@ function doListGens() { popd > /dev/null } +# Removes linked generations. Takes as arguments identifiers of +# generations to remove. +function doRmGenerations() { + if [[ -v VERBOSE ]]; then + export VERBOSE_ARG="--verbose" + else + export VERBOSE_ARG="" + fi + + if [[ -v DRY_RUN ]] ; then + export DRY_RUN_CMD=echo + else + export DRY_RUN_CMD="" + fi + + pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null + + for generationId in "$@"; do + local linkName="home-manager-$generationId-link" + + if [[ ! -e $linkName ]]; then + errorEcho "No generation with ID $generationId" + elif [[ $linkName == $(readlink home-manager) ]]; then + errorEcho "Cannot remove the current generation $generationId" + else + echo Removing generation $generationId + $DRY_RUN_CMD rm $VERBOSE_ARG $linkName + fi + done + + popd > /dev/null +} + function doListPackages() { local outPath outPath="$(nix-env -q --out-path | grep -o '/.*home-manager-path$')" @@ -242,11 +275,21 @@ function doHelp() { echo " -h Print this help" echo echo "Commands" + echo echo " help Print this help" + echo echo " build Build configuration into result directory" + echo echo " switch Build and activate configuration" + echo echo " generations List all home environment generations" + echo + echo " remove-generations ID..." + echo " Remove indicated generations. Use 'generations' command to" + echo " find suitable generation numbers." + echo echo " packages List all packages installed in home-manager-path" + echo echo " news Show news entries in a pager" } @@ -285,7 +328,8 @@ done # Get rid of the options. shift "$((OPTIND-1))" -cmd="$*" +cmd="$1" +shift 1 case "$cmd" in build) @@ -297,6 +341,9 @@ case "$cmd" in generations) doListGens ;; + remove-generations) + doRmGenerations "$@" + ;; packages) doListPackages ;; -- cgit v1.2.3 From 04ea044917f076e8b18be61cfc68e869f0317102 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 12 Nov 2017 14:11:59 +0100 Subject: home-manager: look for '--help' on command line This is a special case to work around the lack of long options in `getopts`. --- home-manager/home-manager | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 0b13a84c510..9d10e61e10e 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -296,6 +296,15 @@ function doHelp() { EXTRA_NIX_PATH=() HOME_MANAGER_CONFIG_ATTRIBUTE="" +# As a special case, if the user has given --help anywhere on the +# command line then print help and exit. +for arg in "$@"; do + if [[ $arg == "--help" ]]; then + doHelp + exit 0 + fi +done + while getopts f:I:A:vnh opt; do case $opt in f) -- cgit v1.2.3 From c718951e97bdae546da977f1141c37cefb741006 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 12 Nov 2017 13:28:12 +0100 Subject: git: add option 'programs.git.ignores' This allows the global Git ignores to be configured. --- modules/programs/git.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 3c07e7999af..ed43e53e407 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -76,6 +76,13 @@ in type = types.attrsOf types.attrs; internal = true; }; + + ignores = mkOption { + type = types.listOf types.str; + default = []; + example = [ "*~" "*.swp" ]; + description = "List of paths that should be globally ignored."; + }; }; }; @@ -89,8 +96,13 @@ in email = cfg.userEmail; }; - xdg.configFile."git/config".text = - generators.toINI {} cfg.iniContent; + xdg.configFile = { + "git/config".text = generators.toINI {} cfg.iniContent; + + "git/ignore" = mkIf (cfg.ignores != []) { + text = concatStringsSep "\n" cfg.ignores + "\n"; + }; + }; } (mkIf (cfg.signing != null) { -- cgit v1.2.3 From 61a869a1f5291bb30717c7c343bd0e4b738efa93 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 3 Nov 2017 02:34:42 +0900 Subject: neovim: add module This is a basic module that allows to configure different Neovim providers than the system ones. Note, it does not generate any `init.vim`. --- modules/default.nix | 1 + modules/misc/news.nix | 6 ++++ modules/programs/neovim.nix | 74 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 modules/programs/neovim.nix diff --git a/modules/default.nix b/modules/default.nix index f82cfdbbcd6..7c67887cbba 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -35,6 +35,7 @@ let ./programs/info.nix ./programs/lesspipe.nix ./programs/man.nix + ./programs/neovim.nix ./programs/rofi.nix ./programs/ssh.nix ./programs/termite.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 44b9d7f59ad..b177d6ce4af 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -442,6 +442,12 @@ in December 6, 2017. ''; } + { + time = "2017-11-12T00:18:59+00:00"; + message = '' + A new program module is available: 'programs.neovim'. + ''; + } ]; }; } diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix new file mode 100644 index 00000000000..8e0663f60cc --- /dev/null +++ b/modules/programs/neovim.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.neovim; + +in + +{ + options = { + programs.neovim = { + enable = mkEnableOption "Neovim"; + + withPython = mkOption { + type = types.bool; + default = true; + description = '' + Enable Python 2 provider. Set to true to + use Python 2 plugins. + ''; + }; + + extraPythonPackages = mkOption { + type = types.listOf types.package; + default = [ ]; + example = literalExample "with pkgs.python2Packages; [ pandas jedi ]"; + description = '' + List here Python 2 packages required for your plugins to + work. + ''; + }; + + withRuby = mkOption { + type = types.nullOr types.bool; + default = true; + description = '' + Enable ruby provider. + ''; + }; + + withPython3 = mkOption { + type = types.bool; + default = true; + description = '' + Enable Python 3 provider. Set to true to + use Python 3 plugins. + ''; + }; + + extraPython3Packages = mkOption { + type = types.listOf types.package; + default = [ ]; + example = literalExample + "with pkgs.python3Packages; [ python-language-server ]"; + description = '' + List here Python 3 packages required for your plugins to work. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (pkgs.neovim.override { + inherit (cfg) + extraPython3Packages withPython3 + extraPythonPackages withPython + withRuby; + }) + ]; + }; +} -- cgit v1.2.3 From 7ca68c649270879f1617d944afb8525e19a4dc6d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 13 Nov 2017 00:03:49 +0100 Subject: emacs: minor cleanup of extra packages option --- modules/programs/emacs.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index a056866a85c..eb12ae19c21 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -29,9 +29,8 @@ in extraPackages = mkOption { default = self: []; - example = literalExample '' - epkgs: [ epkgs.emms epkgs.magit ] - ''; + defaultText = "epkgs: []"; + example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; description = "Extra packages available to Emacs."; }; }; -- cgit v1.2.3 From 4ccf43d753a9a5039e30065f5983c6b18755f25b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 13 Nov 2017 00:38:26 +0100 Subject: readme: use IcedTea in example --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6cee3bfb894..a7e80e16344 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,8 @@ 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 Adobe -Flash enabled, and enable the user gpg-agent service. +Emacs with a few extra packages enabled, install Firefox with the +IcedTea plugin enabled, and enable the user gpg-agent service. To satisfy the above setup we should elaborate the `~/.config/nixpkgs/home.nix` file as follows: @@ -130,7 +130,7 @@ To satisfy the above setup we should elaborate the programs.firefox = { enable = true; - enableAdobeFlash = true; + enableIcedTea = true; }; services.gpg-agent = { -- cgit v1.2.3 From 1946343d5b1990539c383c2edbf529deed2e6916 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Tue, 14 Nov 2017 20:53:55 +0100 Subject: i3: add notification option to startup submodule Fixes https://github.com/rycee/home-manager/issues/129. --- modules/misc/news.nix | 14 ++++++++++++++ modules/services/window-managers/i3.nix | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b177d6ce4af..dff74cc5866 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -448,6 +448,20 @@ in A new program module is available: 'programs.neovim'. ''; } + { + time = "2017-11-14T19:56:49+00:00"; + condition = with config.xsession.windowManager; ( + i3.enable && i3.config != null && i3.config.startup != [] + ); + message = '' + A new 'notification' option was added to + xsession.windowManager.i3.startup submodule. + + Startup commands are now executed with the startup-notification + support enabled by default. Please, set 'notification' to false + where --no-startup-id option is necessary. + ''; + } ]; }; } diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 608e94546e6..9ec8829bb22 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -20,6 +20,15 @@ let description = "Whether to run command on each i3 restart."; }; + notification = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable startup-notification support for the command. + See option description in the i3 user guide. + ''; + }; + workspace = mkOption { type = types.nullOr types.string; default = null; @@ -388,8 +397,8 @@ let ''; example = literalExample '' [ - { command = "systemctl --user restart polybar"; always = true; } - { command = "dropbox start"; } + { command = "systemctl --user restart polybar"; always = true; notification = false; } + { command = "dropbox start"; notification = false; } { command = "firefox"; workspace = "1: web"; } ]; ''; @@ -479,8 +488,10 @@ let floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable"; - startupEntryStr = { command, always, workspace, ... }: '' - ${if always then "exec_always" else "exec"} --no-startup-id ${ + startupEntryStr = { command, always, notification, workspace, ... }: '' + ${if always then "exec_always" else "exec"} ${ + if (notification && workspace == null) then "" else "--no-startup-id" + } ${ if (workspace == null) then command else -- cgit v1.2.3 From a36989a860e1fb3bb29ef0a5eb2f09cf383dc247 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 15 Nov 2017 15:11:31 +0100 Subject: gnome-terminal: remove commented code --- modules/programs/gnome-terminal.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index a10914ad6d8..fff11a82a25 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -146,7 +146,7 @@ let { "profiles:" = { default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile)); - list = attrNames cfg.profile; #mapAttrsToList (n: v: n) cfg.profile; + list = attrNames cfg.profile; }; } // -- cgit v1.2.3 From 130e33a4e7698043fc566754d9dda981c2ebb816 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 14 Nov 2017 21:22:34 +0100 Subject: contributing: add basic style guidelines In particular, refer to the Nixpkgs guidelines and add a note about attribute names referencing packages in Nixpkgs. --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index feda8dedb06..3a96a7a8897 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,15 @@ description if you wish. In addition to the above commit message guidelines, try to follow the [seven rules][] as much as possible. +### Style guidelines ### + +The code in Home Manager should follow the [Nixpkgs syntax +guidelines][]. Note, we prefer `lowerCamelCase` for variable and +attribute names with the accepted exception of variables directly +referencing packages in Nixpkgs which use a hyphenated style. For +example, the Home Manager option `services.gpg-agent.enableSshSupport` +references the `gpg-agent` package in Nixpkgs. + ### News ### Home Manager includes a system for presenting news to the user. When @@ -125,3 +134,4 @@ If you do have a change worthy of a news entry then please add one in [create a pull request]: https://help.github.com/articles/creating-a-pull-request/ [seven rules]: https://chris.beams.io/posts/git-commit/#seven-rules [`news.nix`]: https://github.com/rycee/home-manager/blob/master/modules/misc/news.nix +[Nixpkgs syntax guidelines]: https://nixos.org/nixpkgs/manual/#sec-syntax -- cgit v1.2.3 From 9206f363ff1b13e562d50a3b0697d55f949bbaf6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 15 Nov 2017 18:12:40 +0100 Subject: files: fix order of activation actions Specifically, move the cleanup phase to before we switch over the generation links in `gcroots` and `profiles`. Fixes https://github.com/rycee/home-manager/issues/134 --- modules/files.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/files.nix b/modules/files.nix index 45aa9965964..731a26c0b2b 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -99,6 +99,27 @@ in '' ); + # This activation script will + # + # 1. Remove files from the old generation that are not in the new + # generation. + # + # 2. Switch over the Home Manager gcroot and current profile + # links. + # + # 3. Symlink files from the new generation into $HOME. + # + # This order is needed to ensure that we always know which links + # belong to which generation. Specifically, if we're moving from + # generation A to generation B having sets of home file links FA + # and FB, respectively then cleaning before linking produces state + # transitions similar to + # + # FA → FA ∩ FB → (FA ∩ FB) ∪ FB = FB + # + # and a failure during the intermediate state FA ∩ FB will not + # result in lost links because this set of links are in both the + # source and target generation. home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( let link = pkgs.writeText "link" '' @@ -171,6 +192,8 @@ in | xargs -0 bash ${cleanup} "$newGenFiles" } + cleanOldGen + if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then echo "Creating profile generation $newGenNum" $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath" @@ -181,7 +204,6 @@ in fi linkNewGen - cleanOldGen '' ); -- cgit v1.2.3 From 4fce730326d7c03844fc889b0ccab4ee41d40a7e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 15 Nov 2017 18:31:04 +0100 Subject: files: log when creating home file links --- modules/files.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/files.nix b/modules/files.nix index 731a26c0b2b..08d226da188 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -168,6 +168,8 @@ in in '' function linkNewGen() { + echo "Creating home file links in $HOME" + local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" find "$newGenFiles" -type f -print0 -or -type l -print0 \ -- cgit v1.2.3 From bc2f2ad54612ade98c89b72dd06c7de39e1a2cde Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 16 Nov 2017 15:34:51 +0100 Subject: systemd: honor RefuseManualStart and RefuseManualStop Fixes https://github.com/rycee/home-manager/issues/140 --- modules/systemd.nix | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 8ee2db65985..778912a176d 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -119,6 +119,18 @@ in ); home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' + function isStartable() { + local service="$1" + [[ $(systemctl --user show -p RefuseManualStart "$service") == *=no ]] + } + + function isStoppable() { + if [[ -v oldGenPath ]] ; then + local service="$1" + [[ $(systemctl --user show -p RefuseManualStop "$service") == *=no ]] + fi + } + function systemdPostReload() { local workDir workDir="$(mktemp -d)" @@ -163,19 +175,35 @@ in > $servicesDiffFile || true local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) - local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) - local -a toStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) + local -a maybeStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) + local -a maybeStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) local -a toRestart=( ) + local -a toStop=( ) + local -a toStart=( ) for f in ''${maybeRestart[@]} ; do - if ${cfg.systemctlPath} --quiet --user is-active "$f" \ - && ! cmp --quiet \ - "$oldUserServicePath/$f" \ - "$newUserServicePath/$f" ; then + if isStoppable "$f" \ + && isStartable "$f" \ + && ${cfg.systemctlPath} --quiet --user is-active "$f" \ + && ! cmp --quiet \ + "$oldUserServicePath/$f" \ + "$newUserServicePath/$f" ; then toRestart+=("$f") fi done + for f in ''${maybeStop[@]} ; do + if isStoppable "$f" ; then + toStop+=("$f") + fi + done + + for f in ''${maybeStart[@]} ; do + if isStartable "$f" ; then + toStart+=("$f") + fi + done + rm -r $workDir local sugg="" -- cgit v1.2.3 From 2785bf9cb286896dfae283da278669eca3661cd9 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 17 Nov 2017 01:48:03 +0100 Subject: i3: correct example for config.floating.criteria The parameter accepts a listOf criteriaModule (which is types.attrs, not types.string) --- modules/services/window-managers/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 9ec8829bb22..a9d8c1e87c0 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -163,7 +163,7 @@ let type = types.listOf criteriaModule; default = []; description = "List of criteria for windows that should be opened in a floating mode."; - example = [ "title='Steam - Update News'" "class='Pavucontrol'" ]; + example = [ {"title" = "Steam - Update News";} {"class" = "Pavucontrol";} ]; }; }; }; -- cgit v1.2.3 From 206a4e17b56433768a0ecd83993e7c24feab2937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Wed, 15 Nov 2017 18:47:59 +0100 Subject: i3: fix small formatting error (missing space) --- modules/services/window-managers/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index a9d8c1e87c0..c63eea679d2 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -175,7 +175,7 @@ let type = types.submodule { options = { newWindow = mkOption { - type =types.enum [ "smart" "urgent" "focus" "none" ]; + type = types.enum [ "smart" "urgent" "focus" "none" ]; default = "smart"; description = '' This option modifies focus behavior on new window activation. -- cgit v1.2.3 From 8045e56df273b8bde5ec5aa6b16ea788451043f1 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 17 Nov 2017 09:43:48 +0100 Subject: i3: fix config.gaps.smartBorders default value --- modules/services/window-managers/i3.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index c63eea679d2..51e0c06a28a 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -433,12 +433,11 @@ let smartBorders = mkOption { type = types.enum [ "on" "off" "no_gaps" ]; - default = null; + default = "off"; description = '' This option controls whether to disable container borders on workspace with a single container. ''; - example = true; }; }; }); -- cgit v1.2.3 From 177565567e793e5483290dbb5b9487c3ce15ca60 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 17 Nov 2017 12:22:59 +0100 Subject: i3: extend module New options: i3.config.keycodebindings i3.config.window.commands i3.config.window.hideEdgeBorders i3.config.focus.mouseWarping --- modules/misc/news.nix | 12 ++++++ modules/services/window-managers/i3.nix | 65 +++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index dff74cc5866..d32b1e2440a 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -462,6 +462,18 @@ in where --no-startup-id option is necessary. ''; } + { + time = "2017-11-17T10:36:10+00:00"; + condition = config.xsession.windowManager.i3.enable; + message = '' + The i3 window manager module has been extended with the following options: + + i3.config.keycodebindings + i3.config.window.commands + i3.config.window.hideEdgeBorders + i3.config.focus.mouseWarping + ''; + } ]; }; } diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 51e0c06a28a..af6a8b1f713 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -101,6 +101,22 @@ let }; }; + windowCommandModule = types.submodule { + options = { + command = mkOption { + type = types.string; + description = "i3wm command to execute."; + example = "border pixel 1"; + }; + + criteria = mkOption { + type = criteriaModule; + description = "Criteria of the windows on which command should be executed."; + example = { title = "x200: ~/work"; }; + }; + }; + }; + criteriaModule = types.attrs; configModule = types.submodule { @@ -130,6 +146,22 @@ let default = 2; description = "Window border width."; }; + + hideEdgeBorders = mkOption { + type = types.enum [ "none" "vertical" "horizontal" "both" "smart" ]; + default = "none"; + description = "Hide window borders adjacent to the screen edges."; + }; + + commands = mkOption { + type = types.listOf windowCommandModule; + default = []; + description = '' + List of commands that should be executed on specific windows. + See i3wm option documentation. + ''; + example = [ { command = "border pixel 1"; criteria = { class = "XTerm"; }; } ]; + }; }; }; default = {}; @@ -200,6 +232,15 @@ let See ''; }; + + mouseWarping = mkOption { + type = types.bool; + default = true; + description = '' + Whether mouse cursor should be warped to the center of the window when switching focus + to a window on a different output. + ''; + }; }; }; default = {}; @@ -271,9 +312,8 @@ let }; defaultText = "Default i3 keybindings."; description = '' - An attribute set that assignes keypress to an action. - Only basic keybinding is supported (bindsym keycomb action), - for more advanced setup use 'i3.extraConfig'. + An attribute set that assignes key press to an action using key symbol. + See . ''; example = literalExample '' { @@ -284,6 +324,16 @@ let ''; }; + keycodebindings = mkOption { + type = types.attrs; + default = {}; + description = '' + An attribute set that assignes keypress to an action using key code. + See . + ''; + example = { "214" = "exec --no-startup-id /bin/script.sh"; }; + }; + colors = mkOption { type = types.submodule { options = { @@ -454,6 +504,10 @@ let mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings ); + keycodebindingsStr = keycodebindings: concatStringsSep "\n" ( + mapAttrsToList (keycomb: action: "bindcode ${keycomb} ${action}") keycodebindings + ); + colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]"; @@ -486,6 +540,7 @@ let ''; floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable"; + windowCommandsStr = { command, criteria, ... }: "for_window ${criteriaStr criteria} ${command}"; startupEntryStr = { command, always, notification, workspace, ... }: '' ${if always then "exec_always" else "exec"} ${ @@ -503,9 +558,11 @@ let floating_modifier ${floating.modifier} new_window ${if window.titlebar then "normal" else "pixel"} ${toString window.border} new_float ${if floating.titlebar then "normal" else "pixel"} ${toString floating.border} + hide_edge_borders ${window.hideEdgeBorders} force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"} focus_follows_mouse ${if focus.followMouse then "yes" else "no"} focus_on_window_activation ${focus.newWindow} + mouse_warping ${if focus.mouseWarping then "output" else "none"} client.focused ${colorSetStr colors.focused} client.focused_inactive ${colorSetStr colors.focusedInactive} @@ -515,11 +572,13 @@ let client.background ${colors.background} ${keybindingsStr keybindings} + ${keycodebindingsStr keycodebindings} ${concatStringsSep "\n" (mapAttrsToList modeStr modes)} ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} ${concatStringsSep "\n" (map barStr bars)} ${optionalString (gaps != null) gapsStr} ${concatStringsSep "\n" (map floatingCriteriaStr floating.criteria)} + ${concatStringsSep "\n" (map windowCommandsStr window.commands)} ${concatStringsSep "\n" (map startupEntryStr startup)} '' else "") + "\n" + cfg.extraConfig); -- cgit v1.2.3 From 64befb27ebe59aab9d117b65b3243700a8a5fe71 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Nov 2017 13:58:04 +0100 Subject: news: minor formatting fix --- modules/misc/news.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index d32b1e2440a..b61f72cd976 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -442,12 +442,14 @@ in December 6, 2017. ''; } + { time = "2017-11-12T00:18:59+00:00"; message = '' A new program module is available: 'programs.neovim'. ''; } + { time = "2017-11-14T19:56:49+00:00"; condition = with config.xsession.windowManager; ( @@ -462,6 +464,7 @@ in where --no-startup-id option is necessary. ''; } + { time = "2017-11-17T10:36:10+00:00"; condition = config.xsession.windowManager.i3.enable; -- cgit v1.2.3 From 455ce37398f8c2d16458c443cbcd4f2ed8616a6f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Nov 2017 14:02:28 +0100 Subject: home-manager: avoid unnecessary copy --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index b9eedd47041..519c6650c06 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ rec { home-manager = import ./home-manager { inherit pkgs; - path = ./.; + path = toString ./.; }; install = -- cgit v1.2.3 From 3c875267afdac6348e5e7177df10364db8bb5edd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 20 Nov 2017 21:15:51 +0100 Subject: i3: config.modes.resize: add Return to defaults --- modules/services/window-managers/i3.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index af6a8b1f713..96842788ad6 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -418,6 +418,7 @@ let "Up" = "resize shrink height 10 px or 10 ppt"; "Right" = "resize grow width 10 px or 10 ppt"; "Escape" = "mode default"; + "Return" = "mode default"; }; }; description = '' -- cgit v1.2.3 From 592fd61788e4508b63b58f32e2f090e59e646fb0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 13:51:21 +0100 Subject: module/home-manager: remove `modulesPath` option This option has been deprecated for a month and is removed according to the news entry. --- modules/misc/news.nix | 10 ---------- modules/programs/home-manager.nix | 31 +------------------------------ 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b61f72cd976..b27882ec137 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -342,16 +342,6 @@ in ''; } - { - time = "2017-10-23T22:54:33+00:00"; - condition = config.programs.home-manager.modulesPath != null; - message = '' - The 'programs.home-manager.modulesPath' option is now - deprecated and will be removed on November 24, 2017. Please - use the option 'programs.home-manager.path' instead. - ''; - } - { time = "2017-10-23T23:10:29+00:00"; condition = !config.programs.home-manager.enable; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 724a19ae3da..b27be1dbc73 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -28,43 +28,14 @@ in attempted. ''; }; - - modulesPath = mkOption { - type = types.nullOr types.str; - default = null; - example = "$HOME/devel/home-manager/modules"; - description = '' - The default path to use for Home Manager modules. If this - path does not exist then - $HOME/.config/nixpkgs/home-manager/modules - and $HOME/.nixpkgs/home-manager/modules - will be attempted. DEPRECATED: Use - programs.home-manager.path instead. - ''; - }; }; }; config = mkIf cfg.enable { - warnings = mkIf (cfg.modulesPath != null) [ - ("'programs.home-manager.modulesPath' is deprecated, " - + "please use 'programs.home-manager.path") - ]; - - assertions = [{ - assertion = cfg.path == null || cfg.modulesPath == null; - message = "Cannot simultaneously use " - + "'programs.home-manager.path' and " - + "'programs.home-manager.modulesPath'."; - }]; - home.packages = [ (import ../../home-manager { inherit pkgs; - path = - if cfg.modulesPath != null - then "$(dirname ${cfg.modulesPath})" - else cfg.path; + inherit (cfg) path; }) ]; -- cgit v1.2.3 From bcb82da88f9f5e80dbeb14f6d9a6b58e01212f8e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 8 Nov 2017 01:17:46 +0100 Subject: gtk: improve theme and font configuration Specifically, allow the user to specify the package that provides the theme or font. Fixes #1. --- modules/misc/gtk.nix | 99 ++++++++++++++++++++++++++++++++++++++++++--------- modules/misc/news.nix | 27 ++++++++++++++ 2 files changed, 110 insertions(+), 16 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index f0fc8b1aea7..db374c35f98 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -27,6 +27,50 @@ let in "${n} = ${v'}"; + fontType = types.submodule { + options = { + package = mkOption { + type = types.nullOr types.package; + default = null; + example = literalExample "pkgs.dejavu_fonts"; + description = '' + Package providing the font. This package will be installed + to your profile. If null then the font + is assumed to already be available in your profile. + ''; + }; + + name = mkOption { + type = types.str; + example = "DejaVu Sans 8"; + description = '' + The family name and size of the font within the package. + ''; + }; + }; + }; + + themeType = types.submodule { + options = { + package = mkOption { + type = types.nullOr types.package; + default = null; + example = literalExample "pkgs.gnome3.gnome_themes_standard"; + description = '' + Package providing the theme. This package will be installed + to your profile. If null then the theme + is assumed to already be available in your profile. + ''; + }; + + name = mkOption { + type = types.str; + example = "Adwaita"; + description = "The name of the theme within the package."; + }; + }; + }; + in { @@ -36,27 +80,24 @@ in gtk = { enable = mkEnableOption "GTK 2/3 configuration"; - fontName = mkOption { - type = types.nullOr types.str; + font = mkOption { + type = types.nullOr fontType; default = null; - example = "DejaVu Sans 8"; description = '' The font to use in GTK+ 2/3 applications. ''; }; - themeName = mkOption { - type = types.nullOr types.str; + iconTheme = mkOption { + type = types.nullOr themeType; default = null; - example = "Vertex-Dark"; - description = "The name of the GTK+2/3 theme to use."; + description = "The icon theme to use."; }; - iconThemeName = mkOption { - type = types.nullOr types.str; + theme = mkOption { + type = types.nullOr themeType; default = null; - example = "Tango"; - description = "The name of the icon theme to use."; + description = "The GTK+2/3 theme to use."; }; gtk2 = mkOption { @@ -110,15 +151,24 @@ in let ini = optionalAttrs (cfg.fontName != null) - { gtk-font-name = cfg.fontName; } + { gtk-font-name = cfg.font.name; } // - optionalAttrs (cfg.themeName != null) - { gtk-theme-name = cfg.themeName; } + optionalAttrs (cfg.theme != null) + { gtk-theme-name = cfg.theme.name; } // - optionalAttrs (cfg.iconThemeName != null) - { gtk-icon-theme-name = cfg.iconThemeName; }; + optionalAttrs (cfg.iconTheme != null) + { gtk-icon-theme-name = cfg.iconTheme.name; }; + + optionalPackage = opt: + optional (opt != null && opt.package != null) opt.package; in { + + home.packages = + optionalPackage cfg.font + ++ optionalPackage cfg.theme + ++ optionalPackage cfg.iconTheme; + home.file.".gtkrc-2.0".text = concatStringsSep "\n" ( mapAttrsToList formatGtk2Option ini @@ -130,4 +180,21 @@ in xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; } ); + + imports = + let + name = n: [ "gtk" n ]; + in [ + (mkChangedOptionModule (name "fontName") (name "font") ( + config: { name = getAttrFromPath (name "fontName") config; } + )) + + (mkChangedOptionModule (name "themeName") (name "theme") ( + config: { name = getAttrFromPath (name "themeName") config; } + )) + + (mkChangedOptionModule (name "iconThemeName") (name "iconTheme") ( + config: { name = getAttrFromPath (name "iconThemeName") config; } + )) + ]; } diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b27882ec137..656e95e5fe4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -467,6 +467,33 @@ in i3.config.focus.mouseWarping ''; } + + { + time = "2017-11-23T00:31:12+00:00"; + condition = + config.gtk.fontName != "_mkMergedOptionModule" + || config.gtk.themeName != "_mkMergedOptionModule" + || config.gtk.iconThemeName != "_mkMergedOptionModule"; + message = '' + The options + + gtk.fontName, gtk.themeName, and gtk.iconThemeName + + are deprecated and will be removed on December 23, 2017. + + Please use + + gtk.font.name, gtk.theme.name, and gtk.iconTheme.name + + instead. You can find information about these in the manual + page. + + This change was made to introduce the options + 'gtk.font.package', 'gtk.theme.package', and + 'gtk.iconTheme.package', which allow you to specify the + package that provides the font or theme. + ''; + } ]; }; } -- cgit v1.2.3 From e99de88c5c536346e809269d3b5b48823db123d9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 21:58:16 +0100 Subject: modules core: move modules list to own file This is to simplify use of Home Manager as a NixOS module. --- modules/default.nix | 69 ++-------------------------------------------- modules/modules.nix | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 66 deletions(-) create mode 100644 modules/modules.nix diff --git a/modules/default.nix b/modules/default.nix index 7c67887cbba..4d0e9cc71b1 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,64 +10,6 @@ with lib; let - modules = [ - ./files.nix - ./home-environment.nix - ./manual.nix - ./misc/fontconfig.nix - ./misc/gtk.nix - ./misc/news.nix - ./misc/nixpkgs.nix - ./misc/pam.nix - ./misc/xdg.nix - ./programs/bash.nix - ./programs/beets.nix - ./programs/browserpass.nix - ./programs/command-not-found/command-not-found.nix - ./programs/eclipse.nix - ./programs/emacs.nix - ./programs/feh.nix - ./programs/firefox.nix - ./programs/git.nix - ./programs/gnome-terminal.nix - ./programs/home-manager.nix - ./programs/htop.nix - ./programs/info.nix - ./programs/lesspipe.nix - ./programs/man.nix - ./programs/neovim.nix - ./programs/rofi.nix - ./programs/ssh.nix - ./programs/termite.nix - ./programs/texlive.nix - ./programs/vim.nix - ./programs/zsh.nix - ./services/blueman-applet.nix - ./services/compton.nix - ./services/dunst.nix - ./services/gnome-keyring.nix - ./services/gpg-agent.nix - ./services/keepassx.nix - ./services/network-manager-applet.nix - ./services/owncloud-client.nix - ./services/polybar.nix - ./services/random-background.nix - ./services/redshift.nix - ./services/screen-locker.nix - ./services/syncthing.nix - ./services/taffybar.nix - ./services/tahoe-lafs.nix - ./services/udiskie.nix - ./services/window-managers/i3.nix - ./services/window-managers/xmonad.nix - ./services/xscreensaver.nix - ./systemd.nix - ./xresources.nix - ./xsession.nix - - - ]; - collectFailed = cfg: map (x: x.message) (filter (x: !x.assertion) cfg.assertions); @@ -77,15 +19,10 @@ let in fold f res res.config.warnings; - pkgsModule = { - config._module.args.baseModules = modules; - config._module.args.pkgs = lib.mkDefault pkgs; - config._module.check = check; - config.nixpkgs.system = mkDefault pkgs.system; - }; - rawModule = lib.evalModules { - modules = [ configuration ] ++ modules ++ [ pkgsModule ]; + modules = + [ configuration ] + ++ (import ./modules.nix { inherit check lib pkgs; }); }; module = showWarnings ( diff --git a/modules/modules.nix b/modules/modules.nix new file mode 100644 index 00000000000..4c1e1a1a2e5 --- /dev/null +++ b/modules/modules.nix @@ -0,0 +1,79 @@ +{ pkgs +, lib + + # Whether to enable module type checking. +, check ? true +}: + +with lib; + +let + + modules = [ + ./files.nix + ./home-environment.nix + ./manual.nix + ./misc/fontconfig.nix + ./misc/gtk.nix + ./misc/news.nix + ./misc/nixpkgs.nix + ./misc/pam.nix + ./misc/xdg.nix + ./programs/bash.nix + ./programs/beets.nix + ./programs/browserpass.nix + ./programs/command-not-found/command-not-found.nix + ./programs/eclipse.nix + ./programs/emacs.nix + ./programs/feh.nix + ./programs/firefox.nix + ./programs/git.nix + ./programs/gnome-terminal.nix + ./programs/home-manager.nix + ./programs/htop.nix + ./programs/info.nix + ./programs/lesspipe.nix + ./programs/man.nix + ./programs/neovim.nix + ./programs/rofi.nix + ./programs/ssh.nix + ./programs/termite.nix + ./programs/texlive.nix + ./programs/vim.nix + ./programs/zsh.nix + ./services/blueman-applet.nix + ./services/compton.nix + ./services/dunst.nix + ./services/gnome-keyring.nix + ./services/gpg-agent.nix + ./services/keepassx.nix + ./services/network-manager-applet.nix + ./services/owncloud-client.nix + ./services/polybar.nix + ./services/random-background.nix + ./services/redshift.nix + ./services/screen-locker.nix + ./services/syncthing.nix + ./services/taffybar.nix + ./services/tahoe-lafs.nix + ./services/udiskie.nix + ./services/window-managers/i3.nix + ./services/window-managers/xmonad.nix + ./services/xscreensaver.nix + ./systemd.nix + ./xresources.nix + ./xsession.nix + + + ]; + + pkgsModule = { + config._module.args.baseModules = modules; + config._module.args.pkgs = lib.mkDefault pkgs; + config._module.check = check; + config.nixpkgs.system = mkDefault pkgs.system; + }; + +in + + map import modules ++ [ pkgsModule ] -- cgit v1.2.3 From 7876d533cf36f5378d7cdcbbfae29f497193d199 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 22:25:36 +0100 Subject: gtk: fix erroneous variable reference --- modules/misc/gtk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index db374c35f98..d6fedfe4106 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -150,7 +150,7 @@ in config = mkIf cfg.enable ( let ini = - optionalAttrs (cfg.fontName != null) + optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; } // optionalAttrs (cfg.theme != null) -- cgit v1.2.3 From 7a5b9152e97b74e51fff0e5e3545bef1c59d6504 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Tue, 21 Nov 2017 15:29:30 -0800 Subject: keybase, kbfs: add modules --- modules/misc/news.nix | 9 ++++++ modules/modules.nix | 2 ++ modules/services/kbfs.nix | 66 ++++++++++++++++++++++++++++++++++++++++++++ modules/services/keybase.nix | 35 +++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 modules/services/kbfs.nix create mode 100644 modules/services/keybase.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 656e95e5fe4..c44918bd35c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -494,6 +494,15 @@ in package that provides the font or theme. ''; } + + { + time = "2017-11-26T21:57:23+00:00"; + message = '' + Two new modules are available: + + 'services.kbfs' and 'services.keybase' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 4c1e1a1a2e5..7f9ea026817 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -46,7 +46,9 @@ let ./services/dunst.nix ./services/gnome-keyring.nix ./services/gpg-agent.nix + ./services/kbfs.nix ./services/keepassx.nix + ./services/keybase.nix ./services/network-manager-applet.nix ./services/owncloud-client.nix ./services/polybar.nix diff --git a/modules/services/kbfs.nix b/modules/services/kbfs.nix new file mode 100644 index 00000000000..c19917327dc --- /dev/null +++ b/modules/services/kbfs.nix @@ -0,0 +1,66 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.kbfs; + +in + +{ + options = { + services.kbfs = { + enable = mkEnableOption "Keybase File System"; + + mountPoint = mkOption { + type = types.str; + default = "keybase"; + description = '' + Mount point for the Keybase filesystem, relative to + HOME. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + example = [ + "-label kbfs" + "-mount-type normal" + ]; + description = '' + Additional flags to pass to the Keybase filesystem on launch. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.kbfs = { + Unit = { + Description = "Keybase File System"; + Requires = [ "keybase.service" ]; + After = [ "keybase.service" ]; + }; + + Service = + let + mountPoint = "\"%h/${cfg.mountPoint}\""; + in { + Environment = "PATH=/run/wrappers KEYBASE_SYSTEMD=1"; + ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${mountPoint}"; + ExecStart ="${pkgs.kbfs}/bin/kbfsfuse ${toString cfg.extraFlags} ${mountPoint}"; + ExecStopPost = "/run/wrappers/bin/fusermount -u ${mountPoint}"; + Restart = "on-failure"; + PrivateTmp = true; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + + services.keybase.enable = true; + }; +} diff --git a/modules/services/keybase.nix b/modules/services/keybase.nix new file mode 100644 index 00000000000..4262bd0796f --- /dev/null +++ b/modules/services/keybase.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.keybase; + +in + +{ + options = { + services.keybase = { + enable = mkEnableOption "Keybase"; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.keybase = { + Unit = { + Description = "Keybase service"; + }; + + Service = { + ExecStart = "${pkgs.keybase}/bin/keybase service --auto-forked"; + Restart = "on-failure"; + PrivateTmp = true; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 11da41e106483f253e16661bf4a6f34b044c31ed Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Tue, 28 Nov 2017 16:17:55 -0800 Subject: kbfs: add binaries to user profile Add the binaries produced by 'pkgs.kbfs' to the profile, so that the git-remote-keybase helper can work automatically with 'keybase://' remotes. --- modules/services/kbfs.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/kbfs.nix b/modules/services/kbfs.nix index c19917327dc..15d24596077 100644 --- a/modules/services/kbfs.nix +++ b/modules/services/kbfs.nix @@ -61,6 +61,7 @@ in }; }; + home.packages = [ pkgs.kbfs ]; services.keybase.enable = true; }; } -- cgit v1.2.3 From a1e36a9a37fa1abc28cf66b55635a6b4ff0dc8e2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 29 Nov 2017 23:40:43 +0100 Subject: xmonad: install xmonad command to profile Fixes #153. --- modules/services/window-managers/xmonad.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index d512cde076a..84940cf111d 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -83,6 +83,7 @@ in config = mkIf cfg.enable (mkMerge [ { + home.packages = [ xmonad ]; xsession.windowManager.command = "${xmonad}/bin/xmonad"; } -- cgit v1.2.3 From 06d4f39e7b42fd601eae247e458ac82fece349d0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 12:31:08 +0100 Subject: home-manager: use `shellHook` to install This changes the installation command from nix-shell $HM_PATH -A install --run 'home-manager switch' to nix-shell $HM_PATH -A install The added shell hook will print some useful information and run `home-manager switch`. --- README.md | 4 ++-- default.nix | 8 +++----- home-manager/install.nix | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 home-manager/install.nix diff --git a/README.md b/README.md index a7e80e16344..2daf42a804f 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ Currently the easiest way to install Home Manager is as follows: EOF ``` -4. Create the first Home Manager generation: +4. Install Home Manager and create the first Home Manager generation: ```console - $ nix-shell $HM_PATH -A install --run 'home-manager switch' + $ nix-shell $HM_PATH -A install ``` Home Manager should now be active and available in your user diff --git a/default.nix b/default.nix index 519c6650c06..2988bbbf0d8 100644 --- a/default.nix +++ b/default.nix @@ -6,9 +6,7 @@ rec { path = toString ./.; }; - install = - pkgs.runCommand - "home-manager-install" - { propagatedBuildInputs = [ home-manager ]; } - ""; + install = import ./home-manager/install.nix { + inherit home-manager pkgs; + }; } diff --git a/home-manager/install.nix b/home-manager/install.nix new file mode 100644 index 00000000000..c6d3aa4e4ca --- /dev/null +++ b/home-manager/install.nix @@ -0,0 +1,37 @@ +{ home-manager, pkgs }: + +pkgs.runCommand + "home-manager-install" + { + propagatedBuildInputs = [ home-manager ]; + shellHook = '' + echo + echo "Creating initial Home Manager generation..." + echo + + if home-manager switch; then + cat < Date: Wed, 29 Nov 2017 23:53:49 +0100 Subject: readme: minor rewording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2daf42a804f..f83af33662f 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ Currently the easiest way to install Home Manager is as follows: Note, because the `HM_PATH` variable above points to the live Home Manager repository you will automatically get updates whenever you build a new generation. If you dislike automatic updates then perform -a Git clone of the desired branch and set `programs.home-manager.path` -to the absolute path of your clone. +a Git clone of the desired branch and instead do the above steps with +`HM_PATH` set to the _absolute path_ of your clone. Usage ----- -- cgit v1.2.3 From f8aaba6704818ef6af55d00909d5eb6130cbd3be Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sat, 2 Dec 2017 01:17:41 +0100 Subject: lib: add module --- modules/modules.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/modules.nix b/modules/modules.nix index 7f9ea026817..d9b05f54e6d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -67,6 +67,7 @@ let ./xsession.nix + ]; pkgsModule = { -- cgit v1.2.3 From c023b0532a7c9761840aefc0e059b2e424fb1520 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sun, 24 Sep 2017 19:39:41 +0200 Subject: gpg-agent: add missing options --- modules/services/gpg-agent.nix | 48 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 9f4a9b5414e..b2122219a2f 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -25,14 +25,48 @@ in type = types.nullOr types.int; default = null; description = '' - Set the time a cache entry is valid to the given number of seconds. + Set the time a cache entry is valid to the given number of + seconds. + ''; + }; + + defaultCacheTtlSsh = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Set the time a cache entry used for SSH keys is valid to the + given number of seconds. ''; }; enableSshSupport = mkOption { type = types.bool; default = false; - description = "Whether to use the GnuPG key agent for SSH keys."; + description = '' + Whether to use the GnuPG key agent for SSH keys. + ''; + }; + + grabKeyboardAndMouse = mkOption { + type = types.bool; + default = true; + description = '' + Tell the pinentry to grab the keyboard and mouse. This + option should in general be used to avoid X-sniffing + attacks. When disabled, this option passes + setting to gpg-agent. + ''; + }; + + enableScDaemon = mkOption { + type = types.bool; + default = true; + description = '' + Make use of the scdaemon tool. This option has the effect of + enabling the ability to do smartcard operations. When + disabled, this option passes + setting to gpg-agent. + ''; }; }; }; @@ -40,11 +74,17 @@ in config = mkIf cfg.enable (mkMerge [ { home.file.".gnupg/gpg-agent.conf".text = concatStringsSep "\n" ( - optional cfg.enableSshSupport - "enable-ssh-support" + optional (cfg.enableSshSupport) "enable-ssh-support" + ++ + optional (!cfg.grabKeyboardAndMouse) "no-grab" + ++ + optional (!cfg.enableScDaemon) "disable-scdaemon" ++ optional (cfg.defaultCacheTtl != null) "default-cache-ttl ${toString cfg.defaultCacheTtl}" + ++ + optional (cfg.defaultCacheTtlSsh != null) + "default-cache-ttl-ssh ${toString cfg.defaultCacheTtlSsh}" ); home.sessionVariables = -- cgit v1.2.3 From aa1bf31bcbf44ae4722c4514210bdfa8273e4497 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Tue, 5 Dec 2017 23:23:31 +0100 Subject: parcellite: add module This adds a Parcellite service. It has no configuration options, since the app has its own mutable preferences dialog, which unconditionally replaces `~/.config/parcellite/parcelliterc` when preferences are saved. --- modules/misc/news.nix | 7 ++++++ modules/modules.nix | 1 + modules/services/parcellite.nix | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 modules/services/parcellite.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c44918bd35c..95c94578fcb 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -503,6 +503,13 @@ in 'services.kbfs' and 'services.keybase' ''; } + + { + time = "2017-12-07T22:23:11+00:00"; + message = '' + A new module is available: 'services.parcellite' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d9b05f54e6d..074966cb9a8 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -51,6 +51,7 @@ let ./services/keybase.nix ./services/network-manager-applet.nix ./services/owncloud-client.nix + ./services/parcellite.nix ./services/polybar.nix ./services/random-background.nix ./services/redshift.nix diff --git a/modules/services/parcellite.nix b/modules/services/parcellite.nix new file mode 100644 index 00000000000..455989ffe07 --- /dev/null +++ b/modules/services/parcellite.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.parcellite; + package = pkgs.parcellite; + +in + +{ + meta.maintainers = [ maintainers.gleber ]; + + options = { + services.parcellite = { + enable = mkEnableOption "Parcellite"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ package ]; + + systemd.user.services.parcellite = { + Unit = { + Description = "Lightweight GTK+ clipboard manager"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + # PATH have been added in nixpkgs.parcellite, keeping it here for + # backward compatibility. XDG_DATA_DIRS is necessary to make it pick up + # icons correctly. + Environment = '' + PATH=${package}/bin:${pkgs.which}/bin:${pkgs.xdotool}/bin XDG_DATA_DIRS=${pkgs.hicolor_icon_theme}/share + ''; + ExecStart = "${package}/bin/parcellite"; + Restart = "on-abort"; + }; + }; + }; +} -- cgit v1.2.3 From 0be32c9d42e3a8739263ae7886dc2448c833c19c Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 8 Dec 2017 00:01:50 +0100 Subject: xmonad: make package lower priority This avoids a conflict for when the user has an xmonad package installed through `haskellPackages.ghcWithPackages`, which is necessary for wanting to load the xmonad config with ghc. --- modules/services/window-managers/xmonad.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 84940cf111d..660a609659e 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -83,7 +83,7 @@ in config = mkIf cfg.enable (mkMerge [ { - home.packages = [ xmonad ]; + home.packages = [ (lowPrio xmonad) ]; xsession.windowManager.command = "${xmonad}/bin/xmonad"; } -- cgit v1.2.3 From 61c6c83de41acae058d716c121def6090332fd29 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Dec 2017 13:48:46 +0100 Subject: modules: do not import modules The `evalModules` function is smart enough to import modules and will then also use correct file names. --- modules/modules.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/modules.nix b/modules/modules.nix index 074966cb9a8..c46169c4108 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -80,4 +80,4 @@ let in - map import modules ++ [ pkgsModule ] + modules ++ [ pkgsModule ] -- cgit v1.2.3 From 040159c02f95c302e9768b4589a7fae4924ba779 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Dec 2017 13:51:22 +0100 Subject: modules: fix sorting --- modules/modules.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/modules.nix b/modules/modules.nix index c46169c4108..83cc5929429 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -67,8 +67,8 @@ let ./xresources.nix ./xsession.nix - + ]; pkgsModule = { -- cgit v1.2.3 From 6764c2695483041e85a9fd382fbe3ba253109e51 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Dec 2017 15:14:45 +0100 Subject: files: remove `mode` option This option was deprecated >1 month ago and is therefore removed as per the corresponding news entry. --- modules/files.nix | 22 ++-------------------- modules/lib/file-type.nix | 11 ----------- modules/misc/news.nix | 17 ----------------- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 08d226da188..b32fd54c565 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -49,19 +49,6 @@ in }) ]; - warnings = - let - badFiles = - map (f: f.target) - (filter (f: f.mode != null) - (attrValues cfg)); - badFilesStr = toString badFiles; - in - mkIf (badFiles != []) [ - ("The 'mode' field is deprecated for 'home.file', " - + "use 'executable' instead: ${badFilesStr}") - ]; - # This verifies that the links we are about to create will not # overwrite an existing file. home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( @@ -215,8 +202,7 @@ in nativeBuildInputs = [ pkgs.xlibs.lndir ]; # Symlink directories and files that have the right execute bit. - # Copy files that need their execute bit changed or use the - # deprecated 'mode' option. + # Copy files that need their execute bit changed. buildCommand = '' mkdir -p $out @@ -224,8 +210,7 @@ in local source="$1" local relTarget="$2" local executable="$3" - local mode="$4" # For backwards compatibility. - local recursive="$5" + local recursive="$4" # Figure out the real absolute path to the target. local target @@ -245,8 +230,6 @@ in else ln -s "$source" "$target" fi - elif [[ $mode ]]; then - install -m "$mode" "$source" "$target" else [[ -x $source ]] && isExecutable=1 || isExecutable="" @@ -283,7 +266,6 @@ in "${if v.executable == null then "inherit" else builtins.toString v.executable}" \ - "${builtins.toString v.mode}" \ "${builtins.toString v.recursive}" '') cfg ); diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index d8622d0c8ca..80d4ab45b2c 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -69,17 +69,6 @@ in ''; }; - mode = mkOption { - type = types.nullOr types.str; - default = null; - description = '' - The permissions to apply to the file. - - DEPRECATED: use home.file.<name?>.executable - instead. - ''; - }; - executable = mkOption { type = types.nullOr types.bool; default = null; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 95c94578fcb..4dfedd39bed 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -416,23 +416,6 @@ in ''; } - { - time = "2017-11-06T13:23:17+00:00"; - condition = any (f: f.mode != null) (attrValues config.home.file); - message = '' - The - - home.file..mode - - option is now deprecated. Please use - - home.file..executable - - instead. The 'mode' option will be completely removed - December 6, 2017. - ''; - } - { time = "2017-11-12T00:18:59+00:00"; message = '' -- cgit v1.2.3 From 2ff09158f322f06d0d8c168e0dfc09f0d52bfd85 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Dec 2017 16:58:50 +0100 Subject: systemd: fix systemctl command The command's path should be taken from the configuration, not be assumed to be in `PATH`. --- modules/systemd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 778912a176d..69b0979fc50 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -121,13 +121,13 @@ in home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' function isStartable() { local service="$1" - [[ $(systemctl --user show -p RefuseManualStart "$service") == *=no ]] + [[ $(${cfg.systemctlPath} --user show -p RefuseManualStart "$service") == *=no ]] } function isStoppable() { if [[ -v oldGenPath ]] ; then local service="$1" - [[ $(systemctl --user show -p RefuseManualStop "$service") == *=no ]] + [[ $(${cfg.systemctlPath} --user show -p RefuseManualStop "$service") == *=no ]] fi } -- cgit v1.2.3 From 28e00b68fdeef8eec655e363029c54b7c7218fc7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Dec 2017 17:03:34 +0100 Subject: home-environment: optionally empty PATH in activation This adds the option `home.emptyActivationPath` that, when enabled, will cause the activation script to ignore the calling user's `PATH`. The option is disabled by default to match current behavior but the intent is to change this in the future to reduce risk of accidental dependencies of the environment. --- modules/home-environment.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 323294a37b7..8ed7662c9f0 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -169,6 +169,17 @@ in description = "The derivation installing the user packages."; }; + home.emptyActivationPath = mkOption { + internal = true; + default = false; + type = types.bool; + description = '' + Whether the activation script should start with an empty + PATH variable. When false + then the user's PATH will be used. + ''; + }; + home.activation = mkOption { internal = true; default = {}; @@ -263,7 +274,8 @@ in pkgs.gnused pkgs.ncurses # For `tput`. pkgs.nix - ]; + ] + + optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH"; activationScript = pkgs.writeScript "activation-script" '' #!${pkgs.stdenv.shell} @@ -271,7 +283,7 @@ in set -eu set -o pipefail - export PATH="${activationBinPaths}:$PATH" + export PATH="${activationBinPaths}" . ${./lib-bash/color-echo.sh} -- cgit v1.2.3 From 52bdbc42bb5e44e723f38d035fb31c5623070dba Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 4 Dec 2017 11:17:46 +0100 Subject: systemd: move activation script to separate file This makes the following commit more readable. --- modules/systemd-activate.nix | 112 ++++++++++++++++++++++++++++++++++++++++++ modules/systemd.nix | 113 +------------------------------------------ 2 files changed, 114 insertions(+), 111 deletions(-) create mode 100644 modules/systemd-activate.nix diff --git a/modules/systemd-activate.nix b/modules/systemd-activate.nix new file mode 100644 index 00000000000..5e3b5773df7 --- /dev/null +++ b/modules/systemd-activate.nix @@ -0,0 +1,112 @@ +systemctlPath: +'' +function isStartable() { + local service="$1" + [[ $(${systemctlPath} --user show -p RefuseManualStart "$service") == *=no ]] +} + +function isStoppable() { + if [[ -v oldGenPath ]] ; then + local service="$1" + [[ $(${systemctlPath} --user show -p RefuseManualStop "$service") == *=no ]] + fi +} + +function systemdPostReload() { + local workDir + workDir="$(mktemp -d)" + + if [[ -v oldGenPath ]] ; then + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" + fi + + local newUserServicePath="$newGenPath/home-files/.config/systemd/user" + local oldServiceFiles="$workDir/old-files" + local newServiceFiles="$workDir/new-files" + local servicesDiffFile="$workDir/diff-files" + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ + && ! -d "$newUserServicePath" ]]; then + return + fi + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then + touch "$oldServiceFiles" + else + find "$oldUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$oldServiceFiles" + fi + + if [[ ! -d "$newUserServicePath" ]]; then + touch "$newServiceFiles" + else + find "$newUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$newServiceFiles" + fi + + diff \ + --new-line-format='+%L' \ + --old-line-format='-%L' \ + --unchanged-line-format=' %L' \ + "$oldServiceFiles" "$newServiceFiles" \ + > $servicesDiffFile || true + + local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) + local -a maybeStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) + local -a maybeStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) + local -a toRestart=( ) + local -a toStop=( ) + local -a toStart=( ) + + for f in ''${maybeRestart[@]} ; do + if isStoppable "$f" \ + && isStartable "$f" \ + && ${systemctlPath} --quiet --user is-active "$f" \ + && ! cmp --quiet \ + "$oldUserServicePath/$f" \ + "$newUserServicePath/$f" ; then + toRestart+=("$f") + fi + done + + for f in ''${maybeStop[@]} ; do + if isStoppable "$f" ; then + toStop+=("$f") + fi + done + + for f in ''${maybeStart[@]} ; do + if isStartable "$f" ; then + toStart+=("$f") + fi + done + + rm -r $workDir + + local sugg="" + + if [[ -n "''${toRestart[@]}" ]] ; then + sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" + fi + + if [[ -n "''${toStop[@]}" ]] ; then + sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" + fi + + if [[ -n "''${toStart[@]}" ]] ; then + sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" + fi + + if [[ -n "$sugg" ]] ; then + echo "Suggested commands:" + echo -n -e "$sugg" + fi +} + +$DRY_RUN_CMD ${systemctlPath} --user daemon-reload +systemdPostReload +'' diff --git a/modules/systemd.nix b/modules/systemd.nix index 69b0979fc50..95026d98596 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -118,117 +118,8 @@ in (buildServices "timer" cfg.timers) ); - home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] '' - function isStartable() { - local service="$1" - [[ $(${cfg.systemctlPath} --user show -p RefuseManualStart "$service") == *=no ]] - } - - function isStoppable() { - if [[ -v oldGenPath ]] ; then - local service="$1" - [[ $(${cfg.systemctlPath} --user show -p RefuseManualStop "$service") == *=no ]] - fi - } - - function systemdPostReload() { - local workDir - workDir="$(mktemp -d)" - - if [[ -v oldGenPath ]] ; then - local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" - fi - - local newUserServicePath="$newGenPath/home-files/.config/systemd/user" - local oldServiceFiles="$workDir/old-files" - local newServiceFiles="$workDir/new-files" - local servicesDiffFile="$workDir/diff-files" - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ - && ! -d "$newUserServicePath" ]]; then - return - fi - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then - touch "$oldServiceFiles" - else - find "$oldUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$oldServiceFiles" - fi - - if [[ ! -d "$newUserServicePath" ]]; then - touch "$newServiceFiles" - else - find "$newUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$newServiceFiles" - fi - - diff \ - --new-line-format='+%L' \ - --old-line-format='-%L' \ - --unchanged-line-format=' %L' \ - "$oldServiceFiles" "$newServiceFiles" \ - > $servicesDiffFile || true - - local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) - local -a maybeStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) - local -a maybeStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) - local -a toRestart=( ) - local -a toStop=( ) - local -a toStart=( ) - - for f in ''${maybeRestart[@]} ; do - if isStoppable "$f" \ - && isStartable "$f" \ - && ${cfg.systemctlPath} --quiet --user is-active "$f" \ - && ! cmp --quiet \ - "$oldUserServicePath/$f" \ - "$newUserServicePath/$f" ; then - toRestart+=("$f") - fi - done - - for f in ''${maybeStop[@]} ; do - if isStoppable "$f" ; then - toStop+=("$f") - fi - done - - for f in ''${maybeStart[@]} ; do - if isStartable "$f" ; then - toStart+=("$f") - fi - done - - rm -r $workDir - - local sugg="" - - if [[ -n "''${toRestart[@]}" ]] ; then - sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" - fi - - if [[ -n "''${toStop[@]}" ]] ; then - sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" - fi - - if [[ -n "''${toStart[@]}" ]] ; then - sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" - fi - - if [[ -n "$sugg" ]] ; then - echo "Suggested commands:" - echo -n -e "$sugg" - fi - } - - $DRY_RUN_CMD ${cfg.systemctlPath} --user daemon-reload - systemdPostReload - ''; + home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] + (import ./systemd-activate.nix cfg.systemctlPath); }) ]; } -- cgit v1.2.3 From 8759a5a63e0c54e56955b3bcbfaf28dcdc7ab116 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Mon, 4 Dec 2017 11:17:46 +0100 Subject: systemd: add option to automatically start services --- modules/misc/news.nix | 12 +++ modules/systemd-activate.rb | 189 ++++++++++++++++++++++++++++++++++++++++++++ modules/systemd.nix | 32 +++++++- 3 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 modules/systemd-activate.rb diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 4dfedd39bed..c8726da2bac 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -493,6 +493,18 @@ in A new module is available: 'services.parcellite' ''; } + + { + time = "2017-12-11T17:23:12+00:00"; + condition = config.home.activation ? reloadSystemD; + message = '' + The Boolean option 'systemd.user.startServices' is now + available. When enabled the current naive systemd unit + reload logic is replaced by a more sophisticated one that + attempts to automatically start, stop, and restart units as + necessary. + ''; + } ]; }; } diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb new file mode 100644 index 00000000000..2708280a15c --- /dev/null +++ b/modules/systemd-activate.rb @@ -0,0 +1,189 @@ +require 'set' +require 'open3' + +@dry_run = ENV['DRY_RUN'] +@verbose = ENV['VERBOSE'] + +UnitsDir = 'home-files/.config/systemd/user' + +# 1. Stop all services from the old generation that are not present in the new generation. +# 2. Ensure all services from the new generation that are wanted by active targets are running: +# - Start services that are not already running. +# - Restart services whose unit config files have changed between generations. +# 3. If any services were (re)started, wait 'start_timeout_ms' and report services +# that failed to start. This helps debugging quickly failing services. +# +# Whenever service failures are detected, show the output of +# 'systemd --home status' for the affected services. +# +def setup_services(old_gen_path, new_gen_path, start_timeout_ms_string) + start_timeout_ms = start_timeout_ms_string.to_i + + old_units_path = File.join(old_gen_path, UnitsDir) unless old_gen_path.empty? + new_units_path = File.join(new_gen_path, UnitsDir) + + old_services = get_services(old_units_path) + new_services = get_services(new_units_path) + + exit if old_services.empty? && new_services.empty? + + services_to_run = get_services_to_run(new_units_path) + maybe_changed_services = services_to_run & old_services + + # Only stop active services, otherwise we might get a 'service not loaded' error + # for inactive services that were removed in the current generation. + to_stop = get_active_units(old_services - new_services) + to_restart = get_changed_services(old_units_path, new_units_path, maybe_changed_services) + to_start = get_inactive_units(services_to_run - to_restart) + + raise "daemon-reload failed" unless run_cmd('systemctl --user daemon-reload') + + # Exclude services that aren't allowed to be manually started or stopped + no_manual_start, no_manual_stop = get_restricted_units(to_stop + to_restart + to_start) + to_stop -= no_manual_stop + to_restart -= no_manual_stop + no_manual_start + to_start -= no_manual_start + + if to_stop.empty? && to_start.empty? && to_restart.empty? + print_service_msg("All services are already running", services_to_run) + else + puts "Setting up services" if @verbose + systemctl('stop', to_stop) + systemctl('start', to_start) + systemctl('restart', to_restart) + started_services = to_start + to_restart + if start_timeout_ms > 0 && !started_services.empty? && !@dry_run + failed = wait_and_get_failed_services(started_services, start_timeout_ms) + if failed.empty? + print_service_msg("All services are running", services_to_run) + else + puts + puts "Error. These services failed to start:", failed + show_failed_services_status(failed) + exit 1 + end + end + end +end + +def get_services(dir) + services = get_service_files(dir) if dir && Dir.exists?(dir) + Set.new(services) +end + +def get_service_files(dir) + Dir.chdir(dir) { Dir['*.service'] } +end + +def get_changed_services(dir_a, dir_b, services) + services.select do |service| + a = File.join(dir_a, service) + b = File.join(dir_b, service) + (File.size(a) != File.size(b)) || (File.read(a) != File.read(b)) + end +end + +TargetDirRegexp = /^(.*\.target)\.wants$/ + +# @return all services wanted by active targets +def get_services_to_run(units_dir) + return Set.new unless Dir.exists?(units_dir) + targets = Dir.entries(units_dir).map { |entry| entry[TargetDirRegexp, 1] }.compact + active_targets = get_active_units(targets) + services_to_run = active_targets.map do |target| + get_service_files(File.join(units_dir, "#{target}.wants")) + end.flatten + Set.new(services_to_run) +end + +# @return true on success +def run_cmd(cmd) + print_cmd cmd + @dry_run || system(cmd) +end + +def systemctl(cmd, services) + return if services.empty? + + verb = (cmd == 'stop') ? 'Stopping' : "#{cmd.capitalize}ing" + puts "#{verb}: #{services.join(' ')}" + + cmd = ['systemctl', '--user', cmd, *services] + if @dry_run + puts cmd + return + end + + output, status = Open3.capture2e(*cmd) + print output + # Show status for failed services + unless status.success? + # Due to a bug in systemd, the '--user' argument is not always provided + output.scan(/systemctl (?:--user )?(status .*?)['"]/).flatten.each do |status_cmd| + puts + run_cmd("systemctl --user #{status_cmd}") + end + exit 1 + end +end + +def print_cmd(cmd) + puts cmd if @verbose || @dry_run +end + +def get_active_units(units) + get_units_by_activity(units, true) +end + +def get_inactive_units(units) + get_units_by_activity(units, false) +end + +def get_units_by_activity(units, active) + return [] if units.empty? + units = units.to_a + is_active = `systemctl --user is-active #{units.join(' ')}`.split + units.select.with_index do |_, i| + (is_active[i] == 'active') == active + end +end + +def get_restricted_units(units) + infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.to_a.join(' ')}` + .split("\n\n") + no_manual_start = [] + no_manual_stop = [] + infos.zip(units).each do |info, unit| + no_start, no_stop = info.split("\n") + no_manual_start << unit if no_start.end_with?('yes') + no_manual_stop << unit if no_stop.end_with?('yes') + end + [no_manual_start, no_manual_stop] +end + +def wait_and_get_failed_services(services, start_timeout_ms) + puts "Waiting #{start_timeout_ms} ms for services to fail" + # Force the previous message to always be visible before sleeping + STDOUT.flush + sleep(start_timeout_ms / 1000.0) + get_inactive_units(services) +end + +def show_failed_services_status(services) + puts + services.each do |service| + run_cmd("systemctl --user status #{service}") + puts + end +end + +def print_service_msg(msg, services) + return if services.empty? + if @verbose + puts "#{msg}:", services.to_a + else + puts msg + end +end + +setup_services(*ARGV) diff --git a/modules/systemd.nix b/modules/systemd.nix index 95026d98596..9e0c04d25d7 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -42,6 +42,8 @@ let buildServices = style: serviceCfgs: concatLists (mapAttrsToList (buildService style) serviceCfgs); + servicesStartTimeoutMs = builtins.toString cfg.servicesStartTimeoutMs; + in { @@ -83,6 +85,25 @@ in type = types.attrs; description = "Definition of systemd per-user timers"; }; + + startServices = mkOption { + default = false; + type = types.bool; + description = '' + Start all services that are wanted by active targets. + Additionally, stop obsolete services from the previous + generation. + ''; + }; + + servicesStartTimeoutMs = mkOption { + default = 0; + type = types.int; + description = '' + How long to wait for started services to fail until their + start is considered successful. + ''; + }; }; }; @@ -118,8 +139,15 @@ in (buildServices "timer" cfg.timers) ); - home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] - (import ./systemd-activate.nix cfg.systemctlPath); + home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] ( + if cfg.startServices then + '' + PATH=${dirOf cfg.systemctlPath} \ + ${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \ + "''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}" + '' + else import ./systemd-activate.nix cfg.systemctlPath + ); }) ]; } -- cgit v1.2.3 From f6900f06893e85d13edbb22bab6016de9de841a7 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Fri, 1 Dec 2017 11:15:50 +0100 Subject: files: improve 'target not in $HOME' check Check for prefix instead of inclusion. --- modules/files.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/files.nix b/modules/files.nix index b32fd54c565..78554230ed4 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -217,7 +217,7 @@ in target="$(realpath -m "$out/$relTarget")" # Target path must be within $HOME. - if [[ ! $target =~ $out ]] ; then + if [[ ! $target == $out* ]] ; then echo "Error installing file '$relTarget' outside \$HOME" >&2 exit 1 fi -- cgit v1.2.3 From 8d360c5a573766bbd71b3fa0ac72b345fb7f07f5 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sat, 2 Dec 2017 22:52:35 +0100 Subject: systemd: remove filename hack --- modules/files.nix | 8 +------- modules/systemd.nix | 11 ++++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 78554230ed4..b8efd886f11 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -237,13 +237,7 @@ in # i.e., if the executable bit of the source is the same we # expect for the target. Otherwise, we copy the file and # set the executable bit to the expected value. - # - # Note, as a special case we always copy systemd units - # because it derives the unit name from the ultimate link - # target, which may be a store path with the hash - # included. - if [[ ($executable == inherit || $isExecutable == $executable) \ - && $relTarget != *"/systemd/user/"* ]]; then + if [[ $executable == inherit || $isExecutable == $executable ]]; then ln -s "$source" "$target" else cp "$source" "$target" diff --git a/modules/systemd.nix b/modules/systemd.nix index 9e0c04d25d7..49ad82a015e 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -24,16 +24,21 @@ let buildService = style: name: serviceCfg: let - source = pkgs.writeText "${name}.${style}" (toSystemdIni serviceCfg); + filename = "${name}.${style}"; + + # Needed because systemd derives unit names from the ultimate + # link target. + source = pkgs.writeTextDir filename (toSystemdIni serviceCfg) + + "/" + filename; wantedBy = target: { - name = "systemd/user/${target}.wants/${name}.${style}"; + name = "systemd/user/${target}.wants/${filename}"; value = { inherit source; }; }; in singleton { - name = "systemd/user/${name}.${style}"; + name = "systemd/user/${filename}"; value = { inherit source; }; } ++ -- cgit v1.2.3 From e75b68e39195bda85ccb88541b89b4d75f86631a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 13 Dec 2017 16:31:35 +0100 Subject: home-environment: make username and home directory writable In certain cases it makes sense to override the target username and home directory. In particular, if you're building a configuration for a remote profile. --- modules/home-environment.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 8ed7662c9f0..24f40c74eb7 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -99,15 +99,13 @@ in home.username = mkOption { type = types.str; defaultText = "$USER"; - readOnly = true; - description = "The user's username"; + description = "The user's username."; }; home.homeDirectory = mkOption { type = types.path; defaultText = "$HOME"; - readOnly = true; - description = "The user's home directory"; + description = "The user's home directory."; }; home.language = mkOption { -- cgit v1.2.3 From 7dd09cecda0ea9a84a831259a37609c92fd86652 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 23 Dec 2017 12:46:02 +0100 Subject: gtk: remove deprecated options --- modules/misc/gtk.nix | 17 ----------------- modules/misc/news.nix | 27 --------------------------- 2 files changed, 44 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index d6fedfe4106..7f4f537ed97 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -180,21 +180,4 @@ in xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; } ); - - imports = - let - name = n: [ "gtk" n ]; - in [ - (mkChangedOptionModule (name "fontName") (name "font") ( - config: { name = getAttrFromPath (name "fontName") config; } - )) - - (mkChangedOptionModule (name "themeName") (name "theme") ( - config: { name = getAttrFromPath (name "themeName") config; } - )) - - (mkChangedOptionModule (name "iconThemeName") (name "iconTheme") ( - config: { name = getAttrFromPath (name "iconThemeName") config; } - )) - ]; } diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c8726da2bac..8ca9b7aae11 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -451,33 +451,6 @@ in ''; } - { - time = "2017-11-23T00:31:12+00:00"; - condition = - config.gtk.fontName != "_mkMergedOptionModule" - || config.gtk.themeName != "_mkMergedOptionModule" - || config.gtk.iconThemeName != "_mkMergedOptionModule"; - message = '' - The options - - gtk.fontName, gtk.themeName, and gtk.iconThemeName - - are deprecated and will be removed on December 23, 2017. - - Please use - - gtk.font.name, gtk.theme.name, and gtk.iconTheme.name - - instead. You can find information about these in the manual - page. - - This change was made to introduce the options - 'gtk.font.package', 'gtk.theme.package', and - 'gtk.iconTheme.package', which allow you to specify the - package that provides the font or theme. - ''; - } - { time = "2017-11-26T21:57:23+00:00"; message = '' -- cgit v1.2.3 From f0d207f3807c2111532d361c71047e1883595f3a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 2 Dec 2017 19:15:13 +0100 Subject: Add dag library to `config.lib` Also replace all imports of `dag.nix` by the entry in `config.lib`. --- modules/files.nix | 7 ++++--- modules/home-environment.nix | 9 +++++---- modules/lib/default.nix | 18 ++++++++++++++++++ modules/modules.nix | 1 + modules/programs/gnome-terminal.nix | 5 +++-- modules/programs/home-manager.nix | 5 +++-- modules/programs/info.nix | 5 +++-- modules/services/polybar.nix | 7 ++++--- modules/services/window-managers/i3.nix | 7 ++++--- modules/services/window-managers/xmonad.nix | 7 ++++--- modules/systemd.nix | 5 +++-- 11 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 modules/lib/default.nix diff --git a/modules/files.nix b/modules/files.nix index b8efd886f11..c4978a1aeea 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -1,12 +1,13 @@ { pkgs, config, lib, ... }: with lib; -with import ./lib/dag.nix { inherit lib; }; let cfg = config.home.file; + dag = config.lib.dag; + homeDirectory = config.home.homeDirectory; fileType = (import lib/file-type.nix { @@ -51,7 +52,7 @@ in # This verifies that the links we are about to create will not # overwrite an existing file. - home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] ( + home.activation.checkLinkTargets = dag.entryBefore ["writeBoundary"] ( let check = pkgs.writeText "check" '' . ${./lib-bash/color-echo.sh} @@ -107,7 +108,7 @@ in # and a failure during the intermediate state FA ∩ FB will not # result in lost links because this set of links are in both the # source and target generation. - home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] ( + home.activation.linkGeneration = dag.entryAfter ["writeBoundary"] ( let link = pkgs.writeText "link" '' newGenFiles="$1" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 24f40c74eb7..b761594ace3 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ./lib/dag.nix { inherit lib; }; let cfg = config.home; + dag = config.lib.dag; + languageSubModule = types.submodule { options = { base = mkOption { @@ -241,9 +242,9 @@ in # A dummy entry acting as a boundary between the activation # script's "check" and the "write" phases. - home.activation.writeBoundary = dagEntryAnywhere ""; + home.activation.writeBoundary = dag.entryAnywhere ""; - home.activation.installPackages = dagEntryAfter ["writeBoundary"] '' + home.activation.installPackages = dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD nix-env -i ${cfg.path} ''; @@ -253,7 +254,7 @@ in noteEcho Activating ${res.name} ${res.data} ''; - sortedCommands = dagTopoSort cfg.activation; + sortedCommands = dag.topoSort cfg.activation; activationCmds = if sortedCommands ? result then concatStringsSep "\n" (map mkCmd sortedCommands.result) diff --git a/modules/lib/default.nix b/modules/lib/default.nix new file mode 100644 index 00000000000..5c273f15da7 --- /dev/null +++ b/modules/lib/default.nix @@ -0,0 +1,18 @@ +{ lib }: + +{ + dag = + let + d = import ./dag.nix { inherit lib; }; + in + { + empty = d.emptyDag; + isDag = d.isDag; + topoSort = d.dagTopoSort; + map = d.dagMap; + entryAnywhere = d.dagEntryAnywhere; + entryBetween = d.dagEntryBetween; + entryAfter = d.dagEntryAfter; + entryBefore = d.dagEntryBefore; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 83cc5929429..7fd76147b71 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -75,6 +75,7 @@ let config._module.args.baseModules = modules; config._module.args.pkgs = lib.mkDefault pkgs; config._module.check = check; + config.lib = import ./lib { inherit lib; }; config.nixpkgs.system = mkDefault pkgs.system; }; diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index fff11a82a25..fa379464394 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix { inherit lib; }; let cfg = config.programs.gnome-terminal; + dag = config.lib.dag; + profileColorsSubModule = types.submodule ( { ... }: { options = { @@ -181,7 +182,7 @@ in home.packages = [ pkgs.gnome3.gnome_terminal ]; # The dconf service needs to be installed and prepared. - home.activation.gnomeTerminal = dagEntryAfter ["installPackages"] ( + home.activation.gnomeTerminal = dag.entryAfter ["installPackages"] ( let iniText = toDconfIni (buildIniSet cfg); iniFile = pkgs.writeText "gnome-terminal.ini" iniText; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index b27be1dbc73..306b14a2198 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix { inherit lib; }; let cfg = config.programs.home-manager; + dag = config.lib.dag; + in { @@ -42,7 +43,7 @@ in # Uninstall manually installed home-manager, if such exists. # Without this a file collision error will be printed. home.activation.uninstallHomeManager = - dagEntryBetween [ "installPackages" ] [ "writeBoundary" ] '' + dag.entryBetween [ "installPackages" ] [ "writeBoundary" ] '' if nix-env -q | grep -q "^home-manager$" ; then $DRY_RUN_CMD nix-env -e home-manager diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 5f75ec927a2..5884bb19ec9 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -21,12 +21,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix { inherit lib; }; let cfg = config.programs.info; + dag = config.lib.dag; + # Indexes info files found in this location homeInfoPath = "$HOME/.nix-profile/share/info"; @@ -63,7 +64,7 @@ in home.sessionVariables.INFOPATH = "${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}"; - home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] '' + home.activation.createHomeInfoDir = dag.entryAfter ["installPackages"] '' oPATH=$PATH export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH" $DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}" diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 2e24f2a94e5..b218c6c6133 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../lib/dag.nix { inherit lib; }; let cfg = config.services.polybar; + dag = config.lib.dag; + toPolybarIni = generators.toINI { mkKeyValue = key: value: let @@ -131,7 +132,7 @@ in }; }; - home.activation.checkPolybar = dagEntryBefore [ "linkGeneration" ] '' + home.activation.checkPolybar = dag.entryBefore [ "linkGeneration" ] '' if ! cmp --quiet \ "${configFile}" \ "$HOME/.config/polybar/config"; then @@ -139,7 +140,7 @@ in fi ''; - home.activation.applyPolybar = dagEntryAfter [ "reloadSystemD" ] '' + home.activation.applyPolybar = dag.entryAfter [ "reloadSystemD" ] '' if [[ -v polybarChanged && -v DISPLAY ]]; then echo "Restarting polybar" ${config.systemd.user.systemctlPath} --user restart polybar.service diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 96842788ad6..a40f7462e9e 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../../lib/dag.nix { inherit lib; }; let cfg = config.xsession.windowManager.i3; + dag = config.lib.dag; + startupModule = types.submodule { options = { command = mkOption { @@ -621,7 +622,7 @@ in xsession.windowManager.command = "${cfg.package}/bin/i3"; xdg.configFile."i3/config".source = configFile; - home.activation.checkI3 = dagEntryBefore [ "linkGeneration" ] '' + home.activation.checkI3 = dag.entryBefore [ "linkGeneration" ] '' if ! cmp --quiet \ "${configFile}" \ "${config.xdg.configHome}/i3/config"; then @@ -629,7 +630,7 @@ in fi ''; - home.activation.reloadI3 = dagEntryAfter [ "linkGeneration" ] '' + home.activation.reloadI3 = dag.entryAfter [ "linkGeneration" ] '' if [[ -v i3Changed && -v DISPLAY ]]; then echo "Reloading i3" ${cfg.package}/bin/i3-msg reload 1>/dev/null diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 660a609659e..d4643b09168 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ../../lib/dag.nix { inherit lib; }; let cfg = config.xsession.windowManager.xmonad; + dag = config.lib.dag; + xmonad = pkgs.xmonad-with-packages.override { ghcWithPackages = cfg.haskellPackages.ghcWithPackages; packages = self: @@ -90,13 +91,13 @@ in (mkIf (cfg.config != null) { home.file.".xmonad/xmonad.hs".source = cfg.config; - home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] '' + home.activation.checkXmonad = dag.entryBefore [ "linkGeneration" ] '' if ! cmp --quiet "${cfg.config}" "$HOME/.xmonad/xmonad.hs"; then xmonadChanged=1 fi ''; - home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] '' + home.activation.applyXmonad = dag.entryAfter [ "linkGeneration" ] '' if [[ -v xmonadChanged ]]; then echo "Recompiling xmonad" ${config.xsession.windowManager.command} --recompile diff --git a/modules/systemd.nix b/modules/systemd.nix index 49ad82a015e..3ee5ccc8ef9 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -1,12 +1,13 @@ { config, lib, pkgs, ... }: with lib; -with import ./lib/dag.nix { inherit lib; }; let cfg = config.systemd.user; + dag = config.lib.dag; + enabled = cfg.services != {} || cfg.sockets != {} || cfg.targets != {} @@ -144,7 +145,7 @@ in (buildServices "timer" cfg.timers) ); - home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] ( + home.activation.reloadSystemD = dag.entryAfter ["linkGeneration"] ( if cfg.startServices then '' PATH=${dirOf cfg.systemctlPath} \ -- cgit v1.2.3 From 02219dcd7996b6ee79eda412bb5a91bbd65c6ef8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 5 Jan 2018 08:05:14 +0100 Subject: home-environment: minor code simplification --- modules/home-environment.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index b761594ace3..6278591603e 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -227,8 +227,7 @@ in home.sessionVariables = let - maybeSet = name: value: - listToAttrs (optional (value != null) { inherit name value; }); + maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; }; in (maybeSet "LANG" cfg.language.base) // -- cgit v1.2.3 From 59f44c1189967430dbf65b7f4f8656b21d4f0f84 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 25 Oct 2017 18:01:23 +0200 Subject: home-environment: run activation script in $HOME This avoids issues when starting the activation script somewhere inaccessible. --- modules/home-environment.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 6278591603e..f2936415976 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -281,6 +281,8 @@ in set -eu set -o pipefail + cd $HOME + export PATH="${activationBinPaths}" . ${./lib-bash/color-echo.sh} -- cgit v1.2.3 From 8a2bf21cee1a59e2e47c7851bd93f98ef734da0a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Jan 2018 15:04:57 +0100 Subject: bash: reword option descriptions --- modules/programs/bash.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index dce7969f5c6..f9ad4749468 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -93,13 +93,19 @@ in profileExtra = mkOption { default = ""; type = types.lines; - description = "Extra commands that should be added to .profile."; + description = '' + Extra commands that should be run when initializing a login + shell. + ''; }; initExtra = mkOption { default = ""; type = types.lines; - description = "Extra commands that should be added to .bashrc."; + description = '' + Extra commands that should be run when initializing an + interactive shell. + ''; }; }; }; -- cgit v1.2.3 From 78c308c8357013489e2a6edb39680cfab5799bed Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Jan 2018 15:14:41 +0100 Subject: bash: add option `bashrcExtra` This variable adds some extra flexibility in constructing the `~/.bashrc` file. Currently the option is hidden from public documentation since the option name is provisional. --- modules/programs/bash.nix | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index f9ad4749468..3d4496f764a 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -99,6 +99,17 @@ in ''; }; + bashrcExtra = mkOption { + # Hide for now, may want to rename in the future. + visible = false; + default = ""; + type = types.lines; + description = '' + Extra commands that should be added to + ~/.bashrc. + ''; + }; + initExtra = mkOption { default = ""; type = types.lines; @@ -139,6 +150,25 @@ in mapAttrsToList export (cfg.sessionVariables // globalEnvVars) ); in mkIf cfg.enable { + programs.bash.bashrcExtra = '' + # Commands that should be applied only for interactive shells. + if [[ -n $PS1 ]]; then + ${export "HISTSIZE" cfg.historySize} + ${export "HISTFILESIZE" cfg.historyFileSize} + ${exportIfNonEmpty "HISTCONTROL" histControlStr} + ${exportIfNonEmpty "HISTIGNORE" histIgnoreStr} + + ${shoptsStr} + + ${aliasesStr} + + ${cfg.initExtra} + + ${optionalString cfg.enableAutojump + ". ${pkgs.autojump}/share/autojump/autojump.bash"} + fi + ''; + home.file.".bash_profile".text = '' # -*- mode: sh -*- @@ -160,22 +190,7 @@ in home.file.".bashrc".text = '' # -*- mode: sh -*- - # Skip if not running interactively. - [ -z "$PS1" ] && return - - ${export "HISTSIZE" cfg.historySize} - ${export "HISTFILESIZE" cfg.historyFileSize} - ${exportIfNonEmpty "HISTCONTROL" histControlStr} - ${exportIfNonEmpty "HISTIGNORE" histIgnoreStr} - - ${shoptsStr} - - ${aliasesStr} - - ${cfg.initExtra} - - ${optionalString cfg.enableAutojump - ". ${pkgs.autojump}/share/autojump/autojump.bash"} + ${cfg.bashrcExtra} ''; home.packages = -- cgit v1.2.3 From 8ab6298f305922f2e9871141ce0674144ab5b32e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Jan 2018 16:54:29 +0100 Subject: bash: do not export HIST* variables These are interpreted by the shell itself and it does not make sense to export them to sub-processes. --- modules/programs/bash.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 3d4496f764a..90ab5dd75d9 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -132,8 +132,7 @@ in ); export = n: v: "export ${n}=\"${toString v}\""; - exportIfNonNull = n: v: optionalString (v != null) (export n v); - exportIfNonEmpty = n: v: optionalString (v != "") (export n v); + setIfNonEmpty = n: v: optionalString (v != "") "${n}=${toString v}"; histControlStr = concatStringsSep ":" cfg.historyControl; histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; @@ -153,10 +152,10 @@ in programs.bash.bashrcExtra = '' # Commands that should be applied only for interactive shells. if [[ -n $PS1 ]]; then - ${export "HISTSIZE" cfg.historySize} - ${export "HISTFILESIZE" cfg.historyFileSize} - ${exportIfNonEmpty "HISTCONTROL" histControlStr} - ${exportIfNonEmpty "HISTIGNORE" histIgnoreStr} + HISTSIZE=${toString cfg.historySize} + HISTFILESIZE=${toString cfg.historyFileSize} + ${setIfNonEmpty "HISTCONTROL" histControlStr} + ${setIfNonEmpty "HISTIGNORE" histIgnoreStr} ${shoptsStr} -- cgit v1.2.3 From 33af9948e51d769f95298aa3f7a64598b6d9ffd5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 11:59:58 +0100 Subject: home-environment: describe session variable trickyness --- modules/home-environment.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index f2936415976..61ca0649ef7 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -127,6 +127,25 @@ in example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; description = '' Environment variables to always set at login. + + Note, these variables may be set in any order so no session + variable may have a runtime dependency on another session + variable. In particular code like + + home.sessionVariables = { + FOO = "Hello"; + BAR = "$FOO World!"; + }; + + may not work as expected. If you need to reference another + session variable, then do so inside Nix instead. The above + example then becomes + + home.sessionVariables = { + FOO = "Hello"; + BAR = "''${config.home.sessionVariables.FOO} World!"; + }; + ''; }; -- cgit v1.2.3 From df6590abfc650d23532ef097892f61ba6d203c5f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 12:19:34 +0100 Subject: home-environment: describe session variable values a bit --- modules/home-environment.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 61ca0649ef7..77850a8e364 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -128,6 +128,15 @@ in description = '' Environment variables to always set at login. + The values may refer to other environment variables using + POSIX.2 style variable references. For example, a variable + parameter may be referenced as + $parameter or ''${parameter}. A + default value foo may be given as per + ''${parameter:-foo} and, similarly, an alternate + value bar can be given as per + ''${parameter:+bar}. + Note, these variables may be set in any order so no session variable may have a runtime dependency on another session variable. In particular code like -- cgit v1.2.3 From 58a629b02e46b76ef55c0fd7e4fa998cb87cad91 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 12:21:06 +0100 Subject: lib/shell: add library of convenience functions This library holds a few convenience functions for generating shell code. --- modules/lib/default.nix | 2 ++ modules/lib/shell.nix | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 modules/lib/shell.nix diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 5c273f15da7..8291be0b2ee 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -15,4 +15,6 @@ entryAfter = d.dagEntryAfter; entryBefore = d.dagEntryBefore; }; + + shell = import ./shell.nix { inherit lib; }; } diff --git a/modules/lib/shell.nix b/modules/lib/shell.nix new file mode 100644 index 00000000000..f1443c5466a --- /dev/null +++ b/modules/lib/shell.nix @@ -0,0 +1,11 @@ +{ lib }: + +rec { + # Produces a Bourne shell like variable export statement. + export = n: v: "export ${n}=\"${toString v}\""; + + # Given an attribute set containing shell variable names and their + # assignment, this function produces a string containing an export + # statement for each set entry. + exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars); +} -- cgit v1.2.3 From 026375da49002d4439554d04ac7f74a375e70ef5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 12:22:17 +0100 Subject: bash: use shell library --- modules/programs/bash.nix | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 90ab5dd75d9..fa32a4be731 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -131,12 +131,6 @@ in map (v: "shopt -s ${v}") cfg.shellOptions ); - export = n: v: "export ${n}=\"${toString v}\""; - setIfNonEmpty = n: v: optionalString (v != "") "${n}=${toString v}"; - - histControlStr = concatStringsSep ":" cfg.historyControl; - histIgnoreStr = concatStringsSep ":" cfg.historyIgnore; - # If Bash is the session variable setter then this is the # attribute set of global session variables, otherwise it is an # empty set. @@ -145,17 +139,27 @@ in (config.home.sessionVariableSetter == "bash") config.home.sessionVariables; - envVarsStr = concatStringsSep "\n" ( - mapAttrsToList export (cfg.sessionVariables // globalEnvVars) - ); + envVarsStr = + config.lib.shell.exportAll (cfg.sessionVariables // globalEnvVars); + + historyControlStr = + concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") ( + { + HISTSIZE = toString cfg.historySize; + HISTFILESIZE = toString cfg.historyFileSize; + } + // optionalAttrs (cfg.historyControl != []) { + HISTCONTROL = concatStringsSep ":" cfg.historyControl; + } + // optionalAttrs (cfg.historyIgnore != []) { + HISTIGNORE = concatStringsSep ":" cfg.historyIgnore; + } + )); in mkIf cfg.enable { programs.bash.bashrcExtra = '' # Commands that should be applied only for interactive shells. if [[ -n $PS1 ]]; then - HISTSIZE=${toString cfg.historySize} - HISTFILESIZE=${toString cfg.historyFileSize} - ${setIfNonEmpty "HISTCONTROL" histControlStr} - ${setIfNonEmpty "HISTIGNORE" histIgnoreStr} + ${historyControlStr} ${shoptsStr} -- cgit v1.2.3 From 2fc1b9b5e00e31e23b015b2204840109f4e7fe55 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 12:22:35 +0100 Subject: zsh: use shell library --- modules/programs/zsh.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index a088b332a0f..39203612bed 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -11,17 +11,11 @@ let pluginsDir = if cfg.dotDir != null then relToDotDir "plugins" else ".zsh/plugins"; - export = n: v: "export ${n}=\"${toString v}\""; - - toEnvVarsStr = vars: concatStringsSep "\n" ( - mapAttrsToList export vars - ); - envVars = cfg.sessionVariables // ( if config.home.sessionVariableSetter == "zsh" then config.home.sessionVariables else {} ); - envVarsStr = toEnvVarsStr envVars; + envVarsStr = config.lib.shell.exportAll envVars; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases -- cgit v1.2.3 From e624b9aa6a7caf99eaacfd4ffd9c3ef839c68a66 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 13:15:22 +0100 Subject: home-environment: install `hm-session-vars.sh` file This is a file containing all session variables exported using a Bourne-compatible syntax. --- modules/home-environment.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 77850a8e364..66fe430bccd 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -267,6 +267,23 @@ in // (maybeSet "LC_TIME" cfg.language.time); + home.packages = [ + # Provide a file holding all session variables. + ( + pkgs.writeTextFile { + name = "hm-session-vars.sh"; + destination = "/etc/profile.d/hm-session-vars.sh"; + text = '' + # Only source this once. + if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi + export __HM_SESS_VARS_SOURCED=1 + + ${config.lib.shell.exportAll cfg.sessionVariables} + ''; + } + ) + ]; + # A dummy entry acting as a boundary between the activation # script's "check" and the "write" phases. home.activation.writeBoundary = dag.entryAnywhere ""; -- cgit v1.2.3 From 4f9158e533ddd4e84f36e9846dd29afa5677b138 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 13:27:29 +0100 Subject: readme: add note about session variables file If a user does not want to manage their shell configuration through Home Manager then they have to manually make sure that the session variables are set. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index f83af33662f..7c7d4b12386 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,24 @@ Currently the easiest way to install Home Manager is as follows: Home Manager should now be active and available in your user environment. +5. If you do not plan on having Home Manager manage your shell + configuration then you must source the + + ``` + "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ``` + + file in your shell configuration. Unfortunately, we currently only + support POSIX.2-like shells such as [Bash][] or [Z shell][]. + + For example, if you use Bash then add + + ```bash + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ``` + + to your `~/.profile` file. + Note, because the `HM_PATH` variable above points to the live Home Manager repository you will automatically get updates whenever you build a new generation. If you dislike automatic updates then perform @@ -240,8 +258,10 @@ in your system configuration and in your Home Manager configuration. +[Bash]: https://www.gnu.org/software/bash/ [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/ -- cgit v1.2.3 From a3250dfac70af2784d5cb2a70f76a5d81a4244ab Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 13:28:55 +0100 Subject: xsession: source session variables script --- modules/xsession.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/xsession.nix b/modules/xsession.nix index 9f06e76beb2..40e52202973 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -82,6 +82,9 @@ in }; home.file.".xprofile".text = '' + ${optionalString (config.home.sessionVariableSetter != "pam") + ''. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"''} + if [[ -e "$HOME/.profile" ]]; then . "$HOME/.profile" fi -- cgit v1.2.3 From 803abb58f9fbebf05a8cf62f960a32fb1b101011 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 13:29:45 +0100 Subject: bash: source session variables script This replaces the explicit set within the Bash profile file. --- modules/programs/bash.nix | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index fa32a4be731..b5ac9417bac 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -131,16 +131,7 @@ in map (v: "shopt -s ${v}") cfg.shellOptions ); - # If Bash is the session variable setter then this is the - # attribute set of global session variables, otherwise it is an - # empty set. - globalEnvVars = - optionalAttrs - (config.home.sessionVariableSetter == "bash") - config.home.sessionVariables; - - envVarsStr = - config.lib.shell.exportAll (cfg.sessionVariables // globalEnvVars); + sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables; historyControlStr = concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") ( @@ -185,7 +176,11 @@ in home.file.".profile".text = '' # -*- mode: sh -*- - ${envVarsStr} + ${optionalString (config.home.sessionVariableSetter != "pam") '' + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ''} + + ${sessionVarsStr} ${cfg.profileExtra} ''; -- cgit v1.2.3 From 7631921366c8be1f6d87b57d03279f0bfae30b6d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 13:32:49 +0100 Subject: zsh: source session variables script This replaces the explicit set within the Z shell `zshenv` file. --- modules/programs/zsh.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 39203612bed..4c97a921d2d 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -11,11 +11,7 @@ let pluginsDir = if cfg.dotDir != null then relToDotDir "plugins" else ".zsh/plugins"; - envVars = cfg.sessionVariables // ( - if config.home.sessionVariableSetter == "zsh" then config.home.sessionVariables else {} - ); - - envVarsStr = config.lib.shell.exportAll envVars; + envVarsStr = config.lib.shell.exportAll cfg.sessionVariables; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases @@ -249,6 +245,9 @@ in home.file."${relToDotDir ".zshenv"}".text = '' typeset -U fpath + ${optionalString (config.home.sessionVariableSetter != "pam") '' + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ''} ${envVarsStr} ''; -- cgit v1.2.3 From d7755de116850c4864613029abd15931471b66ea Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 16:11:23 +0100 Subject: pam: add option `pam.sessionVariables` --- modules/misc/pam.nix | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index 3bd0f292561..dfeaf2f339e 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -6,17 +6,35 @@ let homeCfg = config.home; + vars = + optionalAttrs (homeCfg.sessionVariableSetter == "pam") homeCfg.sessionVariables + // config.pam.sessionVariables; + in { meta.maintainers = [ maintainers.rycee ]; - options = {}; + options = { + pam.sessionVariables = mkOption { + default = {}; + type = types.attrs; + example = { EDITOR = "vim"; }; + description = '' + Environment variables that will be set for the PAM session. + The variable values must be as described in + + pam_env.conf + 5 + . + ''; + }; + }; - config = mkIf (homeCfg.sessionVariableSetter == "pam") { + config = mkIf (vars != {}) { home.file.".pam_environment".text = concatStringsSep "\n" ( - mapAttrsToList (n: v: "${n} OVERRIDE=${v}") homeCfg.sessionVariables + mapAttrsToList (n: v: "${n} OVERRIDE=${toString v}") vars ) + "\n"; }; } -- cgit v1.2.3 From 18159c85b9733161ead2b8fcbfbc9fefbef9f3c7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 4 Jan 2018 16:12:06 +0100 Subject: home-environment: deprecate option `home.sessionVariableSetter` --- modules/home-environment.nix | 7 ++++-- modules/misc/news.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 66fe430bccd..197e9dc57f3 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -159,8 +159,8 @@ in }; home.sessionVariableSetter = mkOption { - default = "bash"; - type = types.enum [ "pam" "bash" "zsh" ]; + default = null; + type = types.nullOr (types.enum [ "pam" "bash" "zsh" ]); example = "pam"; description = '' Identifies the module that should set the session variables. @@ -171,6 +171,9 @@ in If "pam" is set then PAM must be used to set the system environment. Also mind that typical environment variables might not be set by the time PAM starts up. + + This option is DEPRECATED, the shell modules are now + automatically setting the session variables when enabled. ''; }; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 8ca9b7aae11..5c11803ed03 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -478,6 +478,60 @@ in necessary. ''; } + + { + time = "2018-01-08T20:39:56+00:00"; + condition = config.home.sessionVariableSetter != null; + message = + let + opts = { + bash = '' + Instead the 'programs.bash' module will, when enabled, + automatically set session variables. You can safely + remove the 'home.sessionVariableSetter' option from your + configuration. + ''; + + zsh = '' + Instead the 'programs.zsh' module will, when enabled, + automatically set session variables. You can safely + remove the 'home.sessionVariableSetter' option from your + configuration. + ''; + + pam = '' + Unfortunately setting general session variables using + PAM will not be directly supported after this date. The + primary reason for this change is its limited support + for variable expansion. + + To continue setting session variables from the Home + Manager configuration you must either use the + 'programs.bash' or 'programs.zsh' modules or manually + source the session variable file + + $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh + + within your shell configuration, see the README file for + more information. This file requires a Bourne-like shell + such as Bash or Z shell but hopefully other shells + will be supported in the future. + + If you specifically need to set a session variable using + PAM then the new option 'pam.sessionVariables' can be + used. It works much the same as 'home.sessionVariables' + but its attribute values must be valid within the PAM + environment file. + ''; + }; + in + '' + The 'home.sessionVariableSetter' option is now deprecated + and will be removed on February 8, 2018. + + ${opts.${config.home.sessionVariableSetter}} + ''; + } ]; }; } -- cgit v1.2.3 From d7715f71adda77c28575ccd9c491abe8f407b31e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 9 Jan 2018 22:03:13 +0100 Subject: eclipse: add option `enableLombok` --- modules/programs/eclipse.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/programs/eclipse.nix b/modules/programs/eclipse.nix index 092db23f4ed..4a432c9fe1a 100644 --- a/modules/programs/eclipse.nix +++ b/modules/programs/eclipse.nix @@ -15,6 +15,16 @@ in programs.eclipse = { enable = mkEnableOption "Eclipse"; + enableLombok = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether to enable the Lombok Java Agent in Eclipse. This is + necessary to use the Lombok class annotations. + ''; + }; + jvmArgs = mkOption { type = types.listOf types.str; default = []; @@ -33,7 +43,10 @@ in home.packages = [ (pkgs.eclipses.eclipseWithPlugins { eclipse = pkgs.eclipses.eclipse-platform; - jvmArgs = cfg.jvmArgs; + jvmArgs = + cfg.jvmArgs + ++ optional cfg.enableLombok + "-javaagent:${pkgs.lombok}/share/java/lombok.jar"; plugins = cfg.plugins; }) ]; -- cgit v1.2.3 From c9294e30d9d8b8167a7064f74a79c051dd9dabf3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 6 Jan 2018 01:10:20 -0800 Subject: bash: add option `historyFile` --- modules/programs/bash.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index b5ac9417bac..115fa7abab4 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -21,6 +21,12 @@ in description = "Number of history lines to keep in memory."; }; + historyFile = mkOption { + type = types.str; + default = "$HOME/.bash_history"; + description = "Location of the bash history file."; + }; + historyFileSize = mkOption { type = types.int; default = 100000; @@ -136,8 +142,9 @@ in historyControlStr = concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") ( { - HISTSIZE = toString cfg.historySize; + HISTFILE = "\"${cfg.historyFile}\""; HISTFILESIZE = toString cfg.historyFileSize; + HISTSIZE = toString cfg.historySize; } // optionalAttrs (cfg.historyControl != []) { HISTCONTROL = concatStringsSep ":" cfg.historyControl; -- cgit v1.2.3 From d6ab6ee3704430db109fa65688e85cde966066b1 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 10 Jan 2018 15:40:07 +0000 Subject: ssh: add extraConfig option for non-standard options --- modules/programs/ssh.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index b2017818c76..609251531a4 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -95,6 +95,12 @@ let default = null; description = "The command to use to connect to the server."; }; + + extraOptions = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Extra configuration options for the host."; + }; }; config.host = mkDefault name; @@ -113,6 +119,7 @@ let " ServerAliveInterval ${toString cf.serverAliveInterval}" ++ optional (!cf.checkHostIP) " CheckHostIP no" ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" + ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); in @@ -157,6 +164,14 @@ in ''; }; + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration. + ''; + }; + matchBlocks = mkOption { type = types.loaOf matchBlockModule; default = []; @@ -190,6 +205,8 @@ in ControlPath ${cfg.controlPath} ControlPersist ${cfg.controlPersist} + ${cfg.extraConfig} + ${concatStringsSep "\n\n" ( map matchBlockStr ( builtins.attrValues cfg.matchBlocks))} -- cgit v1.2.3 From dbcb3dd1aecf318689118a4a95fd1f43d76e2282 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 12 Jan 2018 11:24:08 +0100 Subject: zsh: fix HISTSIZE and HISTFILE configuration HISTSIZE and HISTFILE should be set in ~/.zshrc and before sourcing oh-my-zsh since otherwise it will be overridden. Fixes #177. --- modules/programs/zsh.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 4c97a921d2d..954ecb6bc90 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -238,11 +238,6 @@ in ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; - programs.zsh.sessionVariables = { - HISTSIZE = cfg.history.size; - HISTFILE = "$HOME/" + cfg.history.path; - }; - home.file."${relToDotDir ".zshenv"}".text = '' typeset -U fpath ${optionalString (config.home.sessionVariableSetter != "pam") '' @@ -289,6 +284,11 @@ in source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" '') cfg.plugins)} + # HISTSIZE, HISTFILE have to be set in .zshrc and after oh-my-zsh sourcing + # see https://github.com/rycee/home-manager/issues/177 + HISTSIZE="${toString cfg.history.size}" + HISTFILE="$HOME/${cfg.history.path}" + ${cfg.initExtra} ${aliasesStr} -- cgit v1.2.3 From a93445f3fe5c3a2b0c4bb228519a7d3f03132d2a Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 12 Jan 2018 17:23:58 +0100 Subject: zsh: add history.save option --- modules/programs/zsh.nix | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 954ecb6bc90..9dcbece3f71 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -19,7 +19,7 @@ let zdotdir = "$HOME/" + cfg.dotDir; - historyModule = types.submodule { + historyModule = types.submodule ({ config, ... }: { options = { size = mkOption { type = types.int; @@ -27,6 +27,13 @@ let description = "Number of history lines to keep."; }; + save = mkOption { + type = types.int; + defaultText = 10000; + default = config.size; + description = "Number of history lines to save."; + }; + path = mkOption { type = types.str; default = relToDotDir ".zsh_history"; @@ -49,7 +56,7 @@ let description = "Share command history between zsh sessions."; }; }; - }; + }); pluginModule = types.submodule ({ config, ... }: { options = { @@ -247,10 +254,6 @@ in ''; home.file."${relToDotDir ".zshrc"}".text = '' - setopt HIST_FCNTL_LOCK - ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS - ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY - fpath+="$HOME/.nix-profile/share/zsh/site-functions" fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" @@ -284,10 +287,15 @@ in source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" '') cfg.plugins)} - # HISTSIZE, HISTFILE have to be set in .zshrc and after oh-my-zsh sourcing - # see https://github.com/rycee/home-manager/issues/177 + # History options should be set in .zshrc and after oh-my-zsh sourcing. + # See https://github.com/rycee/home-manager/issues/177. HISTSIZE="${toString cfg.history.size}" HISTFILE="$HOME/${cfg.history.path}" + SAVEHIST="${toString cfg.history.save}" + + setopt HIST_FCNTL_LOCK + ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS + ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY ${cfg.initExtra} -- cgit v1.2.3 From b8b595c6b27b94c178357f83f8309c4ba5986553 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 5 Jan 2018 16:41:44 -0800 Subject: ssh: add a few more options --- modules/programs/ssh.nix | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 609251531a4..9bce30094e5 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -81,6 +81,12 @@ let "Set timeout in seconds after which response will be requested."; }; + compression = mkOption { + type = types.bool; + default = false; + description = "Specifies whether to use compression."; + }; + checkHostIP = mkOption { type = types.bool; default = true; @@ -117,6 +123,7 @@ let ++ optional (cf.hostname != null) " HostName ${cf.hostname}" ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" + ++ optional cf.compression " Compression yes" ++ optional (!cf.checkHostIP) " CheckHostIP no" ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions @@ -139,6 +146,44 @@ in ''; }; + compression = mkOption { + default = false; + type = types.bool; + description = "Specifies whether to use compression."; + }; + + serverAliveInterval = mkOption { + type = types.int; + default = 0; + description = '' + Set default timeout in seconds after which response will be requested. + ''; + }; + + hashKnownHosts = mkOption { + default = false; + type = types.bool; + description = '' + Indicates that + + ssh + 1 + + should hash host names and addresses when they are added to + the known hosts file. + ''; + }; + + userKnownHostsFile = mkOption { + type = types.str; + default = "~/.ssh/known_hosts"; + description = '' + Specifies one or more files to use for the user host key + database, separated by whitespace. The default is + ~/.ssh/known_hosts. + ''; + }; + controlMaster = mkOption { default = "no"; type = types.enum ["yes" "no" "ask" "auto" "autoask"]; @@ -201,6 +246,10 @@ in config = mkIf cfg.enable { home.file.".ssh/config".text = '' ForwardAgent ${yn cfg.forwardAgent} + Compression ${yn cfg.compression} + ServerAliveInterval ${toString cfg.serverAliveInterval} + HashKnownHosts ${yn cfg.hashKnownHosts} + UserKnownHostsFile ${cfg.userKnownHostsFile} ControlMaster ${cfg.controlMaster} ControlPath ${cfg.controlPath} ControlPersist ${cfg.controlPersist} -- cgit v1.2.3 From 576217d33a85a067b903495a295fd7687e90a37c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Jan 2018 15:55:51 +0100 Subject: gpg-agent: use `gpgconf` to set SSH socket path Inspired by #163. --- modules/services/gpg-agent.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index b2122219a2f..dfd4b89cdd8 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -89,7 +89,10 @@ in home.sessionVariables = optionalAttrs cfg.enableSshSupport { - SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"; + SSH_AUTH_SOCK = + if config.home.sessionVariableSetter == "pam" + then "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh" + else "$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)"; }; programs.bash.initExtra = gpgInitStr; -- cgit v1.2.3 From 32b3f7f2d255beae5d1cbefa195a1427592136c5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Jan 2018 22:06:32 +0100 Subject: ssh: allow disabling compression in host block Fixes #181. --- modules/programs/ssh.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 9bce30094e5..4c68ebf8b34 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -82,9 +82,12 @@ let }; compression = mkOption { - type = types.bool; - default = false; - description = "Specifies whether to use compression."; + type = types.nullOr types.bool; + default = null; + description = '' + Specifies whether to use compression. Omitted from the host + block when null. + ''; }; checkHostIP = mkOption { @@ -123,7 +126,7 @@ let ++ optional (cf.hostname != null) " HostName ${cf.hostname}" ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" - ++ optional cf.compression " Compression yes" + ++ optional (cf.compression != null) " Compression ${yn cf.compression}" ++ optional (!cf.checkHostIP) " CheckHostIP no" ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions -- cgit v1.2.3 From 071f7aea8238aa6c64759c58b195bb0d4f3ce9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9-Patrick=20Bubel?= Date: Sat, 20 Jan 2018 11:26:32 +0100 Subject: qsyncthingtray: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/services/qsyncthingtray.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 modules/services/qsyncthingtray.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 5c11803ed03..31ebe55262a 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -532,6 +532,13 @@ in ${opts.${config.home.sessionVariableSetter}} ''; } + + { + time = "2018-01-20T10:36:12+00:00"; + message = '' + A new module is available: 'services.qsyncthingtray' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 7fd76147b71..529350143f2 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,6 +53,7 @@ let ./services/owncloud-client.nix ./services/parcellite.nix ./services/polybar.nix + ./services/qsyncthingtray.nix ./services/random-background.nix ./services/redshift.nix ./services/screen-locker.nix diff --git a/modules/services/qsyncthingtray.nix b/modules/services/qsyncthingtray.nix new file mode 100644 index 00000000000..fb9dc287389 --- /dev/null +++ b/modules/services/qsyncthingtray.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.qsyncthingtray = { + enable = mkEnableOption "QSyncthingTray"; + }; + }; + + config = mkIf config.services.qsyncthingtray.enable { + systemd.user.services.qsyncthingtray = { + Unit = { + Description = "QSyncthingTray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; + }; + }; + }; +} -- cgit v1.2.3 From 1b0a5eb54a9b41ca52e26c5d23197ade7cdb63b3 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sun, 21 Jan 2018 21:01:26 +0100 Subject: polybar: fix the case when config value is a path Polybar treats 'include-file' property differently. In particular, its value can't be enclosed in double quotes. Fixes #185. --- modules/services/polybar.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index b218c6c6133..52ea7b4ec72 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -13,7 +13,7 @@ let let value' = if isBool value then (if value then "true" else "false") - else if isString value then "\"${value}\"" + else if (isString value && key != "include-file") then ''"${value}"'' else toString value; in "${key}=${value'}"; -- cgit v1.2.3 From 38020d9068695272e2541ff4fd46c9c85f7ea91e Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 10 Jan 2018 20:31:28 +0000 Subject: redshift: add option to start redshift tray applet --- modules/services/redshift.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index 9bf66f8946f..423b9fe1b40 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -87,6 +87,15 @@ in ''; }; + tray = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Start the redshift-gtk tray applet. + ''; + }; + extraOptions = mkOption { type = types.listOf types.str; default = []; @@ -118,8 +127,9 @@ in "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" ] ++ cfg.extraOptions; + command = if cfg.tray then "redshift-gtk" else "redshift"; in - "${cfg.package}/bin/redshift ${concatStringsSep " " args}"; + "${cfg.package}/bin/${command} ${concatStringsSep " " args}"; RestartSec = 3; Restart = "always"; }; -- cgit v1.2.3 From 21fefbc8f6f1c0c496414df8ad9c4e578ed4d8e4 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 22 Jan 2018 00:46:33 -0500 Subject: home-manager: check whether a command is passed "set -u" treats unset variables as an error, and $1 is unbound when no command is passed. --- home-manager/home-manager | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 9d10e61e10e..460cf8d392d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -337,6 +337,11 @@ done # Get rid of the options. shift "$((OPTIND-1))" +if [[ $# -eq 0 ]]; then + doHelp >&2 + exit 1 +fi + cmd="$1" shift 1 -- cgit v1.2.3 From a597c66afe50dc54c4ea426497fe99e3c1d45ee5 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sun, 21 Jan 2018 21:24:48 +0100 Subject: syncthing: merge qsyncthingtray into the module --- modules/misc/news.nix | 10 ++++-- modules/modules.nix | 1 - modules/services/qsyncthingtray.nix | 29 ---------------- modules/services/syncthing.nix | 67 ++++++++++++++++++++++++++++--------- 4 files changed, 58 insertions(+), 49 deletions(-) delete mode 100644 modules/services/qsyncthingtray.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 31ebe55262a..202ab915e30 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; @@ -534,9 +534,13 @@ in } { - time = "2018-01-20T10:36:12+00:00"; + time = "2018-01-25T11:35:08+00:00"; + condition = options.services.qsyncthingtray.enable.isDefined; message = '' - A new module is available: 'services.qsyncthingtray' + 'services.qsyncthingtray' has been merged into 'services.syncthing'. + Please, use 'services.syncthing.tray' option to activate the tray service. + + The old module will be removed on February 25, 2018. ''; } ]; diff --git a/modules/modules.nix b/modules/modules.nix index 529350143f2..7fd76147b71 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,7 +53,6 @@ let ./services/owncloud-client.nix ./services/parcellite.nix ./services/polybar.nix - ./services/qsyncthingtray.nix ./services/random-background.nix ./services/redshift.nix ./services/screen-locker.nix diff --git a/modules/services/qsyncthingtray.nix b/modules/services/qsyncthingtray.nix deleted file mode 100644 index fb9dc287389..00000000000 --- a/modules/services/qsyncthingtray.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - options = { - services.qsyncthingtray = { - enable = mkEnableOption "QSyncthingTray"; - }; - }; - - config = mkIf config.services.qsyncthingtray.enable { - systemd.user.services.qsyncthingtray = { - Unit = { - Description = "QSyncthingTray"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; - }; - }; - }; -} diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index f722208d1a3..5b34d9aa5e1 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -3,32 +3,67 @@ with lib; { + imports = [ + (mkRenamedOptionModule + [ "services" "qsyncthingtray" "enable" ] + [ "services" "syncthing" "tray" ]) + ]; + meta.maintainers = [ maintainers.rycee ]; options = { services.syncthing = { enable = mkEnableOption "Syncthing continuous file synchronization"; + + tray = mkOption { + type = types.bool; + default = false; + description = "Whether to enable QSyncthingTray service."; + }; }; }; - config = mkIf config.services.syncthing.enable { - systemd.user.services.syncthing = { - Unit = { - Description = "Syncthing - Open Source Continuous File Synchronization"; - Documentation = "man:syncthing(1)"; - After = [ "network.target" ]; - }; + config = mkIf config.services.syncthing.enable (mkMerge [ + { + systemd.user.services = { + syncthing = { + Unit = { + Description = "Syncthing - Open Source Continuous File Synchronization"; + Documentation = "man:syncthing(1)"; + After = [ "network.target" ]; + }; - Service = { - ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; - Restart = "on-failure"; - SuccessExitStatus = [ 3 4 ]; - RestartForceExitStatus = [ 3 4 ]; + Service = { + ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; + Restart = "on-failure"; + SuccessExitStatus = [ 3 4 ]; + RestartForceExitStatus = [ 3 4 ]; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; }; + } + (mkIf config.services.syncthing.tray { + systemd.user.services = { + qsyncthingtray = { + Unit = { + Description = "QSyncthingTray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; + }; - Install = { - WantedBy = [ "default.target" ]; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; }; - }; - }; + }) + ]); } -- cgit v1.2.3 From 9d3d7426aad3b826c330170ec64a7959e56547ca Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 26 Jan 2018 19:39:28 +0100 Subject: license: bump year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 216b3e3e076..cce91e4e0ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Robert Helgesson +Copyright (c) 2017-2018 Robert Helgesson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal -- cgit v1.2.3 From a9dc7fa7cc87842372c6df9d1eff5e8369204523 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Jan 2018 09:39:45 +0100 Subject: home-manager: improve the generation timestamp format --- home-manager/home-manager | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 460cf8d392d..f56ba1cdc28 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -157,9 +157,9 @@ function doSwitch() { function doListGens() { pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null - ls --color=yes -gG --sort time home-manager-*-link \ + ls --color=yes -gG --time-style=long-iso --sort time home-manager-*-link \ | cut -d' ' -f 4- \ - | sed -E 's/home-manager-([[:digit:]]*)-link/id \1/' + | sed -E 's/home-manager-([[:digit:]]*)-link/: id \1/' popd > /dev/null } -- cgit v1.2.3 From 5fe8d574ca3e44556d1277a0c50c2dfef714d2b7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Jan 2018 09:43:57 +0100 Subject: home-manager: add shellcheck directives --- home-manager/home-manager | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index f56ba1cdc28..3a4bbee4101 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -8,6 +8,7 @@ PATH=@coreutils@/bin:@less@/bin${PATH:+:}$PATH set -euo pipefail function errorEcho() { + # shellcheck disable=2048,2086 echo $* >&2 } @@ -67,6 +68,7 @@ function doBuildAttr() { extraArgs="$extraArgs --show-trace" fi + # shellcheck disable=2086 nix-build \ "" \ $extraArgs \ @@ -82,6 +84,7 @@ function presentNews() { # shellcheck source=/dev/null . "$infoFile" + # shellcheck disable=2154 if [[ $newsNumUnread -eq 0 ]]; then return elif [[ "$newsDisplay" == "silent" ]]; then @@ -157,6 +160,7 @@ function doSwitch() { function doListGens() { pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null + # shellcheck disable=2012 ls --color=yes -gG --time-style=long-iso --sort time home-manager-*-link \ | cut -d' ' -f 4- \ | sed -E 's/home-manager-([[:digit:]]*)-link/: id \1/' @@ -241,6 +245,7 @@ function doShowNews() { # shellcheck source=/dev/null . "$infoFile" + # shellcheck disable=2154 case $1 in --all) ${PAGER:-less} "$newsFileAll" @@ -253,6 +258,7 @@ function doShowNews() { return 1 esac + # shellcheck disable=2154 if [[ -s "$newsUnreadIdsFile" ]]; then local newsReadIdsFile newsReadIdsFile="$(newsReadIdsFile)" -- cgit v1.2.3 From a154e2ea1a53da4b6edfcd565db315dc5246032b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Jan 2018 10:17:42 +0100 Subject: readme: add basic rollback instructions --- README.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c7d4b12386..3e19c1c9a55 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ distributions and NixOS versions. Also, the `home-manager` tool does not explicitly support rollbacks at the moment so if your home directory gets messed up you'll have to fix -it yourself (you can attempt to run the activation script for the -desired generation). +it yourself. See the [rollbacks](#rollbacks) section for instructions +on how to manually perform a rollback. Now when your expectations have been built up and you are eager to try all this out you can go ahead and read the rest of this text. @@ -186,6 +186,40 @@ examples run $ 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 ----------------------------- -- cgit v1.2.3 From 8b77f1db2c98b1c0209b88b83f8182673db9955e Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 27 Jan 2018 13:03:28 +0100 Subject: syncthing: start tray service after bars The QSyncthingTray service requires running tray providers such as polybar and taffybar. --- modules/services/syncthing.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 5b34d9aa5e1..12c76e32225 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -51,7 +51,7 @@ with lib; qsyncthingtray = { Unit = { Description = "QSyncthingTray"; - After = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" "polybar.service" "taffybar.service" ]; PartOf = [ "graphical-session.target" ]; }; -- cgit v1.2.3 From 81fb420457dc3bddd47a36a810e380b60b2fec53 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Jan 2018 11:11:36 +0100 Subject: home-manager: switch NIX_PATH order This new order allows overriding the home-manager path from the command line using `home-manager -I home-manager=/a/b/c`. --- home-manager/home-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 3a4bbee4101..63af9687b6e 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -48,7 +48,7 @@ function setHomeManagerNixPath() { "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" \ "$HOME/.nixpkgs/home-manager" ; do if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then - export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path" + export NIX_PATH="home-manager=$path${NIX_PATH:+:}$NIX_PATH" return fi done -- cgit v1.2.3 From 9de2549dfbed355fdd7d37d5dc5fe2cbfc8458e6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Jan 2018 11:04:01 +0100 Subject: contributing: explain how to use local clone Fixes #180. --- CONTRIBUTING.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a96a7a8897..156d0c9daf6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,6 +41,27 @@ descriptive name. Perform your changes on this branch and when you are happy with the result push the branch to GitHub and [create a pull request][]. +Assuming your clone is at `$HOME/devel/home-manager` then you can make +the `home-manager` command use it by either + +1. overriding the default path by using the `-I` command line option: + + home-manager -I home-manager=$HOME/devel/home-manager + + or + +2. changing the default path by ensuring your configuration includes + + programs.home-manager.enable = true; + programs.home-manager.path = "$HOME/devel/home-manager"; + + and running `home-manager switch` to activate the change. + Afterwards, `home-manager build` and `home-manager switch` will + use your cloned repository. + +The first option is good if you only temporarily want to use your +clone. + ### Commits ### The commits in your pull request should be reasonably self-contained, -- cgit v1.2.3 From 6fc0fd315cd70ac5fe455bc8ddf909558e8af6dd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 30 Jan 2018 20:15:31 +0100 Subject: syncthing: allow enabling tray independently --- modules/services/syncthing.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 12c76e32225..1906814bcc8 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -23,8 +23,8 @@ with lib; }; }; - config = mkIf config.services.syncthing.enable (mkMerge [ - { + config = mkMerge [ + (mkIf config.services.syncthing.enable { systemd.user.services = { syncthing = { Unit = { @@ -45,7 +45,8 @@ with lib; }; }; }; - } + }) + (mkIf config.services.syncthing.tray { systemd.user.services = { qsyncthingtray = { @@ -65,5 +66,5 @@ with lib; }; }; }) - ]); + ]; } -- cgit v1.2.3 From 616dbd67f7a903d2a57ef4b8d0d9bcc4f567eab3 Mon Sep 17 00:00:00 2001 From: Alistair Potts Date: Thu, 1 Feb 2018 13:33:24 +0000 Subject: mercurial: add module Very simple module for hg based on programs.git, and is intended to have compatible options. For simple setups, a user should be able to write something like: {...}: let vcsconfig = { enable = true; userName = "John Smith"; userEmail = "js@example.com"; ignores = [ "*.swp" "*~" ]; }; in { programs.git = vcsconfig // {...extra git config...}; programs.mercurial = vcsconfig // {...extra hg confg...}; } For this reason, the ignore options are `ignores` for `syntax: glob` and `ignoresRegexp` for `syntax: regexp` so that simple glob ignores can (very likely) be shared with a git config, despite regular expressions being the default for mercurial. --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/mercurial.nix | 102 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 modules/programs/mercurial.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 202ab915e30..1dab10ae4f8 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -543,6 +543,13 @@ in The old module will be removed on February 25, 2018. ''; } + + { + time = "2018-02-02T11:15:00+00:00"; + message = '' + A new program configuration is available: 'programs.mercurial' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 7fd76147b71..8c000d2f69c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -34,6 +34,7 @@ let ./programs/info.nix ./programs/lesspipe.nix ./programs/man.nix + ./programs/mercurial.nix ./programs/neovim.nix ./programs/rofi.nix ./programs/ssh.nix diff --git a/modules/programs/mercurial.nix b/modules/programs/mercurial.nix new file mode 100644 index 00000000000..5daee39f153 --- /dev/null +++ b/modules/programs/mercurial.nix @@ -0,0 +1,102 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.mercurial; + +in + +{ + + options = { + programs.mercurial = { + enable = mkEnableOption "Mercurial"; + + package = mkOption { + type = types.package; + default = pkgs.mercurial; + defaultText = "pkgs.mercurial"; + description = "Mercurial package to install."; + }; + + userName = mkOption { + type = types.str; + description = "Default user name to use."; + }; + + userEmail = mkOption { + type = types.str; + description = "Default user email to use."; + }; + + aliases = mkOption { + type = types.attrs; + default = {}; + description = "Mercurial aliases to define."; + }; + + extraConfig = mkOption { + type = types.either types.attrs types.lines; + default = {}; + description = "Additional configuration to add."; + }; + + iniContent = mkOption { + type = types.attrsOf types.attrs; + internal = true; + }; + + ignores = mkOption { + type = types.listOf types.str; + default = []; + example = [ "*~" "*.swp" ]; + description = "List of globs for files to be globally ignored."; + }; + + ignoresRegexp = mkOption { + type = types.listOf types.str; + default = []; + example = [ "^.*~$" "^.*\\.swp$" ]; + description = + "List of regular expressions for files to be globally ignored."; + }; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + { + home.packages = [ cfg.package ]; + + programs.mercurial.iniContent.ui = { + username = cfg.userName + " <" + cfg.userEmail + ">"; + }; + + xdg.configFile."hg/hgrc".text = generators.toINI {} cfg.iniContent; + } + + (mkIf (cfg.ignores != [] || cfg.ignoresRegexp != []) { + programs.mercurial.iniContent.ui.ignore = + "${config.xdg.configHome}/hg/hgignore_global"; + + xdg.configFile."hg/hgignore_global".text = + "syntax: glob\n" + concatStringsSep "\n" cfg.ignores + "\n" + + "syntax: regexp\n" + concatStringsSep "\n" cfg.ignoresRegexp + "\n"; + }) + + (mkIf (cfg.aliases != {}) { + programs.mercurial.iniContent.alias = cfg.aliases; + }) + + (mkIf (lib.isAttrs cfg.extraConfig) { + programs.mercurial.iniContent = cfg.extraConfig; + }) + + (mkIf (lib.isString cfg.extraConfig) { + xdg.configFile."hg/hgrc".text = cfg.extraConfig; + }) + ] + ); +} -- cgit v1.2.3 From 91a98f919db2fab3e5c9d47d3955e3896f320f3a Mon Sep 17 00:00:00 2001 From: Alistair Potts Date: Fri, 2 Feb 2018 15:25:51 +0000 Subject: stalonetray: add module Adds a service for the Stalonetray system tray. Configured through a 'config' attribute set, which writes space separated key value pairs on successive lines to `~/.stalonetrayrc`. --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/services/stalonetray.nix | 94 ++++++++++++++++++++++++++++++++++++++++ modules/services/syncthing.nix | 5 ++- 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 modules/services/stalonetray.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1dab10ae4f8..0cb5758ec82 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -550,6 +550,13 @@ in A new program configuration is available: 'programs.mercurial' ''; } + + { + time = "2018-02-03T10:00:00+00:00"; + message = '' + A new module is available: 'services.stalonetray' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 8c000d2f69c..aa04f3271da 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -57,6 +57,7 @@ let ./services/random-background.nix ./services/redshift.nix ./services/screen-locker.nix + ./services/stalonetray.nix ./services/syncthing.nix ./services/taffybar.nix ./services/tahoe-lafs.nix diff --git a/modules/services/stalonetray.nix b/modules/services/stalonetray.nix new file mode 100644 index 00000000000..7b16f7544f7 --- /dev/null +++ b/modules/services/stalonetray.nix @@ -0,0 +1,94 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.stalonetray; + +in + +{ + options = { + services.stalonetray = { + enable = mkEnableOption "Stalonetray system tray"; + + package = mkOption { + default = pkgs.stalonetray; + defaultText = "pkgs.stalonetray"; + type = types.package; + example = literalExample "pkgs.stalonetray"; + description = "The package to use for the Stalonetray binary."; + }; + + config = mkOption { + type = with types; + attrsOf (nullOr (either str (either bool int))); + description = '' + Stalonetray configuration as a set of attributes. + ''; + default = {}; + example = { + geometry = "3x1-600+0"; + decorations = null; + icon_size = 30; + sticky = true; + background = "#cccccc"; + }; + }; + + extraConfig = mkOption { + type = types.lines; + description = "Additional configuration lines for stalonetrayrc."; + default = ""; + example = '' + geometry 3x1-600+0 + decorations none + icon_size 30 + sticky true + background "#cccccc" + ''; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { + home.packages = [ cfg.package ]; + + systemd.user.services.stalonetray = { + Unit = { + Description = "Stalonetray system tray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/stalonetray"; + Restart = "on-failure"; + }; + }; + } + + (mkIf (cfg.config != {}) { + home.file.".stalonetrayrc".text = + let + valueToString = v: + if isBool v then (if v then "true" else "false") + else if (v==null) then "none" + else ''"${toString v}"''; + in + concatStrings ( + mapAttrsToList (k: v: "${k} ${valueToString v}\n") cfg.config + ); + }) + + (mkIf (cfg.extraConfig != "") { + home.file.".stalonetrayrc".text = cfg.extraConfig; + }) + ]); +} diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 1906814bcc8..5acf313f81b 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -52,7 +52,10 @@ with lib; qsyncthingtray = { Unit = { Description = "QSyncthingTray"; - After = [ "graphical-session-pre.target" "polybar.service" "taffybar.service" ]; + After = [ "graphical-session-pre.target" + "polybar.service" + "taffybar.service" + "stalonetray.service" ]; PartOf = [ "graphical-session.target" ]; }; -- cgit v1.2.3 From fa6f697dbbe06b47b17057d93dffdfcd6f39cbbc Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 25 Jan 2018 14:13:44 +0100 Subject: zsh: move session variables export to zshrc Unlike .zshenv, .zshrc file is sourced only by interactive shells. --- modules/programs/zsh.nix | 86 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 9dcbece3f71..6706fa68a96 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -171,10 +171,8 @@ in sessionVariables = mkOption { default = {}; type = types.attrs; - example = { ZSH_CACHE_DIR = "$HOME/.cache/zsh"; }; - description = '' - Environment variables that will be set for zsh session. - ''; + example = { MAILCHECK = 30; }; + description = "Environment variables that will be set for zsh session."; }; initExtra = mkOption { @@ -240,20 +238,46 @@ in }; config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.profileExtra != "") { + home.file."${relToDotDir ".zprofile"}".text = cfg.profileExtra; + }) + + (mkIf (cfg.loginExtra != "") { + home.file."${relToDotDir ".zlogin"}".text = cfg.loginExtra; + }) + + (mkIf (cfg.logoutExtra != "") { + home.file."${relToDotDir ".zlogout"}".text = cfg.logoutExtra; + }) + + (mkIf cfg.oh-my-zsh.enable { + home.file."${relToDotDir ".zshenv"}".text = '' + ZSH="${pkgs.oh-my-zsh}/share/oh-my-zsh"; + ZSH_CACHE_DIR="''${XDG_CACHE_HOME:-''$HOME/.cache}/oh-my-zsh"; + ''; + }) + + (mkIf (cfg.dotDir != null) { + home.file."${relToDotDir ".zshenv"}".text = '' + ZDOTDIR=${zdotdir} + ''; + + # When dotDir is set, only use ~/.zshenv to source ZDOTDIR/.zshenv, + # This is so that if ZDOTDIR happens to be + # already set correctly (by e.g. spawning a zsh inside a zsh), all env + # vars still get exported + home.file.".zshenv".text = '' + source ${zdotdir}/.zshenv + ''; + }) + { home.packages = with pkgs; [ zsh ] ++ optional cfg.enableCompletion nix-zsh-completions ++ optional cfg.oh-my-zsh.enable oh-my-zsh; - home.file."${relToDotDir ".zshenv"}".text = '' - typeset -U fpath - ${optionalString (config.home.sessionVariableSetter != "pam") '' - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - ''} - ${envVarsStr} - ''; - home.file."${relToDotDir ".zshrc"}".text = '' + typeset -U path cdpath fpath manpath fpath+="$HOME/.nix-profile/share/zsh/site-functions" fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" @@ -299,41 +323,17 @@ in ${cfg.initExtra} + # Environment variables + ${optionalString (config.home.sessionVariableSetter != "pam") '' + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ''} + ${envVarsStr} + + # Aliases ${aliasesStr} ''; } - (mkIf cfg.oh-my-zsh.enable { - programs.zsh.sessionVariables = { - ZSH = "${pkgs.oh-my-zsh}/share/oh-my-zsh"; - ZSH_CACHE_DIR = "\${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"; - }; - }) - - (mkIf (cfg.profileExtra != "") { - home.file."${relToDotDir ".zprofile"}".text = cfg.profileExtra; - }) - - (mkIf (cfg.loginExtra != "") { - home.file."${relToDotDir ".zlogin"}".text = cfg.loginExtra; - }) - - (mkIf (cfg.logoutExtra != "") { - home.file."${relToDotDir ".zlogout"}".text = cfg.logoutExtra; - }) - - (mkIf (cfg.dotDir != null) { - programs.zsh.sessionVariables.ZDOTDIR = zdotdir; - - # When dotDir is set, only use ~/.zshenv to source ZDOTDIR/.zshenv, - # This is so that if ZDOTDIR happens to be - # already set correctly (by e.g. spawning a zsh inside a zsh), all env - # vars still get exported - home.file.".zshenv".text = '' - source ${zdotdir}/.zshenv - ''; - }) - (mkIf cfg.oh-my-zsh.enable { # Oh-My-Zsh calls compinit during initialization, # calling it twice causes sight start up slowdown -- cgit v1.2.3 From 2304c145f342ae98968c1ea295f02c1183539ea3 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 29 Jan 2018 11:30:26 +0100 Subject: zsh: add system packages' completion path to fpath --- modules/programs/zsh.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 6706fa68a96..a5163d87f50 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -153,7 +153,13 @@ in enableCompletion = mkOption { default = true; - description = "Enable zsh completion."; + description = '' + Enable zsh completion. Don't forget to add + + environment.pathsToLink = [ "/share/zsh" ]; + + to your system configuration to get completion for system packages (e.g. systemd). + ''; type = types.bool; }; @@ -278,8 +284,10 @@ in home.file."${relToDotDir ".zshrc"}".text = '' typeset -U path cdpath fpath manpath - fpath+="$HOME/.nix-profile/share/zsh/site-functions" - fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" + + for profile in ''${(z)NIX_PROFILES}; do + fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions) + done HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" -- cgit v1.2.3 From 6833f96c147779fe197657bbcc4bd323324cd6c3 Mon Sep 17 00:00:00 2001 From: Mogria Date: Sat, 27 Jan 2018 18:10:13 +0100 Subject: rofi: add options to for location, xoffset & yoffset --- modules/programs/rofi.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 9391b2d0927..de98a4667be 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -113,6 +113,17 @@ let (rowsColorsToString colors.rows)} ''; + locationsMap = { + center = 0; + top-left = 1; + top = 2; + top-right = 3; + right = 4; + bottom-right = 5; + bottom = 6; + bottom-left = 7; + left = 8; + }; in { @@ -195,6 +206,28 @@ in description = "Whether to run rofi fullscreen."; }; + location = mkOption { + default = "center"; + type = types.enum (builtins.attrNames locationsMap); + description = "The location rofi appears on the screen."; + }; + + xoffset = mkOption { + default = 0; + type = types.int; + description = '' + Offset in the x-axis in pixels relative to the chosen location. + ''; + }; + + yoffset = mkOption { + default = 0; + type = types.int; + description = '' + Offset in the y-axis in pixels relative to the chosen location. + ''; + }; + colors = mkOption { default = null; type = types.nullOr colorsSubmodule; @@ -258,6 +291,9 @@ in ${setOption "terminal" cfg.terminal} ${setOption "cycle" cfg.cycle} ${setOption "fullscreen" cfg.fullscreen} + ${setOption "location" (builtins.getAttr cfg.location locationsMap)} + ${setOption "xoffset" cfg.xoffset} + ${setOption "yoffset" cfg.yoffset} ${setColorScheme cfg.colors} -- cgit v1.2.3 From 6cca1fc512146e34396af8c846bcf736e818c368 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 5 Feb 2018 22:17:31 +0100 Subject: faq: add basic FAQ --- FAQ.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 FAQ.md diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 00000000000..f89a34c5109 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,66 @@ +Frequently Asked Questions (FAQ) +================================ + +Why is there a collision error when switching generation? +--------------------------------------------------------- + +Home Manager currently installs packages into the user environment, +precisely as if the packages were installed through +`nix-env --install`. This means that you will get a collision error if +your Home Manager configuration attempts to install a package that you +already have installed manually, that is, packages that shows up when +you run `nix-env --query`. + +For example, imagine you have the `hello` package installed in your +environment + +```console +$ nix-env --query +hello-2.10 +``` + +and your Home Manager configuration contains + + home.packages = [ pkgs.hello ]; + +Then attempting to switch to this configuration will result in an +error similar to + +```console +$ home-manager switch +these derivations will be built: + /nix/store/xg69wsnd1rp8xgs9qfsjal017nf0ldhm-home-manager-path.drv +[…] +Activating installPackages +replacing old ‘home-manager-path’ +installing ‘home-manager-path’ +building path(s) ‘/nix/store/b5c0asjz9f06l52l9812w6k39ifr49jj-user-environment’ +Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79. +collision between ‘/nix/store/fmwa4axzghz11cnln5absh31nbhs9lq1-home-manager-path/bin/hello’ and ‘/nix/store/c2wyl8b9p4afivpcz8jplc9kis8rj36d-hello-2.10/bin/hello’; use ‘nix-env --set-flag priority NUMBER PKGNAME’ to change the priority of one of the conflicting packages +builder for ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed with exit code 2 +error: build of ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed +``` + +The solution is typically to uninstall the package from the +environment using `nix-env --uninstall` and reattempt the Home Manager +generation switch. + +Why are the session variables not set? +-------------------------------------- + +Home Manager is only able to set session variables automatically if it +manages your Bash or Z shell configuration. If you don't want to let +Home Manager manage your shell then you will have to manually source +the + + ~/.nix-profile/etc/profile.d/hm-session-vars.sh + +file in an appropriate way. In Bash and Z shell this can be done by +adding + +```sh +. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" +``` + +to your `.profile` and `.zshrc` files, respectively. The +`hm-session-vars.sh` file should work in most Bourne-like shells. -- cgit v1.2.3 From 563a20fc82124abebd75a1fbaa6b6ead835d2553 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Thu, 1 Feb 2018 23:37:45 -0500 Subject: xcursor: add module This is a new module for configuring the X cursor theme. --- modules/misc/news.nix | 11 ++++++++ modules/modules.nix | 1 + modules/xcursor.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 modules/xcursor.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0cb5758ec82..47efef6a146 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -557,6 +557,17 @@ in A new module is available: 'services.stalonetray' ''; } + + { + time = "2018-02-04T22:58:49+00:00"; + condition = config.xsession.enable; + message = '' + A new option 'xsession.pointerCursor' is now available. It + allows specifying the pointer cursor theme and size. The + settings will be applied in the xsession, Xresources, and + GTK configurations. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index aa04f3271da..c179c732536 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -66,6 +66,7 @@ let ./services/window-managers/xmonad.nix ./services/xscreensaver.nix ./systemd.nix + ./xcursor.nix ./xresources.nix ./xsession.nix diff --git a/modules/xcursor.nix b/modules/xcursor.nix new file mode 100644 index 00000000000..bb8af9b7833 --- /dev/null +++ b/modules/xcursor.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession.pointerCursor; + + cursorType = types.submodule { + options = { + package = mkOption { + type = types.package; + example = literalExample "pkgs.vanilla-dmz"; + description = "Package providing the cursor theme."; + }; + + name = mkOption { + type = types.str; + example = "Vanilla-DMZ"; + description = "The cursor name within the package."; + }; + + size = mkOption { + type = types.int; + default = 32; + example = 64; + description = "The cursor size."; + }; + }; + }; + +in + +{ + meta.maintainers = [ maintainers.league ]; + + options = { + xsession.pointerCursor = mkOption { + type = types.nullOr cursorType; + default = null; + description = '' + The X cursor theme and settings. The package + xorg.xcursorthemes contains cursors named + whiteglass, redglass, and handhelds. The package + vanilla-dmz contains cursors named Vanilla-DMZ + and Vanilla-DMZ-AA. Note: handhelds does not seem to work at + custom sizes. + ''; + }; + }; + + config = mkIf (cfg != null) { + + home.packages = [cfg.package]; + + xsession.initExtra = '' + ${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cfg.package}/share/icons/${cfg.name}/cursors/X_cursor ${toString cfg.size} + ''; + + xresources.properties = { + "Xcursor.theme" = cfg.name; + "Xcursor.size" = cfg.size; + }; + + gtk.gtk2.extraConfig = '' + gtk-cursor-theme-name="${cfg.name}" + gtk-cursor-theme-size=${toString cfg.size} + ''; + + gtk.gtk3.extraConfig = { + "gtk-cursor-theme-name" = cfg.name; + "gtk-cursor-theme-size" = cfg.size; + }; + + }; +} -- cgit v1.2.3 From 1bc59f729047886b845ffd9162d40593fad5c7f0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 14 Oct 2017 20:56:02 +0200 Subject: allow Home Manager to be used as a NixOS module This is a NixOS module that is intended to be imported into a NixOS system configuration. It allows the system users to be set up directly from the system configuration. The actual profile switch is performed by a oneshot systemd unit per configured user that acts much like the regular `home-manager switch` command. With this implementation, the NixOS module does not work properly with the `nixos-rebuild build-vm` command. This can be solved by using the `users.users..packages` option to install packages but this does not work flawlessly with certain Nixpkgs packages. In particular, for programs using the Qt libraries. --- default.nix | 2 + modules/home-environment.nix | 1 + modules/misc/news.nix | 46 +++++++++++++++ modules/modules.nix | 10 ++++ modules/programs/home-manager.nix | 2 +- modules/systemd-activate.nix | 112 ------------------------------------- modules/systemd-activate.sh | 114 ++++++++++++++++++++++++++++++++++++++ modules/systemd.nix | 26 +++++++-- nixos/default.nix | 57 +++++++++++++++++++ 9 files changed, 252 insertions(+), 118 deletions(-) delete mode 100644 modules/systemd-activate.nix create mode 100644 modules/systemd-activate.sh create mode 100644 nixos/default.nix diff --git a/default.nix b/default.nix index 2988bbbf0d8..9ae18232316 100644 --- a/default.nix +++ b/default.nix @@ -9,4 +9,6 @@ rec { install = import ./home-manager/install.nix { inherit home-manager pkgs; }; + + nixos = import ./nixos; } diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 197e9dc57f3..6c98343d792 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -291,6 +291,7 @@ in # script's "check" and the "write" phases. home.activation.writeBoundary = dag.entryAnywhere ""; + # Install packages to the user environment. home.activation.installPackages = dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD nix-env -i ${cfg.path} ''; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 47efef6a146..0fffe2ea8c9 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -568,6 +568,52 @@ in GTK configurations. ''; } + + { + time = "2018-02-06T20:23:34+00:00"; + message = '' + It is now possible to use Home Manager as a NixOS module. + This allows you to prepare user environments from the system + configuration file, which often is more convenient than + using the 'home-manager' tool. It also opens up additional + possibilities, for example, to automatically configure user + environments in NixOS declarative containers or on systems + deployed through NixOps. + + This feature should be considered experimental for now and + some critial limitations apply. For example, it is currently + not possible to use 'nixos-rebuild build-vm' when using the + Home Manager NixOS module. That said, it should be + reasonably robust and stable for simpler use cases. + + To make Home Manager available in your NixOS system + configuration you can add + + imports = [ + "''${builtins.fetchTarball https://github.com/rycee/home-manager/archive/master.tar.gz}/nixos" + ]; + + to your 'configuration.nix' file. This will introduce a new + NixOS option called 'home-manager.users' whose type is an + attribute set mapping user names to Home Manager + configurations. + + For example, a NixOS configuration may include the lines + + users.users.eve.isNormalUser = true; + home-manager.users.eve = { + home.packages = [ pkgs.atool pkgs.httpie ]; + programs.bash.enable = true; + }; + + and after a 'nixos-rebuild switch' the user eve's + environment should include a basic Bash configuration and + the packages atool and httpie. + + More detailed documentation on the intricacies of this new + feature is slowly forthcoming. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index c179c732536..7e9e6dae7e4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -3,6 +3,9 @@ # Whether to enable module type checking. , check ? true + + # Whether these modules are inside a NixOS submodule. +, nixosSubmodule ? false }: with lib; @@ -75,10 +78,17 @@ let ]; pkgsModule = { + options.nixosSubmodule = mkOption { + type = types.bool; + internal = true; + readOnly = true; + }; + config._module.args.baseModules = modules; config._module.args.pkgs = lib.mkDefault pkgs; config._module.check = check; config.lib = import ./lib { inherit lib; }; + config.nixosSubmodule = nixosSubmodule; config.nixpkgs.system = mkDefault pkgs.system; }; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 306b14a2198..e9d48117da0 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -32,7 +32,7 @@ in }; }; - config = mkIf cfg.enable { + config = mkIf (cfg.enable && !config.nixosSubmodule) { home.packages = [ (import ../../home-manager { inherit pkgs; diff --git a/modules/systemd-activate.nix b/modules/systemd-activate.nix deleted file mode 100644 index 5e3b5773df7..00000000000 --- a/modules/systemd-activate.nix +++ /dev/null @@ -1,112 +0,0 @@ -systemctlPath: -'' -function isStartable() { - local service="$1" - [[ $(${systemctlPath} --user show -p RefuseManualStart "$service") == *=no ]] -} - -function isStoppable() { - if [[ -v oldGenPath ]] ; then - local service="$1" - [[ $(${systemctlPath} --user show -p RefuseManualStop "$service") == *=no ]] - fi -} - -function systemdPostReload() { - local workDir - workDir="$(mktemp -d)" - - if [[ -v oldGenPath ]] ; then - local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" - fi - - local newUserServicePath="$newGenPath/home-files/.config/systemd/user" - local oldServiceFiles="$workDir/old-files" - local newServiceFiles="$workDir/new-files" - local servicesDiffFile="$workDir/diff-files" - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ - && ! -d "$newUserServicePath" ]]; then - return - fi - - if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then - touch "$oldServiceFiles" - else - find "$oldUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$oldServiceFiles" - fi - - if [[ ! -d "$newUserServicePath" ]]; then - touch "$newServiceFiles" - else - find "$newUserServicePath" \ - -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ - | sort \ - > "$newServiceFiles" - fi - - diff \ - --new-line-format='+%L' \ - --old-line-format='-%L' \ - --unchanged-line-format=' %L' \ - "$oldServiceFiles" "$newServiceFiles" \ - > $servicesDiffFile || true - - local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) ) - local -a maybeStop=( $(grep '^-' $servicesDiffFile | cut -c2-) ) - local -a maybeStart=( $(grep '^+' $servicesDiffFile | cut -c2-) ) - local -a toRestart=( ) - local -a toStop=( ) - local -a toStart=( ) - - for f in ''${maybeRestart[@]} ; do - if isStoppable "$f" \ - && isStartable "$f" \ - && ${systemctlPath} --quiet --user is-active "$f" \ - && ! cmp --quiet \ - "$oldUserServicePath/$f" \ - "$newUserServicePath/$f" ; then - toRestart+=("$f") - fi - done - - for f in ''${maybeStop[@]} ; do - if isStoppable "$f" ; then - toStop+=("$f") - fi - done - - for f in ''${maybeStart[@]} ; do - if isStartable "$f" ; then - toStart+=("$f") - fi - done - - rm -r $workDir - - local sugg="" - - if [[ -n "''${toRestart[@]}" ]] ; then - sugg="''${sugg}systemctl --user restart ''${toRestart[@]}\n" - fi - - if [[ -n "''${toStop[@]}" ]] ; then - sugg="''${sugg}systemctl --user stop ''${toStop[@]}\n" - fi - - if [[ -n "''${toStart[@]}" ]] ; then - sugg="''${sugg}systemctl --user start ''${toStart[@]}\n" - fi - - if [[ -n "$sugg" ]] ; then - echo "Suggested commands:" - echo -n -e "$sugg" - fi -} - -$DRY_RUN_CMD ${systemctlPath} --user daemon-reload -systemdPostReload -'' diff --git a/modules/systemd-activate.sh b/modules/systemd-activate.sh new file mode 100644 index 00000000000..1c464693cfc --- /dev/null +++ b/modules/systemd-activate.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash + +function isStartable() { + local service="$1" + [[ $(systemctl --user show -p RefuseManualStart "$service") == *=no ]] +} + +function isStoppable() { + if [[ -v oldGenPath ]] ; then + local service="$1" + [[ $(systemctl --user show -p RefuseManualStop "$service") == *=no ]] + fi +} + +function systemdPostReload() { + local workDir + workDir="$(mktemp -d)" + + if [[ -v oldGenPath ]] ; then + local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user" + fi + + local newUserServicePath="$newGenPath/home-files/.config/systemd/user" + local oldServiceFiles="$workDir/old-files" + local newServiceFiles="$workDir/new-files" + local servicesDiffFile="$workDir/diff-files" + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \ + && ! -d "$newUserServicePath" ]]; then + return + fi + + if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then + touch "$oldServiceFiles" + else + find "$oldUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$oldServiceFiles" + fi + + if [[ ! -d "$newUserServicePath" ]]; then + touch "$newServiceFiles" + else + find "$newUserServicePath" \ + -maxdepth 1 -name '*.service' -exec basename '{}' ';' \ + | sort \ + > "$newServiceFiles" + fi + + diff \ + --new-line-format='+%L' \ + --old-line-format='-%L' \ + --unchanged-line-format=' %L' \ + "$oldServiceFiles" "$newServiceFiles" \ + > "$servicesDiffFile" || true + + local -a maybeRestart=( $(grep '^ ' "$servicesDiffFile" | cut -c2-) ) + local -a maybeStop=( $(grep '^-' "$servicesDiffFile" | cut -c2-) ) + local -a maybeStart=( $(grep '^+' "$servicesDiffFile" | cut -c2-) ) + local -a toRestart=( ) + local -a toStop=( ) + local -a toStart=( ) + + for f in "${maybeRestart[@]}" ; do + if isStoppable "$f" \ + && isStartable "$f" \ + && systemctl --quiet --user is-active "$f" \ + && ! cmp --quiet \ + "$oldUserServicePath/$f" \ + "$newUserServicePath/$f" ; then + toRestart+=("$f") + fi + done + + for f in "${maybeStop[@]}" ; do + if isStoppable "$f" ; then + toStop+=("$f") + fi + done + + for f in "${maybeStart[@]}" ; do + if isStartable "$f" ; then + toStart+=("$f") + fi + done + + rm -r "$workDir" + + local sugg="" + + if [[ -n "${toRestart[@]}" ]] ; then + sugg="${sugg}systemctl --user restart ${toRestart[@]}\n" + fi + + if [[ -n "${toStop[@]}" ]] ; then + sugg="${sugg}systemctl --user stop ${toStop[@]}\n" + fi + + if [[ -n "${toStart[@]}" ]] ; then + sugg="${sugg}systemctl --user start ${toStart[@]}\n" + fi + + if [[ -n "$sugg" ]] ; then + echo "Suggested commands:" + echo -n -e "$sugg" + fi +} + +oldGenPath="$1" +newGenPath="$2" + +$DRY_RUN_CMD systemctl --user daemon-reload +systemdPostReload diff --git a/modules/systemd.nix b/modules/systemd.nix index 3ee5ccc8ef9..9eaba7c22b1 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -145,14 +145,30 @@ in (buildServices "timer" cfg.timers) ); + # Run systemd service reload if user is logged in. If we're + # running this from the NixOS module then XDG_RUNTIME_DIR is not + # set and systemd commands will fail. We'll therefore have to + # set it ourselves in that case. home.activation.reloadSystemD = dag.entryAfter ["linkGeneration"] ( - if cfg.startServices then + let + autoReloadCmd = '' + ${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \ + "''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}" + ''; + + legacyReloadCmd = '' + bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath" + ''; + in '' - PATH=${dirOf cfg.systemctlPath} \ - ${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \ - "''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}" + if who | grep -q '^${config.home.username} '; then + XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)} \ + PATH=${dirOf cfg.systemctlPath}:$PATH \ + ${if cfg.startServices then autoReloadCmd else legacyReloadCmd} + else + echo "User ${config.home.username} not logged in. Skipping." + fi '' - else import ./systemd-activate.nix cfg.systemctlPath ); }) ]; diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 00000000000..d72d8a19557 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,57 @@ +{ config, lib, pkgs, utils, ... }: + +with lib; + +let + + cfg = config.home-manager; + + hmModule = types.submodule ({name, ...}: { + imports = import ../modules/modules.nix { + inherit lib pkgs; + nixosSubmodule = true; + }; + + config = { + home.username = config.users.users.${name}.name; + home.homeDirectory = config.users.users.${name}.home; + }; + }); + +in + +{ + options = { + home-manager.users = mkOption { + type = types.attrsOf hmModule; + default = {}; + description = '' + Per-user Home Manager configuration. + ''; + }; + }; + + config = mkIf (cfg.users != {}) { + systemd.services = mapAttrs' (username: usercfg: + nameValuePair ("home-manager-${utils.escapeSystemdPath username}") { + description = "Home Manager environment for ${username}"; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + User = username; + Type = "oneshot"; + RemainAfterExit = "yes"; + SyslogIdentifier = "hm-activate-${username}"; + + # The activation script is run by a login shell to make sure + # that the user is given a sane Nix environment. + ExecStart = pkgs.writeScript "activate-${username}" '' + #! ${pkgs.stdenv.shell} -el + echo Activating home-manager configuration for ${username} + exec ${usercfg.home.activationPackage}/activate + ''; + }; + } + ) cfg.users; + }; +} -- cgit v1.2.3 From 9ea353569a437659157230d740467778e91a2baa Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 8 Feb 2018 22:54:29 +0100 Subject: Remove deprecated option `home.sessionVariableSetter` --- modules/home-environment.nix | 31 ++++++++++-------------- modules/misc/news.nix | 54 ------------------------------------------ modules/misc/pam.nix | 6 +---- modules/programs/bash.nix | 4 +--- modules/programs/info.nix | 7 ------ modules/programs/zsh.nix | 4 +--- modules/services/gpg-agent.nix | 5 +--- modules/xsession.nix | 3 +-- 8 files changed, 17 insertions(+), 97 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 6c98343d792..164d3e9c339 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -96,6 +96,18 @@ in { meta.maintainers = [ maintainers.rycee ]; + imports = [ + (mkRemovedOptionModule [ "home" "sessionVariableSetter" ] '' + Session variables are now always set through the shell. This is + done automatically if the shell configuration is managed by Home + Manager. If not, then you must source the + + ~/.nix-profile/etc/profile.d/hm-session-vars.sh + + file yourself. + '') + ]; + options = { home.username = mkOption { type = types.str; @@ -158,25 +170,6 @@ in ''; }; - home.sessionVariableSetter = mkOption { - default = null; - type = types.nullOr (types.enum [ "pam" "bash" "zsh" ]); - example = "pam"; - description = '' - Identifies the module that should set the session variables. - - If "bash" is set then config.bash.enable - must also be enabled. - - If "pam" is set then PAM must be used to set the system - environment. Also mind that typical environment variables - might not be set by the time PAM starts up. - - This option is DEPRECATED, the shell modules are now - automatically setting the session variables when enabled. - ''; - }; - home.packages = mkOption { type = types.listOf types.package; default = []; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0fffe2ea8c9..fada8e74a2c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -479,60 +479,6 @@ in ''; } - { - time = "2018-01-08T20:39:56+00:00"; - condition = config.home.sessionVariableSetter != null; - message = - let - opts = { - bash = '' - Instead the 'programs.bash' module will, when enabled, - automatically set session variables. You can safely - remove the 'home.sessionVariableSetter' option from your - configuration. - ''; - - zsh = '' - Instead the 'programs.zsh' module will, when enabled, - automatically set session variables. You can safely - remove the 'home.sessionVariableSetter' option from your - configuration. - ''; - - pam = '' - Unfortunately setting general session variables using - PAM will not be directly supported after this date. The - primary reason for this change is its limited support - for variable expansion. - - To continue setting session variables from the Home - Manager configuration you must either use the - 'programs.bash' or 'programs.zsh' modules or manually - source the session variable file - - $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh - - within your shell configuration, see the README file for - more information. This file requires a Bourne-like shell - such as Bash or Z shell but hopefully other shells - will be supported in the future. - - If you specifically need to set a session variable using - PAM then the new option 'pam.sessionVariables' can be - used. It works much the same as 'home.sessionVariables' - but its attribute values must be valid within the PAM - environment file. - ''; - }; - in - '' - The 'home.sessionVariableSetter' option is now deprecated - and will be removed on February 8, 2018. - - ${opts.${config.home.sessionVariableSetter}} - ''; - } - { time = "2018-01-25T11:35:08+00:00"; condition = options.services.qsyncthingtray.enable.isDefined; diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index dfeaf2f339e..91b75f5b5ec 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -4,11 +4,7 @@ with lib; let - homeCfg = config.home; - - vars = - optionalAttrs (homeCfg.sessionVariableSetter == "pam") homeCfg.sessionVariables - // config.pam.sessionVariables; + vars = config.pam.sessionVariables; in diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 115fa7abab4..786478c1ff1 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -183,9 +183,7 @@ in home.file.".profile".text = '' # -*- mode: sh -*- - ${optionalString (config.home.sessionVariableSetter != "pam") '' - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - ''} + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ${sessionVarsStr} diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 5884bb19ec9..4f3f1e5670d 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -54,13 +54,6 @@ in }; config = mkIf cfg.enable { - assertions = [{ - assertion = config.home.sessionVariableSetter != "pam"; - message = '' - The info module does not work with PAM as a session variable setter. - ''; - }]; - home.sessionVariables.INFOPATH = "${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}"; diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index a5163d87f50..8005d69f9e8 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -332,9 +332,7 @@ in ${cfg.initExtra} # Environment variables - ${optionalString (config.home.sessionVariableSetter != "pam") '' - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - ''} + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ${envVarsStr} # Aliases diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index dfd4b89cdd8..f193b564332 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -89,10 +89,7 @@ in home.sessionVariables = optionalAttrs cfg.enableSshSupport { - SSH_AUTH_SOCK = - if config.home.sessionVariableSetter == "pam" - then "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh" - else "$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)"; + SSH_AUTH_SOCK = "$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)"; }; programs.bash.initExtra = gpgInitStr; diff --git a/modules/xsession.nix b/modules/xsession.nix index 40e52202973..3bce4506521 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -82,8 +82,7 @@ in }; home.file.".xprofile".text = '' - ${optionalString (config.home.sessionVariableSetter != "pam") - ''. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"''} + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" if [[ -e "$HOME/.profile" ]]; then . "$HOME/.profile" -- cgit v1.2.3 From afa865587e17c0c6af29451d41015599ec4d37aa Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 10 Feb 2018 19:21:25 +0100 Subject: zsh: move env variables setting before oh-my-zsh Fixes #207. --- modules/programs/zsh.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 8005d69f9e8..d1371159fa3 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -301,6 +301,10 @@ in "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } + # Environment variables + . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ${envVarsStr} + ${optionalString cfg.oh-my-zsh.enable '' # oh-my-zsh configuration generated by NixOS ${optionalString (cfg.oh-my-zsh.plugins != []) @@ -331,10 +335,6 @@ in ${cfg.initExtra} - # Environment variables - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - ${envVarsStr} - # Aliases ${aliasesStr} ''; -- cgit v1.2.3 From f2265b10e4eb48c66d334fa1d90bebb4affbec69 Mon Sep 17 00:00:00 2001 From: Andrew Scott <3648487+ayyjayess@users.noreply.github.com> Date: Mon, 29 Jan 2018 14:30:25 +0000 Subject: rofi: add theme option The preferred method of theming rofi is now to use "rasi" theme files. This commit therefore downplays the colors option and introduces the theme option. --- modules/misc/news.nix | 17 +++++++++++++++++ modules/programs/rofi.nix | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index fada8e74a2c..07b7ea3006e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -560,6 +560,23 @@ in feature is slowly forthcoming. ''; } + + { + time = "2018-02-09T21:14:42+00:00"; + condition = with config.programs.rofi; enable && colors != null; + message = '' + The new and preferred way to configure the rofi theme is + using rasi themes through the 'programs.rofi.theme' option. + This option can take as value either the name of a + pre-installed theme or the path to a theme file. + + A rasi theme can be generated from an Xresources config + using 'rofi -dump-theme'. + + The option 'programs.rofi.colors' is still supported but may + become deprecated and removed in the future. + ''; + } ]; }; } diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index de98a4667be..19a18fae84f 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -124,6 +124,14 @@ let bottom-left = 7; left = 8; }; + + themeName = + if (cfg.theme == null) then null + else if (lib.isString cfg.theme) then cfg.theme + else lib.removeSuffix ".rasi" (baseNameOf cfg.theme); + + themePath = if (lib.isString cfg.theme) then null else cfg.theme; + in { @@ -232,8 +240,10 @@ in default = null; type = types.nullOr colorsSubmodule; description = '' - Color scheme settings. - Colors can be specified in CSS color formats. + Color scheme settings. Colors can be specified in CSS color + formats. This option may become deprecated in the future and + therefore the programs.rofi.theme option + should be used whenever possible. ''; example = literalExample '' colors = { @@ -258,6 +268,17 @@ in ''; }; + theme = mkOption { + default = null; + type = with types; nullOr (either string path); + example = "Arc"; + description = '' + Name of theme or path to theme file in rasi format. Available + named themes can be viewed using the + rofi-theme-selector tool. + ''; + }; + configPath = mkOption { default = ".config/rofi/config"; type = types.string; @@ -273,6 +294,15 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.theme == null || cfg.colors == null; + message = '' + Cannot use the rofi options 'theme' and 'colors' simultaneously. + ''; + } + ]; + home.packages = [ pkgs.rofi ]; home.file."${cfg.configPath}".text = '' @@ -296,8 +326,13 @@ in ${setOption "yoffset" cfg.yoffset} ${setColorScheme cfg.colors} + ${setOption "theme" themeName} ${cfg.extraConfig} ''; + + xdg.dataFile = mkIf (themePath != null) { + "rofi/themes/${themeName}.rasi".source = themePath; + }; }; } -- cgit v1.2.3 From be60600a477bec543e6f904431eca22b8af64fec Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Wed, 31 Jan 2018 17:14:01 +0900 Subject: neovim: add 'configure' flag so that we have the same options as in nixpkgs. --- modules/programs/neovim.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 8e0663f60cc..d0f1002620b 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -58,6 +58,28 @@ in List here Python 3 packages required for your plugins to work. ''; }; + + configure = mkOption { + type = types.nullOr types.attrs; + default = null; + example = literalExample '' + configure = { + customRC = $'''' + " here your custom configuration goes! + $''''; + packages.myVimPackage = with pkgs.vimPlugins; { + # loaded on launch + start = [ fugitive ]; + # manually loadable by calling `:packadd $plugin-name` + opt = [ ]; + }; + }; + ''; + description = '' + Generate your init file from your list of plugins and custom commands, + and loads it from the store via nvim -u /nix/store/hash-vimrc + ''; + }; }; }; @@ -67,7 +89,7 @@ in inherit (cfg) extraPython3Packages withPython3 extraPythonPackages withPython - withRuby; + withRuby configure; }) ]; }; -- cgit v1.2.3 From de001e05da3f9456d658aabe62f1cc2fa663cbb0 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 17 Feb 2018 20:13:41 +0100 Subject: i3: add missing bar options New options are: id, commmand, workspaceNumbers, colors. Fixes #210. --- modules/services/window-managers/i3.nix | 134 +++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index a40f7462e9e..926d40151c0 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -38,6 +38,25 @@ let }; }; + barColorSetModule = types.submodule { + options = { + border = mkOption { + type = types.string; + visible = false; + }; + + background = mkOption { + type = types.string; + visible = false; + }; + + text = mkOption { + type = types.string; + visible = false; + }; + }; + }; + colorSetModule = types.submodule { options = { border = mkOption { @@ -69,6 +88,16 @@ let barModule = types.submodule { options = { + id = mkOption { + type = types.nullOr types.string; + default = null; + description = '' + Specifies the bar ID for the configured bar instance. + If this option is missing, the ID is set to bar-x, where x corresponds + to the position of the embedding bar block in the config file. + ''; + }; + mode = mkOption { type = types.enum [ "dock" "hide" "invisible" ]; default = "dock"; @@ -93,12 +122,98 @@ let description = "Whether workspace buttons should be shown or not."; }; + workspaceNumbers = mkOption { + type = types.bool; + default = true; + description = "Whether workspace numbers should be displayed within the workspace buttons."; + }; + + command = mkOption { + type = types.string; + default = "${cfg.package}/bin/i3bar"; + defaultText = "i3bar"; + description = "Command that will be used to start a bar."; + example = "${pkgs.i3-gaps}/bin/i3bar -t"; + }; + statusCommand = mkOption { type = types.string; default = "${pkgs.i3status}/bin/i3status"; description = "Command that will be used to get status lines."; }; + colors = mkOption { + type = types.submodule { + options = { + background = mkOption { + type = types.string; + default = "#000000"; + description = "Background color of the bar."; + }; + + statusline = mkOption { + type = types.string; + default = "#ffffff"; + description = "Text color to be used for the statusline."; + }; + + separator = mkOption { + type = types.string; + default = "#666666"; + description = "Text color to be used for the separator."; + }; + + focusedWorkspace = mkOption { + type = barColorSetModule; + default = { border = "#4c7899"; background = "#285577"; text = "#ffffff"; }; + description = '' + Border, background and text color for a workspace button when the workspace has focus. + ''; + }; + + activeWorkspace = mkOption { + type = barColorSetModule; + default = { border = "#333333"; background = "#5f676a"; text = "#ffffff"; }; + description = '' + Border, background and text color for a workspace button when the workspace is active. + ''; + }; + + inactiveWorkspace = mkOption { + type = barColorSetModule; + default = { border = "#333333"; background = "#222222"; text = "#888888"; }; + description = '' + Border, background and text color for a workspace button when the workspace does not + have focus and is not active. + ''; + }; + + urgentWorkspace = mkOption { + type = barColorSetModule; + default = { border = "#2f343a"; background = "#900000"; text = "#ffffff"; }; + description = '' + Border, background and text color for a workspace button when the workspace contains + a window with the urgency hint set. + ''; + }; + + bindingMode = mkOption { + type = barColorSetModule; + default = { border = "#2f343a"; background = "#900000"; text = "#ffffff"; }; + description = "Border, background and text color for the binding mode indicator"; + }; + }; + }; + default = {}; + description = '' + Bar color settings. All color classes can be specified using submodules + with 'border', 'background', 'text', fields and RGB color hex-codes as values. + See default values for the reference. + Note that 'background', 'status', and 'separator' parameters take a single RGB value. + + See . + ''; + }; }; }; @@ -511,6 +626,7 @@ let ); colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; + barColorSetStr = c: concatStringsSep " " [ c.border c.background c.text ]; criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]"; @@ -524,13 +640,29 @@ let map (c: "assign ${criteriaStr c} ${workspace}") criteria ); - barStr = { mode, hiddenState, position, workspaceButtons, statusCommand, ... }: '' + barStr = { + id, mode, hiddenState, position, workspaceButtons, + workspaceNumbers, command, statusCommand, colors, ... + }: '' bar { + ${optionalString (id != null) "id ${id}"} mode ${mode} hidden_state ${hiddenState} position ${position} status_command ${statusCommand} + i3bar_command ${command} workspace_buttons ${if workspaceButtons then "yes" else "no"} + strip_workspace_numbers ${if !workspaceNumbers then "yes" else "no"} + colors { + background ${colors.background} + statusline ${colors.statusline} + separator ${colors.separator} + focused_workspace ${barColorSetStr colors.focusedWorkspace} + active_workspace ${barColorSetStr colors.activeWorkspace} + inactive_workspace ${barColorSetStr colors.inactiveWorkspace} + urgent_workspace ${barColorSetStr colors.urgentWorkspace} + binding_mode ${barColorSetStr colors.bindingMode} + } } ''; -- cgit v1.2.3 From 6d7b5c9513039efb980319a6449a9b1c77c57c82 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 19 Feb 2018 16:28:30 +0900 Subject: i3: don't evaluate "command" example else it attempts to build i3-gaps and fails on darwin see https://github.com/rycee/home-manager/pull/214#issuecomment-366594833 --- modules/services/window-managers/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 926d40151c0..5cd2e44f382 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -133,7 +133,7 @@ let default = "${cfg.package}/bin/i3bar"; defaultText = "i3bar"; description = "Command that will be used to start a bar."; - example = "${pkgs.i3-gaps}/bin/i3bar -t"; + example = literalExample "${pkgs.i3-gaps}/bin/i3bar -t"; }; statusCommand = mkOption { -- cgit v1.2.3 From 05ad0c9e06e5a1e851a3a846c044ce28efb58864 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 19 Feb 2018 20:17:33 +0100 Subject: i3: escape ${} in bars.command example --- modules/services/window-managers/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 5cd2e44f382..043716642d9 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -133,7 +133,7 @@ let default = "${cfg.package}/bin/i3bar"; defaultText = "i3bar"; description = "Command that will be used to start a bar."; - example = literalExample "${pkgs.i3-gaps}/bin/i3bar -t"; + example = "\${pkgs.i3-gaps}/bin/i3bar -t"; }; statusCommand = mkOption { -- cgit v1.2.3 From 5c783e1a6309fea6e4f56bec80412cd54db4b61d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 19 Feb 2018 21:30:16 +0100 Subject: Add initial Travis-CI configuration --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..56f9599d5ee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: nix + +os: + - linux + - osx + +before_script: + - mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER + - mkdir -p ~/.config/nixpkgs + - echo "{}" > ~/.config/nixpkgs/home.nix + +script: + nix-shell . -A install -- cgit v1.2.3 From 4745c7a00dbef714dae0a399a5b33ed04983b21c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 17 Feb 2018 09:39:31 +0100 Subject: pidgin: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/pidgin.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 modules/programs/pidgin.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 07b7ea3006e..23f8f5b136c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -577,6 +577,13 @@ in become deprecated and removed in the future. ''; } + + { + time = "2018-02-19T21:45:26+00:00"; + message = '' + A new module is available: 'programs.pidgin' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 7e9e6dae7e4..3b5f705abe0 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -39,6 +39,7 @@ let ./programs/man.nix ./programs/mercurial.nix ./programs/neovim.nix + ./programs/pidgin.nix ./programs/rofi.nix ./programs/ssh.nix ./programs/termite.nix diff --git a/modules/programs/pidgin.nix b/modules/programs/pidgin.nix new file mode 100644 index 00000000000..534ee5f0cb2 --- /dev/null +++ b/modules/programs/pidgin.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.pidgin; + +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + programs.pidgin = { + enable = mkEnableOption "Pidgin messaging client"; + + package = mkOption { + type = types.package; + default = pkgs.pidgin; + defaultText = "pkgs.pidgin"; + description = "The Pidgin package to use."; + }; + + plugins = mkOption { + default = []; + example = literalExample "[ pkgs.pidgin-otr pkgs.pidgin-osd ]"; + description = "Plugins that should be available to Pidgin."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ (cfg.package.override { inherit (cfg) plugins; }) ]; + }; +} -- cgit v1.2.3 From e307ceeee7fea63dbe898cc995917b48345a3d85 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Feb 2018 16:39:28 +0100 Subject: systemd: replace use of `who` command Curiously the `who` command sometimes does not list logged-in users, resulting in systemd not being reloaded. Instead we use systemctl --user is-system-running to more directly detect whether systemd is running. --- modules/systemd.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 9eaba7c22b1..ce3c2c1bbd5 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -159,14 +159,16 @@ in legacyReloadCmd = '' bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath" ''; + + ensureRuntimeDir = "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"; in '' - if who | grep -q '^${config.home.username} '; then - XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)} \ + if ${ensureRuntimeDir} ${cfg.systemctlPath} --quiet --user is-system-running 2> /dev/null; then + ${ensureRuntimeDir} \ PATH=${dirOf cfg.systemctlPath}:$PATH \ ${if cfg.startServices then autoReloadCmd else legacyReloadCmd} else - echo "User ${config.home.username} not logged in. Skipping." + echo "User systemd daemon not running. Skipping reload." fi '' ); -- cgit v1.2.3 From b47cc4bc66c918416418644282042fcec06b8823 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Feb 2018 22:30:28 +0100 Subject: qsyncthingtray: remove deprecated option --- modules/misc/news.nix | 11 ----------- modules/services/syncthing.nix | 6 ------ 2 files changed, 17 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 23f8f5b136c..c591dde7fe4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -479,17 +479,6 @@ in ''; } - { - time = "2018-01-25T11:35:08+00:00"; - condition = options.services.qsyncthingtray.enable.isDefined; - message = '' - 'services.qsyncthingtray' has been merged into 'services.syncthing'. - Please, use 'services.syncthing.tray' option to activate the tray service. - - The old module will be removed on February 25, 2018. - ''; - } - { time = "2018-02-02T11:15:00+00:00"; message = '' diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 5acf313f81b..8d52943e1f1 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -3,12 +3,6 @@ with lib; { - imports = [ - (mkRenamedOptionModule - [ "services" "qsyncthingtray" "enable" ] - [ "services" "syncthing" "tray" ]) - ]; - meta.maintainers = [ maintainers.rycee ]; options = { -- cgit v1.2.3 From 19b4002f25cc468b4242de05099ae22bf75704c3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 27 Feb 2018 20:31:03 +0100 Subject: home-environment: use nix-env from PATH It is safest to use the system install of Nix since that will be compatible with the running nix-daemon and/or databases. Also add a printout of the used Nix version in the activation script when running in verbose mode. Fixes #218. --- modules/home-environment.nix | 1 - modules/lib-bash/activation-init.sh | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 164d3e9c339..c6fc345d7a2 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -313,7 +313,6 @@ in pkgs.gnugrep pkgs.gnused pkgs.ncurses # For `tput`. - pkgs.nix ] + optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH"; diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index 1239e18e2a6..b5472504ce9 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + function setupVars() { local profilesPath="/nix/var/nix/profiles/per-user/$USER" local gcPath="/nix/var/nix/gcroots/per-user/$USER" @@ -46,6 +48,11 @@ else export DRY_RUN_CMD="" fi +if [[ -v VERBOSE ]]; then + echo -n "Using Nix version: " + nix-env --version +fi + $VERBOSE_ECHO "Activation variables:" if [[ -v oldGenNum ]] ; then $VERBOSE_ECHO " oldGenNum=$oldGenNum" -- cgit v1.2.3 From fbff38de33bc43ebae6bc49080d33473716b8a75 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 1 Mar 2018 23:21:45 +0100 Subject: xscreensaver: install the xscreensaver package This is needed to make the xscreensaver tools available. --- modules/services/xscreensaver.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix index e500c5d85a6..23df90c4d57 100644 --- a/modules/services/xscreensaver.nix +++ b/modules/services/xscreensaver.nix @@ -12,6 +12,9 @@ with lib; }; config = mkIf config.services.xscreensaver.enable { + # To make the xscreensaver-command tool available. + home.packages = [ pkgs.xscreensaver ]; + systemd.user.services.xscreensaver = { Unit = { Description = "XScreenSaver"; -- cgit v1.2.3 From 06e7d087f29c7890f33e698c2fab073e1a67ce02 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 3 Mar 2018 21:58:22 +0100 Subject: home-manager: colorize only when connected to terminal Before, the output of `home-manager generations` would be colorized even when used in a pipeline. --- home-manager/home-manager | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 63af9687b6e..2f04cd8620d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -159,9 +159,15 @@ function doSwitch() { } function doListGens() { + # Whether to colorize the generations output. + local color="never" + if [[ -t 1 ]]; then + color="always" + fi + pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null # shellcheck disable=2012 - ls --color=yes -gG --time-style=long-iso --sort time home-manager-*-link \ + ls --color=$color -gG --time-style=long-iso --sort time home-manager-*-link \ | cut -d' ' -f 4- \ | sed -E 's/home-manager-([[:digit:]]*)-link/: id \1/' popd > /dev/null -- cgit v1.2.3 From 8fc8e158e2dcb4cd83dbf77011ce2a2633437dd5 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Sat, 3 Mar 2018 22:53:10 -0800 Subject: unclutter: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/services/unclutter.nix | 63 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 modules/services/unclutter.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c591dde7fe4..c9edc879823 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -573,6 +573,13 @@ in A new module is available: 'programs.pidgin' ''; } + + { + time = "2018-03-04T06:54:26+00:00"; + message = '' + A new module is available: 'services.unclutter' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 3b5f705abe0..de5749ff7c4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -66,6 +66,7 @@ let ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix + ./services/unclutter.nix ./services/window-managers/i3.nix ./services/window-managers/xmonad.nix ./services/xscreensaver.nix diff --git a/modules/services/unclutter.nix b/modules/services/unclutter.nix new file mode 100644 index 00000000000..26dca37ab44 --- /dev/null +++ b/modules/services/unclutter.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.unclutter; + +in { + options.services.unclutter = { + + enable = mkEnableOption "unclutter"; + + package = mkOption { + description = "unclutter derivation to use."; + type = types.package; + default = pkgs.unclutter-xfixes; + defaultText = "pkgs.unclutter-xfixes"; + }; + + timeout = mkOption { + description = "Number of seconds before the cursor is marked inactive."; + type = types.int; + default = 1; + }; + + threshold = mkOption { + description = "Minimum number of pixels considered cursor movement."; + type = types.int; + default = 1; + }; + + extraOptions = mkOption { + description = "More arguments to pass to the unclutter command."; + type = types.listOf types.str; + default = [ ]; + example = [ "exclude-root" "ignore-scrolling" ]; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.unclutter = { + Unit = { + Description = "unclutter"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = '' + ${cfg.package}/bin/unclutter \ + --timeout ${toString cfg.timeout} \ + --jitter ${toString (cfg.threshold - 1)} \ + ${concatMapStrings (x: " --${x}") cfg.extraOptions} + ''; + RestartSec = 3; + Restart = "always"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From bc50202d0d1be0dbebcab712e04ea8d3dcbacfe2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 4 Mar 2018 22:18:17 +0100 Subject: gpg-agent: do updatestartuptty only when SSH is enabled Inspired by #163. --- modules/services/gpg-agent.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index f193b564332..ea96312f34a 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -9,8 +9,9 @@ let gpgInitStr = '' GPG_TTY="$(tty)" export GPG_TTY - ${pkgs.gnupg}/bin/gpg-connect-agent updatestartuptty /bye > /dev/null - ''; + '' + + optionalString cfg.enableSshSupport + "${pkgs.gnupg}/bin/gpg-connect-agent updatestartuptty /bye > /dev/null"; in -- cgit v1.2.3 From 46a94cce566a5293ae3fb8876ec3fd916eda9fa8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 5 Mar 2018 19:03:46 +0100 Subject: texlive: add option programs.texlive.package This read-only option will hold a reference to the customized texlive package. --- modules/programs/texlive.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/programs/texlive.nix b/modules/programs/texlive.nix index 1d944cef13a..e857a062590 100644 --- a/modules/programs/texlive.nix +++ b/modules/programs/texlive.nix @@ -22,13 +22,18 @@ in ''; description = "Extra packages available to Texlive."; }; + + package = mkOption { + type = types.package; + description = "Resulting customized Texlive package."; + readOnly = true; + }; }; }; config = mkIf cfg.enable { - home.packages = [ - (pkgs.texlive.combine (cfg.extraPackages pkgs.texlive)) - ]; - + home.packages = [ cfg.package ]; + programs.texlive.package = + pkgs.texlive.combine (cfg.extraPackages pkgs.texlive); }; } -- cgit v1.2.3 From fa7d63d9d1fbee1423272bb281f41e8dd5da74bd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Feb 2018 09:45:10 +0100 Subject: fzf: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/fzf.nix | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 modules/programs/fzf.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c9edc879823..a0718b190d2 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -580,6 +580,13 @@ in A new module is available: 'services.unclutter' ''; } + + { + time = "2018-03-07T21:38:27+00:00"; + message = '' + A new module is available: 'programs.fzf'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index de5749ff7c4..eca0678d404 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -30,6 +30,7 @@ let ./programs/emacs.nix ./programs/feh.nix ./programs/firefox.nix + ./programs/fzf.nix ./programs/git.nix ./programs/gnome-terminal.nix ./programs/home-manager.nix diff --git a/modules/programs/fzf.nix b/modules/programs/fzf.nix new file mode 100644 index 00000000000..7949f7f8f16 --- /dev/null +++ b/modules/programs/fzf.nix @@ -0,0 +1,78 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.fzf; + +in + +{ + options.programs.fzf = { + enable = mkEnableOption "fzf - a command-line fuzzy finder"; + + defaultOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--height 40%" "--border" ]; + description = '' + Extra command line options given to fzf by default. + ''; + }; + + fileWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--preview 'head {}'" ]; + description = '' + Command line options for the CTRL-T keybinding. + ''; + }; + + changeDirWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--preview 'tree -C {} | head -200'" ]; + description = '' + Command line options for the ALT-C keybinding. + ''; + }; + + historyWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--sort" "--exact" ]; + description = '' + Command line options for the CTRL-R keybinding. + ''; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.fzf ]; + + home.sessionVariables = + mapAttrs (n: v: toString v) ( + filterAttrs (n: v: v != []) { + FZF_ALT_C_OPTS = cfg.changeDirWidgetOptions; + FZF_CTRL_R_OPTS = cfg.historyWidgetOptions; + FZF_CTRL_T_OPTS = cfg.fileWidgetOptions; + FZF_DEFAULT_OPTS = cfg.defaultOptions; + } + ); + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + . ${pkgs.fzf}/share/fzf/completion.bash + . ${pkgs.fzf}/share/fzf/key-bindings.bash + ''; + }; +} -- cgit v1.2.3 From 567b21b1d627b1c35f43a61ed57946b9ac5be5d5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 13 Mar 2018 20:49:45 +0100 Subject: activation-init: sanity check oldGenNum and oldGenPath Something is terribly wrong if one is set but not the other so error out with a message if that happens. --- modules/lib-bash/activation-init.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index b5472504ce9..5cdb66e5920 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -11,27 +11,38 @@ function setupVars() { | sort -rn \ | head -1) - if [[ -n "$greatestGenNum" ]] ; then + if [[ -n $greatestGenNum ]] ; then oldGenNum=$greatestGenNum newGenNum=$((oldGenNum + 1)) else newGenNum=1 fi - if [[ -e "$gcPath/current-home" ]] ; then + if [[ -e $gcPath/current-home ]] ; then oldGenPath="$(readlink -e "$gcPath/current-home")" fi + $VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath" + if [[ -v oldGenNum && ! -v oldGenPath + || ! -v oldGenNum && -v oldGenPath ]]; then + errorEcho "Invalid profile number and GC root values! These must be" + errorEcho "either both empty or both set but are now set to" + errorEcho " '${oldGenNum:-}' and '${oldGenPath:-}'" + errorEcho "If you don't mind losing previous profile generations then" + errorEcho "the easiest solution is probably to run" + errorEcho " rm $profilesPath/home-manager*" + errorEcho " rm $gcPath/current-home" + errorEcho "and trying home-manager switch again. Good luck!" + exit 1 + fi + + genProfilePath="$profilesPath/home-manager" newGenPath="@GENERATION_DIR@"; newGenProfilePath="$profilesPath/home-manager-$newGenNum-link" newGenGcPath="$gcPath/current-home" } -setupVars - -echo "Starting home manager activation" - if [[ -v VERBOSE ]]; then export VERBOSE_ECHO=echo export VERBOSE_ARG="--verbose" @@ -40,6 +51,10 @@ else export VERBOSE_ARG="" fi +echo "Starting home manager activation" + +setupVars + if [[ -v DRY_RUN ]] ; then echo "This is a dry run" export DRY_RUN_CMD=echo -- cgit v1.2.3 From 9bf9e7ac5c60ba442f4f0dbc3fea27c09a999ab3 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sun, 11 Mar 2018 22:46:41 +0100 Subject: gpg-agent: add `enableExtraSocket` and `verbose` options. This option enables a GPG Agent restricted socket (aka "extra-socket"), which can be used to forward GPG Agent over SSH. Additionally `verbose` option enables verbose output of an `gpg-agent.service` unit for easier debugging. See: https://wiki.gnupg.org/AgentForwarding --- modules/services/gpg-agent.nix | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index ea96312f34a..aa2ecdb7eb7 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -48,6 +48,23 @@ in ''; }; + enableExtraSocket = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable extra socket of the GnuPG key agent (useful for GPG + Agent forwarding). + ''; + }; + + verbose = mkOption { + type = types.bool; + default = false; + description = '' + Whether to produce verbose output. + ''; + }; + grabKeyboardAndMouse = mkOption { type = types.bool; default = true; @@ -115,7 +132,8 @@ in }; Service = { - ExecStart = "${pkgs.gnupg}/bin/gpg-agent --supervised"; + ExecStart = "${pkgs.gnupg}/bin/gpg-agent --supervised" + + optionalString cfg.verbose " --verbose"; ExecReload = "${pkgs.gnupg}/bin/gpgconf --reload gpg-agent"; }; }; @@ -159,5 +177,26 @@ in }; }; }) + + (mkIf cfg.enableExtraSocket { + systemd.user.sockets.gpg-agent-extra = { + Unit = { + Description = "GnuPG cryptographic agent and passphrase cache (restricted)"; + Documentation = "man:gpg-agent(1) man:ssh(1)"; + }; + + Socket = { + ListenStream = "%t/gnupg/S.gpg-agent.extra"; + FileDescriptorName = "extra"; + Service = "gpg-agent.service"; + SocketMode = "0600"; + DirectoryMode = "0700"; + }; + + Install = { + WantedBy = [ "sockets.target" ]; + }; + }; + }) ]); } -- cgit v1.2.3 From f8398339a3d45dd8509c0f3fb5bd1403ea560d71 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Mon, 12 Mar 2018 23:29:46 +0100 Subject: fzf: add `enableZshIntegration` option When enabled this will extend user's `$HOME/.zshrc` with sourcing of fzf's completion and key-bindings integration libraries. --- modules/programs/fzf.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/programs/fzf.nix b/modules/programs/fzf.nix index 7949f7f8f16..2085d9e5248 100644 --- a/modules/programs/fzf.nix +++ b/modules/programs/fzf.nix @@ -55,6 +55,14 @@ in Whether to enable Bash integration. ''; }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; }; config = mkIf cfg.enable { @@ -74,5 +82,10 @@ in . ${pkgs.fzf}/share/fzf/completion.bash . ${pkgs.fzf}/share/fzf/key-bindings.bash ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + . ${pkgs.fzf}/share/fzf/completion.zsh + . ${pkgs.fzf}/share/fzf/key-bindings.zsh + ''; }; } -- cgit v1.2.3 From 75c40753457431d0a0a9cbe143ce52959c8c7133 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 17 Mar 2018 17:08:41 +0100 Subject: nixpkgs: expand description of nixpkgs.config and nixpkgs.overlays --- modules/misc/nixpkgs.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index d86e2fd1c07..23c79b0f442 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -61,10 +61,28 @@ in The configuration of the Nix Packages collection. (For details, see the Nixpkgs documentation.) It allows you to set package configuration options. + + If null, then configuration is taken from the fallback location, for example, ~/.config/nixpkgs/config.nix. + + + + Note, this option will not apply outside your Home Manager + configuration like when installing manually through + nix-env. If you want to apply it both + inside and outside Home Manager you can put it in a separate + file and include something like + + + nixpkgs.config = import ./nixpkgs-config.nix; + xdg.configFile."nixpkgs/config.nix".source = + ./nixpkgs-config.nix; + + + in your Home Manager configuration. ''; }; @@ -89,10 +107,19 @@ in an argument the original Nixpkgs. The first argument should be used for finding dependencies, and the second should be used for overriding recipes. + + If null, then the overlays are taken from the fallback location, for example, ~/.config/nixpkgs/overlays. + + + + Like nixpkgs.config this option only + applies within the Home Manager configuration. See + nixpkgs.config for a suggested setup that + works both internally and externally. ''; }; -- cgit v1.2.3 From 4205c91609d6309ebbcddfa675fc63937718c14b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 23 Mar 2018 19:32:02 +0100 Subject: ssh: move options to end of configuration file This is needed to support overriding these options inside match blocks. A new option `programs.ssh.extraOptionOverrides` has been added to allow global overrides. --- modules/misc/news.nix | 18 ++++++++++++++++++ modules/programs/ssh.nix | 35 ++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a0718b190d2..e903669ed6b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -587,6 +587,24 @@ in A new module is available: 'programs.fzf'. ''; } + + { + time = "2018-03-25T06:49:57+00:00"; + condition = with config.programs.ssh; enable && matchBlocks != {}; + message = '' + Options set through the 'programs.ssh' module are now placed + at the end of the SSH configuration file. This was done to + make it possible to override global options such as + 'ForwardAgent' or 'Compression' inside a host match block. + + If you truly need to override an SSH option across all match + blocks then the new option + + programs.ssh.extraOptionOverrides + + can be used. + ''; + } ]; }; } diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 4c68ebf8b34..c62f37eb65c 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -220,9 +220,18 @@ in ''; }; + extraOptionOverrides = mkOption { + type = types.attrsOf types.str; + default = {}; + description = '' + Extra SSH configuration options that take precedence over any + host specific configuration. + ''; + }; + matchBlocks = mkOption { type = types.loaOf matchBlockModule; - default = []; + default = {}; example = literalExample '' { "john.example.com" = { @@ -248,20 +257,24 @@ in config = mkIf cfg.enable { home.file.".ssh/config".text = '' - ForwardAgent ${yn cfg.forwardAgent} - Compression ${yn cfg.compression} - ServerAliveInterval ${toString cfg.serverAliveInterval} - HashKnownHosts ${yn cfg.hashKnownHosts} - UserKnownHostsFile ${cfg.userKnownHostsFile} - ControlMaster ${cfg.controlMaster} - ControlPath ${cfg.controlPath} - ControlPersist ${cfg.controlPersist} - - ${cfg.extraConfig} + ${concatStringsSep "\n" ( + mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)} ${concatStringsSep "\n\n" ( map matchBlockStr ( builtins.attrValues cfg.matchBlocks))} + + Host * + ForwardAgent ${yn cfg.forwardAgent} + Compression ${yn cfg.compression} + ServerAliveInterval ${toString cfg.serverAliveInterval} + HashKnownHosts ${yn cfg.hashKnownHosts} + UserKnownHostsFile ${cfg.userKnownHostsFile} + ControlMaster ${cfg.controlMaster} + ControlPath ${cfg.controlPath} + ControlPersist ${cfg.controlPersist} + + ${replaceStrings ["\n"] ["\n "] cfg.extraConfig} ''; }; } -- cgit v1.2.3 From 7c9278bd92a067832c421e79f25401a9791aaddd Mon Sep 17 00:00:00 2001 From: Lenz Weber Date: Sun, 25 Mar 2018 14:59:05 +0200 Subject: xresources: add option extraConfig --- modules/xresources.nix | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index 8608438065f..634314f3ae9 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -28,17 +28,40 @@ in "Emacs*toolBar" = 0; }; description = '' - X server resources that should be set. If null, - then this feature is disabled and no + X server resources that should be set. + If this and all other xresources options are + null, then this feature is disabled and no + ~/.Xresources link is produced. + ''; + }; + + xresources.extraConfig = mkOption { + type = types.lines; + default = ""; + example = literalExample '' + builtins.readFile ( + pkgs.fetchFromGitHub { + owner = "solarized"; + repo = "xresources"; + rev = "025ceddbddf55f2eb4ab40b05889148aab9699fc"; + sha256 = "0lxv37gmh38y9d3l8nbnsm1mskcv10g3i83j0kac0a2qmypv1k9f"; + } + "/Xresources.dark" + ) + ''; + description = '' + Additional X server resources contents. + If this and all other xresources options are + null, then this feature is disabled and no ~/.Xresources link is produced. ''; }; }; - config = mkIf (cfg.properties != null) { + config = mkIf (cfg.properties != null || cfg.extraConfig != "") { home.file.".Xresources".text = - concatStringsSep "\n" ( - mapAttrsToList formatLine cfg.properties + concatStringsSep "\n" ([] + ++ (optional (cfg.extraConfig != "") cfg.extraConfig) + ++ (optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) ) + "\n"; }; } -- cgit v1.2.3 From 96250b7ad3515620f21c6df5f25137cbb80ecd1c Mon Sep 17 00:00:00 2001 From: Guthrie McAfee Armstrong Date: Sun, 15 Apr 2018 15:48:08 -0400 Subject: Fix typo: compton.shadowOffsets description --- modules/services/compton.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index f425db8ab06..54a29dc2120 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -94,7 +94,7 @@ in { default = [ (-15) (-15) ]; example = [ (-10) (-15) ]; description = '' - Left and right offset for shadows (in pixels). + Horizontal and vertical offsets for shadows (in pixels). ''; }; -- cgit v1.2.3 From 5bdebf5ab045a07450f64e18f4c19c416a6611e1 Mon Sep 17 00:00:00 2001 From: Anton Plotnikov Date: Sun, 15 Apr 2018 05:06:44 +0300 Subject: Add opacity-rules to compton --- modules/services/compton.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index 54a29dc2120..d4ac549c902 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -29,6 +29,7 @@ let active-opacity = ${cfg.activeOpacity}; inactive-opacity = ${cfg.inactiveOpacity}; menu-opacity = ${cfg.menuOpacity}; + opacity-rule = ${toJSON cfg.opacityRule}; # other options backend = ${toJSON cfg.backend}; @@ -148,6 +149,19 @@ in { ''; }; + opacityRule = mkOption { + type = types.listOf types.str; + default = []; + example = [ + "87:class_i ?= 'scratchpad'" + "91:class_i ?= 'xterm'" + ]; + description = '' + List of opacity rules. + See compton(1) man page for more examples. + ''; + }; + backend = mkOption { type = types.str; default = "glx"; -- cgit v1.2.3 From 8ff7d934b2dc83aa3c37b9846f515691ff5e1fce Mon Sep 17 00:00:00 2001 From: Anton Plotnikov Date: Sun, 15 Apr 2018 05:19:37 +0300 Subject: Add blur options to compton --- modules/services/compton.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index d4ac549c902..b6e85f041a5 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -24,7 +24,15 @@ let shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; shadow-opacity = ${cfg.shadowOpacity}; shadow-exclude = ${toJSON cfg.shadowExclude}; + '' + + optionalString cfg.blur '' + + # blur + blur-background = true; + blur-background-exclude = ${toJSON cfg.blurExclude}; + no-dock-blur = ${toString cfg.noDockBlur}; '' + '' + # opacity active-opacity = ${cfg.activeOpacity}; inactive-opacity = ${cfg.inactiveOpacity}; @@ -42,6 +50,35 @@ in { options.services.compton = { enable = mkEnableOption "Compton X11 compositor"; + blur = mkOption { + type = types.bool; + default = false; + description = '' + Enable background blur on transparent windows. + ''; + }; + + noDockBlur = mkOption { + type = types.bool; + default = false; + description = '' + Avoid blur on docks. + ''; + }; + + blurExclude = mkOption { + type = types.listOf types.str; + default = []; + example = [ + "class_g = 'slop'" + "class_i = 'polybar'" + ]; + description = '' + List of windows to exclude background blur. + See compton(1) man page for more examples. + ''; + }; + fade = mkOption { type = types.bool; default = false; -- cgit v1.2.3 From 581ad6fc29acc268a4b67ccffb7d0a89f45336f7 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Tue, 17 Apr 2018 13:02:52 -0700 Subject: kbfs: fix systemd service PATH --- modules/services/kbfs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/kbfs.nix b/modules/services/kbfs.nix index 15d24596077..863f4feea3b 100644 --- a/modules/services/kbfs.nix +++ b/modules/services/kbfs.nix @@ -48,7 +48,7 @@ in let mountPoint = "\"%h/${cfg.mountPoint}\""; in { - Environment = "PATH=/run/wrappers KEYBASE_SYSTEMD=1"; + Environment = "PATH=/run/wrappers/bin KEYBASE_SYSTEMD=1"; ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${mountPoint}"; ExecStart ="${pkgs.kbfs}/bin/kbfsfuse ${toString cfg.extraFlags} ${mountPoint}"; ExecStopPost = "/run/wrappers/bin/fusermount -u ${mountPoint}"; -- cgit v1.2.3 From f314ee3d6aebf7fe6ef20486634c67c4136812ff Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 9 Apr 2018 15:04:43 +0200 Subject: autorandr: add module --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/autorandr.nix | 230 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100644 modules/programs/autorandr.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e903669ed6b..04669b13e44 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -605,6 +605,13 @@ in can be used. ''; } + + { + time = "2018-04-19T07:42:01+00:00"; + message = '' + A new module is available: 'programs.autorandr'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index eca0678d404..ff48a43502e 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -22,6 +22,7 @@ let ./misc/nixpkgs.nix ./misc/pam.nix ./misc/xdg.nix + ./programs/autorandr.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix new file mode 100644 index 00000000000..b97b604527f --- /dev/null +++ b/modules/programs/autorandr.nix @@ -0,0 +1,230 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.autorandr; + + profileModule = types.submodule { + options = { + fingerprint = mkOption { + type = types.attrsOf types.string; + description = '' + Output name to EDID mapping. + Use autorandr --fingerprint to get current setup values. + ''; + default = {}; + }; + + config = mkOption { + type = types.attrsOf configModule; + description = "Per output profile configuration."; + default = {}; + }; + + hooks = mkOption { + type = profileHooksModule; + description = "Profile hook scripts."; + default = {}; + }; + }; + }; + + configModule = types.submodule { + options = { + enable = mkOption { + type = types.bool; + description = "Whether to enable the output."; + default = true; + }; + + primary = mkOption { + type = types.bool; + description = "Whether output should be marked as primary"; + default = false; + }; + + position = mkOption { + type = types.string; + description = "Output position"; + default = ""; + example = "5760x0"; + }; + + mode = mkOption { + type = types.string; + description = "Output resolution."; + default = ""; + example = "3840x2160"; + }; + + rate = mkOption { + type = types.string; + description = "Output framerate."; + default = ""; + example = "60.00"; + }; + + gamma = mkOption { + type = types.string; + description = "Output gamma configuration."; + default = ""; + example = "1.0:0.909:0.833"; + }; + }; + }; + + hookType = types.lines; + + globalHooksModule = types.submodule { + options = { + postswitch = mkOption { + type = types.attrsOf hookType; + description = "Postswitch hook executed after mode switch."; + default = {}; + }; + + preswitch = mkOption { + type = types.attrsOf hookType; + description = "Preswitch hook executed before mode switch."; + default = {}; + }; + + predetect = mkOption { + type = types.attrsOf hookType; + description = "Predetect hook executed before autorandr attempts to run xrandr."; + default = {}; + }; + }; + }; + + profileHooksModule = types.submodule { + options = { + postswitch = mkOption { + type = hookType; + description = "Postswitch hook executed after mode switch."; + default = ""; + }; + + preswitch = mkOption { + type = hookType; + description = "Preswitch hook executed before mode switch."; + default = ""; + }; + + predetect = mkOption { + type = hookType; + description = "Predetect hook executed before autorandr attempts to run xrandr."; + default = ""; + }; + }; + }; + + hookToFile = folder: name: hook: + nameValuePair + "autorandr/${folder}/${name}" + { source = "${pkgs.writeShellScriptBin "hook" hook}/bin/hook"; }; + profileToFiles = name: profile: with profile; mkMerge ([ + { + "autorandr/${name}/setup".text = concatStringsSep "\n" (mapAttrsToList fingerprintToString fingerprint); + "autorandr/${name}/config".text = concatStringsSep "\n" (mapAttrsToList configToString profile.config); + } + (mkIf (hooks.postswitch != "") (listToAttrs [ (hookToFile name "postswitch" hooks.postswitch) ])) + (mkIf (hooks.preswitch != "") (listToAttrs [ (hookToFile name "preswitch" hooks.preswitch) ])) + (mkIf (hooks.predetect != "") (listToAttrs [ (hookToFile name "predetect" hooks.predetect) ])) + ]); + fingerprintToString = name: edid: "${name} ${edid}"; + configToString = name: config: if config.enable then '' + output ${name} + ${optionalString (config.position != "") "pos ${config.position}"} + ${optionalString config.primary "primary"} + ${optionalString (config.gamma != "") "gamma ${config.gamma}"} + ${optionalString (config.mode != "") "mode ${config.mode}"} + ${optionalString (config.rate != "") "rate ${config.rate}"} + '' else '' + output ${name} + off + ''; + +in + +{ + options = { + programs.autorandr = { + enable = mkEnableOption "Autorandr"; + + hooks = mkOption { + type = globalHooksModule; + description = "Global hook scripts"; + default = {}; + example = literalExample '' + { + postswitch = { + "notify-i3" = "''${pkgs.i3}/bin/i3-msg restart"; + "change-background" = readFile ./change-background.sh; + "change-dpi" = ''' + case "$AUTORANDR_CURRENT_PROFILE" in + default) + DPI=120 + ;; + home) + DPI=192 + ;; + work) + DPI=144 + ;; + *) + echo "Unknown profle: $AUTORANDR_CURRENT_PROFILE" + exit 1 + esac + + echo "Xft.dpi: $DPI" | ''${pkgs.xorg.xrdb}/bin/xrdb -merge + ''' + }; + } + ''; + }; + + profiles = mkOption { + type = types.attrsOf profileModule; + description = "Autorandr profiles specification."; + default = {}; + example = literalExample '' + { + "work" = { + fingerprint = { + eDP1 = ""; + DP1 = ""; + }; + config = { + eDP1.enable = false; + DP1 = { + enable = true; + primary = true; + position = "0x0"; + mode = "3840x2160"; + gamma = "1.0:0.909:0.833"; + rate = "60.00"; + }; + }; + hooks.postswitch = readFile ./work-postswitch.sh; + }; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.autorandr ]; + xdg.configFile = mkMerge ([ + (mapAttrs' (hookToFile "postswitch.d") cfg.hooks.postswitch) + (mapAttrs' (hookToFile "preswitch.d") cfg.hooks.preswitch) + (mapAttrs' (hookToFile "predetect.d") cfg.hooks.predetect) + (mkMerge (mapAttrsToList profileToFiles cfg.profiles)) + ]); + }; + + meta.maintainers = [ maintainers.uvnikita ]; +} -- cgit v1.2.3 From d294aa4356f382f9905a0ae39f7c66b000acba89 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 16 Apr 2018 22:12:53 +0200 Subject: zsh: only source plugin file if it exists This allows adding plugins to fpath without sourcing anything --- modules/programs/zsh.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index d1371159fa3..c07e8a74c0f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -320,7 +320,9 @@ in ''} ${concatStrings (map (plugin: '' - source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" + if [ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]; then + source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" + fi '') cfg.plugins)} # History options should be set in .zshrc and after oh-my-zsh sourcing. -- cgit v1.2.3 From 6dc4f31ba13215823c4641907b48825971a516e1 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Wed, 18 Apr 2018 14:41:20 -0700 Subject: git: add 'includes' option --- modules/misc/news.nix | 22 ++++++++++++++++++++++ modules/programs/git.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 04669b13e44..af122a23dfc 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -612,6 +612,28 @@ in A new module is available: 'programs.autorandr'. ''; } + + { + time = "2018-04-19T15:44:55+00:00"; + condition = config.programs.git.enable; + message = '' + A new option 'programs.git.includes' is available. Additional + Git configuration files may be included via + + programs.git.includes = [ + { path = "~/path/to/config.inc"; } + ]; + + or conditionally via + + programs.git.includes = [ + { path = "~/path/to/config.inc"; condition = "gitdir:~/src/"; } + ]; + + and the corresponding '[include]' or '[includeIf]' sections will be + appended to the main Git configuration file. + ''; + } ]; }; } diff --git a/modules/programs/git.nix b/modules/programs/git.nix index ed43e53e407..e8018dc185e 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -28,6 +28,28 @@ let }; }; + includeModule = types.submodule { + options = { + condition = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Include this configuration only when condition + matches. Allowed conditions are described in + + git-config + 1 + . + ''; + }; + + path = mkOption { + type = types.str; + description = "Path of the configuration file to include."; + }; + }; + }; + in { @@ -83,6 +105,21 @@ in example = [ "*~" "*.swp" ]; description = "List of paths that should be globally ignored."; }; + + includes = mkOption { + type = types.listOf includeModule; + default = []; + example = literalExample '' + [ + { path = "~/path/to/config.inc"; } + { + path = "~/path/to/conditional.inc"; + condition = "gitdir:~/src/dir"; + } + ] + ''; + description = "List of configuration files to include."; + }; }; }; @@ -124,6 +161,16 @@ in (mkIf (lib.isString cfg.extraConfig) { xdg.configFile."git/config".text = cfg.extraConfig; }) + + (mkIf (cfg.includes != []) { + xdg.configFile."git/config".text = mkAfter + (concatMapStringsSep "\n" + (i: with i; '' + [${if (condition == null) then "include" else "includeIf \"${condition}\""}] + path = ${path} + '') + cfg.includes); + }) ] ); } -- cgit v1.2.3 From 9141d11a7d8f2293d52aa6eed840afe18b998a3e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 19 Apr 2018 18:29:04 +0200 Subject: readme: update stable NixOS version to 18.03 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e19c1c9a55..b7c55510479 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwrite was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] unstable and NixOS version 17.09 (the +Home Manager targets [NixOS][] unstable and NixOS version 18.03 (the current stable version), it may or may not work on other Linux distributions and NixOS versions. @@ -64,10 +64,10 @@ Currently the easiest way to install Home Manager is as follows: or ```console - $ HM_PATH=https://github.com/rycee/home-manager/archive/release-17.09.tar.gz + $ HM_PATH=https://github.com/rycee/home-manager/archive/release-18.03.tar.gz ``` - depending on whether you follow Nixpkgs unstable or version 17.09. + depending on whether you follow Nixpkgs unstable or version 18.03. 3. Create an initial Home Manager configuration file: -- cgit v1.2.3 From 9a3b1ec222ab2c2b947833ba008db85a94582ac7 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 29 Apr 2018 15:58:42 +0200 Subject: screen-locker: Add extraOptions for xss-lock and xautolock --- modules/services/screen-locker.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/services/screen-locker.nix b/modules/services/screen-locker.nix index 291416564b9..844075eee44 100644 --- a/modules/services/screen-locker.nix +++ b/modules/services/screen-locker.nix @@ -26,6 +26,23 @@ in { See . ''; }; + + xautolockExtraOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command-line arguments to pass to xautolock. + ''; + }; + + xssLockExtraOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command-line arguments to pass to xss-lock. + ''; + }; + }; config = mkIf cfg.enable { @@ -45,7 +62,8 @@ in { ${pkgs.xautolock}/bin/xautolock \ -detectsleep \ -time ${toString cfg.inactiveInterval} \ - -locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID' + -locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID' \ + ${concatStringsSep " " cfg.xautolockExtraOptions} ''; }; }; @@ -53,7 +71,7 @@ in { # xss-lock will run specified screen locker when the session is locked via loginctl # can't be started as a systemd service, # see https://bitbucket.org/raymonad/xss-lock/issues/13/allow-operation-as-systemd-user-unit - xsession.initExtra = "${pkgs.xss-lock}/bin/xss-lock -- ${cfg.lockCmd} &"; + xsession.initExtra = "${pkgs.xss-lock}/bin/xss-lock ${concatStringsSep " " cfg.xssLockExtraOptions} -- ${cfg.lockCmd} &"; }; } -- cgit v1.2.3 From f26cc3b957ef77374f8b5275c1fc62217d13c6e3 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 26 Apr 2018 14:36:09 -0700 Subject: mbsync: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/services/mbsync.nix | 111 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 modules/services/mbsync.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index af122a23dfc..1ece1114a7f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -634,6 +634,13 @@ in appended to the main Git configuration file. ''; } + + { + time = "2018-05-01T20:49:31+00:00"; + message = '' + A new module is available: 'services.mbsync'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index ff48a43502e..897fd6a1ef1 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -56,6 +56,7 @@ let ./services/kbfs.nix ./services/keepassx.nix ./services/keybase.nix + ./services/mbsync.nix ./services/network-manager-applet.nix ./services/owncloud-client.nix ./services/parcellite.nix diff --git a/modules/services/mbsync.nix b/modules/services/mbsync.nix new file mode 100644 index 00000000000..a14e252371c --- /dev/null +++ b/modules/services/mbsync.nix @@ -0,0 +1,111 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.mbsync; + + mbsyncOptions = + [ "--all" + ] ++ optional (cfg.verbose) "--verbose" + ++ optional (cfg.configFile != null) "--config ${cfg.configFile}"; + +in + +{ + meta.maintainers = [ maintainers.pjones ]; + + options.services.mbsync = { + enable = mkEnableOption "mbsync"; + + package = mkOption { + type = types.package; + default = pkgs.isync; + defaultText = "pkgs.isync"; + example = literalExample "pkgs.isync"; + description = "The package to use for the mbsync binary."; + }; + + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to run mbsync. This value is passed to the systemd + timer configuration as the onCalendar option. See + + systemd.time + 7 + + for more information about the format. + ''; + }; + + verbose = mkOption { + type = types.bool; + default = true; + description = '' + Whether mbsync should produce verbose output. + ''; + }; + + configFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Optional configuration file to link to use instead of + the default file (~/.mbsyncrc). + ''; + }; + + preExec = mkOption { + type = types.nullOr types.str; + default = null; + example = "mkdir -p %h/mail"; + description = '' + An optional command to run before mbsync executes. This is + useful for creating the directories mbsync is going to use. + ''; + }; + + postExec = mkOption { + type = types.nullOr types.str; + default = null; + example = "mu index"; + description = '' + An optional command to run after mbsync executes successfully. + This is useful for running mailbox indexing tools. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.mbsync = { + Unit = { + Description = "mbsync mailbox synchronization"; + PartOf = [ "network-online.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/mbsync ${concatStringsSep " " mbsyncOptions}"; + } // (optionalAttrs (cfg.postExec != null) { ExecStartPost = cfg.postExec; }) + // (optionalAttrs (cfg.preExec != null) { ExecStartPre = cfg.preExec; }); + }; + + systemd.user.timers.mbsync = { + Unit = { + Description = "mbsync mailbox synchronization"; + }; + + Timer = { + OnCalendar = cfg.frequency; + Unit = "mbsync.service"; + }; + + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From e055e4a092e0920cc2f8dc7f6b665bf6dbba6a4b Mon Sep 17 00:00:00 2001 From: Hamish Hutchings Date: Thu, 3 May 2018 14:29:03 +0200 Subject: flameshot: add module --- modules/misc/news.nix | 6 ++++++ modules/modules.nix | 1 + modules/services/flameshot.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 modules/services/flameshot.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1ece1114a7f..99a7cb3e8d9 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -641,6 +641,12 @@ in A new module is available: 'services.mbsync'. ''; } + { + time = "2018-05-03T12:34:47+00:00"; + message = '' + A new module is available: 'services.flameshot'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 897fd6a1ef1..b36ad4f4ae7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -51,6 +51,7 @@ let ./services/blueman-applet.nix ./services/compton.nix ./services/dunst.nix + ./services/flameshot.nix ./services/gnome-keyring.nix ./services/gpg-agent.nix ./services/kbfs.nix diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix new file mode 100644 index 00000000000..d5e8309d96c --- /dev/null +++ b/modules/services/flameshot.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.flameshot; + package = pkgs.flameshot; + +in + +{ + meta.maintainers = [ maintainers.hamhut1066 ]; + + options = { + services.flameshot = { + enable = mkEnableOption "Flameshot"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ package ]; + + systemd.user.services.flameshot = { + Unit = { + Description = "Powerful yet simple to use screenshot software"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${package}/bin/flameshot"; + Restart = "on-abort"; + }; + }; + }; +} -- cgit v1.2.3 From 91725ddcedddc99054504953c87632e7d50cc7e8 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 4 May 2018 13:01:34 +0200 Subject: owncloud-client: fix startup Workaround for #249. --- modules/services/owncloud-client.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/owncloud-client.nix b/modules/services/owncloud-client.nix index e168ab11197..353e0136c08 100644 --- a/modules/services/owncloud-client.nix +++ b/modules/services/owncloud-client.nix @@ -18,6 +18,7 @@ with lib; }; Service = { + Environment = "PATH=%h/.nix-profile/bin"; ExecStart = "${pkgs.owncloud-client}/bin/owncloud"; }; -- cgit v1.2.3 From 74f4ed5fd25e5c698e97807c567141cccdd1d033 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 4 May 2018 13:08:08 +0200 Subject: syncthing: fix tray startup Workaround for #249. --- modules/services/syncthing.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 8d52943e1f1..11511725134 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -54,6 +54,7 @@ with lib; }; Service = { + Environment = "PATH=%h/.nix-profile/bin"; ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; }; -- cgit v1.2.3 From 12603493848be0e22369ade385cf0ba3567673f8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 6 May 2018 22:14:50 +0200 Subject: doc: make documentation independent from NixOS Unfortunately this duplicates some code from NixOS but it does allow much more flexibility and, hopefully, stability in the Home Manager documentation. Fixes #254. --- doc/default.nix | 329 ++++++++++++++++++++++++++++++++++++++++++++++ doc/man-configuration.xml | 34 +++++ doc/man-home-manager.xml | 62 +++++++++ doc/man-pages.xml | 16 +++ doc/manual.xml | 40 ++++++ modules/manual.nix | 26 +--- 6 files changed, 485 insertions(+), 22 deletions(-) create mode 100644 doc/default.nix create mode 100644 doc/man-configuration.xml create mode 100644 doc/man-home-manager.xml create mode 100644 doc/man-pages.xml create mode 100644 doc/manual.xml diff --git a/doc/default.nix b/doc/default.nix new file mode 100644 index 00000000000..8b995c5a688 --- /dev/null +++ b/doc/default.nix @@ -0,0 +1,329 @@ +{ pkgs, options, config, version, revision, extraSources ? [] }: + +with pkgs; + +let + lib = pkgs.lib; + + # Remove invisible and internal options. + optionsListVisible = lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList options); + + # Replace functions by the string + substFunction = x: + if builtins.isAttrs x then lib.mapAttrs (name: substFunction) x + else if builtins.isList x then map substFunction x + else if lib.isFunction x then "" + else x; + + # Generate DocBook documentation for a list of packages. This is + # what `relatedPackages` option of `mkOption` from + # ../../../lib/options.nix influences. + # + # Each element of `relatedPackages` can be either + # - a string: that will be interpreted as an attribute name from `pkgs`, + # - a list: that will be interpreted as an attribute path from `pkgs`, + # - an attrset: that can specify `name`, `path`, `package`, `comment` + # (either of `name`, `path` is required, the rest are optional). + genRelatedPackages = packages: + let + unpack = p: if lib.isString p then { name = p; } + else if lib.isList p then { path = p; } + else p; + describe = args: + let + name = args.name or (lib.concatStringsSep "." args.path); + path = args.path or [ args.name ]; + package = args.package or (lib.attrByPath path (throw "Invalid package attribute path `${toString path}'") pkgs); + in "" + + "pkgs.${name} (${package.meta.name})" + + lib.optionalString (!package.meta.available) " [UNAVAILABLE]" + + ": ${package.meta.description or "???"}." + + lib.optionalString (args ? comment) "\n${args.comment}" + # Lots of `longDescription's break DocBook, so we just wrap them into + + lib.optionalString (package.meta ? longDescription) "\n${package.meta.longDescription}" + + ""; + in "${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}"; + + optionsListDesc = lib.flip map optionsListVisible (opt: opt // { + # Clean up declaration sites to not refer to the NixOS source tree. + declarations = map stripAnyPrefixes opt.declarations; + } + // lib.optionalAttrs (opt ? example) { example = substFunction opt.example; } + // lib.optionalAttrs (opt ? default) { default = substFunction opt.default; } + // lib.optionalAttrs (opt ? type) { type = substFunction opt.type; } + // lib.optionalAttrs (opt ? relatedPackages) { relatedPackages = genRelatedPackages opt.relatedPackages; }); + + # We need to strip references to /nix/store/* from options, + # including any `extraSources` if some modules came from elsewhere, + # or else the build will fail. + # + # E.g. if some `options` came from modules in ${pkgs.customModules}/nix, + # you'd need to include `extraSources = [ pkgs.customModules ]` + prefixesToStrip = map (p: "${toString p}/") ([ ../../.. ] ++ extraSources); + stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip; + + # Custom "less" that pushes up all the things ending in ".enable*" + # and ".package*" + optionLess = a: b: + let + ise = lib.hasPrefix "enable"; + isp = lib.hasPrefix "package"; + cmp = lib.splitByAndCompare ise lib.compare + (lib.splitByAndCompare isp lib.compare lib.compare); + in lib.compareLists cmp a.loc b.loc < 0; + + # Customly sort option list for the man page. + optionsList = lib.sort optionLess optionsListDesc; + + # Convert the list of options into an XML file. + optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList); + + optionsDocBook = runCommand "options-db.xml" {} '' + optionsXML=${optionsXML} + if grep /home--manager/modules $optionsXML; then + echo "The manual appears to depend on the location of Home Manager, which is bad" + echo "since this prevents sharing via the NixOS channel. This is typically" + echo "caused by an option default that refers to a relative path (see above" + echo "for hints about the offending path)." + exit 1 + fi + ${buildPackages.libxslt.bin}/bin/xsltproc \ + --stringparam revision '${revision}' \ + -o $out ${} $optionsXML + ''; + + sources = lib.sourceFilesBySuffices ./. [".xml"]; + + modulesDoc = builtins.toFile "modules.xml" '' +
+ ${(lib.concatMapStrings (path: '' + + '') (lib.catAttrs "value" config.meta.doc))} +
+ ''; + + generatedSources = runCommand "generated-docbook" {} '' + mkdir $out + ln -s ${modulesDoc} $out/modules.xml + ln -s ${optionsDocBook} $out/options-db.xml + printf "%s" "${version}" > $out/version + ''; + + copySources = + '' + cp -prd $sources/* . # */ + ln -s ${generatedSources} ./generated + chmod -R u+w . + ''; + + toc = builtins.toFile "toc.xml" + '' + + + + + + ''; + + manualXsltprocOptions = toString [ + "--param section.autolabel 1" + "--param section.label.includes.component.label 1" + "--stringparam html.stylesheet 'style.css overrides.css highlightjs/mono-blue.css'" + "--stringparam html.script './highlightjs/highlight.pack.js ./highlightjs/loader.js'" + "--param xref.with.number.and.title 1" + "--param toc.section.depth 3" + "--stringparam admon.style ''" + "--stringparam callout.graphics.extension .svg" + "--stringparam current.docid manual" + "--param chunk.section.depth 0" + "--param chunk.first.sections 1" + "--param use.id.as.filename 1" + "--stringparam generate.toc 'book toc appendix toc'" + "--stringparam chunk.toc ${toc}" + ]; + + manual-combined = runCommand "home-manager-manual-combined" + { inherit sources; + nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + meta.description = "The Home Manager manual as plain docbook XML"; + } + '' + ${copySources} + + xmllint --xinclude --output ./manual-combined.xml ./manual.xml + xmllint --xinclude --noxincludenode \ + --output ./man-pages-combined.xml ./man-pages.xml + + # outputs the context of an xmllint error output + # LEN lines around the failing line are printed + function context { + # length of context + local LEN=6 + # lines to print before error line + local BEFORE=4 + + # xmllint output lines are: + # file.xml:1234: there was an error on line 1234 + while IFS=':' read -r file line rest; do + echo + if [[ -n "$rest" ]]; then + echo "$file:$line:$rest" + local FROM=$(($line>$BEFORE ? $line - $BEFORE : 1)) + # number lines & filter context + nl --body-numbering=a "$file" | sed -n "$FROM,+$LEN p" + else + if [[ -n "$line" ]]; then + echo "$file:$line" + else + echo "$file" + fi + fi + done + } + + function lintrng { + xmllint --debug --noout --nonet \ + --relaxng ${docbook5}/xml/rng/docbook/docbook.rng \ + "$1" \ + 2>&1 | context 1>&2 + # ^ redirect assumes xmllint doesn’t print to stdout + } + + lintrng manual-combined.xml + lintrng man-pages-combined.xml + + mkdir $out + cp manual-combined.xml $out/ + cp man-pages-combined.xml $out/ + ''; + + olinkDB = runCommand "manual-olinkdb" + { inherit sources; + nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + } + '' + xsltproc \ + ${manualXsltprocOptions} \ + --stringparam collect.xref.targets only \ + --stringparam targets.filename "$out/manual.db" \ + --nonet \ + ${docbook5_xsl}/xml/xsl/docbook/xhtml/chunktoc.xsl \ + ${manual-combined}/manual-combined.xml + + cat > "$out/olinkdb.xml" < + + ]> + + + Allows for cross-referencing olinks between the manpages + and manual. + + + &manualtargets; + + EOF + ''; + +in rec { + inherit generatedSources; + + # The Home Manager options in JSON format. + optionsJSON = runCommand "options-json" + { meta.description = "List of Home Manager options in JSON format"; + } + '' + # Export list of options in different format. + dst=$out/share/doc/home-manager + mkdir -p $dst + + cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON + (builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList)))) + } $dst/options.json + + mkdir -p $out/nix-support + echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products + ''; # */ + + # Generate the Home Manager manual. + manual = runCommand "home-manager-manual" + { inherit sources; + nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + meta.description = "The Home Manager manual in HTML format"; + allowedReferences = ["out"]; + } + '' + # Generate the HTML manual. + dst=$out/share/doc/home-manager + mkdir -p $dst + xsltproc \ + ${manualXsltprocOptions} \ + --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ + --nonet --output $dst/ \ + ${docbook5_xsl}/xml/xsl/docbook/xhtml/chunktoc.xsl \ + ${manual-combined}/manual-combined.xml + + mkdir -p $dst/images/callouts + cp ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.svg $dst/images/callouts/ + + cp ${../../../doc/style.css} $dst/style.css + cp ${../../../doc/overrides.css} $dst/overrides.css + cp -r ${pkgs.documentation-highlighter} $dst/highlightjs + + mkdir -p $out/nix-support + echo "nix-build out $out" >> $out/nix-support/hydra-build-products + echo "doc manual $dst" >> $out/nix-support/hydra-build-products + ''; # */ + + + manualEpub = runCommand "home-manager-manual-epub" + { inherit sources; + buildInputs = [ libxml2.bin libxslt.bin zip ]; + } + '' + # Generate the epub manual. + dst=$out/share/doc/home-manager + + xsltproc \ + ${manualXsltprocOptions} \ + --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ + --nonet --xinclude --output $dst/epub/ \ + ${docbook5_xsl}/xml/xsl/docbook/epub/docbook.xsl \ + ${manual-combined}/manual-combined.xml + + mkdir -p $dst/epub/OEBPS/images/callouts + cp -r ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.svg $dst/epub/OEBPS/images/callouts # */ + echo "application/epub+zip" > mimetype + manual="$dst/home-manager-manual.epub" + zip -0Xq "$manual" mimetype + cd $dst/epub && zip -Xr9D "$manual" * + + rm -rf $dst/epub + + mkdir -p $out/nix-support + echo "doc-epub manual $manual" >> $out/nix-support/hydra-build-products + ''; + + + # Generate the Home Manager manpages. + manpages = runCommand "home-manager-manpages" + { inherit sources; + nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + allowedReferences = ["out"]; + } + '' + # Generate manpages. + mkdir -p $out/share/man + xsltproc --nonet \ + --param man.output.in.separate.dir 1 \ + --param man.output.base.dir "'$out/share/man/'" \ + --param man.endnotes.are.numbered 0 \ + --param man.break.after.slash 1 \ + --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ + ${docbook5_xsl}/xml/xsl/docbook/manpages/docbook.xsl \ + ${manual-combined}/man-pages-combined.xml + ''; + +} diff --git a/doc/man-configuration.xml b/doc/man-configuration.xml new file mode 100644 index 00000000000..c36cf619d33 --- /dev/null +++ b/doc/man-configuration.xml @@ -0,0 +1,34 @@ + + + home-configuration.nix + 5 + Home Manager + + + + + home-configuration.nix + Home Manager configuration specification + + + + Description + + The file ~/.config/nixpkgs/home.nix contains + the declarative specification of your Home Manager configuration. + The command home-manager takes this file and + realises the user environment configuration specified therein. + + + + + Options + + You can use the following options in + home-configuration.nix: + + + + diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml new file mode 100644 index 00000000000..79ae5b45713 --- /dev/null +++ b/doc/man-home-manager.xml @@ -0,0 +1,62 @@ + + + home-manager + 8 + Home Manager + + + + + home-manager + reconfigure a user environment + + + + + home-manager + + + + + + + + + + + + + + Description + + This command updates the user environment so that it corresponds to the configuration + specified in ~/.config/nixpkgs/home.nix. + + + + + Files + + + ~/.local/share/home-manager/news-read-ids + + + Identifiers of news items that have been shown. Can be deleted + to reset the read news indicator. + + + + + + + + Bugs + + Please report any bugs on the project + issue tracker. + + + diff --git a/doc/man-pages.xml b/doc/man-pages.xml new file mode 100644 index 00000000000..b94b01413b2 --- /dev/null +++ b/doc/man-pages.xml @@ -0,0 +1,16 @@ + + Home Manager Reference Pages + + + Home Manager contributors + Author + + + 2017-2018Home Manager contributors + + + + + diff --git a/doc/manual.xml b/doc/manual.xml new file mode 100644 index 00000000000..9998763606e --- /dev/null +++ b/doc/manual.xml @@ -0,0 +1,40 @@ + + + Home Manager Manual + + + Preface + + This manual will eventually describes how to install, use and + extend Home Manager. + + + If you encounter problems, please report them on the + nix-devel + mailing list or on the + #nixos channel on Freenode. Bugs should be + reported in + NixOS’ + GitHub issue tracker. + + + + Commands prefixed with # have to be run as root, either + requiring to login as root user or temporarily switching to it using + sudo for example. + + + + + Configuration Options + + + diff --git a/modules/manual.nix b/modules/manual.nix index 636b184c308..6ab612967b9 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -9,14 +9,14 @@ let It isn't perfect, but it seems to cover a vast majority of use cases. Caveat: even if the package is reached by a different means, the path above will be shown and not e.g. `${config.services.foo.package}`. */ - nixosManual = import { + homeManagerManual = import { inherit pkgs config; version = "0.1"; revision = "release-0.1"; options = let scrubbedEval = evalModules { - modules = [ { nixpkgs.system = pkgs.stdenv.system; } ] ++ baseModules; + modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ baseModules; args = (config._module.args) // { modules = [ ]; }; specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; }; }; @@ -32,14 +32,6 @@ let in scrubbedEval.options; }; - homeEnvironmentManPages = pkgs.runCommand "home-environment-manpages" { - allowedReferences = [ "out" ]; - } '' - install -v -D -m444 \ - ${nixosManual.manpages}/share/man/man5/configuration.nix.5 \ - $out/share/man/man5/home-configuration.nix.5 - ''; - in { @@ -60,22 +52,12 @@ in }; config = mkIf config.manual.manpages.enable { - home.packages = [ homeEnvironmentManPages ]; + home.packages = [ homeManagerManual.manpages ]; }; # To fix error during manpage build. meta = { maintainers = [ maintainers.rycee ]; - doc = builtins.toFile "nothingness" '' - - this is just to make the docs compile - - - - ''; + doc = builtins.toFile "nothingness" ""; }; } -- cgit v1.2.3 From f9af8e039008664ebac7f8f31231d5a226d67e36 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 7 May 2018 00:10:58 +0200 Subject: manual: fix import path Need to refer to the `default.nix` in the same home-manager source otherwise you might get an old version. --- modules/manual.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/manual.nix b/modules/manual.nix index 6ab612967b9..ae0ff1d9592 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -9,7 +9,7 @@ let It isn't perfect, but it seems to cover a vast majority of use cases. Caveat: even if the package is reached by a different means, the path above will be shown and not e.g. `${config.services.foo.package}`. */ - homeManagerManual = import { + homeManagerManual = import ../doc { inherit pkgs config; version = "0.1"; revision = "release-0.1"; -- cgit v1.2.3 From 394045f68acd83676a5f24d1ab056d504ff7ed69 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Wed, 9 May 2018 16:22:02 +0200 Subject: systemd: improve comments --- modules/systemd-activate.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb index 2708280a15c..517de40df4b 100644 --- a/modules/systemd-activate.rb +++ b/modules/systemd-activate.rb @@ -14,7 +14,7 @@ UnitsDir = 'home-files/.config/systemd/user' # that failed to start. This helps debugging quickly failing services. # # Whenever service failures are detected, show the output of -# 'systemd --home status' for the affected services. +# 'systemd --user status' for the affected services. # def setup_services(old_gen_path, new_gen_path, start_timeout_ms_string) start_timeout_ms = start_timeout_ms_string.to_i @@ -27,6 +27,7 @@ def setup_services(old_gen_path, new_gen_path, start_timeout_ms_string) exit if old_services.empty? && new_services.empty? + # These services should be running when this script is finished services_to_run = get_services_to_run(new_units_path) maybe_changed_services = services_to_run & old_services -- cgit v1.2.3 From 73b8aa8bcc0fef5fc46561a26591ee1761bc58e5 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Wed, 9 May 2018 15:22:34 +0200 Subject: systemd: merge unit definitions recursively This removes the need for monolithic unit definitions and allows users to modify existing units. Example: ``` { systemd.user.services.owncloud-client.Unit.OnFailure = "my-notify-service"; } ``` --- modules/systemd.nix | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index ce3c2c1bbd5..16939ad25bd 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -50,6 +50,10 @@ let servicesStartTimeoutMs = builtins.toString cfg.servicesStartTimeoutMs; + attrsRecursivelyMerged = types.attrs // { + merge = loc: foldl' (res: def: recursiveUpdate res def.value) {}; + }; + in { @@ -70,26 +74,38 @@ in services = mkOption { default = {}; - type = types.attrs; - description = "Definition of systemd per-user service units."; + type = attrsRecursivelyMerged; + description = '' + Definition of systemd per-user service units. Attributes are + merged recursively. + ''; }; sockets = mkOption { default = {}; - type = types.attrs; - description = "Definition of systemd per-user sockets"; + type = attrsRecursivelyMerged; + description = '' + Definition of systemd per-user sockets. Attributes are + merged recursively. + ''; }; targets = mkOption { default = {}; - type = types.attrs; - description = "Definition of systemd per-user targets"; + type = attrsRecursivelyMerged; + description = '' + Definition of systemd per-user targets. Attributes are + merged recursively. + ''; }; timers = mkOption { default = {}; - type = types.attrs; - description = "Definition of systemd per-user timers"; + type = attrsRecursivelyMerged; + description = '' + Definition of systemd per-user timers. Attributes are merged + recursively. + ''; }; startServices = mkOption { -- cgit v1.2.3 From 1a471b0a45ac15f1128f2f948b50da2677728164 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 5 May 2018 22:50:08 +0200 Subject: xcursor: add default cursor file option --- modules/xcursor.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/xcursor.nix b/modules/xcursor.nix index bb8af9b7833..171586028cd 100644 --- a/modules/xcursor.nix +++ b/modules/xcursor.nix @@ -26,6 +26,13 @@ let example = 64; description = "The cursor size."; }; + + defaultCursor = mkOption { + type = types.str; + default = "left_ptr"; + example = "X_cursor"; + description = "The default cursor file to use within the package."; + }; }; }; @@ -54,7 +61,7 @@ in home.packages = [cfg.package]; xsession.initExtra = '' - ${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cfg.package}/share/icons/${cfg.name}/cursors/X_cursor ${toString cfg.size} + ${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cfg.package}/share/icons/${cfg.name}/cursors/${cfg.defaultCursor} ${toString cfg.size} ''; xresources.properties = { -- cgit v1.2.3 From ec3cbf81c43805468a60d953ebe63b7c9d07ef11 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 11 May 2018 19:25:06 +0200 Subject: manual: some cleanups --- doc/default.nix | 30 +++-- doc/manual.xml | 19 +--- doc/options-to-docbook.xsl | 239 +++++++++++++++++++++++++++++++++++++++ doc/overrides.css | 9 ++ doc/style.css | 271 +++++++++++++++++++++++++++++++++++++++++++++ modules/manual.nix | 2 +- 6 files changed, 539 insertions(+), 31 deletions(-) create mode 100644 doc/options-to-docbook.xsl create mode 100644 doc/overrides.css create mode 100644 doc/style.css diff --git a/doc/default.nix b/doc/default.nix index 8b995c5a688..f55163d8aa3 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -59,7 +59,7 @@ let # # E.g. if some `options` came from modules in ${pkgs.customModules}/nix, # you'd need to include `extraSources = [ pkgs.customModules ]` - prefixesToStrip = map (p: "${toString p}/") ([ ../../.. ] ++ extraSources); + prefixesToStrip = map (p: "${toString p}/") ([ ./.. ] ++ extraSources); stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip; # Custom "less" that pushes up all the things ending in ".enable*" @@ -78,19 +78,17 @@ let # Convert the list of options into an XML file. optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList); - optionsDocBook = runCommand "options-db.xml" {} '' - optionsXML=${optionsXML} - if grep /home--manager/modules $optionsXML; then - echo "The manual appears to depend on the location of Home Manager, which is bad" - echo "since this prevents sharing via the NixOS channel. This is typically" - echo "caused by an option default that refers to a relative path (see above" - echo "for hints about the offending path)." - exit 1 - fi - ${buildPackages.libxslt.bin}/bin/xsltproc \ - --stringparam revision '${revision}' \ - -o $out ${} $optionsXML - ''; + optionsDocBook = runCommand "options-db.xml" + { + nativeBuildInputs = [ buildPackages.libxslt.bin ]; + } + '' + optionsXML=${optionsXML} + xsltproc \ + --stringparam program 'home-manager' \ + --stringparam revision '${revision}' \ + -o $out ${./options-to-docbook.xsl} $optionsXML + ''; sources = lib.sourceFilesBySuffices ./. [".xml"]; @@ -268,8 +266,8 @@ in rec { mkdir -p $dst/images/callouts cp ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.svg $dst/images/callouts/ - cp ${../../../doc/style.css} $dst/style.css - cp ${../../../doc/overrides.css} $dst/overrides.css + cp ${./style.css} $dst/style.css + cp ${./overrides.css} $dst/overrides.css cp -r ${pkgs.documentation-highlighter} $dst/highlightjs mkdir -p $out/nix-support diff --git a/doc/manual.xml b/doc/manual.xml index 9998763606e..f076f833886 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -2,27 +2,19 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.0" - xml:id="book-nixos-manual"> + xml:id="book-home-manager-manual"> Home Manager Manual Preface - This manual will eventually describes how to install, use and + This manual will eventually describes how to install, use, and extend Home Manager. - If you encounter problems, please report them on the - nix-devel - mailing list or on the - #nixos channel on Freenode. Bugs should be - reported in - NixOS’ - GitHub issue tracker. + If you encounter problems or bugs then please report them on the + Home Manager issue tracker. @@ -34,7 +26,6 @@ Configuration Options - + diff --git a/doc/options-to-docbook.xsl b/doc/options-to-docbook.xsl new file mode 100644 index 00000000000..0fef4e1df65 --- /dev/null +++ b/doc/options-to-docbook.xsl @@ -0,0 +1,239 @@ + + + + + + + + + + + + + Configuration Options + + + + + + + + + + + + + + + + + + Type: + + + + + (read only) + + + + + + + Default: + + + + + + + + Example: + + + + + + + + + + + + + + + Related packages: + + + + + + + + Declared by: + + + + + + + Defined by: + + + + + + + + + + + + + + + + + + + +'' +'' + + + + + + + + + + null + + + + + + + '''' + + + "" + + + + + + + + + + + + true + + + + + false + + + + + [ + + + + + ] + + + + + + + + + + { + + + = + ; + + } + + + + + (build of ) + + + + + + + + + + + + https://github.com/rycee/home-manager/blob//#blob-path + + + https://github.com/NixOS/nixpkgs/blob/master/ + + + https://github.com/NixOS/nixpkgs/blob// + + + + + https://github.com/NixOS/nixops/blob//nix/ + + + file:// + + + + + + <home-manager/> + + + <nixpkgs/> + + + <nixops/> + + + + + + + + + + + + + λ + + + + diff --git a/doc/overrides.css b/doc/overrides.css new file mode 100644 index 00000000000..4c7d4a31be2 --- /dev/null +++ b/doc/overrides.css @@ -0,0 +1,9 @@ +.docbook .xref img[src^=images\/callouts\/], +.screen img, +.programlisting img { + width: 1em; +} + +.calloutlist img { + width: 1.5em; +} diff --git a/doc/style.css b/doc/style.css new file mode 100644 index 00000000000..0db907815b6 --- /dev/null +++ b/doc/style.css @@ -0,0 +1,271 @@ +/* Copied from http://bakefile.sourceforge.net/, which appears + licensed under the GNU GPL. */ + + +/*************************************************************************** + Basic headers and text: + ***************************************************************************/ + +body +{ + font-family: "Nimbus Sans L", sans-serif; + background: white; + margin: 2em 1em 2em 1em; +} + +h1, h2, h3, h4 +{ + color: #005aa0; +} + +h1 /* title */ +{ + font-size: 200%; +} + +h2 /* chapters, appendices, subtitle */ +{ + font-size: 180%; +} + +/* Extra space between chapters, appendices. */ +div.chapter > div.titlepage h2, div.appendix > div.titlepage h2 +{ + margin-top: 1.5em; +} + +div.section > div.titlepage h2 /* sections */ +{ + font-size: 150%; + margin-top: 1.5em; +} + +h3 /* subsections */ +{ + font-size: 125%; +} + +div.simplesect h2 +{ + font-size: 110%; +} + +div.appendix h3 +{ + font-size: 150%; + margin-top: 1.5em; +} + +div.refnamediv h2, div.refsynopsisdiv h2, div.refsection h2 /* refentry parts */ +{ + margin-top: 1.4em; + font-size: 125%; +} + +div.refsection h3 +{ + font-size: 110%; +} + + +/*************************************************************************** + Examples: + ***************************************************************************/ + +div.example +{ + border: 1px solid #b0b0b0; + padding: 6px 6px; + margin-left: 1.5em; + margin-right: 1.5em; + background: #f4f4f8; + border-radius: 0.4em; + box-shadow: 0.4em 0.4em 0.5em #e0e0e0; +} + +div.example p.title +{ + margin-top: 0em; +} + +div.example pre +{ + box-shadow: none; +} + + +/*************************************************************************** + Screen dumps: + ***************************************************************************/ + +pre.screen, pre.programlisting +{ + border: 1px solid #b0b0b0; + padding: 3px 3px; + margin-left: 1.5em; + margin-right: 1.5em; + + background: #f4f4f8; + font-family: monospace; + border-radius: 0.4em; + box-shadow: 0.4em 0.4em 0.5em #e0e0e0; +} + +div.example pre.programlisting +{ + border: 0px; + padding: 0 0; + margin: 0 0 0 0; +} + +/*************************************************************************** + Notes, warnings etc: + ***************************************************************************/ + +.note, .warning +{ + border: 1px solid #b0b0b0; + padding: 3px 3px; + margin-left: 1.5em; + margin-right: 1.5em; + margin-bottom: 1em; + padding: 0.3em 0.3em 0.3em 0.3em; + background: #fffff5; + border-radius: 0.4em; + box-shadow: 0.4em 0.4em 0.5em #e0e0e0; +} + +div.note, div.warning +{ + font-style: italic; +} + +div.note h3, div.warning h3 +{ + color: red; + font-size: 100%; + padding-right: 0.5em; + display: inline; +} + +div.note p, div.warning p +{ + margin-bottom: 0em; +} + +div.note h3 + p, div.warning h3 + p +{ + display: inline; +} + +div.note h3 +{ + color: blue; + font-size: 100%; +} + +div.navfooter * +{ + font-size: 90%; +} + + +/*************************************************************************** + Links colors and highlighting: + ***************************************************************************/ + +a { text-decoration: none; } +a:hover { text-decoration: underline; } +a:link { color: #0048b3; } +a:visited { color: #002a6a; } + + +/*************************************************************************** + Table of contents: + ***************************************************************************/ + +div.toc +{ + font-size: 90%; +} + +div.toc dl +{ + margin-top: 0em; + margin-bottom: 0em; +} + + +/*************************************************************************** + Special elements: + ***************************************************************************/ + +tt, code +{ + color: #400000; +} + +.term +{ + font-weight: bold; + +} + +div.variablelist dd p, div.glosslist dd p +{ + margin-top: 0em; +} + +div.variablelist dd, div.glosslist dd +{ + margin-left: 1.5em; +} + +div.glosslist dt +{ + font-style: italic; +} + +.varname +{ + color: #400000; +} + +span.command strong +{ + font-weight: normal; + color: #400000; +} + +div.calloutlist table +{ + box-shadow: none; +} + +table +{ + border-collapse: collapse; + box-shadow: 0.4em 0.4em 0.5em #e0e0e0; +} + +table.simplelist +{ + text-align: left; + color: #005aa0; + border: 0; + padding: 5px; + background: #fffff5; + font-weight: normal; + font-style: italic; + box-shadow: none; + margin-bottom: 1em; +} + +div.navheader table, div.navfooter table { + box-shadow: none; +} + +div.affiliation +{ + font-style: italic; +} diff --git a/modules/manual.nix b/modules/manual.nix index ae0ff1d9592..b603dac8a19 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -12,7 +12,7 @@ let homeManagerManual = import ../doc { inherit pkgs config; version = "0.1"; - revision = "release-0.1"; + revision = "master"; options = let scrubbedEval = evalModules { -- cgit v1.2.3 From bbcef2fd33165c987ec0b746211782aca7815ac6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 11 May 2018 22:38:47 +0200 Subject: readme: add link to online options documentation --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7c55510479..ecb755bd04f 100644 --- a/README.md +++ b/README.md @@ -179,8 +179,9 @@ $ home-manager build which will create a `result` link to a directory containing an activation script and the generated home directory files. -To see available configuration options with descriptions and usage -examples run +Documentation of available configuration options, including +descriptions and usage examples, is available in the [Home Manager +manual][configuration options] or offline by running ```console $ man home-configuration.nix @@ -299,3 +300,4 @@ in your Home Manager configuration. [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/ +[configuration options]: https://rycee.github.io/home-manager/options.html -- cgit v1.2.3 From b6da6569c4ff53cf0cabd5371b501069810febf3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 17 May 2018 19:39:26 +0200 Subject: qt: add module --- modules/misc/news.nix | 10 ++++++++++ modules/misc/qt.nix | 39 +++++++++++++++++++++++++++++++++++++++ modules/modules.nix | 1 + 3 files changed, 50 insertions(+) create mode 100644 modules/misc/qt.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 99a7cb3e8d9..1fa0277d0d1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -647,6 +647,16 @@ in A new module is available: 'services.flameshot'. ''; } + + { + time = "2018-05-18T18:34:15+00:00"; + message = '' + A new module is available: 'qt' + + At the moment this module allows you to set up Qt to use the + GTK+ theme, and not much else. + ''; + } ]; }; } diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix new file mode 100644 index 00000000000..ae697b25ec2 --- /dev/null +++ b/modules/misc/qt.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.qt; + dag = config.lib.dag; + +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + qt = { + enable = mkEnableOption "Qt 4 and 5 configuration"; + + useGtkTheme = mkOption { + type = types.bool; + default = false; + description = '' + Whether Qt 4 and 5 should be set up to use the GTK theme + settings. + ''; + }; + }; + }; + + config = mkIf (cfg.enable && cfg.useGtkTheme) { + home.sessionVariables.QT_QPA_PLATFORMTHEME = "gtk2"; + home.packages = [ pkgs.libsForQt5.qtstyleplugins ]; + + home.activation.useGtkThemeInQt4 = dag.entryAfter ["writeBoundary"] '' + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ + --set $HOME/.config/Trolltech.conf Qt style GTK+ + ''; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index b36ad4f4ae7..b35a0e86604 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -21,6 +21,7 @@ let ./misc/news.nix ./misc/nixpkgs.nix ./misc/pam.nix + ./misc/qt.nix ./misc/xdg.nix ./programs/autorandr.nix ./programs/bash.nix -- cgit v1.2.3 From f812260c233693c176d8b4a11ed9baf57ddc4966 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 18 May 2018 23:18:12 +0200 Subject: manual: add HTML manual Also add a `home-manager-help` script that attempts to open the HTML manual in a browser. --- modules/manual.nix | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/modules/manual.nix b/modules/manual.nix index b603dac8a19..5e60b98faf3 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -4,6 +4,8 @@ with lib; let + cfg = config.manual; + /* For the purpose of generating docs, evaluate options with each derivation in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}". It isn't perfect, but it seems to cover a vast majority of use cases. @@ -32,10 +34,42 @@ let in scrubbedEval.options; }; + manualHtmlRoot = "${homeManagerManual.manual}/share/doc/home-manager/index.html"; + + helpScript = pkgs.writeScriptBin "home-manager-help" '' + #!${pkgs.bash}/bin/bash -e + + if [ -z "$BROWSER" ]; then + for candidate in xdg-open open w3m; do + BROWSER="$(type -P $candidate || true)" + if [ -x "$BROWSER" ]; then + break; + fi + done + fi + + if [ -z "$BROWSER" ]; then + echo "$0: unable to start a web browser; please set \$BROWSER" + exit 1 + fi + + exec "$BROWSER" ${manualHtmlRoot} + ''; + in { options = { + manual.html.enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to install the HTML manual. This also installs the + home-manager-help tool, which opens a local + copy of the Home Manager manual in the system web browser. + ''; + }; + manual.manpages.enable = mkOption { type = types.bool; default = true; @@ -51,8 +85,12 @@ in }; }; - config = mkIf config.manual.manpages.enable { - home.packages = [ homeManagerManual.manpages ]; + config = { + home.packages = mkMerge [ + (mkIf cfg.html.enable [ helpScript homeManagerManual.manual ]) + + (mkIf cfg.manpages.enable [ homeManagerManual.manpages ]) + ]; }; # To fix error during manpage build. -- cgit v1.2.3 From dfaccdd03b083bb36ac78ff5e9ec01e8d2335efc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 22 May 2018 18:14:37 +0200 Subject: readme: make branch suggestion more clear Fixes #270. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ecb755bd04f..23cc3d45049 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,13 @@ Currently the easiest way to install Home Manager is as follows: $ HM_PATH=https://github.com/rycee/home-manager/archive/master.tar.gz ``` - or + if you are following Nixpkgs master or an unstable channel and ```console $ HM_PATH=https://github.com/rycee/home-manager/archive/release-18.03.tar.gz ``` - depending on whether you follow Nixpkgs unstable or version 18.03. + if you follow a Nixpkgs version 18.03 channel. 3. Create an initial Home Manager configuration file: -- cgit v1.2.3 From 10865f99529b72c8a5ff5931ab2c4a05074b2dfe Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 26 May 2018 10:52:40 +0200 Subject: bash: escape alias values This should allow use of the apostrophe character within aliases without having to escape them manually. Fixes #273 --- modules/programs/bash.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 786478c1ff1..6adcbd942a4 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -130,7 +130,7 @@ in config = ( let aliasesStr = concatStringsSep "\n" ( - mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + mapAttrsToList (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases ); shoptsStr = concatStringsSep "\n" ( -- cgit v1.2.3 From 4b388ee90267a54c5bed0b922ba8669b7d85c427 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 25 May 2018 17:25:49 +0200 Subject: i3: fix reloading for nixos module By default, i3-msg gets socket from X11 property which is not available when home manager is running as nixos module. This patch changes i3-msg command call by specifying all i3 sockets found in $XDG_RUNTIME_DIR/i3 folder. Fixes #252. --- modules/services/window-managers/i3.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 043716642d9..a6675651cd7 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -763,9 +763,10 @@ in ''; home.activation.reloadI3 = dag.entryAfter [ "linkGeneration" ] '' - if [[ -v i3Changed && -v DISPLAY ]]; then + SOCKET=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* + if [ -v i3Changed ] && [ -S $SOCKET ]; then echo "Reloading i3" - ${cfg.package}/bin/i3-msg reload 1>/dev/null + ${cfg.package}/bin/i3-msg -s $SOCKET reload 1>/dev/null fi ''; } -- cgit v1.2.3 From cacb8d410ec8e0e5ff08ac7aa81cd10e8e3f2eb6 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 26 May 2018 20:39:58 +0200 Subject: i3: deprecate i3.config.startup.*.workspace option Fixes #265. --- modules/services/window-managers/i3.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index a6675651cd7..fd144314e18 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -33,7 +33,11 @@ let workspace = mkOption { type = types.nullOr types.string; default = null; - description = "Launch application on a particular workspace."; + description = '' + Launch application on a particular workspace. + DEPRECATED: Use i3.config.assigns instead. + See https://github.com/rycee/home-manager/issues/265. + ''; }; }; }; @@ -776,5 +780,13 @@ in if (cfg.config.gaps != null) then pkgs.i3-gaps else pkgs.i3 ); }) + + (mkIf (cfg.config != null && (any (s: s.workspace != null) cfg.config.startup)) { + warnings = [ + ("'xsession.windowManager.i3.config.startup.*.workspace' is deprecated, " + + "use 'xsession.windowManager.i3.config.assigns' instead." + + "See https://github.com/rycee/home-manager/issues/265.") + ]; + }) ]); } -- cgit v1.2.3 From 30c97391d7febf310f776fcfea2f6abd2043a917 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 26 May 2018 23:44:57 +0200 Subject: i3: add modifier option This allows to easily change modifier key for default keybindings and gives a possibility to reference specified value in other modules. Fixes #147. --- modules/services/window-managers/i3.nix | 115 ++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index fd144314e18..535889df739 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -306,7 +306,8 @@ let modifier = mkOption { type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ]; - default = "Mod1"; + default = cfg.config.modifier; + defaultText = "i3.config.modifier"; description = "Modifier key that can be used to drag floating windows."; example = "Mod4"; }; @@ -382,64 +383,78 @@ let ''; }; + modifier = mkOption { + type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ]; + default = "Mod1"; + description = "Modifier key that is used for all default keybindings."; + example = "Mod4"; + }; + keybindings = mkOption { type = types.attrs; default = { - "Mod1+Return" = "exec i3-sensible-terminal"; - "Mod1+Shift+q" = "kill"; - "Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; - - "Mod1+Left" = "focus left"; - "Mod1+Down" = "focus down"; - "Mod1+Up" = "focus up"; - "Mod1+Right" = "focus right"; - - "Mod1+h" = "split h"; - "Mod1+v" = "split v"; - "Mod1+f" = "fullscreen toggle"; - - "Mod1+s" = "layout stacking"; - "Mod1+w" = "layout tabbed"; - "Mod1+e" = "layout toggle split"; - - "Mod1+Shift+space" = "floating toggle"; - - "Mod1+1" = "workspace 1"; - "Mod1+2" = "workspace 2"; - "Mod1+3" = "workspace 3"; - "Mod1+4" = "workspace 4"; - "Mod1+5" = "workspace 5"; - "Mod1+6" = "workspace 6"; - "Mod1+7" = "workspace 7"; - "Mod1+8" = "workspace 8"; - "Mod1+9" = "workspace 9"; - - "Mod1+Shift+1" = "move container to workspace 1"; - "Mod1+Shift+2" = "move container to workspace 2"; - "Mod1+Shift+3" = "move container to workspace 3"; - "Mod1+Shift+4" = "move container to workspace 4"; - "Mod1+Shift+5" = "move container to workspace 5"; - "Mod1+Shift+6" = "move container to workspace 6"; - "Mod1+Shift+7" = "move container to workspace 7"; - "Mod1+Shift+8" = "move container to workspace 8"; - "Mod1+Shift+9" = "move container to workspace 9"; - - "Mod1+Shift+c" = "reload"; - "Mod1+Shift+r" = "restart"; - "Mod1+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; - - "Mod1+r" = "mode resize"; + "${cfg.config.modifier}+Return" = "exec i3-sensible-terminal"; + "${cfg.config.modifier}+Shift+q" = "kill"; + "${cfg.config.modifier}+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + + "${cfg.config.modifier}+Left" = "focus left"; + "${cfg.config.modifier}+Down" = "focus down"; + "${cfg.config.modifier}+Up" = "focus up"; + "${cfg.config.modifier}+Right" = "focus right"; + + "${cfg.config.modifier}+h" = "split h"; + "${cfg.config.modifier}+v" = "split v"; + "${cfg.config.modifier}+f" = "fullscreen toggle"; + + "${cfg.config.modifier}+s" = "layout stacking"; + "${cfg.config.modifier}+w" = "layout tabbed"; + "${cfg.config.modifier}+e" = "layout toggle split"; + + "${cfg.config.modifier}+Shift+space" = "floating toggle"; + + "${cfg.config.modifier}+1" = "workspace 1"; + "${cfg.config.modifier}+2" = "workspace 2"; + "${cfg.config.modifier}+3" = "workspace 3"; + "${cfg.config.modifier}+4" = "workspace 4"; + "${cfg.config.modifier}+5" = "workspace 5"; + "${cfg.config.modifier}+6" = "workspace 6"; + "${cfg.config.modifier}+7" = "workspace 7"; + "${cfg.config.modifier}+8" = "workspace 8"; + "${cfg.config.modifier}+9" = "workspace 9"; + + "${cfg.config.modifier}+Shift+1" = "move container to workspace 1"; + "${cfg.config.modifier}+Shift+2" = "move container to workspace 2"; + "${cfg.config.modifier}+Shift+3" = "move container to workspace 3"; + "${cfg.config.modifier}+Shift+4" = "move container to workspace 4"; + "${cfg.config.modifier}+Shift+5" = "move container to workspace 5"; + "${cfg.config.modifier}+Shift+6" = "move container to workspace 6"; + "${cfg.config.modifier}+Shift+7" = "move container to workspace 7"; + "${cfg.config.modifier}+Shift+8" = "move container to workspace 8"; + "${cfg.config.modifier}+Shift+9" = "move container to workspace 9"; + + "${cfg.config.modifier}+Shift+c" = "reload"; + "${cfg.config.modifier}+Shift+r" = "restart"; + "${cfg.config.modifier}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; + + "${cfg.config.modifier}+r" = "mode resize"; }; defaultText = "Default i3 keybindings."; description = '' - An attribute set that assignes key press to an action using key symbol. + An attribute set that assigns a key press to an action using a key symbol. See . +
+ Consider to use lib.mkOptionDefault function to extend or override + default keybindings instead of specifying all of them from scratch. ''; example = literalExample '' - { - "Mod1+Return" = "exec i3-sensible-terminal"; - "Mod1+Shift+q" = "kill"; - "Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + let + modifier = xsession.windowManager.i3.config.modifier; + in + + lib.mkOptionDefault { + "''${modifier}+Return" = "exec i3-sensible-terminal"; + "''${modifier}+Shift+q" = "kill"; + "''${modifier}+d" = "exec \${pkgs.dmenu}/bin/dmenu_run"; } ''; }; -- cgit v1.2.3 From 69445cb4a0dda46c0676d0588b1d843c83f7da5a Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Tue, 29 May 2018 22:24:26 -0700 Subject: udiskie: change package The old package is deprecated. --- modules/services/udiskie.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index e4d4f527915..5155b37cd1c 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -73,7 +73,7 @@ in }; Service = { - ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 ${commandArgs}"; + ExecStart = "${pkgs.udiskie}/bin/udiskie -2 ${commandArgs}"; }; Install = { -- cgit v1.2.3 From 965bad626adba63a579a31ef1688d912d0cf820b Mon Sep 17 00:00:00 2001 From: Lenz Weber Date: Sun, 20 May 2018 00:03:16 +0200 Subject: flameshot: set PATH to let Qt find plugins --- modules/services/flameshot.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix index d5e8309d96c..7c259d43af1 100644 --- a/modules/services/flameshot.nix +++ b/modules/services/flameshot.nix @@ -33,6 +33,7 @@ in }; Service = { + Environment = "PATH=%h/.nix-profile/bin"; ExecStart = "${package}/bin/flameshot"; Restart = "on-abort"; }; -- cgit v1.2.3 From faf04b009bf2cfaba85802880986affd8bf47653 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 3 Jun 2018 17:25:39 +0200 Subject: qt: support GTK+ theming for Qt services --- modules/misc/qt.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index ae697b25ec2..c644c70409a 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -30,6 +30,8 @@ in config = mkIf (cfg.enable && cfg.useGtkTheme) { home.sessionVariables.QT_QPA_PLATFORMTHEME = "gtk2"; home.packages = [ pkgs.libsForQt5.qtstyleplugins ]; + xsession.profileExtra = + "systemctl --user import-environment QT_QPA_PLATFORMTHEME"; home.activation.useGtkThemeInQt4 = dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ -- cgit v1.2.3 From ed0cd78e05d3d0b27f28e892546881b6a6ae7004 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 3 Jun 2018 20:53:07 +0200 Subject: i3: use fancy docbook markup in description --- modules/services/window-managers/i3.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 535889df739..4a356328b9e 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -34,9 +34,9 @@ let type = types.nullOr types.string; default = null; description = '' - Launch application on a particular workspace. - DEPRECATED: Use i3.config.assigns instead. - See https://github.com/rycee/home-manager/issues/265. + Launch application on a particular workspace. DEPRECATED: + Use xsession.windowManager.i3.config.assigns + instead. See . ''; }; }; -- cgit v1.2.3 From 53f10f4d46c02113143ccdb0312149a68d3dd6be Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 4 Jun 2018 21:59:38 +0800 Subject: kdeconnect: add module --- modules/misc/news.nix | 8 +++++ modules/modules.nix | 1 + modules/services/kdeconnect.nix | 75 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 modules/services/kdeconnect.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1fa0277d0d1..3c703e0a9ea 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -657,6 +657,14 @@ in GTK+ theme, and not much else. ''; } + + { + time = "2018-06-05T01:36:45+00:00"; + message = '' + A new module is available: 'services.kdeconnect'. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index b35a0e86604..055fb607917 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -56,6 +56,7 @@ let ./services/gnome-keyring.nix ./services/gpg-agent.nix ./services/kbfs.nix + ./services/kdeconnect.nix ./services/keepassx.nix ./services/keybase.nix ./services/mbsync.nix diff --git a/modules/services/kdeconnect.nix b/modules/services/kdeconnect.nix new file mode 100644 index 00000000000..b0983bbe3db --- /dev/null +++ b/modules/services/kdeconnect.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.kdeconnect; + package = pkgs.kdeconnect; + +in + +{ + meta.maintainers = [ maintainers.adisbladis ]; + + options = { + services.kdeconnect = { + enable = mkEnableOption "KDE connect"; + + indicator = mkOption { + type = types.bool; + default = false; + description = "Whether to enable kdeconnect-indicator service."; + }; + + }; + }; + + config = mkMerge [ + (mkIf cfg.enable { + home.packages = [ package ]; + + systemd.user.services.kdeconnect = { + Unit = { + Description = "Adds communication between your desktop and your smartphone"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=%h/.nix-profile/bin"; + ExecStart = "${package}/lib/libexec/kdeconnectd"; + Restart = "on-abort"; + }; + }; + }) + + (mkIf cfg.indicator { + systemd.user.services.kdeconnect-indicator = { + Unit = { + Description = "kdeconnect-indicator"; + After = [ "graphical-session-pre.target" + "polybar.service" + "taffybar.service" + "stalonetray.service" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=%h/.nix-profile/bin"; + ExecStart = "${package}/bin/kdeconnect-indicator"; + Restart = "on-abort"; + }; + }; + }) + + ]; +} -- cgit v1.2.3 From 06a984e4ff62b3f07e7e41ff93b45f0b759c9c56 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Wed, 6 Jun 2018 23:32:46 +0300 Subject: zsh: add extended, expireDuplicatesFirst history options --- modules/programs/zsh.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index c07e8a74c0f..91ce167557f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -50,6 +50,18 @@ let ''; }; + expireDuplicatesFirst = mkOption { + type = types.bool; + default = false; + description = "Expire duplicates first"; + }; + + extended = mkOption { + type = types.bool; + default = false; + description = "Save timestamp into the history file"; + }; + share = mkOption { type = types.bool; default = true; @@ -333,7 +345,9 @@ in setopt HIST_FCNTL_LOCK ${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS + ${if cfg.history.expireDuplicatesFirst then "setopt" else "unsetopt"} HIST_EXPIRE_DUPS_FIRST ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY + ${if cfg.history.extended then "setopt" else "unsetopt"} EXTENDED_HISTORY ${cfg.initExtra} -- cgit v1.2.3 From f3473b9eba568532719aae7de942d989d061b03c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 9 Jun 2018 10:29:02 +0200 Subject: zsh: add missing periods in descriptions --- modules/programs/zsh.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 91ce167557f..6253d2a77fe 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -53,13 +53,13 @@ let expireDuplicatesFirst = mkOption { type = types.bool; default = false; - description = "Expire duplicates first"; + description = "Expire duplicates first."; }; extended = mkOption { type = types.bool; default = false; - description = "Save timestamp into the history file"; + description = "Save timestamp into the history file."; }; share = mkOption { -- cgit v1.2.3 From 4caa45b8bb2ee8aafcfaa2e96328127b9d19ce0f Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Fri, 8 Jun 2018 22:09:20 +0300 Subject: newsboat: add module --- modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/programs/newsboat.nix | 98 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 modules/programs/newsboat.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3c703e0a9ea..5704cf269a2 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -665,6 +665,13 @@ in ''; } + { + time = "2018-06-09T09:11:59+00:00"; + message = '' + A new module is available: `programs.newsboat`. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 055fb607917..619437483b6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -42,6 +42,7 @@ let ./programs/man.nix ./programs/mercurial.nix ./programs/neovim.nix + ./programs/newsboat.nix ./programs/pidgin.nix ./programs/rofi.nix ./programs/ssh.nix diff --git a/modules/programs/newsboat.nix b/modules/programs/newsboat.nix new file mode 100644 index 00000000000..e955e2ad912 --- /dev/null +++ b/modules/programs/newsboat.nix @@ -0,0 +1,98 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.newsboat; + wrapQuote = x: "\"${x}\""; + +in + +{ + options = { + programs.newsboat = { + enable = mkEnableOption "the Newsboat feed reader."; + + urls = mkOption { + type = types.listOf types.attrs; + default = []; + example = [{url = "http://example.com"; tags = ["foo" "bar"];}]; + description = "List of urls and tokens."; + }; + + maxItems = mkOption { + type = types.int; + default = 0; + description = "Maximum number of items per feed, 0 for infinite."; + }; + + reloadThreads = mkOption { + type = types.int; + default = 5; + description = "How many threads to use for updating the feeds."; + }; + + autoReload = mkOption { + type = types.bool; + default = false; + description = "Whether to enable automatic reloading while newsboat is running."; + }; + + reloadTime = mkOption { + type = types.nullOr types.int; + default = 60; + description = "Time in minutes between reloads."; + }; + + browser = mkOption { + type = types.string; + default = "${pkgs.xdg_utils}/bin/xdg-open"; + description = "External browser to use."; + }; + + queries = mkOption { + type = types.attrsOf types.string; + default = {}; + example = { + "foo" = "rssurl =~ \"example.com\""; + }; + description = "A list of queries to use."; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Extra configuration values that will be appended to the end."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.newsboat ]; + home.file.".newsboat/urls".text = + let + urls = builtins.concatStringsSep "\n" ( + map (u: builtins.concatStringsSep " " ([u.url] ++ (map wrapQuote u.tags))) + cfg.urls); + queries = builtins.concatStringsSep "\n" ( + mapAttrsToList (n: v: "\"query:${n}:${escape ["\""] v}\"") cfg.queries); + + in + + '' + ${urls} + + ${queries} + ''; + home.file.".newsboat/config".text = '' + max-items ${toString cfg.maxItems} + browser ${cfg.browser} + reload-threads ${toString cfg.reloadThreads} + auto-reload ${if cfg.autoReload then "yes" else "no"} + ${optionalString (cfg.reloadTime != null) (toString "reload-time ${toString cfg.reloadTime}")} + prepopulate-query-feeds yes + + ${cfg.extraConfig} + ''; + }; +} -- cgit v1.2.3 From e27cd96494c91534797d5620698168ea9d7a49b6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 9 Jun 2018 11:40:49 +0200 Subject: newsboat: remove unnecessary period --- modules/programs/newsboat.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/newsboat.nix b/modules/programs/newsboat.nix index e955e2ad912..05b8b260084 100644 --- a/modules/programs/newsboat.nix +++ b/modules/programs/newsboat.nix @@ -11,7 +11,7 @@ in { options = { programs.newsboat = { - enable = mkEnableOption "the Newsboat feed reader."; + enable = mkEnableOption "the Newsboat feed reader"; urls = mkOption { type = types.listOf types.attrs; -- cgit v1.2.3 From 7190f469384afc72a83cb356b5b6c33c68f9037c Mon Sep 17 00:00:00 2001 From: gmarmstrong Date: Sun, 10 Jun 2018 22:41:27 -0400 Subject: bash: fix shellAliases description The aliases aren't added to all users' shells. --- modules/programs/bash.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 6adcbd942a4..830e832e181 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -84,8 +84,7 @@ in example = { ll = "ls -l"; ".." = "cd .."; }; description = '' An attribute set that maps aliases (the top level attribute names in - this option) to command strings or directly to build outputs. The - aliases are added to all users' shells. + this option) to command strings or directly to build outputs. ''; type = types.attrs; }; -- cgit v1.2.3 From ad634c0a9411ff0a6b98c06e5389b7d491c235dd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 13 Jun 2018 23:51:53 +0200 Subject: compton: use docbook man page references --- modules/services/compton.nix | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index b6e85f041a5..a564cf9e016 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -75,7 +75,12 @@ in { ]; description = '' List of windows to exclude background blur. - See compton(1) man page for more examples. + See the + + compton + 1 + + man page for more examples. ''; }; @@ -115,7 +120,12 @@ in { ]; description = '' List of conditions of windows that should not be faded. - See compton(1) man page for more examples. + See the + + compton + 1 + + man page for more examples. ''; }; @@ -155,7 +165,12 @@ in { ]; description = '' List of conditions of windows that should have no shadow. - See compton(1) man page for more examples. + See the + + compton + 1 + + man page for more examples. ''; }; @@ -195,7 +210,12 @@ in { ]; description = '' List of opacity rules. - See compton(1) man page for more examples. + See the + + compton + 1 + + man page for more examples. ''; }; @@ -208,13 +228,18 @@ in { }; vSync = mkOption { - type = types.str; - default = "none"; - example = "opengl-swc"; - description = '' - Enable vertical synchronization using the specified method. - See compton(1) man page available methods. - ''; + type = types.str; + default = "none"; + example = "opengl-swc"; + description = '' + Enable vertical synchronization using the specified method. + See the + + compton + 1 + + man page for available methods. + ''; }; refreshRate = mkOption { -- cgit v1.2.3 From 2e9fbbc978fdd1e4bc82616ea3478345c94da5c2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 13 Jun 2018 23:56:25 +0200 Subject: termite: use docbook man page reference --- modules/programs/termite.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/programs/termite.nix b/modules/programs/termite.nix index ce047b8fdbf..7e3288bbcb6 100644 --- a/modules/programs/termite.nix +++ b/modules/programs/termite.nix @@ -150,7 +150,11 @@ in type = types.nullOr types.bool; description = '' Emit escape sequences for extra keys, - like the modifyOtherKeys resource for xterm(1). + like the modifyOtherKeys resource for + + xterm + 1 + . ''; }; -- cgit v1.2.3 From 5641ee3f942e700de35b28fc879b0d8a10a7a1fe Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 14 Jun 2018 00:49:49 +0100 Subject: i3: use null to disable a keybinding --- modules/services/window-managers/i3.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 4a356328b9e..7b663a4fcae 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -637,11 +637,11 @@ let }; keybindingsStr = keybindings: concatStringsSep "\n" ( - mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings + mapAttrsToList (keycomb: action: optionalString (action != null) "bindsym ${keycomb} ${action}") keybindings ); keycodebindingsStr = keycodebindings: concatStringsSep "\n" ( - mapAttrsToList (keycomb: action: "bindcode ${keycomb} ${action}") keycodebindings + mapAttrsToList (keycomb: action: optionalString (action != null) "bindcode ${keycomb} ${action}") keycodebindings ); colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; -- cgit v1.2.3 From 6aa44d62ad6526177a8c1f1babe1646c06738614 Mon Sep 17 00:00:00 2001 From: Denny Schaefer Date: Mon, 25 Jun 2018 21:24:36 +0200 Subject: autorandr: add rotate option --- modules/programs/autorandr.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix index b97b604527f..034675e2fe1 100644 --- a/modules/programs/autorandr.nix +++ b/modules/programs/autorandr.nix @@ -72,6 +72,13 @@ let default = ""; example = "1.0:0.909:0.833"; }; + + rotate = mkOption { + type = types.nullOr (types.enum ["normal" "left" "right" "inverted"]); + description = "Output rotate configuration."; + default = null; + example = "left"; + }; }; }; @@ -142,6 +149,7 @@ let ${optionalString (config.gamma != "") "gamma ${config.gamma}"} ${optionalString (config.mode != "") "mode ${config.mode}"} ${optionalString (config.rate != "") "rate ${config.rate}"} + ${optionalString (config.rotate != null) "rotate ${config.rotate}"} '' else '' output ${name} off @@ -206,6 +214,7 @@ in mode = "3840x2160"; gamma = "1.0:0.909:0.833"; rate = "60.00"; + rotate = "left"; }; }; hooks.postswitch = readFile ./work-postswitch.sh; -- cgit v1.2.3 From 0d3f9ba913dca444a3cb3ba566575196ed90d92c Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Wed, 27 Jun 2018 15:18:30 +0200 Subject: compton: fix syntax error --- modules/services/compton.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index a564cf9e016..c282ba474d6 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -30,7 +30,7 @@ let # blur blur-background = true; blur-background-exclude = ${toJSON cfg.blurExclude}; - no-dock-blur = ${toString cfg.noDockBlur}; + no-dock-blur = ${toJSON cfg.noDockBlur}; '' + '' # opacity -- cgit v1.2.3 From 97ee4578c9b305b9497ee5b0bb7c2b1d1278c2d7 Mon Sep 17 00:00:00 2001 From: jD91mZM2 Date: Thu, 28 Jun 2018 19:33:47 +0200 Subject: gpg-agent: Add maxCacheTtl(Ssh) options --- modules/services/gpg-agent.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index aa2ecdb7eb7..5e2a41388a1 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -40,6 +40,28 @@ in ''; }; + maxCacheTtl = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Set the maximum time a cache entry is valid to n seconds. After this + time a cache entry will be expired even if it has been accessed + recently or has been set using gpg-preset-passphrase. The default is + 2 hours (7200 seconds). + ''; + }; + + maxCacheTtlSsh = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Set the maximum time a cache entry used for SSH keys is valid to n + seconds. After this time a cache entry will be expired even if it has + been accessed recently or has been set using gpg-preset-passphrase. + The default is 2 hours (7200 seconds). + ''; + }; + enableSshSupport = mkOption { type = types.bool; default = false; @@ -103,6 +125,12 @@ in ++ optional (cfg.defaultCacheTtlSsh != null) "default-cache-ttl-ssh ${toString cfg.defaultCacheTtlSsh}" + ++ + optional (cfg.maxCacheTtl != null) + "max-cache-ttl ${toString cfg.maxCacheTtl}" + ++ + optional (cfg.maxCacheTtlSsh != null) + "max-cache-ttl-ssh ${toString cfg.maxCacheTtlSsh}" ); home.sessionVariables = -- cgit v1.2.3 From 299e01722f9f8ac0b54aad2310e0fedae10beaaf Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Fri, 29 Jun 2018 13:14:35 +0300 Subject: Add support for systemd path units --- modules/systemd.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 16939ad25bd..74490691615 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -11,7 +11,8 @@ let enabled = cfg.services != {} || cfg.sockets != {} || cfg.targets != {} - || cfg.timers != {}; + || cfg.timers != {} + || cfg.paths != {}; toSystemdIni = generators.toINI { mkKeyValue = key: value: @@ -108,6 +109,15 @@ in ''; }; + paths = mkOption { + default = {}; + type = attrsRecursivelyMerged; + description = '' + Definition of systemd per-user path units. Attributes are + merged recursively. + ''; + }; + startServices = mkOption { default = false; type = types.bool; @@ -138,7 +148,7 @@ in let names = concatStringsSep ", " ( attrNames ( - cfg.services // cfg.sockets // cfg.targets // cfg.timers + cfg.services // cfg.sockets // cfg.targets // cfg.timers // cfg.paths ) ); in @@ -159,6 +169,8 @@ in (buildServices "target" cfg.targets) ++ (buildServices "timer" cfg.timers) + ++ + (buildServices "path" cfg.paths) ); # Run systemd service reload if user is logged in. If we're -- cgit v1.2.3 From 34bb9b5766fe1af5818f497d0ccd7dd66a7d8722 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 26 Jun 2018 23:41:30 +0200 Subject: email: add module This adds a general module infrastructure for configuring email accounts. The intent is to specify high level information such as IMAP and SMTP hostnames and login information so that more specific program and service modules do not have to duplicate options for specifying accounts. It is allowed for modules to inject further options within this namespace where relevant. For example, an MUA may wish add an option to add per-account filter rules. Co-authored-by: Matthieu Coudron --- modules/accounts/email.nix | 323 +++++++++++++++++++++++++++++++++++++++++++++ modules/misc/news.nix | 18 +++ modules/modules.nix | 1 + 3 files changed, 342 insertions(+) create mode 100644 modules/accounts/email.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix new file mode 100644 index 00000000000..6846cadb199 --- /dev/null +++ b/modules/accounts/email.nix @@ -0,0 +1,323 @@ +{ config, lib, ... }: + +with lib; + +let + + cfg = config.accounts.email; + + tlsModule = types.submodule { + options = { + enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable TLS/SSL. + ''; + }; + + useStartTls = mkOption { + type = types.bool; + default = false; + description = '' + Whether to use STARTTLS. + ''; + }; + + certificatesFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Path to file containing certificate authorities that should + be used to validate the connection authenticity. If + null then the system default is used. + Note, if set then the system default may still be accepted. + ''; + }; + }; + }; + + imapModule = types.submodule { + options = { + host = mkOption { + type = types.str; + example = "imap.example.org"; + description = '' + Hostname of IMAP server. + ''; + }; + + port = mkOption { + type = types.nullOr types.ints.positive; + default = null; + example = 993; + description = '' + The port on which the IMAP server listens. If + null then the default port is used. + ''; + }; + + tls = mkOption { + type = tlsModule; + default = {}; + description = '' + Configuration for secure connections. + ''; + }; + }; + }; + + smtpModule = types.submodule { + options = { + host = mkOption { + type = types.str; + example = "smtp.example.org"; + description = '' + Hostname of SMTP server. + ''; + }; + + port = mkOption { + type = types.nullOr types.ints.positive; + default = null; + example = 465; + description = '' + The port on which the SMTP server listens. If + null then the default port is used. + ''; + }; + + tls = mkOption { + type = tlsModule; + default = {}; + description = '' + Configuration for secure connections. + ''; + }; + }; + }; + + maildirModule = types.submodule ({ config, ... }: { + options = { + path = mkOption { + type = types.str; + description = '' + Path to maildir directory where mail for this account is + stored. This is relative to the base maildir path. + ''; + }; + + absPath = mkOption { + type = types.path; + readOnly = true; + internal = true; + default = "${cfg.maildirBasePath}/${config.path}"; + description = '' + A convenience option whose value is the absolute path of + this maildir. + ''; + }; + }; + }); + + # gpgModule = types.submodule { + # }; + + mailAccount = types.submodule ({ name, config, ... }: { + options = { + name = mkOption { + type = types.str; + readOnly = true; + description = '' + Unique identifier of the account. This is set to the + attribute name of the account configuration. + ''; + }; + + primary = mkOption { + type = types.bool; + default = false; + description = '' + Whether this is the primary account. Only one account may be + set as primary. + ''; + }; + + flavor = mkOption { + type = types.enum [ "plain" "runbox.com" ]; + default = "plain"; + description = '' + Some email providers have peculiar behavior that require + special treatment. This option is therefore intended to + indicate the nature of the provider. + + When this indicates a specific provider then, for example, + the IMAP and SMTP server configuration may be set + automatically. + ''; + }; + + address = mkOption { + type = types.strMatching ".*@.*"; + example = "jane.doe@example.org"; + description = "The email address of this account."; + }; + + realName = mkOption { + type = types.str; + example = "Jane Doe"; + description = "Name displayed when sending mails."; + }; + + userName = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The server username of this account. This will be used as + the SMTP and IMAP user name. + ''; + }; + + passwordCommand = mkOption { + type = types.nullOr (types.either types.str (types.listOf types.str)); + default = null; + apply = p: if isString p then splitString " " p else p; + example = "secret-tool lookup email me@example.org"; + description = '' + A command, which when run writes the account password on + standard output. + ''; + }; + + folders = mkOption { + type = types.submodule { + options = { + inbox = mkOption { + type = types.str; + default = "Inbox"; + description = '' + Relative path of the inbox mail. + ''; + }; + + sent = mkOption { + type = types.nullOr types.str; + default = "Sent"; + description = '' + Relative path of the sent mail folder. + ''; + }; + + drafts = mkOption { + type = types.str; + default = "Drafts"; + description = '' + Relative path of the drafts mail folder. + ''; + }; + + trash = mkOption { + type = types.str; + default = "Trash"; + description = '' + Relative path of the deleted mail folder. + ''; + }; + }; + }; + default = {}; + description = '' + Standard email folders. + ''; + }; + + imap = mkOption { + type = types.nullOr imapModule; + default = null; + description = '' + The IMAP configuration to use for this account. + ''; + }; + + smtp = mkOption { + type = types.nullOr smtpModule; + default = null; + description = '' + The SMTP configuration to use for this account. + ''; + }; + + maildir = mkOption { + type = types.nullOr maildirModule; + defaultText = { path = "\${name}"; }; + description = '' + Maildir configuration for this account. + ''; + }; + }; + + config = mkMerge [ + { + name = name; + maildir = mkOptionDefault { path = "${name}"; }; + } + + (mkIf (config.flavor == "runbox.com") { + imap = { + host = "mail.runbox.com"; + }; + + smtp = { + host = "mail.runbox.com"; + }; + }) + ]; + }); + +in + +{ + options.accounts.email = { + maildirBasePath = mkOption { + type = types.str; + default = "${config.home.homeDirectory}/Maildir"; + defaultText = "$HOME/Maildir"; + apply = p: + if hasPrefix "/" p + then p + else "${config.home.homeDirectory}/${p}"; + description = '' + The base directory for account maildir directories. May be a + relative path, in which case it is relative the home + directory. + ''; + }; + + accounts = mkOption { + type = types.attrsOf mailAccount; + default = {}; + description = "List of email accounts."; + }; + }; + + config = mkIf (cfg.accounts != {}) { + assertions = [ + ( + let + primaries = + catAttrs "name" + (filter (a: a.primary) + (attrValues cfg.accounts)); + in + { + assertion = length primaries == 1; + message = + "Must have exactly one primary mail account but found " + + toString (length primaries) + + optionalString (length primaries > 1) + (", namely " + concatStringsSep ", " primaries); + } + ) + ]; + }; +} diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 5704cf269a2..99c2de5cc9b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -672,6 +672,24 @@ in ''; } + { + time = "2018-07-01T14:33:15+00:00"; + message = '' + A new module is available: 'accounts.email'. + + As the name suggests, this new module offers a number of + options for configuring email accounts. This, for example, + includes the email address and owner's real name but also + server settings for IMAP and SMTP. + + The intent is to have a central location for account + specific configuration that other modules can use. + + Note, this module is still somewhat experimental and its + structure should not be seen as final. Feedback is greatly + appreciated, both positive and negative. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 619437483b6..6229ec4b59e 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -13,6 +13,7 @@ with lib; let modules = [ + ./accounts/email.nix ./files.nix ./home-environment.nix ./manual.nix -- cgit v1.2.3 From 8dc1737e39e19f2070ecb94f4badc6aa0c9af0c8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 27 Jun 2018 00:45:00 +0200 Subject: mbsync: add module Co-authored-by: Matthieu Coudron --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/mbsync.nix | 241 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 249 insertions(+) create mode 100644 modules/programs/mbsync.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 99c2de5cc9b..f87daed8130 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -690,6 +690,13 @@ in appreciated, both positive and negative. ''; } + + { + time = "2018-07-01T16:07:04+00:00"; + message = '' + A new module is available: 'programs.mbsync'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 6229ec4b59e..312c9c971e7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -41,6 +41,7 @@ let ./programs/info.nix ./programs/lesspipe.nix ./programs/man.nix + ./programs/mbsync.nix ./programs/mercurial.nix ./programs/neovim.nix ./programs/newsboat.nix diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix new file mode 100644 index 00000000000..f0e6fc1f1ed --- /dev/null +++ b/modules/programs/mbsync.nix @@ -0,0 +1,241 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + dag = config.lib.dag; + + cfg = config.programs.mbsync; + + # Accounts for which mbsync is enabled. + mbsyncAccounts = + filter (a: a.mbsync.enable) (attrValues config.accounts.email.accounts); + + genTlsConfig = tls: { + SSLType = + if !tls.enable then "None" + else if tls.useStartTls then "STARTTLS" + else "IMAPS"; + } + // + optionalAttrs (tls.enable && tls.certificatesFile != null) { + CertificateFile = tls.certificatesFile; + }; + + masterSlaveMapping = { + none = "None"; + imap = "Master"; + maildir = "Slave"; + both = "Both"; + }; + + genSection = header: entries: + let + escapeValue = escape [ "\"" ]; + genValue = v: + if isList v + then concatMapStringsSep " " genValue v + else "\"${escapeValue v}\""; + in + '' + ${header} + ${concatStringsSep "\n" + (mapAttrsToList (n: v: "${n} ${genValue v}") entries)} + ''; + + genAccountConfig = account: with account; + if (imap == null || maildir == null) + then "" + else + genSection "IMAPAccount ${name}" ( + { + Host = imap.host; + User = userName; + PassCmd = toString passwordCommand; + } + // + genTlsConfig imap.tls + // + optionalAttrs (imap.port != null) { Port = toString imap.port; } + ) + + "\n" + + genSection "IMAPStore ${name}-remote" { + Account = name; + } + + "\n" + + genSection "MaildirStore ${name}-local" ( + { + Path = "${maildir.absPath}/"; + Inbox = "${maildir.absPath}/${folders.inbox}"; + SubFolders = "Verbatim"; + } + // + optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; } + ) + + "\n" + + genSection "Channel ${name}" { + Master = ":${name}-remote:"; + Slave = ":${name}-local:"; + Patterns = mbsync.patterns; + Create = masterSlaveMapping.${mbsync.create}; + Remove = masterSlaveMapping.${mbsync.remove}; + Expunge = masterSlaveMapping.${mbsync.expunge}; + SyncState = "*"; + } + + "\n"; + + genGroupConfig = name: channels: + let + genGroupChannel = n: boxes: "Channel ${n}:${concatStringsSep "," boxes}"; + in + concatStringsSep "\n" ( + [ "Group ${name}" ] ++ mapAttrsToList genGroupChannel channels + ); + +in + +{ + options = { + programs.mbsync = { + enable = mkEnableOption "mbsync IMAP4 and Maildir mailbox synchronizer"; + + package = mkOption { + type = types.package; + default = pkgs.isync; + defaultText = "pkgs.isync"; + example = literalExample "pkgs.isync"; + description = "The package to use for the mbsync binary."; + }; + + groups = mkOption { + type = types.attrsOf (types.attrsOf (types.listOf types.str)); + default = {}; + example = literalExample '' + { + inboxes = { + account1 = [ "Inbox" ]; + account2 = [ "Inbox" ]; + }; + } + ''; + description = '' + Definition of groups. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration lines to add to the mbsync configuration. + ''; + }; + }; + + accounts.email.accounts = mkOption { + options = [ + { + mbsync = { + enable = mkEnableOption "synchronization using mbsync"; + + flatten = mkOption { + type = types.nullOr types.str; + default = null; + example = "."; + description = '' + If set, flattens the hierarchy within the maildir by + substituting the canonical hierarchy delimiter + / with this value. + ''; + }; + + create = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "maildir"; + description = '' + Automatically create missing mailboxes within the + given mail store. + ''; + }; + + remove = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "imap"; + description = '' + Propagate mailbox deletions to the given mail store. + ''; + }; + + expunge = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "both"; + description = '' + Permanently remove messages marked for deletion from + the given mail store. + ''; + }; + + patterns = mkOption { + type = types.listOf types.str; + default = [ "*" ]; + description = '' + Pattern of mailboxes to synchronize. + ''; + }; + }; + } + ]; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + ( + let + badAccounts = filter (a: a.maildir == null) mbsyncAccounts; + in + { + assertion = badAccounts == []; + message = "mbsync: Missing maildir configuration for accounts: " + + concatMapStringsSep ", " (a: a.name) badAccounts; + } + ) + + ( + let + badAccounts = filter (a: a.imap == null) mbsyncAccounts; + in + { + assertion = badAccounts == []; + message = "mbsync: Missing IMAP configuration for accounts: " + + concatMapStringsSep ", " (a: a.name) badAccounts; + } + ) + ]; + + home.packages = [ cfg.package ]; + + home.file.".mbsyncrc".text = + let + accountsConfig = map genAccountConfig mbsyncAccounts; + groupsConfig = mapAttrsToList genGroupConfig cfg.groups; + in + concatStringsSep "\n" ( + [ "# Generated by Home Manager.\n" ] + ++ accountsConfig + ++ groupsConfig + ++ optional (cfg.extraConfig != "") cfg.extraConfig + ); + + home.activation.createMaildir = + dag.entryBetween [ "linkGeneration" ] [ "writeBoundary" ] '' + $DRY_RUN_CMD mkdir -m700 -p $VERBOSE_ARG ${ + concatMapStringsSep " " (a: a.maildir.absPath) mbsyncAccounts + } + ''; + }; +} -- cgit v1.2.3 From eecebbf18632facd6d6fac51b2d54496cac68d92 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 28 Jun 2018 23:42:25 +0200 Subject: notmuch: add module Co-authored-by: Matthieu Coudron --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/mbsync.nix | 2 + modules/programs/notmuch.nix | 196 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 modules/programs/notmuch.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f87daed8130..aba6e3bebba 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -697,6 +697,13 @@ in A new module is available: 'programs.mbsync'. ''; } + + { + time = "2018-07-01T16:12:20+00:00"; + message = '' + A new module is available: 'programs.notmuch'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 312c9c971e7..b9727ff396c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -45,6 +45,7 @@ let ./programs/mercurial.nix ./programs/neovim.nix ./programs/newsboat.nix + ./programs/notmuch.nix ./programs/pidgin.nix ./programs/rofi.nix ./programs/ssh.nix diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index f0e6fc1f1ed..87a78355848 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -219,6 +219,8 @@ in home.packages = [ cfg.package ]; + programs.notmuch.new.ignore = [ ".uidvalidity" ".mbsyncstate" ]; + home.file.".mbsyncrc".text = let accountsConfig = map genAccountConfig mbsyncAccounts; diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix new file mode 100644 index 00000000000..3d7a651f35f --- /dev/null +++ b/modules/programs/notmuch.nix @@ -0,0 +1,196 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + dag = config.lib.dag; + + cfg = config.programs.notmuch; + + mkIniKeyValue = key: value: + let + tweakVal = v: + if isString v then v + else if isList v then concatMapStringsSep ";" tweakVal v + else if isBool v then toJSON v + else toString v; + in + "${key}=${tweakVal value}"; + + notmuchIni = + recursiveUpdate + { + database = { + path = config.accounts.email.maildirBasePath; + }; + + new = { + ignore = cfg.new.ignore; + tags = cfg.new.tags; + }; + + user = + let + accounts = + filter (a: a.notmuch.enable) + (attrValues config.accounts.email.accounts); + primary = filter (a: a.primary) accounts; + secondaries = filter (a: !a.primary) accounts; + in { + name = catAttrs "realName" primary; + primary_email = catAttrs "address" primary; + other_email = catAttrs "address" secondaries; + }; + + search = { + exclude_tags = [ "deleted" "spam" ]; + }; + } + cfg.extraConfig; + +in + +{ + options = { + programs.notmuch = { + enable = mkEnableOption "Notmuch mail indexer"; + + new = mkOption { + type = types.submodule { + options = { + ignore = mkOption { + type = types.listOf types.str; + default = []; + description = '' + A list to specify files and directories that will not be + searched for messages by notmuch new. + ''; + }; + + tags = mkOption { + type = types.listOf types.str; + default = [ "unread" "inbox" ]; + example = [ "new" ]; + description = '' + A list of tags that will be added to all messages + incorporated by notmuch new. + ''; + }; + }; + }; + default = {}; + description = '' + Options related to email processing performed by + notmuch new. + ''; + }; + + extraConfig = mkOption { + type = types.attrsOf (types.attrsOf types.str); + default = { + maildir = { synchronize_flags = "True"; }; + }; + description = '' + Options that should be appended to the notmuch configuration file. + ''; + }; + + hooks = { + preNew = mkOption { + type = types.lines; + default = ""; + example = "mbsync --all"; + description = '' + Bash statements run before scanning or importing new + messages into the database. + ''; + }; + + postNew = mkOption { + type = types.lines; + default = ""; + example = '' + notmuch tag +nixos -- tag:new and from:nixos1@discoursemail.com + ''; + description = '' + Bash statements run after new messages have been imported + into the database and initial tags have been applied. + ''; + }; + + postInsert = mkOption { + type = types.lines; + default = ""; + description = '' + Bash statements run after a message has been inserted + into the database and initial tags have been applied. + ''; + }; + }; + }; + + accounts.email.accounts = mkOption { + options = [ + { + notmuch = { + enable = mkEnableOption "notmuch indexing"; + }; + } + ]; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = notmuchIni.user.name != []; + message = "notmuch: Must have a user name set."; + } + { + assertion = notmuchIni.user.primary_email != []; + message = "notmuch: Must have a user primary email address set."; + } + ]; + + home.packages = [ pkgs.notmuch ]; + + home.sessionVariables = { + NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/notmuchrc"; + NMBGIT = "${config.xdg.dataHome}/notmuch/nmbug"; + }; + + xdg.configFile."notmuch/notmuchrc".text = + let + toIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; + in + "# Generated by Home Manager.\n\n" + + toIni notmuchIni; + + home.file = + let + hook = name: cmds: + { + target = "${notmuchIni.database.path}/.notmuch/hooks/${name}"; + source = pkgs.writeScript name '' + #!${pkgs.stdenv.shell} + + export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH" + export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/notmuchrc" + export NMBGIT="${config.xdg.dataHome}/notmuch/nmbug" + + ${cmds} + ''; + executable = true; + }; + in + optional (cfg.hooks.preNew != "") + (hook "pre-new" cfg.hooks.preNew) + ++ + optional (cfg.hooks.postNew != "") + (hook "post-new" cfg.hooks.postNew) + ++ + optional (cfg.hooks.postInsert != "") + (hook "post-insert" cfg.hooks.postInsert); + }; +} -- cgit v1.2.3 From 86fcfc74da38edd53ef2c8117388bafb254efd19 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 4 Jul 2018 19:54:27 +0200 Subject: nixpkgs: replace use of `traceValIfNot` The `traceValIfNot` function is deprecated in Nixpkgs master. Instead use `traceSeqN`. Fixes #301 --- modules/misc/nixpkgs.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index 23c79b0f442..f51588f9d3e 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -34,7 +34,11 @@ let configType = mkOptionType { name = "nixpkgs-config"; description = "nixpkgs config"; - check = traceValIfNot isConfig; + check = x: + let traceXIfNot = c: + if c x then true + else lib.traceSeqN 1 x false; + in traceXIfNot isConfig; merge = args: fold (def: mergeConfig def.value) {}; }; -- cgit v1.2.3 From e365943a709fbc0246b40fb124557bb6efd8a86d Mon Sep 17 00:00:00 2001 From: LightDiscord Date: Sat, 7 Jul 2018 11:58:10 +0200 Subject: awesome: add module --- modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/services/window-managers/awesome.nix | 57 ++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 modules/services/window-managers/awesome.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index aba6e3bebba..8f160ad258d 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -704,6 +704,13 @@ in A new module is available: 'programs.notmuch'. ''; } + + { + time = "2018-07-07T15:48:56+00:00"; + message = '' + A new module is available: 'xsession.windowManager.awesome'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index b9727ff396c..78254c1d456 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -77,6 +77,7 @@ let ./services/tahoe-lafs.nix ./services/udiskie.nix ./services/unclutter.nix + ./services/window-managers/awesome.nix ./services/window-managers/i3.nix ./services/window-managers/xmonad.nix ./services/xscreensaver.nix diff --git a/modules/services/window-managers/awesome.nix b/modules/services/window-managers/awesome.nix new file mode 100644 index 00000000000..ef01414f07b --- /dev/null +++ b/modules/services/window-managers/awesome.nix @@ -0,0 +1,57 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession.windowManager.awesome; + awesome = cfg.package; + getLuaPath = lib: dir: "${lib}/${dir}/lua/${pkgs.luaPackages.lua.luaversion}"; + makeSearchPath = lib.concatMapStrings (path: + " --search ${getLuaPath path "share"}" + " --search ${getLuaPath path "lib"}" + ); + +in + +{ + options = { + xsession.windowManager.awesome = { + enable = mkEnableOption "Awesome window manager."; + + package = mkOption { + type = types.package; + default = pkgs.awesome; + defaultText = "pkgs.awesome"; + description = "Package to use for running the Awesome WM."; + }; + + luaModules = mkOption { + default = []; + type = types.listOf types.package; + description = '' + List of lua packages available for being + used in the Awesome configuration. + ''; + example = literalExample "[ luaPackages.oocairo ]"; + }; + + noArgb = mkOption { + default = false; + type = types.bool; + description = '' + Disable client transparency support, which can be greatly + detrimental to performance in some setups + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ awesome ]; + xsession.windowManager.command = + "${awesome}/bin/awesome " + + optionalString cfg.noArgb "--no-argb " + + makeSearchPath cfg.luaModules; + }; +} -- cgit v1.2.3 From dadfaed82913692b26ad8816ad6a6ce993c66100 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 13 Jun 2018 21:00:26 +0200 Subject: home-manager: add support for the nix tool This adds an experimantal, undocumented, and unsupported flag `-2` for the `home-manager` command that enables the use of the new `nix` command instead of `nix-build`. --- home-manager/home-manager | 77 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 2f04cd8620d..5ad842bdc76 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -58,6 +58,8 @@ function doBuildAttr() { setConfigFile setHomeManagerNixPath + local subCommand="$1" + shift local extraArgs="$*" for p in "${EXTRA_NIX_PATH[@]}"; do @@ -69,11 +71,25 @@ function doBuildAttr() { fi # shellcheck disable=2086 - nix-build \ - "" \ - $extraArgs \ - --argstr confPath "$HOME_MANAGER_CONFIG" \ - --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" + if [[ -v USE_NIX2_COMMAND ]]; then + if [[ $subCommand == 'eval' ]]; then + extraArgs="$extraArgs --raw" + fi + nix $subCommand \ + -f "" \ + $extraArgs \ + --argstr confPath "$HOME_MANAGER_CONFIG" \ + --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" + else + if [[ $subCommand == 'eval' ]]; then + extraArgs="$extraArgs --no-out-link" + fi + nix-build \ + "" \ + $extraArgs \ + --argstr confPath "$HOME_MANAGER_CONFIG" \ + --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" + fi } # Presents news to the user. Takes as argument the path to a "news @@ -125,8 +141,14 @@ function doBuild() { newsInfo=$(buildNews) local exitCode - doBuildAttr -A activationPackage \ - && exitCode=0 || exitCode=1 + + if [[ -v USE_NIX2_COMMAND ]]; then + doBuildAttr build activationPackage \ + && exitCode=0 || exitCode=1 + else + doBuildAttr build --attr activationPackage \ + && exitCode=0 || exitCode=1 + fi presentNews "$newsInfo" @@ -145,9 +167,21 @@ function doSwitch() { # specify an output link so that it is treated as a GC root. This # prevents an unfortunately timed GC from removing the generation # before activation completes. - wrkdir="$(mktemp -d)" - generation=$(doBuildAttr -o "$wrkdir/result" -A activationPackage) \ - && $generation/activate || exitCode=1 + wrkdir="$(mktemp -d home-manager-build.XXXXXXXXXX)" + generation="$wrkdir/result" + + if [[ -v USE_NIX2_COMMAND ]]; then + doBuildAttr build \ + --out-link "$generation" \ + activationPackage \ + && "$generation/activate" || exitCode=1 + else + doBuildAttr build \ + --out-link "$generation" \ + --no-build-output \ + --attr activationPackage > /dev/null \ + && "$generation/activate" || exitCode=1 + fi # Because the previous command never fails, the script keeps # running and $wrkdir is always removed. @@ -237,11 +271,19 @@ function newsReadIdsFile() { # (although this exposes the risk of GC removing the result before we # manage to source it). function buildNews() { - doBuildAttr --quiet \ - --attr newsInfo \ - --no-out-link \ - --arg check false \ - --argstr newsReadIdsFile "$(newsReadIdsFile)" + if [[ -v USE_NIX2_COMMAND ]]; then + doBuildAttr eval \ + --quiet \ + --arg check false \ + --argstr newsReadIdsFile "$(newsReadIdsFile)" \ + newsInfo + else + doBuildAttr eval \ + --quiet \ + --arg check false \ + --argstr newsReadIdsFile "$(newsReadIdsFile)" \ + --attr newsInfo + fi } function doShowNews() { @@ -317,8 +359,11 @@ for arg in "$@"; do fi done -while getopts f:I:A:vnh opt; do +while getopts 2f:I:A:vnh opt; do case $opt in + 2) + USE_NIX2_COMMAND=1 + ;; f) HOME_MANAGER_CONFIG="$OPTARG" ;; -- cgit v1.2.3 From f4a1a5e94c448df35da24bdd13ba96d021aef6d0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 12 Jul 2018 00:30:54 +0200 Subject: home-manager: resolve default configuration file path Home Manager needs an absolute and resolved path to its configuration file. The default configuration path is absolute but not necessarily resolved. For example, some users may have `~/.config` be a symbolic link to somewhere else. We therefore run the default configuration path through the `realpath` tool to resolve it. Fixes #304 --- home-manager/home-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 5ad842bdc76..419e962d88d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -32,7 +32,7 @@ function setConfigFile() { for confFile in "$defaultConfFile" \ "$HOME/.nixpkgs/home.nix" ; do if [[ -e "$confFile" ]] ; then - HOME_MANAGER_CONFIG="$confFile" + HOME_MANAGER_CONFIG="$(realpath "$confFile")" return fi done -- cgit v1.2.3 From 092706eff85aa4501994016375693320ef9d2e7b Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Thu, 12 Jul 2018 19:10:01 -0500 Subject: nixpkgs: only pass pkgs_i686 argument on Linux Nixpkgs added an assertion on pkgsi686Linux [1] to avoid evaluating it pkgsi686Linux on non-Linux systems. [1] https://github.com/nixos/nixpkgs/commit/ad20a4a1c328967c7e4abe211f3dd63bb68bf966 --- modules/misc/nixpkgs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index f51588f9d3e..287a74b201e 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -144,7 +144,7 @@ in config = { _module.args = { pkgs = _pkgs; - pkgs_i686 = _pkgs.pkgsi686Linux; + pkgs_i686 = if _pkgs.stdenv.isLinux then _pkgs.pkgsi686Linux else {}; }; }; } -- cgit v1.2.3 From 34db8df6d91d8c142435d0d66bad50a6b2c090f0 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 13 Jul 2018 21:54:20 +0300 Subject: redshift: enable geoclue2 --- modules/services/redshift.nix | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index 423b9fe1b40..b1351dfb872 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -25,18 +25,33 @@ in }; latitude = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = '' - Your current latitude, between - -90.0 and 90.0. + Your current latitude, between -90.0 and + 90.0. Must be provided along with + longitude. ''; }; longitude = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = '' - Your current longitude, between - between -180.0 and 180.0. + Your current longitude, between -180.0 and + 180.0. Must be provided along with + latitude. + ''; + }; + + provider = mkOption { + type = types.enum [ "manual" "geoclue2" ]; + default = "manual"; + description = '' + The location provider to use for determining your location. If set to + manual you must also provide latitude/longitude. + If set to geoclue2, you must also enable the global + geoclue2 service. ''; }; @@ -122,11 +137,17 @@ in Service = { ExecStart = let + providerString = + if cfg.provider == "manual" + then "${cfg.latitude}:${cfg.longitude}" + else cfg.provider; + args = [ - "-l ${cfg.latitude}:${cfg.longitude}" + "-l ${providerString}" "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" ] ++ cfg.extraOptions; + command = if cfg.tray then "redshift-gtk" else "redshift"; in "${cfg.package}/bin/${command} ${concatStringsSep " " args}"; -- cgit v1.2.3 From d3871ed77447fdebe3673b69df7d75589378c53b Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 15 Jul 2018 09:33:32 +0300 Subject: mpd: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/services/mpd.nix | 148 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 modules/services/mpd.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 8f160ad258d..88c8f632f68 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -711,6 +711,13 @@ in A new module is available: 'xsession.windowManager.awesome'. ''; } + + { + time = "2018-07-18T20:14:11+00:00"; + message = '' + A new module is available: 'services.mpd'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 78254c1d456..323fe176acb 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -64,6 +64,7 @@ let ./services/keepassx.nix ./services/keybase.nix ./services/mbsync.nix + ./services/mpd.nix ./services/network-manager-applet.nix ./services/owncloud-client.nix ./services/parcellite.nix diff --git a/modules/services/mpd.nix b/modules/services/mpd.nix new file mode 100644 index 00000000000..5cc5811767c --- /dev/null +++ b/modules/services/mpd.nix @@ -0,0 +1,148 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + name = "mpd"; + + cfg = config.services.mpd; + + mpdConf = pkgs.writeText "mpd.conf" '' + music_directory "${cfg.musicDirectory}" + playlist_directory "${cfg.playlistDirectory}" + ${lib.optionalString (cfg.dbFile != null) '' + db_file "${cfg.dbFile}" + ''} + state_file "${cfg.dataDir}/state" + sticker_file "${cfg.dataDir}/sticker.sql" + log_file "syslog" + + ${optionalString (cfg.network.listenAddress != "any") + ''bind_to_address "${cfg.network.listenAddress}"''} + ${optionalString (cfg.network.port != 6600) + ''port "${toString cfg.network.port}"''} + + ${cfg.extraConfig} + ''; + +in { + + ###### interface + + options = { + + services.mpd = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable MPD, the music player daemon. + ''; + }; + + musicDirectory = mkOption { + type = types.path; + default = "${config.home.homeDirectory}/music"; + defaultText = "$HOME/music"; + description = '' + The directory where mpd reads music from. + ''; + }; + + playlistDirectory = mkOption { + type = types.path; + default = "${cfg.dataDir}/playlists"; + defaultText = ''''${dataDir}/playlists''; + description = '' + The directory where mpd stores playlists. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra directives added to to the end of MPD's configuration + file, mpd.conf. Basic configuration + like file location and uid/gid is added automatically to the + beginning of the file. For available options see + + mpd.conf + 5 + . + ''; + }; + + dataDir = mkOption { + type = types.path; + default = "${config.xdg.dataHome}/${name}"; + defaultText = "$XDG_DATA_HOME/mpd"; + description = '' + The directory where MPD stores its state, tag cache, + playlists etc. + ''; + }; + + network = { + + listenAddress = mkOption { + type = types.str; + default = "127.0.0.1"; + example = "any"; + description = '' + The address for the daemon to listen on. + Use any to listen on all addresses. + ''; + }; + + port = mkOption { + type = types.ints.positive; + default = 6600; + description = '' + The TCP port on which the the daemon will listen. + ''; + }; + + }; + + dbFile = mkOption { + type = types.nullOr types.str; + default = "${cfg.dataDir}/tag_cache"; + defaultText = ''''${dataDir}/tag_cache''; + description = '' + The path to MPD's database. If set to + null the parameter is omitted from the + configuration. + ''; + }; + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + systemd.user.services.mpd = { + Unit = { + After = [ "network.target" "sound.target" ]; + Description = "Music Player Daemon"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + + Service = { + Environment = "PATH=%h/.nix-profile/bin"; + ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${mpdConf}"; + Type = "notify"; + ExecStartPre = ''${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p '${cfg.dataDir}' '${cfg.playlistDirectory}'"''; + }; + }; + }; + +} -- cgit v1.2.3 From 9570cedff62a6d08eb13f8c6164b496ff88c834f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Jul 2018 13:15:34 +0200 Subject: nixos module: we need a running nix-daemon Make sure the nix-daemon is prepared before we attempt to do the user activation otherwise the script may fail due to not being able to communicate. --- nixos/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index d72d8a19557..c101f5a981d 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -36,6 +36,8 @@ in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") { description = "Home Manager environment for ${username}"; wantedBy = [ "multi-user.target" ]; + wants = [ "nix-daemon.socket" ]; + after = [ "nix-daemon.socket" ]; serviceConfig = { User = username; -- cgit v1.2.3 From 29ad012763f4e07c5c50635915c1d4ae751123cc Mon Sep 17 00:00:00 2001 From: Anton Plotnikov Date: Fri, 20 Jul 2018 00:55:23 +0300 Subject: udiskie: add sni support --- modules/services/udiskie.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index 5155b37cd1c..2976a631892 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -13,6 +13,7 @@ let (if cfg.notify then "n" else "N") ({ always = "t"; auto = "s"; never = "T"; }.${cfg.tray}) ] + ++ optional cfg.sni "--appindicator" ); in @@ -36,6 +37,12 @@ in description = "Whether to show pop-up notifications."; }; + sni = mkOption { + type = types.bool; + default = false; + description = "Whether to enable sni (appindicator) support."; + }; + tray = mkOption { type = types.enum [ "always" "auto" "never" ]; default = "auto"; -- cgit v1.2.3 From 6ae2d74fca6d84303283f0594a329db7c5738067 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 24 Jul 2018 12:48:53 +0200 Subject: xsession: add option `preferStatusNotifierItems` The intent is for tray applets to honor this option if they support the SNI protocol. --- modules/xsession.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/xsession.nix b/modules/xsession.nix index 3bce4506521..816a1aa9fbd 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -30,6 +30,17 @@ in ''; }; + preferStatusNotifierItems = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether tray applets should prefer using the Status Notifier + Items (SNI) protocol, commonly called App Indicators. Note, + not all tray applets or status bars support SNI. + ''; + }; + profileExtra = mkOption { type = types.lines; default = ""; -- cgit v1.2.3 From a5a49c350d22b6f61b82e69d0232fd8c3457bbc3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 24 Jul 2018 12:53:31 +0200 Subject: network-manager-applet: use xsession.preferStatusNotifierItems --- modules/services/network-manager-applet.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index 6fd50575a1f..e91b8543ee6 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -2,6 +2,12 @@ with lib; +let + + cfg = config.services.network-manager-applet; + +in + { meta.maintainers = [ maintainers.rycee ]; @@ -11,7 +17,7 @@ with lib; }; }; - config = mkIf config.services.network-manager-applet.enable { + config = mkIf cfg.enable { systemd.user.services.network-manager-applet = { Unit = { Description = "Network Manager applet"; @@ -24,7 +30,12 @@ with lib; }; Service = { - ExecStart = "${pkgs.networkmanagerapplet}/bin/nm-applet --sm-disable"; + ExecStart = toString ( + [ + "${pkgs.networkmanagerapplet}/bin/nm-applet" + "--sm-disable" + ] ++ optional config.xsession.preferStatusNotifierItems "--indicator" + ); }; }; }; -- cgit v1.2.3 From 6694330bb2c648379a6ba4f84e44be8146c5f116 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 24 Jul 2018 12:59:11 +0200 Subject: udiskie: use xsession.preferStatusNotifierItems --- modules/services/udiskie.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index 2976a631892..c058a23de6c 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -13,7 +13,7 @@ let (if cfg.notify then "n" else "N") ({ always = "t"; auto = "s"; never = "T"; }.${cfg.tray}) ] - ++ optional cfg.sni "--appindicator" + ++ optional config.xsession.preferStatusNotifierItems "--appindicator" ); in @@ -21,6 +21,16 @@ in { meta.maintainers = [ maintainers.rycee ]; + imports = [ + (mkRemovedOptionModule [ "services" "udiskie" "sni" ] '' + Support for Status Notifier Items is now configured globally through the + + xsession.preferStatusNotifierItems + + option. Please change to use that instead. + '') + ]; + options = { services.udiskie = { enable = mkEnableOption "udiskie mount daemon"; @@ -37,12 +47,6 @@ in description = "Whether to show pop-up notifications."; }; - sni = mkOption { - type = types.bool; - default = false; - description = "Whether to enable sni (appindicator) support."; - }; - tray = mkOption { type = types.enum [ "always" "auto" "never" ]; default = "auto"; -- cgit v1.2.3 From cf80199bfcbcecf6be84fea122c66fc081c4edd3 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sun, 22 Jul 2018 20:57:01 +0200 Subject: xresources: join lists with a "," --- modules/xresources.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index 634314f3ae9..7afee8bb7c8 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -8,11 +8,17 @@ let formatLine = n: v: let - v' = + formatList = x: + if isList x + then throw "can not convert 2-dimensional lists to Xresources format" + else formatValue x; + + formatValue = v: if isBool v then (if v then "true" else "false") + else if isList v then concatMapStringsSep ", " formatList v else toString v; in - "${n}: ${v'}"; + "${n}: ${formatValue v}"; in @@ -24,11 +30,16 @@ in type = types.nullOr types.attrs; default = null; example = { - "XTerm*faceName" = "dejavu sans mono"; "Emacs*toolBar" = 0; + "XTerm*faceName" = "dejavu sans mono"; + "XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ]; }; description = '' X server resources that should be set. + Booleans are formatted as "true" or "false" respectively. + List elements are recursively formatted as a string and joined by commas. + All other values are directly formatted using builtins.toString. + Note, that 2-dimensional lists are not supported and specifying one will throw an exception. If this and all other xresources options are null, then this feature is disabled and no ~/.Xresources link is produced. -- cgit v1.2.3 From dda65c0877b0b6c98d0f628374f2651d92597086 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 26 Jul 2018 17:59:06 +0200 Subject: polybar: let systemd reload trigger restart --- modules/services/polybar.nix | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 52ea7b4ec72..a187f62a0d4 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -119,6 +119,7 @@ in Description = "Polybar status bar"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; + X-Restart-Triggers = [ config.xdg.configFile."polybar/config".source ]; }; Service = { @@ -131,21 +132,6 @@ in WantedBy = [ "graphical-session.target" ]; }; }; - - home.activation.checkPolybar = dag.entryBefore [ "linkGeneration" ] '' - if ! cmp --quiet \ - "${configFile}" \ - "$HOME/.config/polybar/config"; then - polybarChanged=1 - fi - ''; - - home.activation.applyPolybar = dag.entryAfter [ "reloadSystemD" ] '' - if [[ -v polybarChanged && -v DISPLAY ]]; then - echo "Restarting polybar" - ${config.systemd.user.systemctlPath} --user restart polybar.service - fi - ''; }; } -- cgit v1.2.3 From 30cba446f2c2e04db5a5001aaf606a4a5563e1de Mon Sep 17 00:00:00 2001 From: Andrew Scott <3648487+ayyjayess@users.noreply.github.com> Date: Fri, 16 Feb 2018 23:32:29 +0000 Subject: files: add `onChange` option This option allows execution of arbitrary shell code when a file that is linked into the home directory has been changed between generations. --- modules/files.nix | 18 ++++++++++++++++++ modules/lib/file-type.nix | 11 +++++++++++ modules/services/window-managers/i3.nix | 27 ++++++++++----------------- modules/services/window-managers/xmonad.nix | 25 ++++++++----------------- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index c4978a1aeea..fd58027b36c 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -197,6 +197,24 @@ in '' ); + home.activation.checkFilesChanged = dag.entryBefore ["linkGeneration"] ( + '' + declare -A changedFiles + '' + concatMapStrings (v: '' + cmp --quiet "${v.source}" "${config.home.homeDirectory}/${v.target}" \ + && changedFiles["${v.target}"]=0 \ + || changedFiles["${v.target}"]=1 + '') (filter (v: v.onChange != "") (attrValues cfg)) + ); + + home.activation.onFilesChange = dag.entryAfter ["linkGeneration"] ( + concatMapStrings (v: '' + if [[ ${"$\{changedFiles"}["${v.target}"]} -eq 1 ]]; then + ${v.onChange} + fi + '') (filter (v: v.onChange != "") (attrValues cfg)) + ); + home-files = pkgs.stdenv.mkDerivation { name = "home-manager-files"; diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index 80d4ab45b2c..0c435aaa908 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -95,6 +95,17 @@ in are symbolic links to the files of the source directory. ''; }; + + onChange = mkOption { + type = types.lines; + default = ""; + description = '' + Shell commands to run when file has changed between + generations. The script will be run + after the new files have been linked + into place. + ''; + }; }; config = { diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 7b663a4fcae..84b5d25e65b 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -771,23 +771,16 @@ in { home.packages = [ cfg.package ]; xsession.windowManager.command = "${cfg.package}/bin/i3"; - xdg.configFile."i3/config".source = configFile; - - home.activation.checkI3 = dag.entryBefore [ "linkGeneration" ] '' - if ! cmp --quiet \ - "${configFile}" \ - "${config.xdg.configHome}/i3/config"; then - i3Changed=1 - fi - ''; - - home.activation.reloadI3 = dag.entryAfter [ "linkGeneration" ] '' - SOCKET=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* - if [ -v i3Changed ] && [ -S $SOCKET ]; then - echo "Reloading i3" - ${cfg.package}/bin/i3-msg -s $SOCKET reload 1>/dev/null - fi - ''; + xdg.configFile."i3/config" = { + source = configFile; + onChange = '' + i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* + if [ -S $i3Socket ]; then + echo "Reloading i3" + $DRY_RUN_CMD ${cfg.package}/bin/i3-msg -s $i3Socket reload 1>/dev/null + fi + ''; + }; } (mkIf (cfg.config != null) { diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index d4643b09168..754e7f1fbf4 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -90,23 +90,14 @@ in (mkIf (cfg.config != null) { home.file.".xmonad/xmonad.hs".source = cfg.config; - - home.activation.checkXmonad = dag.entryBefore [ "linkGeneration" ] '' - if ! cmp --quiet "${cfg.config}" "$HOME/.xmonad/xmonad.hs"; then - xmonadChanged=1 - fi - ''; - - home.activation.applyXmonad = dag.entryAfter [ "linkGeneration" ] '' - if [[ -v xmonadChanged ]]; then - echo "Recompiling xmonad" - ${config.xsession.windowManager.command} --recompile - - # Attempt to restart xmonad if X is running. - if [[ -v DISPLAY ]] ; then - echo "Restarting xmonad" - ${config.xsession.windowManager.command} --restart - fi + home.file.".xmonad/xmonad.hs".onChange = '' + echo "Recompiling xmonad" + $DRY_RUN_CMD ${config.xsession.windowManager.command} --recompile + + # Attempt to restart xmonad if X is running. + if [[ -v DISPLAY ]] ; then + echo "Restarting xmonad" + $DRY_RUN_CMD ${config.xsession.windowManager.command} --restart fi ''; }) -- cgit v1.2.3 From 4f67e8d0c32a51897529eecb3351c3700f1209c0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Jul 2018 13:42:56 +0200 Subject: home-manager: fix GC issue It was previously possible to create the news information and lose it in a Nix GC before being able to view it. This also causes a switch to error out. This change makes the news information a root in the garbage collector. Note, this change also removes the need for `nix eval` so the `doBuildAttr` function is simplified accordingly. Fixes #327 --- home-manager/home-manager | 58 ++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 419e962d88d..b5639be2605 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -12,6 +12,14 @@ function errorEcho() { echo $* >&2 } +function setWorkDir() { + if [[ ! -v WORK_DIR ]]; then + WORK_DIR="$(mktemp --tmpdir -d home-manager-build.XXXXXXXXXX)" + # shellcheck disable=2064 + trap "rm -r '$WORK_DIR'" EXIT + fi +} + # Attempts to set the HOME_MANAGER_CONFIG global variable. # # If no configuration file can be found then this function will print @@ -58,8 +66,6 @@ function doBuildAttr() { setConfigFile setHomeManagerNixPath - local subCommand="$1" - shift local extraArgs="$*" for p in "${EXTRA_NIX_PATH[@]}"; do @@ -72,18 +78,12 @@ function doBuildAttr() { # shellcheck disable=2086 if [[ -v USE_NIX2_COMMAND ]]; then - if [[ $subCommand == 'eval' ]]; then - extraArgs="$extraArgs --raw" - fi - nix $subCommand \ + nix build \ -f "" \ $extraArgs \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" else - if [[ $subCommand == 'eval' ]]; then - extraArgs="$extraArgs --no-out-link" - fi nix-build \ "" \ $extraArgs \ @@ -143,10 +143,10 @@ function doBuild() { local exitCode if [[ -v USE_NIX2_COMMAND ]]; then - doBuildAttr build activationPackage \ + doBuildAttr activationPackage \ && exitCode=0 || exitCode=1 else - doBuildAttr build --attr activationPackage \ + doBuildAttr --attr activationPackage \ && exitCode=0 || exitCode=1 fi @@ -156,37 +156,33 @@ function doBuild() { } function doSwitch() { + setWorkDir + local newsInfo newsInfo=$(buildNews) local generation local exitCode=0 - local wrkdir # Build the generation and run the activate script. Note, we # specify an output link so that it is treated as a GC root. This # prevents an unfortunately timed GC from removing the generation # before activation completes. - wrkdir="$(mktemp -d home-manager-build.XXXXXXXXXX)" - generation="$wrkdir/result" + generation="$WORK_DIR/generation" if [[ -v USE_NIX2_COMMAND ]]; then - doBuildAttr build \ + doBuildAttr \ --out-link "$generation" \ activationPackage \ && "$generation/activate" || exitCode=1 else - doBuildAttr build \ + doBuildAttr \ --out-link "$generation" \ --no-build-output \ --attr activationPackage > /dev/null \ && "$generation/activate" || exitCode=1 fi - # Because the previous command never fails, the script keeps - # running and $wrkdir is always removed. - rm -r "$wrkdir" - presentNews "$newsInfo" return $exitCode @@ -267,26 +263,36 @@ function newsReadIdsFile() { # Builds news meta information to be sourced into this script. # # Note, we suppress build output to remove unnecessary verbosity. We -# also use "no out link" to avoid the need for a build directory -# (although this exposes the risk of GC removing the result before we -# manage to source it). +# put the output in the work directory to avoid the risk of an +# unfortunately timed GC removing it. function buildNews() { + local output + output="$WORK_DIR/news-info.sh" + if [[ -v USE_NIX2_COMMAND ]]; then - doBuildAttr eval \ + doBuildAttr \ + --out-link "$output" \ --quiet \ --arg check false \ --argstr newsReadIdsFile "$(newsReadIdsFile)" \ newsInfo else - doBuildAttr eval \ + doBuildAttr \ + --out-link "$output" \ + --no-build-output \ --quiet \ --arg check false \ --argstr newsReadIdsFile "$(newsReadIdsFile)" \ - --attr newsInfo + --attr newsInfo \ + > /dev/null fi + + echo "$output" } function doShowNews() { + setWorkDir + local infoFile infoFile=$(buildNews) || return 1 -- cgit v1.2.3 From 2e9e1909dacbe22539855857bf6ee0d01300bae6 Mon Sep 17 00:00:00 2001 From: Anton Plotnikov Date: Fri, 20 Jul 2018 00:29:47 +0300 Subject: status-notifier-watcher: add service --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/services/status-notifier-watcher.nix | 46 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 modules/services/status-notifier-watcher.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 88c8f632f68..aa3d4f73c88 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -718,6 +718,13 @@ in A new module is available: 'services.mpd'. ''; } + + { + time = "2018-07-31T13:33:39+00:00"; + message = '' + A new module is available: 'services.status-notifier-watcher'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 323fe176acb..982dab956a6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -73,6 +73,7 @@ let ./services/redshift.nix ./services/screen-locker.nix ./services/stalonetray.nix + ./services/status-notifier-watcher.nix ./services/syncthing.nix ./services/taffybar.nix ./services/tahoe-lafs.nix diff --git a/modules/services/status-notifier-watcher.nix b/modules/services/status-notifier-watcher.nix new file mode 100644 index 00000000000..08c668bf050 --- /dev/null +++ b/modules/services/status-notifier-watcher.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.status-notifier-watcher; + +in + +{ + meta.maintainers = [ maintainers.pltanton ]; + + options = { + services.status-notifier-watcher = { + enable = mkEnableOption "Status Notifier Watcher"; + + package = mkOption { + default = pkgs.haskellPackages.status-notifier-item; + defaultText = "pkgs.haskellPackages.status-notifier-item"; + type = types.package; + example = literalExample "pkgs.haskellPackages.status-notifier-item"; + description = "The package to use for the status notifier watcher binary."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.status-notifier-watcher = { + Unit = { + Description = "SNI watcher"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + Before = [ "taffybar.service" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/status-notifier-watcher"; + }; + + Install = { + WantedBy = [ "graphical-session.target" "taffybar.service" ]; + }; + }; + }; +} -- cgit v1.2.3 From 93ef6aefce9c2cf5f6a3598a5b263c872cdddfc4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Jul 2018 15:48:08 +0200 Subject: direnv: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/direnv.nix | 50 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 modules/programs/direnv.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index aa3d4f73c88..27580912c84 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -725,6 +725,13 @@ in A new module is available: 'services.status-notifier-watcher'. ''; } + + { + time = "2018-07-31T13:47:06+00:00"; + message = '' + A new module is available: 'programs.direnv'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 982dab956a6..1b8733fcf82 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -29,6 +29,7 @@ let ./programs/beets.nix ./programs/browserpass.nix ./programs/command-not-found/command-not-found.nix + ./programs/direnv.nix ./programs/eclipse.nix ./programs/emacs.nix ./programs/feh.nix diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix new file mode 100644 index 00000000000..1f0211a1643 --- /dev/null +++ b/modules/programs/direnv.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.direnv; + +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options.programs.direnv = { + enable = mkEnableOption "direnv, the environment switcher"; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.direnv ]; + + programs.bash.initExtra = + mkIf cfg.enableBashIntegration ( + # Using mkAfter to make it more likely to appear after other + # manipulations of the prompt. + mkAfter '' + eval "$(${pkgs.direnv}/bin/direnv hook bash)" + '' + ); + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${pkgs.direnv}/bin/direnv hook zsh)" + ''; + }; +} -- cgit v1.2.3 From c18b1328a52c0d5ce54924051a43a597b86ff4e3 Mon Sep 17 00:00:00 2001 From: Malte Brandy Date: Sun, 29 Jul 2018 18:15:50 +0200 Subject: Parametrize path to profile directory --- modules/home-environment.nix | 13 +++++++++++++ modules/misc/fontconfig.nix | 4 ++-- modules/programs/bash.nix | 2 +- modules/programs/info.nix | 2 +- modules/programs/zsh.nix | 2 +- modules/services/dunst.nix | 2 +- modules/services/flameshot.nix | 2 +- modules/services/kdeconnect.nix | 4 ++-- modules/services/mpd.nix | 4 ++-- modules/services/owncloud-client.nix | 2 +- modules/services/syncthing.nix | 2 +- modules/xsession.nix | 2 +- 12 files changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index c6fc345d7a2..ae0e4ad572a 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -121,6 +121,17 @@ in description = "The user's home directory."; }; + home.profileDirectory = mkOption { + type = types.path; + defaultText = "~/.nix-profile"; + internal = true; + readOnly = true; + description = '' + The profile directory where Home Manager generations are + installed. + ''; + }; + home.language = mkOption { type = languageSubModule; default = {}; @@ -249,6 +260,8 @@ in home.username = mkDefault (builtins.getEnv "USER"); home.homeDirectory = mkDefault (builtins.getEnv "HOME"); + home.profileDirectory = cfg.homeDirectory + "/.nix-profile"; + home.sessionVariables = let maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; }; diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index e76e135eb6d..9ad8b195f72 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -33,8 +33,8 @@ in - ~/.nix-profile/lib/X11/fonts - ~/.nix-profile/share/fonts + ${config.home.profileDirectory}/lib/X11/fonts + ${config.home.profileDirectory}/share/fonts ''; }; diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 830e832e181..d8359c12f0b 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -182,7 +182,7 @@ in home.file.".profile".text = '' # -*- mode: sh -*- - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" ${sessionVarsStr} diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 4f3f1e5670d..93dcaf474af 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -29,7 +29,7 @@ let dag = config.lib.dag; # Indexes info files found in this location - homeInfoPath = "$HOME/.nix-profile/share/info"; + homeInfoPath = "${config.home.profileDirectory}/share/info"; # Installs this package -- the interactive just means that it # includes the curses `info` program. We also use `install-info` diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 6253d2a77fe..f4605fc6587 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -314,7 +314,7 @@ in } # Environment variables - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" ${envVarsStr} ${optionalString cfg.oh-my-zsh.enable '' diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index e01211b579a..1273ef39de7 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -99,7 +99,7 @@ in basePaths = [ "/run/current-system/sw" - "${config.home.homeDirectory}/.nix-profile" + config.home.profileDirectory cfg.iconTheme.package ] ++ optional useCustomTheme hicolorTheme.package; diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix index 7c259d43af1..d4cf90d59db 100644 --- a/modules/services/flameshot.nix +++ b/modules/services/flameshot.nix @@ -33,7 +33,7 @@ in }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${package}/bin/flameshot"; Restart = "on-abort"; }; diff --git a/modules/services/kdeconnect.nix b/modules/services/kdeconnect.nix index b0983bbe3db..a953c4ab8d3 100644 --- a/modules/services/kdeconnect.nix +++ b/modules/services/kdeconnect.nix @@ -41,7 +41,7 @@ in }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${package}/lib/libexec/kdeconnectd"; Restart = "on-abort"; }; @@ -64,7 +64,7 @@ in }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${package}/bin/kdeconnect-indicator"; Restart = "on-abort"; }; diff --git a/modules/services/mpd.nix b/modules/services/mpd.nix index 5cc5811767c..822d2fe3936 100644 --- a/modules/services/mpd.nix +++ b/modules/services/mpd.nix @@ -131,13 +131,13 @@ in { After = [ "network.target" "sound.target" ]; Description = "Music Player Daemon"; }; - + Install = { WantedBy = [ "default.target" ]; }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${mpdConf}"; Type = "notify"; ExecStartPre = ''${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p '${cfg.dataDir}' '${cfg.playlistDirectory}'"''; diff --git a/modules/services/owncloud-client.nix b/modules/services/owncloud-client.nix index 353e0136c08..d98a508f088 100644 --- a/modules/services/owncloud-client.nix +++ b/modules/services/owncloud-client.nix @@ -18,7 +18,7 @@ with lib; }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${pkgs.owncloud-client}/bin/owncloud"; }; diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 11511725134..7fc556c5234 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -54,7 +54,7 @@ with lib; }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; }; diff --git a/modules/xsession.nix b/modules/xsession.nix index 816a1aa9fbd..d55118e41eb 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -93,7 +93,7 @@ in }; home.file.".xprofile".text = '' - . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" if [[ -e "$HOME/.profile" ]]; then . "$HOME/.profile" -- cgit v1.2.3 From 39213a18470b0b6e6a7660d758fc9e3a2f539883 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Jul 2018 21:05:05 +0200 Subject: home-manager: fix work directory when building generation --- home-manager/home-manager | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index b5639be2605..0a89057c7e4 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -137,6 +137,8 @@ function doBuild() { return 1 fi + setWorkDir + local newsInfo newsInfo=$(buildNews) -- cgit v1.2.3 From 99c900946dbbaf5ba1fd3b1c1fe83b18fb66c84e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 31 Jul 2018 21:05:36 +0200 Subject: Avoid substitution for some derivations In particular, don't bother attempting to do substitution of the home files and home generation derivations since these rarely, if ever, could be substituted. Fixes #330 --- home-manager/install.nix | 2 ++ modules/files.nix | 3 +++ modules/home-environment.nix | 3 +++ 3 files changed, 8 insertions(+) diff --git a/home-manager/install.nix b/home-manager/install.nix index c6d3aa4e4ca..be9f17df067 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -4,6 +4,8 @@ pkgs.runCommand "home-manager-install" { propagatedBuildInputs = [ home-manager ]; + preferLocalBuild = true; + allowSubstitutes = false; shellHook = '' echo echo "Creating initial Home Manager generation..." diff --git a/modules/files.nix b/modules/files.nix index fd58027b36c..a9b8740dbb7 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -220,6 +220,9 @@ in nativeBuildInputs = [ pkgs.xlibs.lndir ]; + preferLocalBuild = true; + allowSubstitutes = false; + # Symlink directories and files that have the right execute bit. # Copy files that need their execute bit changed. buildCommand = '' diff --git a/modules/home-environment.nix b/modules/home-environment.nix index ae0e4ad572a..229e3d22ff4 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -349,6 +349,9 @@ in pkgs.stdenv.mkDerivation { name = "home-manager-generation"; + preferLocalBuild = true; + allowSubstitutes = false; + buildCommand = '' mkdir -p $out -- cgit v1.2.3 From 4b32f16747f5b21d4a512112d44cf60aa6ef2601 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 16 Aug 2018 21:37:42 +0200 Subject: Use submodules for program email accounts This reworks the way program specific email account options are specified. In particular, we no longer use the deprecated `options` field of `mkOption`. Instead submodules are used. --- modules/accounts/email.nix | 10 ++++-- modules/programs/mbsync-accounts.nix | 57 ++++++++++++++++++++++++++++++++++ modules/programs/mbsync.nix | 58 ----------------------------------- modules/programs/notmuch-accounts.nix | 7 +++++ modules/programs/notmuch.nix | 10 ------ 5 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 modules/programs/mbsync-accounts.nix create mode 100644 modules/programs/notmuch-accounts.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 6846cadb199..031b8baa28f 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -123,7 +123,7 @@ let # gpgModule = types.submodule { # }; - mailAccount = types.submodule ({ name, config, ... }: { + mailAccountOpts = { name, config, ... }: { options = { name = mkOption { type = types.str; @@ -272,7 +272,7 @@ let }; }) ]; - }); + }; in @@ -294,7 +294,11 @@ in }; accounts = mkOption { - type = types.attrsOf mailAccount; + type = types.attrsOf (types.submodule [ + mailAccountOpts + (import ../programs/mbsync-accounts.nix) + (import ../programs/notmuch-accounts.nix) + ]); default = {}; description = "List of email accounts."; }; diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix new file mode 100644 index 00000000000..a983b7ff9da --- /dev/null +++ b/modules/programs/mbsync-accounts.nix @@ -0,0 +1,57 @@ +{ lib, ... }: + +with lib; + +{ + options.mbsync = { + enable = mkEnableOption "synchronization using mbsync"; + + flatten = mkOption { + type = types.nullOr types.str; + default = null; + example = "."; + description = '' + If set, flattens the hierarchy within the maildir by + substituting the canonical hierarchy delimiter + / with this value. + ''; + }; + + create = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "maildir"; + description = '' + Automatically create missing mailboxes within the + given mail store. + ''; + }; + + remove = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "imap"; + description = '' + Propagate mailbox deletions to the given mail store. + ''; + }; + + expunge = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "both"; + description = '' + Permanently remove messages marked for deletion from + the given mail store. + ''; + }; + + patterns = mkOption { + type = types.listOf types.str; + default = [ "*" ]; + description = '' + Pattern of mailboxes to synchronize. + ''; + }; + }; +} diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 87a78355848..4abfc7b3fed 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -132,64 +132,6 @@ in ''; }; }; - - accounts.email.accounts = mkOption { - options = [ - { - mbsync = { - enable = mkEnableOption "synchronization using mbsync"; - - flatten = mkOption { - type = types.nullOr types.str; - default = null; - example = "."; - description = '' - If set, flattens the hierarchy within the maildir by - substituting the canonical hierarchy delimiter - / with this value. - ''; - }; - - create = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "maildir"; - description = '' - Automatically create missing mailboxes within the - given mail store. - ''; - }; - - remove = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "imap"; - description = '' - Propagate mailbox deletions to the given mail store. - ''; - }; - - expunge = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "both"; - description = '' - Permanently remove messages marked for deletion from - the given mail store. - ''; - }; - - patterns = mkOption { - type = types.listOf types.str; - default = [ "*" ]; - description = '' - Pattern of mailboxes to synchronize. - ''; - }; - }; - } - ]; - }; }; config = mkIf cfg.enable { diff --git a/modules/programs/notmuch-accounts.nix b/modules/programs/notmuch-accounts.nix new file mode 100644 index 00000000000..7c9c93d3f95 --- /dev/null +++ b/modules/programs/notmuch-accounts.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + options.notmuch = { + enable = lib.mkEnableOption "notmuch indexing"; + }; +} diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 3d7a651f35f..ef9f2ec4bf3 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -129,16 +129,6 @@ in }; }; }; - - accounts.email.accounts = mkOption { - options = [ - { - notmuch = { - enable = mkEnableOption "notmuch indexing"; - }; - } - ]; - }; }; config = mkIf cfg.enable { -- cgit v1.2.3 From 34133ca7f34d4ef80d83052ca6580e89885837eb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 16 Aug 2018 23:09:20 +0200 Subject: accounts.email: add global certificatesFile option This defaults to `/etc/ssl/certs/ca-certificates.crt` and will be picked up as default by the account specific option. --- modules/accounts/email.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 031b8baa28f..2f45fe7e7d7 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -25,8 +25,9 @@ let }; certificatesFile = mkOption { - type = types.nullOr types.path; - default = null; + type = types.path; + default = config.accounts.email.certificatesFile; + defaultText = "config.accounts.email.certificatesFile"; description = '' Path to file containing certificate authorities that should be used to validate the connection authenticity. If @@ -278,6 +279,16 @@ in { options.accounts.email = { + certificatesFile = mkOption { + type = types.path; + default = "/etc/ssl/certs/ca-certificates.crt"; + description = '' + Path to default file containing certificate authorities that + should be used to validate the connection authenticity. This + path may be overridden on a per-account basis. + ''; + }; + maildirBasePath = mkOption { type = types.str; default = "${config.home.homeDirectory}/Maildir"; -- cgit v1.2.3 From 168d5463042b9e8090190e20bb49f6f951034b02 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 6 Aug 2018 19:10:57 +0900 Subject: accounts.mail: add "gmail.com" as a flavor To help with some autoconfiguration. --- modules/accounts/email.nix | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 2f45fe7e7d7..640edc59b33 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -121,9 +121,6 @@ let }; }); - # gpgModule = types.submodule { - # }; - mailAccountOpts = { name, config, ... }: { options = { name = mkOption { @@ -145,7 +142,7 @@ let }; flavor = mkOption { - type = types.enum [ "plain" "runbox.com" ]; + type = types.enum [ "plain" "gmail.com" "runbox.com" ]; default = "plain"; description = '' Some email providers have peculiar behavior that require @@ -263,6 +260,19 @@ let maildir = mkOptionDefault { path = "${name}"; }; } + (mkIf (config.flavor == "gmail.com") { + userName = mkDefault config.address; + + imap = { + host = "imap.gmail.com"; + }; + + smtp = { + host = "smtp.gmail.com"; + port = 587; + }; + }) + (mkIf (config.flavor == "runbox.com") { imap = { host = "mail.runbox.com"; -- cgit v1.2.3 From 29191eb2c7f2b5a1032d55a97bdf3c22a1adfa20 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 14 Aug 2018 09:39:22 +0200 Subject: fish: add module Signed-off-by: Vincent Demeester --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/fish.nix | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 modules/programs/fish.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 27580912c84..6ba574b5386 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -732,6 +732,13 @@ in A new module is available: 'programs.direnv'. ''; } + + { + time = "2018-08-17T20:30:14+00:00"; + message = '' + A new module is available: 'programs.fish'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1b8733fcf82..03508b90fe4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -34,6 +34,7 @@ let ./programs/emacs.nix ./programs/feh.nix ./programs/firefox.nix + ./programs/fish.nix ./programs/fzf.nix ./programs/git.nix ./programs/gnome-terminal.nix diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix new file mode 100644 index 00000000000..fbef818b2e8 --- /dev/null +++ b/modules/programs/fish.nix @@ -0,0 +1,115 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.fish; + + abbrsStr = concatStringsSep "\n" ( + mapAttrsToList (k: v: "abbr --add ${k} '${v}'") cfg.shellAbbrs + ); + + aliasesStr = concatStringsSep "\n" ( + mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + ); + +in + +{ + options = { + programs.fish = { + enable = mkEnableOption "fish friendly interactive shell"; + + shellAliases = mkOption { + default = {}; + description = '' + Set of aliases for fish shell. See + for an option format description. + ''; + type = types.attrs; + }; + + shellAbbrs = mkOption { + default = {}; + description = '' + Set of abbreviations for fish shell. + ''; + type = types.attrs; + }; + + shellInit = mkOption { + default = ""; + description = '' + Shell script code called during fish shell initialisation. + ''; + type = types.lines; + }; + + loginShellInit = mkOption { + default = ""; + description = '' + Shell script code called during fish login shell initialisation. + ''; + type = types.lines; + }; + + interactiveShellInit = mkOption { + default = ""; + description = '' + Shell script code called during interactive fish shell initialisation. + ''; + type = types.lines; + }; + + promptInit = mkOption { + default = ""; + description = '' + Shell script code used to initialise fish prompt. + ''; + type = types.lines; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.fish ]; + + xdg.configFile."fish/config.fish".text = '' + # ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated automatically. + # if we haven't sourced the general config, do it + if not set -q __fish_general_config_sourced + + ${cfg.shellInit} + # and leave a note so we don't source this config section again from + # this very shell (children will source the general config anew) + set -g __fish_general_config_sourced 1 + end + # if we haven't sourced the login config, do it + status --is-login; and not set -q __fish_login_config_sourced + and begin + + ${cfg.loginShellInit} + # and leave a note so we don't source this config section again from + # this very shell (children will source the general config anew) + set -g __fish_login_config_sourced 1 + end + # if we haven't sourced the interactive config, do it + status --is-interactive; and not set -q __fish_interactive_config_sourced + and begin + # Abbrs + ${abbrsStr} + + # Aliases + ${aliasesStr} + + ${cfg.promptInit} + ${cfg.interactiveShellInit} + # and leave a note so we don't source this config section again from + # this very shell (children will source the general config anew, + # allowing configuration changes in, e.g, aliases, to propagate) + set -g __fish_interactive_config_sourced 1 + end + ''; + }; +} -- cgit v1.2.3 From 26342588ab99fdc10bbcc06da18cd331018e2fd5 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Sat, 18 Aug 2018 11:57:09 -0700 Subject: gpg-agent: add extraConfig option --- modules/misc/news.nix | 11 +++++++++++ modules/services/gpg-agent.nix | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 6ba574b5386..1f6bbcc2675 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -739,6 +739,17 @@ in A new module is available: 'programs.fish'. ''; } + + { + time = "2018-08-18T19:03:42+00:00"; + condition = config.services.gpg-agent.enable; + message = '' + A new option is available: 'services.gpg-agent.extraConfig'. + + Extra lines may be appended to $HOME/.gnupg/gpg-agent.conf + using this option. + ''; + } ]; }; } diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 5e2a41388a1..c4c045e5021 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -108,6 +108,19 @@ in setting to gpg-agent. ''; }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + allow-emacs-pinentry + allow-loopback-pinentry + ''; + description = '' + Extra configuration lines to append to the gpg-agent + configuration file. + ''; + }; }; }; @@ -131,6 +144,8 @@ in ++ optional (cfg.maxCacheTtlSsh != null) "max-cache-ttl-ssh ${toString cfg.maxCacheTtlSsh}" + ++ + [ cfg.extraConfig ] ); home.sessionVariables = -- cgit v1.2.3 From f9ac73732b25dedabb6a0b0fd6ace6598a1dd601 Mon Sep 17 00:00:00 2001 From: LightDiscord Date: Sat, 18 Aug 2018 20:41:44 +0200 Subject: awesome: fix missing concatenation --- modules/services/window-managers/awesome.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/awesome.nix b/modules/services/window-managers/awesome.nix index ef01414f07b..a01ee70dce1 100644 --- a/modules/services/window-managers/awesome.nix +++ b/modules/services/window-managers/awesome.nix @@ -9,7 +9,7 @@ let getLuaPath = lib: dir: "${lib}/${dir}/lua/${pkgs.luaPackages.lua.luaversion}"; makeSearchPath = lib.concatMapStrings (path: " --search ${getLuaPath path "share"}" - " --search ${getLuaPath path "lib"}" + + " --search ${getLuaPath path "lib"}" ); in -- cgit v1.2.3 From dd25fbcb4bbbbc9464d24334050f95e3dbf63fff Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Tue, 29 May 2018 09:41:53 -0700 Subject: chromium: add module --- modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/programs/chromium.nix | 93 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 modules/programs/chromium.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1f6bbcc2675..558806f968a 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -750,6 +750,13 @@ in using this option. ''; } + + { + time = "2018-08-19T20:46:09+00:00"; + message = '' + A new modules is available: 'programs.chromium'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 03508b90fe4..97caa4c0735 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -28,6 +28,7 @@ let ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix + ./programs/chromium.nix ./programs/command-not-found/command-not-found.nix ./programs/direnv.nix ./programs/eclipse.nix diff --git a/modules/programs/chromium.nix b/modules/programs/chromium.nix new file mode 100644 index 00000000000..8a39702776f --- /dev/null +++ b/modules/programs/chromium.nix @@ -0,0 +1,93 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + browserModule = defaultPkg: name: visible: + let + browser = (builtins.parseDrvName defaultPkg.name).name; + in + { + enable = mkOption { + inherit visible; + default = false; + example = true; + description = "Whether to enable ${name}."; + type = lib.types.bool; + }; + + package = mkOption { + inherit visible; + type = types.package; + default = defaultPkg; + defaultText = "pkgs.${browser}"; + description = "The ${name} package to use."; + }; + + extensions = mkOption { + inherit visible; + type = types.listOf types.str; + default = []; + example = literalExample '' + [ + "chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet + "mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot + "gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere + "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin + ] + ''; + description = '' + List of ${name} extensions to install. + To find the extension ID, check its URL on the + Chrome Web Store. + ''; + }; + }; + + browserConfig = cfg: + let + + browser = (builtins.parseDrvName cfg.package).name; + + darwinDirs = { + chromium = "Chromium"; + google-chrome = "Google/Chrome"; + google-chrome-beta = "Google/Chrome Beta"; + google-chrome-dev = "Google/Chrome Dev"; + }; + + configDir = if pkgs.stdenv.isDarwin + then "Library/Application Support/${getAttr browser darwinDirs}" + else "${config.xdg.configHome}/${browser}"; + + extensionJson = ext: { + target = "${configDir}/External Extensions/${ext}.json"; + text = builtins.toJSON { + external_update_url = "https://clients2.google.com/service/update2/crx"; + }; + }; + + in + mkIf cfg.enable { + home.packages = [ cfg.package ]; + home.file = map extensionJson cfg.extensions; + }; + +in + +{ + options.programs = { + chromium = browserModule pkgs.chromium "Chromium" true; + google-chrome = browserModule pkgs.google-chrome "Google Chrome" false; + google-chrome-beta = browserModule pkgs.google-chrome-beta "Google Chrome Beta" false; + google-chrome-dev = browserModule pkgs.google-chrome-dev "Google Chrome Dev" false; + }; + + config = mkMerge [ + (browserConfig config.programs.chromium) + (browserConfig config.programs.google-chrome) + (browserConfig config.programs.google-chrome-beta) + (browserConfig config.programs.google-chrome-dev) + ]; +} -- cgit v1.2.3 From 6630cfbe16af28cd9f448aaf8e5b526928bed7f9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Aug 2018 07:05:23 +0200 Subject: chromium: only enable for the `linux` platform --- modules/misc/news.nix | 1 + modules/modules.nix | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 558806f968a..680df418637 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -753,6 +753,7 @@ in { time = "2018-08-19T20:46:09+00:00"; + condition = pkgs.stdenv.isLinux; message = '' A new modules is available: 'programs.chromium'. ''; diff --git a/modules/modules.nix b/modules/modules.nix index 97caa4c0735..c50ed931eb8 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -28,7 +28,6 @@ let ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix - ./programs/chromium.nix ./programs/command-not-found/command-not-found.nix ./programs/direnv.nix ./programs/eclipse.nix @@ -93,7 +92,9 @@ let - ]; + ] + ++ + optional pkgs.stdenv.isLinux ./programs/chromium.nix; pkgsModule = { options.nixosSubmodule = mkOption { -- cgit v1.2.3 From 7a8d50a80381188e6fbdda7b2dd517ca71c3b487 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Aug 2018 18:31:10 +0900 Subject: xdg: create $XDG_CACHE_HOME Some programs fail silently (bash with HISTFILE for instance) when the folder doesn't exist. --- modules/misc/xdg.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 3e7a3bcb51c..c3e7981b725 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -6,6 +6,8 @@ let cfg = config.xdg; + dag = config.lib.dag; + fileType = (import ../lib/file-type.nix { inherit (config.home) homeDirectory; inherit lib pkgs; @@ -91,6 +93,9 @@ in { home.file = mkMerge [ cfg.configFile cfg.dataFile ]; + home.activation.xdgCreateCache = dag.entryAfter [ "writeBoundary" ] '' + $DRY_RUN_CMD mkdir $VERBOSE_ARG -m0700 -p "${config.xdg.cacheHome}" + ''; } ]; } -- cgit v1.2.3 From 8e05229e62c2c3a9d1afe2495fc411e705076112 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Aug 2018 21:04:16 +0200 Subject: Add initial GitLab CI configuration This will automatically build and publish the Home Manager manual on GitLab Pages. --- .gitlab-ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000000..18f19731e53 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +image: nixos/nix:latest + +pages: + script: + - mkdir -p ~/.config/nixpkgs + - echo '{ manual.html.enable = true; }' > ~/.config/nixpkgs/home.nix + - nix-shell . -A install + - mkdir public + - cp -r ~/.nix-profile/share/doc/home-manager/* public/ + artifacts: + paths: + - public + only: + - master -- cgit v1.2.3 From d5bbbbd41d851b587f89f35c93c2a4e47a7969ff Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Aug 2018 22:47:49 +0200 Subject: email: note that passwordCommand should output '\n' This is because some programs, for example msmtp, expect the output to end with a newline character. --- modules/accounts/email.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 640edc59b33..9334f731b66 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -182,8 +182,8 @@ let apply = p: if isString p then splitString " " p else p; example = "secret-tool lookup email me@example.org"; description = '' - A command, which when run writes the account password on - standard output. + A command that writes the account password on standard + output followed by a newline when it is run. ''; }; -- cgit v1.2.3 From 906965b48bb545b2450329a73001d7ff2f1214ce Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Aug 2018 00:19:33 +0200 Subject: Revert "email: note that passwordCommand should output '\n'" This reverts commit d5bbbbd41d851b587f89f35c93c2a4e47a7969ff. This was premature, the example will not emit a terminal newline and it is not clear whether it is a good idea to force this limitation. --- modules/accounts/email.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 9334f731b66..640edc59b33 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -182,8 +182,8 @@ let apply = p: if isString p then splitString " " p else p; example = "secret-tool lookup email me@example.org"; description = '' - A command that writes the account password on standard - output followed by a newline when it is run. + A command, which when run writes the account password on + standard output. ''; }; -- cgit v1.2.3 From cfa06c3f3866fdc708d5e9f7aa6a2f59759a1c61 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 6 Aug 2018 19:02:49 +0900 Subject: msmtp: add module msmtp is a simple mail transfer agent (MTA). --- modules/accounts/email.nix | 1 + modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/programs/msmtp-accounts.nix | 25 ++++++++++++ modules/programs/msmtp.nix | 77 +++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 modules/programs/msmtp-accounts.nix create mode 100644 modules/programs/msmtp.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 640edc59b33..74bb84acfed 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -318,6 +318,7 @@ in type = types.attrsOf (types.submodule [ mailAccountOpts (import ../programs/mbsync-accounts.nix) + (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) ]); default = {}; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 680df418637..bcf0c766bfb 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -758,6 +758,13 @@ in A new modules is available: 'programs.chromium'. ''; } + + { + time = "2018-08-20T20:27:26+00:00"; + message = '' + A new module is available: 'programs.msmtp'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index c50ed931eb8..d08a418e3bb 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -45,6 +45,7 @@ let ./programs/man.nix ./programs/mbsync.nix ./programs/mercurial.nix + ./programs/msmtp.nix ./programs/neovim.nix ./programs/newsboat.nix ./programs/notmuch.nix diff --git a/modules/programs/msmtp-accounts.nix b/modules/programs/msmtp-accounts.nix new file mode 100644 index 00000000000..d4d4663f8ab --- /dev/null +++ b/modules/programs/msmtp-accounts.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: + +with lib; + +{ + options.msmtp = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable msmtp. + + If enabled then it is possible to use the + command line option to send a + message for a given account using the msmtp + or msmtpq tool. For example, + msmtp --account=private + would send using the account defined in + . If the + option is not given then the + primary account will be used. + ''; + }; + }; +} diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix new file mode 100644 index 00000000000..4d009915521 --- /dev/null +++ b/modules/programs/msmtp.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.msmtp; + + dag = config.lib.dag; + + msmtpAccounts = filter (a: a.msmtp.enable) + (attrValues config.accounts.email.accounts); + + onOff = p: if p then "on" else "off"; + + accountStr = account: with account; + concatStringsSep "\n" ( + [ "account ${name}" ] + ++ mapAttrsToList (n: v: n + " " + v) ( + { + host = smtp.host; + from = address; + auth = "on"; + user = userName; + tls = onOff smtp.tls.enable; + tls_starttls = onOff smtp.tls.useStartTls; + tls_trust_file = smtp.tls.certificatesFile; + } + // optionalAttrs (smtp.port != null) { + port = toString smtp.port; + } + // optionalAttrs (passwordCommand != null) { + # msmtp requires the password to finish with a newline. + passwordeval = ''${pkgs.bash}/bin/bash -c "${toString passwordCommand}; echo"''; + } + ) + ++ optional primary "\naccount default : ${name}" + ); + + configFile = mailAccounts: '' + # Generated by Home Manager. + + ${cfg.extraConfig} + + ${concatStringsSep "\n\n" (map accountStr mailAccounts)} + ''; + +in + +{ + + options = { + programs.msmtp = { + enable = mkEnableOption "msmtp"; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration lines to add to ~/.msmtprc. + See for examples. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.msmtp ]; + + home.file.".msmtprc".text = configFile msmtpAccounts; + + home.sessionVariables = { + MSMTP_QUEUE = "${config.xdg.dataHome}/msmtp/queue"; + MSMTP_LOG = "${config.xdg.dataHome}/msmtp/queue.log"; + }; + }; +} -- cgit v1.2.3 From da8307cd267452b85078607270b8c8493dfa1ce5 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Wed, 22 Aug 2018 10:27:04 -0700 Subject: chromium: parseDrvName quick fix --- modules/programs/chromium.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/chromium.nix b/modules/programs/chromium.nix index 8a39702776f..ba39c50b5dc 100644 --- a/modules/programs/chromium.nix +++ b/modules/programs/chromium.nix @@ -48,7 +48,7 @@ let browserConfig = cfg: let - browser = (builtins.parseDrvName cfg.package).name; + browser = (builtins.parseDrvName cfg.package.name).name; darwinDirs = { chromium = "Chromium"; -- cgit v1.2.3 From 90bcaaf582c46af65bcdc64de65ef6b0e571ac52 Mon Sep 17 00:00:00 2001 From: Anton Plotnikov Date: Tue, 21 Aug 2018 16:52:45 +0300 Subject: pasystray: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/services/pasystray.nix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 modules/services/pasystray.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index bcf0c766bfb..8e893658777 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -765,6 +765,13 @@ in A new module is available: 'programs.msmtp'. ''; } + + { + time = "2018-08-21T20:13:50+00:00"; + message = '' + A new module is available: 'services.pasystray'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d08a418e3bb..914d275c376 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -71,6 +71,7 @@ let ./services/network-manager-applet.nix ./services/owncloud-client.nix ./services/parcellite.nix + ./services/pasystray.nix ./services/polybar.nix ./services/random-background.nix ./services/redshift.nix diff --git a/modules/services/pasystray.nix b/modules/services/pasystray.nix new file mode 100644 index 00000000000..da0436b665a --- /dev/null +++ b/modules/services/pasystray.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + meta.maintainers = [ maintainers.pltanton ]; + + options = { + services.pasystray = { + enable = mkEnableOption "PulseAudio system tray"; + }; + }; + + config = mkIf config.services.pasystray.enable { + systemd.user.services.pasystray = { + Unit = { + Description = "PulseAudio system tray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.pasystray}/bin/pasystray"; + }; + }; + }; +} -- cgit v1.2.3 From 2548c4317519f5b23c3d3304d69e12651da36e5a Mon Sep 17 00:00:00 2001 From: Mogria Date: Thu, 16 Aug 2018 18:04:36 +0200 Subject: fzf: add options for setting commands for all keys This allows you to specify your own custom commands to be run when calling fzf. You might use tools like fd to search faster and take `.gitignore` files into consideration. --- modules/programs/fzf.nix | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/modules/programs/fzf.nix b/modules/programs/fzf.nix index 2085d9e5248..7279d9035f4 100644 --- a/modules/programs/fzf.nix +++ b/modules/programs/fzf.nix @@ -12,6 +12,16 @@ in options.programs.fzf = { enable = mkEnableOption "fzf - a command-line fuzzy finder"; + defaultCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type f"; + description = '' + The command that gets executed as the default source for fzf + when running. + ''; + }; + defaultOptions = mkOption { type = types.listOf types.str; default = []; @@ -21,6 +31,16 @@ in ''; }; + fileWidgetCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type f"; + description = '' + The command that gets executed as the source for fzf for the + CTRL-T keybinding. + ''; + }; + fileWidgetOptions = mkOption { type = types.listOf types.str; default = []; @@ -30,6 +50,16 @@ in ''; }; + changeDirWidgetCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type d" ; + description = '' + The command that gets executed as the source for fzf for the + ALT-C keybinding. + ''; + }; + changeDirWidgetOptions = mkOption { type = types.listOf types.str; default = []; @@ -39,6 +69,15 @@ in ''; }; + historyWidgetCommand = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The command that gets executed as the source for fzf for the + CTRL-R keybinding. + ''; + }; + historyWidgetOptions = mkOption { type = types.listOf types.str; default = []; @@ -70,10 +109,14 @@ in home.sessionVariables = mapAttrs (n: v: toString v) ( - filterAttrs (n: v: v != []) { + filterAttrs (n: v: v != [] && v != null) { + FZF_ALT_C_COMMAND = cfg.changeDirWidgetCommand; FZF_ALT_C_OPTS = cfg.changeDirWidgetOptions; + FZF_CTRL_R_COMMAND = cfg.historyWidgetCommand; FZF_CTRL_R_OPTS = cfg.historyWidgetOptions; + FZF_CTRL_T_COMMAND = cfg.fileWidgetCommand; FZF_CTRL_T_OPTS = cfg.fileWidgetOptions; + FZF_DEFAULT_COMMAND = cfg.defaultCommand; FZF_DEFAULT_OPTS = cfg.defaultOptions; } ); -- cgit v1.2.3 From 99a0e2469bae1711b53bdf3fd20f88aa333f6655 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 27 Aug 2018 19:21:01 +0800 Subject: direnv: add fish support --- modules/programs/direnv.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 1f0211a1643..e1654309319 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -29,6 +29,14 @@ in Whether to enable Zsh integration. ''; }; + + enableFishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Fish integration. + ''; + }; }; config = mkIf cfg.enable { @@ -46,5 +54,9 @@ in programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' eval "$(${pkgs.direnv}/bin/direnv hook zsh)" ''; + + programs.fish.shellInit = mkIf cfg.enableFishIntegration '' + eval (${pkgs.direnv}/bin/direnv hook fish) + ''; }; } -- cgit v1.2.3 From 859c132ee29fe31ad30473855ca8e85c3150af97 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 28 Aug 2018 00:17:57 +0200 Subject: home-manager: enable build output during switch Fixes #352 --- home-manager/home-manager | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 0a89057c7e4..c3f8e0b5e5d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -180,8 +180,7 @@ function doSwitch() { else doBuildAttr \ --out-link "$generation" \ - --no-build-output \ - --attr activationPackage > /dev/null \ + --attr activationPackage \ && "$generation/activate" || exitCode=1 fi -- cgit v1.2.3 From 629d66e0b983b0ea5780ddf805f65a024d7deb5b Mon Sep 17 00:00:00 2001 From: Jonathan Reeve Date: Sun, 26 Aug 2018 14:32:00 -0400 Subject: polybar: only quote strings if needed Polybar expects quoted values only when whitespace is important to the value. Fixes #356 --- modules/services/polybar.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index a187f62a0d4..423b0f1682b 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -11,9 +11,14 @@ let toPolybarIni = generators.toINI { mkKeyValue = key: value: let + quoted = v: + if hasPrefix " " v || hasSuffix " " v + then ''"${v}"'' + else v; + value' = if isBool value then (if value then "true" else "false") - else if (isString value && key != "include-file") then ''"${value}"'' + else if (isString value && key != "include-file") then quoted value else toString value; in "${key}=${value'}"; -- cgit v1.2.3 From 4602c00dcf9f8d23ae1475f384b29be96d29822b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 29 Aug 2018 21:46:11 +0200 Subject: polybar: minor reformatting --- modules/services/polybar.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 423b0f1682b..a8fe86a70c4 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -10,18 +10,18 @@ let toPolybarIni = generators.toINI { mkKeyValue = key: value: - let - quoted = v: - if hasPrefix " " v || hasSuffix " " v - then ''"${v}"'' - else v; - - value' = - if isBool value then (if value then "true" else "false") - else if (isString value && key != "include-file") then quoted value - else toString value; - in - "${key}=${value'}"; + let + quoted = v: + if hasPrefix " " v || hasSuffix " " v + then ''"${v}"'' + else v; + + value' = + if isBool value then (if value then "true" else "false") + else if (isString value && key != "include-file") then quoted value + else toString value; + in + "${key}=${value'}"; }; configFile = pkgs.writeText "polybar.conf" -- cgit v1.2.3 From 5eca556fe78989d17caddc58a58a944bf08558fa Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 6 Aug 2018 19:04:56 +0900 Subject: offlineimap: add module OfflineIMAP is a Mail Retrieval Agent (MRA) like mbsync but written in Python. --- modules/accounts/email.nix | 1 + modules/misc/news.nix | 7 + modules/modules.nix | 1 + modules/programs/offlineimap-accounts.nix | 46 +++++++ modules/programs/offlineimap.nix | 206 ++++++++++++++++++++++++++++++ 5 files changed, 261 insertions(+) create mode 100644 modules/programs/offlineimap-accounts.nix create mode 100644 modules/programs/offlineimap.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 74bb84acfed..660f6ad86c0 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -320,6 +320,7 @@ in (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) + (import ../programs/offlineimap-accounts.nix) ]); default = {}; description = "List of email accounts."; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 8e893658777..ed16f9624d7 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -772,6 +772,13 @@ in A new module is available: 'services.pasystray'. ''; } + + { + time = "2018-08-29T20:27:04+00:00"; + message = '' + A new module is available: 'programs.offlineimap'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 914d275c376..39db0cc8ac6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -49,6 +49,7 @@ let ./programs/neovim.nix ./programs/newsboat.nix ./programs/notmuch.nix + ./programs/offlineimap.nix ./programs/pidgin.nix ./programs/rofi.nix ./programs/ssh.nix diff --git a/modules/programs/offlineimap-accounts.nix b/modules/programs/offlineimap-accounts.nix new file mode 100644 index 00000000000..1900617ca11 --- /dev/null +++ b/modules/programs/offlineimap-accounts.nix @@ -0,0 +1,46 @@ +{ config, lib, ... }: + +with lib; + +let + + extraConfigType = with types; attrsOf (either (either str int) bool); + +in + +{ + options.offlineimap = { + enable = mkEnableOption "OfflineIMAP"; + + extraConfig.local = mkOption { + type = extraConfigType; + default = {}; + example = { + sync_deletes = true; + }; + description = '' + Extra configuration options to add to the local account + section. + ''; + }; + + extraConfig.remote = mkOption { + type = extraConfigType; + default = {}; + example = { + maxconnections = 2; + expunge = false; + }; + description = '' + Extra configuration options to add to the remote account + section. + ''; + }; + + postSyncHookCommand = mkOption { + type = types.lines; + default = ""; + description = "Command to run after fetching new mails."; + }; + }; +} diff --git a/modules/programs/offlineimap.nix b/modules/programs/offlineimap.nix new file mode 100644 index 00000000000..7a1b5734bbb --- /dev/null +++ b/modules/programs/offlineimap.nix @@ -0,0 +1,206 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.offlineimap; + + accounts = filter (a: a.offlineimap.enable) + (attrValues config.accounts.email.accounts); + + toIni = generators.toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "yes" else "no") + else toString value; + in + "${key} = ${value'}"; + }; + + # Generates a script to fetch only a specific account. + # + # Note, these scripts are not actually created and installed at the + # moment. It will need some thinking on whether this is a good idea + # and whether other modules should have some similar functionality. + # + # Perhaps have a single tool `email` that wraps the command? + # Something like + # + # $ email + genOfflineImapScript = account: with account; + pkgs.writeShellScriptBin "offlineimap-${name}" '' + exec ${pkgs.offlineimap}/bin/offlineimap -a${account.name} "$@" + ''; + + accountStr = account: with account; + let + postSyncHook = optionalAttrs (offlineimap.postSyncHookCommand != "") { + postsynchook = + pkgs.writeShellScriptBin + "postsynchook" + offlineimap.postSyncHookCommand + + "/bin/postsynchook"; + }; + + localType = + if account.flavor == "gmail.com" + then "GmailMaildir" + else "Maildir"; + + remoteType = + if account.flavor == "gmail.com" + then "Gmail" + else "IMAP"; + + remoteHost = optionalAttrs (imap.host != null) { + remotehost = imap.host; + }; + + remotePort = optionalAttrs ((imap.port or null) != null) { + remoteport = imap.port; + }; + + ssl = + if imap.tls.enable + then + { + ssl = true; + sslcacertfile = imap.tls.certificatesFile; + starttls = imap.tls.useStartTls; + } + else + { + ssl = false; + }; + + remotePassEval = + let + arglist = concatMapStringsSep "," (x: "'${x}'") passwordCommand; + in + optionalAttrs (passwordCommand != null) { + remotepasseval = ''get_pass("${name}", [${arglist}])''; + }; + in + toIni { + "Account ${name}" = { + localrepository = "${name}-local"; + remoterepository = "${name}-remote"; + } + // postSyncHook; + + "Repository ${name}-local" = { + type = localType; + localfolders = maildir.absPath; + } + // offlineimap.extraConfig.local; + + "Repository ${name}-remote" = { + type = remoteType; + remoteuser = userName; + } + // remoteHost + // remotePort + // remotePassEval + // ssl + // offlineimap.extraConfig.remote; + }; + + extraConfigType = with types; attrsOf (either (either str int) bool); + +in + +{ + options = { + programs.offlineimap = { + enable = mkEnableOption "OfflineIMAP"; + + pythonFile = mkOption { + type = types.lines; + default = '' + import subprocess + + def get_pass(service, cmd): + return subprocess.check_output(cmd, ) + ''; + description = '' + Python code that can then be used in other parts of the + configuration. + ''; + }; + + extraConfig.general = mkOption { + type = extraConfigType; + default = {}; + example = { + maxage = 30; + ui = "blinkenlights"; + }; + description = '' + Extra configuration options added to the + section. + ''; + }; + + extraConfig.default = mkOption { + type = extraConfigType; + default = {}; + example = { + gmailtrashfolder = "[Gmail]/Papierkorb"; + }; + description = '' + Extra configuration options added to the + section. + ''; + }; + + extraConfig.mbnames = mkOption { + type = extraConfigType; + default = {}; + example = literalExample '' + { + filename = "~/.config/mutt/mailboxes"; + header = "'mailboxes '"; + peritem = "'+%(accountname)s/%(foldername)s'"; + sep = "' '"; + footer = "'\\n'"; + } + ''; + description = '' + Extra configuration options added to the + mbnames section. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.offlineimap ]; + + xdg.configFile."offlineimap/get_settings.py".text = cfg.pythonFile; + + xdg.configFile."offlineimap/config".text = + '' + # Generated by Home Manager. + # See https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf + # for an exhaustive list of options. + '' + + toIni ({ + general = { + accounts = concatMapStringsSep "," (a: a.name) accounts; + pythonfile = "${config.xdg.configHome}/offlineimap/get_settings.py"; + metadata = "${config.xdg.dataHome}/offlineimap"; + } + // cfg.extraConfig.general; + } + // optionalAttrs (cfg.extraConfig.mbnames != {}) { + mbnames = { enabled = true; } // cfg.extraConfig.mbnames; + } + // optionalAttrs (cfg.extraConfig.default != {}) { + DEFAULT = cfg.extraConfig.default; + }) + + "\n" + + concatStringsSep "\n" (map accountStr accounts); + }; +} -- cgit v1.2.3 From 7699ed3fc8a5ff4ba3e2b936c85e7008ed72d508 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 1 Sep 2018 20:01:18 -0500 Subject: email: fix port setting for flavor gmail.com See https://support.google.com/mail/answer/7126229. --- modules/accounts/email.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 660f6ad86c0..a6e265c40c8 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -269,7 +269,7 @@ let smtp = { host = "smtp.gmail.com"; - port = 587; + port = if config.smtp.tls.useStartTls then 587 else 465; }; }) -- cgit v1.2.3 From 9fe6fa7f44d8672f1824620192fe585edee14fcc Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sat, 18 Aug 2018 04:50:49 +0200 Subject: neovim: add vi{,m}Alias options --- modules/programs/neovim.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index d0f1002620b..2e9cbca6725 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -13,6 +13,22 @@ in programs.neovim = { enable = mkEnableOption "Neovim"; + viAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink `vi` to `nvim` binary. + ''; + }; + + vimAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink `vim` to `nvim` binary. + ''; + }; + withPython = mkOption { type = types.bool; default = true; @@ -89,7 +105,7 @@ in inherit (cfg) extraPython3Packages withPython3 extraPythonPackages withPython - withRuby configure; + withRuby viAlias vimAlias configure; }) ]; }; -- cgit v1.2.3 From 97c6073d39a49a361ac0b217a47e6d8002a86c38 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 5 Sep 2018 19:13:32 +0300 Subject: i3 module: fonts option for bar section --- modules/services/window-managers/i3.nix | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 84b5d25e65b..3e4452351d6 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -8,6 +8,18 @@ let dag = config.lib.dag; + commonOptions = { + fonts = mkOption { + type = types.listOf types.string; + default = ["monospace 8"]; + description = '' + Font list used for window titles. Only FreeType fonts are supported. + The order here is improtant (e.g. icons font should go before the one used for text). + ''; + example = [ "FontAwesome 10" "Terminus 10" ]; + }; + }; + startupModule = types.submodule { options = { command = mkOption { @@ -92,6 +104,8 @@ let barModule = types.submodule { options = { + inherit (commonOptions) fonts; + id = mkOption { type = types.nullOr types.string; default = null; @@ -241,15 +255,7 @@ let configModule = types.submodule { options = { - fonts = mkOption { - type = types.listOf types.string; - default = ["monospace 8"]; - description = '' - Font list used for window titles. Only FreeType fonts are supported. - The order here is improtant (e.g. icons font should go before the one used for text). - ''; - example = [ "FontAwesome 10" "Terminus 10" ]; - }; + inherit (commonOptions) fonts; window = mkOption { type = types.submodule { @@ -660,11 +666,12 @@ let ); barStr = { - id, mode, hiddenState, position, workspaceButtons, + id, fonts, mode, hiddenState, position, workspaceButtons, workspaceNumbers, command, statusCommand, colors, ... }: '' bar { ${optionalString (id != null) "id ${id}"} + font pango:${concatStringsSep ", " fonts} mode ${mode} hidden_state ${hiddenState} position ${position} -- cgit v1.2.3 From 453d0494fbdc1d999a9e0c17330b3a648fcead94 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 2 Sep 2018 15:00:06 +0900 Subject: notmuch: synchronize_flag should be "true" ...and not "True" According to doc https://notmuchmail.org/manpages/notmuch-config-1/ It also causes a crash in astroid : https://github.com/astroidmail/astroid/issues/546 --- modules/programs/notmuch.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index ef9f2ec4bf3..939b8ef6de3 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -89,7 +89,7 @@ in extraConfig = mkOption { type = types.attrsOf (types.attrsOf types.str); default = { - maildir = { synchronize_flags = "True"; }; + maildir = { synchronize_flags = "true"; }; }; description = '' Options that should be appended to the notmuch configuration file. -- cgit v1.2.3 From 2bff6e518833024cb96a92996cd96ef6490db54d Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sun, 9 Sep 2018 15:41:36 +0300 Subject: fish module: envoke hm-session-vars.sh --- modules/programs/fish.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index fbef818b2e8..d384ec2a11e 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -79,7 +79,10 @@ in # ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated automatically. # if we haven't sourced the general config, do it if not set -q __fish_general_config_sourced - + set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path + fenv source ${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh > /dev/null + set -e fish_function_path[1] + ${cfg.shellInit} # and leave a note so we don't source this config section again from # this very shell (children will source the general config anew) -- cgit v1.2.3 From 8d2cb0ef9b78ff6badeb7f630de2f5a6ff1358ce Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 9 Sep 2018 21:17:49 +0200 Subject: fish: minor formatting fixes --- modules/programs/fish.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index d384ec2a11e..61e74c45a8a 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -24,12 +24,13 @@ in shellAliases = mkOption { default = {}; description = '' - Set of aliases for fish shell. See - for an option format description. + Set of aliases for fish shell. See + for an option + format description. ''; type = types.attrs; }; - + shellAbbrs = mkOption { default = {}; description = '' @@ -99,13 +100,13 @@ in end # if we haven't sourced the interactive config, do it status --is-interactive; and not set -q __fish_interactive_config_sourced - and begin + and begin # Abbrs ${abbrsStr} - + # Aliases ${aliasesStr} - + ${cfg.promptInit} ${cfg.interactiveShellInit} # and leave a note so we don't source this config section again from -- cgit v1.2.3 From 63efd267673eb5febf4da728923f21f5353d8462 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sat, 8 Sep 2018 17:10:32 +0200 Subject: neovim: support new extraPython*Packages options Also fix `configure` argument. --- modules/programs/neovim.nix | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 2e9cbca6725..76dcd42d297 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -6,6 +6,24 @@ let cfg = config.programs.neovim; + extraPythonPackageType = mkOptionType { + name = "extra-python-packages"; + description = "python packages in python.withPackages format"; + check = with types; (x: if isFunction x + then isList (x pkgs.pythonPackages) + else false); + merge = mergeOneOption; + }; + + extraPython3PackageType = mkOptionType { + name = "extra-python3-packages"; + description = "python3 packages in python.withPackages format"; + check = with types; (x: if isFunction x + then isList (x pkgs.python3Packages) + else false); + merge = mergeOneOption; + }; + in { @@ -39,12 +57,13 @@ in }; extraPythonPackages = mkOption { - type = types.listOf types.package; - default = [ ]; - example = literalExample "with pkgs.python2Packages; [ pandas jedi ]"; + type = with types; either extraPythonPackageType (listOf package); + default = (_: []); + defaultText = "ps: []"; + example = literalExample "(ps: with ps; [ pandas jedi ])"; description = '' - List here Python 2 packages required for your plugins to - work. + A function in python.withPackages format, which returns a + list of Python 2 packages required for your plugins to work. ''; }; @@ -66,18 +85,19 @@ in }; extraPython3Packages = mkOption { - type = types.listOf types.package; - default = [ ]; - example = literalExample - "with pkgs.python3Packages; [ python-language-server ]"; + type = with types; either extraPython3PackageType (listOf package); + default = (_: []); + defaultText = "ps: []"; + example = literalExample "(ps: with ps; [ python-language-server ])"; description = '' - List here Python 3 packages required for your plugins to work. + A function in python.withPackages format, which returns a + list of Python 3 packages required for your plugins to work. ''; }; configure = mkOption { - type = types.nullOr types.attrs; - default = null; + type = types.attrs; + default = {}; example = literalExample '' configure = { customRC = $'''' @@ -92,7 +112,7 @@ in }; ''; description = '' - Generate your init file from your list of plugins and custom commands, + Generate your init file from your list of plugins and custom commands, and loads it from the store via nvim -u /nix/store/hash-vimrc ''; }; -- cgit v1.2.3 From 055d100548fb941e60142e99916d47933d4558bc Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sun, 9 Sep 2018 15:02:11 +0300 Subject: i3 module: add missing pieces to default config --- modules/services/window-managers/i3.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 3e4452351d6..2af12e57e79 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -408,6 +408,11 @@ let "${cfg.config.modifier}+Up" = "focus up"; "${cfg.config.modifier}+Right" = "focus right"; + "${cfg.config.modifier}+Shift+Left" = "move left"; + "${cfg.config.modifier}+Shift+Down" = "move down"; + "${cfg.config.modifier}+Shift+Up" = "move up"; + "${cfg.config.modifier}+Shift+Right" = "move right"; + "${cfg.config.modifier}+h" = "split h"; "${cfg.config.modifier}+v" = "split v"; "${cfg.config.modifier}+f" = "fullscreen toggle"; @@ -417,6 +422,7 @@ let "${cfg.config.modifier}+e" = "layout toggle split"; "${cfg.config.modifier}+Shift+space" = "floating toggle"; + "${cfg.config.modifier}+space" = "focus mode_toggle"; "${cfg.config.modifier}+1" = "workspace 1"; "${cfg.config.modifier}+2" = "workspace 2"; -- cgit v1.2.3 From 50de1a6885dc7c306fa85c3c4538ee8ba54a65f7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 11 Sep 2018 21:23:11 +0200 Subject: emacs: add internal `finalPackage` option --- modules/programs/emacs.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index eb12ae19c21..87f47a76ab7 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -33,10 +33,19 @@ in example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; description = "Extra packages available to Emacs."; }; + + finalPackage = mkOption { + type = types.package; + internal = true; + readOnly = true; + description = "The Emacs package including any extra packages."; + }; }; }; config = mkIf cfg.enable { - home.packages = [ (emacsWithPackages cfg.extraPackages) ]; + home.packages = [ cfg.finalPackage ]; + + programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages; }; } -- cgit v1.2.3 From ea7482017692d92e123b191abad2ff103280527a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 14 Sep 2018 21:08:51 +0200 Subject: home-environment: add option `home.extraProfileCommands` This _internal_ option indicates extra commands that should be run in the `postBuild` step of the profile environment build. Fixes #386 --- modules/home-environment.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 229e3d22ff4..c98cb9ea966 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -243,6 +243,15 @@ in Extra commands to run in the Home Manager generation builder. ''; }; + + home.extraProfileCommands = mkOption { + type = types.lines; + default = ""; + internal = true; + description = '' + Extra commands to run in the Home Manager profile builder. + ''; + }; }; config = { @@ -373,6 +382,8 @@ in paths = cfg.packages; inherit (cfg) extraOutputsToInstall; + postBuild = cfg.extraProfileCommands; + meta = { description = "Environment of packages installed through home-manager"; }; -- cgit v1.2.3 From 6eea2a409e56d23f1e3f703afb3aa0527d1cc8e7 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 15 Sep 2018 10:58:13 +0200 Subject: vim: improve instructions for listing available plugins --- modules/programs/vim.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index c77c0d45d30..0caa6dcc350 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -75,8 +75,8 @@ in default = defaultPlugins; example = [ "YankRing" ]; description = '' - List of vim plugins to install. For supported plugins see: - . + List of vim plugins to install. To get a list of supported plugins run: + nix-env -f '<nixpkgs>' -qaP -A vimPlugins. ''; }; -- cgit v1.2.3 From 5ff03ce5ac9ddb6a0d241e77ba7b327cca38becf Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 13 Sep 2018 19:36:57 +0200 Subject: taskwarrior: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/taskwarrior.nix | 112 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 modules/programs/taskwarrior.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ed16f9624d7..f1d6de45bb4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -779,6 +779,13 @@ in A new module is available: 'programs.offlineimap'. ''; } + + { + time = "2018-09-18T21:25:14+00:00"; + message = '' + A new module is available: 'programs.taskwarrior'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 39db0cc8ac6..3d9fe85c9d1 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,6 +53,7 @@ let ./programs/pidgin.nix ./programs/rofi.nix ./programs/ssh.nix + ./programs/taskwarrior.nix ./programs/termite.nix ./programs/texlive.nix ./programs/vim.nix diff --git a/modules/programs/taskwarrior.nix b/modules/programs/taskwarrior.nix new file mode 100644 index 00000000000..eeacc77da29 --- /dev/null +++ b/modules/programs/taskwarrior.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, ... }: + +with lib; + +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" + else if isList value then concatMapStringsSep "," formatValue value + else toString value; + + formatLine = key: value: + "${key}=${formatValue value}"; + + formatSet = key: values: + (concatStringsSep "\n" + (mapAttrsToList + (subKey: subValue: formatPair "${key}.${subKey}" subValue) + values)); + + formatPair = key: value: + if isAttrs value then formatSet key value + else formatLine key value; + +in + +{ + options = { + programs.taskwarrior = { + enable = mkEnableOption "Task Warrior"; + + config = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + confirmation = false; + report.minimal.filter = "status:pending"; + report.active.columns = [ "id" "start" "entry.age" "priority" "project" "due" "description" ]; + report.active.labels = [ "ID" "Started" "Age" "Priority" "Project" "Due" "Description" ]; + taskd = { + certificate = "/path/to/cert"; + key = "/path/to/key"; + ca = "/path/to/ca"; + server = "host.domain:53589"; + credentials = "Org/First Last/cf31f287-ee9e-43a8-843e-e8bbd5de4294"; + }; + } + ''; + description = '' + Key-value configuration written to + ~/.taskrc. + ''; + }; + + dataLocation = mkOption { + type = types.str; + default = "${config.xdg.dataHome}/task"; + defaultText = "$XDG_DATA_HOME/task"; + description = '' + Location where Task Warrior will store its data. + + Home Manager will attempt to create this directory. + ''; + }; + + colorTheme = mkOption { + type = with types; nullOr (either str path); + default = null; + example = "dark-blue-256"; + description = '' + Either one of the default provided theme as string, or a + path to a theme configuration file. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Additional content written at the end of + ~/.taskrc. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.taskwarrior ]; + + home.file."${cfg.dataLocation}/.keep".text = ""; + + home.file.".taskrc".text = '' + data.location=${cfg.dataLocation} + ${includeTheme cfg.colorTheme} + + ${concatStringsSep "\n" ( + mapAttrsToList formatPair cfg.config)} + + ${cfg.extraConfig} + ''; + }; +} -- cgit v1.2.3 From d27bccdff1530422db605810833e6d4e084dc629 Mon Sep 17 00:00:00 2001 From: Adam Washington Date: Thu, 13 Sep 2018 17:25:53 +0100 Subject: zathura: add module Add the zathura document viewer as a program option with support for managing the zathurarc configuration file. --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/zathura.nix | 61 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 modules/programs/zathura.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f1d6de45bb4..b8d4f86b37b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -786,6 +786,13 @@ in A new module is available: 'programs.taskwarrior'. ''; } + + { + time = "2018-09-18T21:43:54+00:00"; + message = '' + A new module is available: 'programs.zathura'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 3d9fe85c9d1..a7f05eed486 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -57,6 +57,7 @@ let ./programs/termite.nix ./programs/texlive.nix ./programs/vim.nix + ./programs/zathura.nix ./programs/zsh.nix ./services/blueman-applet.nix ./services/compton.nix diff --git a/modules/programs/zathura.nix b/modules/programs/zathura.nix new file mode 100644 index 00000000000..b81d594e610 --- /dev/null +++ b/modules/programs/zathura.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ...}: + +with lib; + +let + + cfg = config.programs.zathura; + + formatLine = n: v: + let + formatValue = v: + if isBool v then (if v then "true" else "false") + else toString v; + in + "set ${n}\t\"${formatValue v}\""; + +in + +{ + meta.maintainers = [ maintainers.rprospero ]; + + options.programs.zathura = { + enable = mkEnableOption '' + Zathura, a highly customizable and funtional document viewer + focused on keyboard interaction''; + + options = mkOption { + default = {}; + type = with types; attrsOf (either str (either bool int)); + description = '' + Add command options to zathura and make + them permanent. See + + zathurarc + 5 + + for the full list of options. + ''; + example = { default-bg = "#000000"; default-fg = "#FFFFFF"; }; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Additional commands for zathura that will be added to the + zathurarc file. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.zathura ]; + + xdg.configFile."zathura/zathurarc".text = + concatStringsSep "\n" ([] + ++ optional (cfg.extraConfig != "") cfg.extraConfig + ++ mapAttrsToList formatLine cfg.options + ) + "\n"; + }; +} -- cgit v1.2.3 From 701b4130bd38d4ada810994aa089f7e9f23998d2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 19 Sep 2018 00:13:31 +0200 Subject: Remove unnecessary `dag` variables Also remove a few trailing whitespaces. --- modules/programs/msmtp.nix | 2 -- modules/programs/notmuch.nix | 10 ++++------ modules/services/polybar.nix | 2 -- modules/services/window-managers/i3.nix | 2 -- modules/services/window-managers/xmonad.nix | 2 -- 5 files changed, 4 insertions(+), 14 deletions(-) diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index 4d009915521..7f00bbb0a13 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -6,8 +6,6 @@ let cfg = config.programs.msmtp; - dag = config.lib.dag; - msmtpAccounts = filter (a: a.msmtp.enable) (attrValues config.accounts.email.accounts); diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 939b8ef6de3..2d8478f692e 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -4,8 +4,6 @@ with lib; let - dag = config.lib.dag; - cfg = config.programs.notmuch; mkIniKeyValue = key: value: @@ -24,12 +22,12 @@ let database = { path = config.accounts.email.maildirBasePath; }; - + new = { ignore = cfg.new.ignore; tags = cfg.new.tags; }; - + user = let accounts = @@ -42,7 +40,7 @@ let primary_email = catAttrs "address" primary; other_email = catAttrs "address" secondaries; }; - + search = { exclude_tags = [ "deleted" "spam" ]; }; @@ -168,7 +166,7 @@ in export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH" export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/notmuchrc" export NMBGIT="${config.xdg.dataHome}/notmuch/nmbug" - + ${cmds} ''; executable = true; diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index a8fe86a70c4..f75e0890bf2 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -6,8 +6,6 @@ let cfg = config.services.polybar; - dag = config.lib.dag; - toPolybarIni = generators.toINI { mkKeyValue = key: value: let diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 2af12e57e79..85fde7dd881 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -6,8 +6,6 @@ let cfg = config.xsession.windowManager.i3; - dag = config.lib.dag; - commonOptions = { fonts = mkOption { type = types.listOf types.string; diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 754e7f1fbf4..5b64963b6ef 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -6,8 +6,6 @@ let cfg = config.xsession.windowManager.xmonad; - dag = config.lib.dag; - xmonad = pkgs.xmonad-with-packages.override { ghcWithPackages = cfg.haskellPackages.ghcWithPackages; packages = self: -- cgit v1.2.3 From 9f0fdc68a9b81fb71d9ee6502614c90eb81ef17d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 15 Sep 2018 22:49:53 +0200 Subject: xsession: add option `xsession.scriptPath` This option allows overriding the default script path `~/.xsession`. On NixOS, this is needed to allow multiple possible graphical login sessions. Fixes #391. --- modules/xsession.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index d55118e41eb..1c562dd0dfc 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -15,6 +15,16 @@ in xsession = { enable = mkEnableOption "X Session"; + scriptPath = mkOption { + type = types.str; + default = ".xsession"; + example = ".xsession-hm"; + description = '' + Path, relative HOME, where Home Manager + should write the X session script. + ''; + }; + windowManager.command = mkOption { type = types.str; example = literalExample '' @@ -117,7 +127,7 @@ in export HM_XPROFILE_SOURCED=1 ''; - home.file.".xsession" = { + home.file.${cfg.scriptPath} = { executable = true; text = '' if [[ ! -v HM_XPROFILE_SOURCED ]]; then -- cgit v1.2.3 From 3f34bf4465b367c6eb4bc109349e75638e64ae52 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Wed, 19 Sep 2018 09:00:00 -0500 Subject: noti: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/noti.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 modules/programs/noti.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b8d4f86b37b..082f371ad6f 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -793,6 +793,13 @@ in A new module is available: 'programs.zathura'. ''; } + + { + time = "2018-09-20T19:26:40+00:00"; + message = '' + A new module is available: 'programs.noti'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index a7f05eed486..889df467d54 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -48,6 +48,7 @@ let ./programs/msmtp.nix ./programs/neovim.nix ./programs/newsboat.nix + ./programs/noti.nix ./programs/notmuch.nix ./programs/offlineimap.nix ./programs/pidgin.nix diff --git a/modules/programs/noti.nix b/modules/programs/noti.nix new file mode 100644 index 00000000000..476c2eb1978 --- /dev/null +++ b/modules/programs/noti.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ...}: + +with lib; + +let + + cfg = config.programs.noti; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.noti = { + enable = mkEnableOption "Noti"; + + settings = mkOption { + type = types.attrsOf (types.attrsOf types.str); + default = {}; + description = '' + Configuration written to + ~/.config/noti/noti.yaml. + + See + + noti.yaml + 5 + . + for the full list of options. + ''; + example = literalExample '' + { + say = { + voice = "Alex"; + }; + slack = { + token = "1234567890abcdefg"; + channel = "@jaime"; + }; + } + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.noti ]; + + xdg.configFile."noti/noti.yaml" = mkIf (cfg.settings != {}) { + text = generators.toYAML {} cfg.settings; + }; + }; + +} -- cgit v1.2.3 From 0635423e7365e9dbccac2fa154f53a45e952898e Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sat, 18 Aug 2018 16:13:33 +0200 Subject: go: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/go.nix | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 modules/programs/go.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 082f371ad6f..c79962c49e8 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -800,6 +800,13 @@ in A new module is available: 'programs.noti'. ''; } + + { + time = "2018-09-20T22:10:45+00:00"; + message = '' + A new module is available: 'programs.go'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 889df467d54..c5e96b33da3 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -38,6 +38,7 @@ let ./programs/fzf.nix ./programs/git.nix ./programs/gnome-terminal.nix + ./programs/go.nix ./programs/home-manager.nix ./programs/htop.nix ./programs/info.nix diff --git a/modules/programs/go.nix b/modules/programs/go.nix new file mode 100644 index 00000000000..d1817ae265d --- /dev/null +++ b/modules/programs/go.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.go; + +in + +{ + meta.maintainers = [ maintainers.rvolosatovs ]; + + options = { + programs.go = { + enable = mkEnableOption "Go"; + + package = mkOption { + type = types.package; + default = pkgs.go; + defaultText = "pkgs.go"; + description = "The Go package to use."; + }; + + packages = mkOption { + type = with types; attrsOf path; + default = {}; + example = literalExample '' + { + "golang.org/x/time/rate" = builtins.fetchGit "https://go.googlesource.com/text"; + } + ''; + description = "Packages to add to GOPATH."; + }; + + goPath = mkOption { + type = with types; nullOr str; + default = null; + example = "go"; + description = "GOPATH relative to HOME"; + }; + + goBin = mkOption { + type = with types; nullOr str; + default = null; + example = ".local/bin.go"; + description = "GOBIN relative to HOME"; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { + home.packages = [ cfg.package ]; + + home.file = + let + goPath = if cfg.goPath != null then cfg.goPath else "go"; + + mkSrc = n: v: { + target = "${goPath}/src/${n}"; + source = v; + }; + in + mapAttrsToList mkSrc cfg.packages; + } + (mkIf (cfg.goPath != null) { + home.sessionVariables.GOPATH = builtins.toPath "${config.home.homeDirectory}/${cfg.goPath}"; + }) + (mkIf (cfg.goBin != null) { + home.sessionVariables.GOBIN = builtins.toPath "${config.home.homeDirectory}/${cfg.goBin}"; + }) + ]); +} -- cgit v1.2.3 From 4d870f665b7f0269554eedb2b9096c50292c0b9e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 21 Sep 2018 00:51:23 +0200 Subject: taffybar: fix indentation --- modules/services/taffybar.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index b8a642408e1..3ccec98a448 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -27,19 +27,19 @@ in config = mkIf config.services.taffybar.enable { systemd.user.services.taffybar = { - Unit = { - Description = "Taffybar desktop bar"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = "${cfg.package}/bin/taffybar"; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Unit = { + Description = "Taffybar desktop bar"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/taffybar"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; }; }; } -- cgit v1.2.3 From f7dc354f427b792f50e2fb647a26a7ca0347f16a Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Fri, 21 Sep 2018 09:42:38 +0200 Subject: go: Fix package example --- modules/programs/go.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/programs/go.nix b/modules/programs/go.nix index d1817ae265d..bccf7c9a2e5 100644 --- a/modules/programs/go.nix +++ b/modules/programs/go.nix @@ -27,7 +27,8 @@ in default = {}; example = literalExample '' { - "golang.org/x/time/rate" = builtins.fetchGit "https://go.googlesource.com/text"; + "golang.org/x/text" = builtins.fetchGit "https://go.googlesource.com/text"; + "golang.org/x/time" = builtins.fetchGit "https://go.googlesource.com/time"; } ''; description = "Packages to add to GOPATH."; -- cgit v1.2.3 From 151f29a17a6027cd2bdbd8276ef79631a1a950f6 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 2 Sep 2018 14:58:54 +0900 Subject: mbsync: add options extraConfig.{channel|local|remote} To allow supporting more advanced configurations. The local refers to the "maildir store" configuration, remote to the "IMAP store", and "channel" to the channel. --- modules/programs/mbsync-accounts.nix | 36 ++++++++++++++++++++++++++++ modules/programs/mbsync.nix | 46 +++++++++++++++++++++--------------- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix index a983b7ff9da..4a1a51c49f0 100644 --- a/modules/programs/mbsync-accounts.nix +++ b/modules/programs/mbsync-accounts.nix @@ -2,6 +2,12 @@ with lib; +let + + extraConfigType = with lib.types; attrsOf (either (either str int) bool); + +in + { options.mbsync = { enable = mkEnableOption "synchronization using mbsync"; @@ -53,5 +59,35 @@ with lib; Pattern of mailboxes to synchronize. ''; }; + + extraConfig.channel = mkOption { + type = extraConfigType; + default = {}; + example = literalExample '' + { + MaxMessages = 10000; + MaxSize = "1m"; + }; + ''; + description = '' + Per channel extra configuration. + ''; + }; + + extraConfig.local = mkOption { + type = extraConfigType; + default = {}; + description = '' + Local store extra configuration. + ''; + }; + + extraConfig.remote = mkOption { + type = extraConfigType; + default = {}; + description = '' + Remote store extra configuration. + ''; + }; }; } diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 4abfc7b3fed..fc8503778a3 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -33,10 +33,14 @@ let genSection = header: entries: let escapeValue = escape [ "\"" ]; + hasSpace = v: builtins.match ".* .*" v != null; genValue = v: if isList v then concatMapStringsSep " " genValue v - else "\"${escapeValue v}\""; + else if isBool v then (if v then "yes" else "no") + else if isInt v then toString v + else if hasSpace v then "\"${escapeValue v}\"" + else v; in '' ${header} @@ -54,15 +58,16 @@ let User = userName; PassCmd = toString passwordCommand; } - // - genTlsConfig imap.tls - // - optionalAttrs (imap.port != null) { Port = toString imap.port; } + // genTlsConfig imap.tls + // optionalAttrs (imap.port != null) { Port = toString imap.port; } ) + "\n" - + genSection "IMAPStore ${name}-remote" { - Account = name; - } + + genSection "IMAPStore ${name}-remote" ( + { + Account = name; + } + // mbsync.extraConfig.remote + ) + "\n" + genSection "MaildirStore ${name}-local" ( { @@ -70,19 +75,22 @@ let Inbox = "${maildir.absPath}/${folders.inbox}"; SubFolders = "Verbatim"; } - // - optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; } + // optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; } + // mbsync.extraConfig.local ) + "\n" - + genSection "Channel ${name}" { - Master = ":${name}-remote:"; - Slave = ":${name}-local:"; - Patterns = mbsync.patterns; - Create = masterSlaveMapping.${mbsync.create}; - Remove = masterSlaveMapping.${mbsync.remove}; - Expunge = masterSlaveMapping.${mbsync.expunge}; - SyncState = "*"; - } + + genSection "Channel ${name}" ( + { + Master = ":${name}-remote:"; + Slave = ":${name}-local:"; + Patterns = mbsync.patterns; + Create = masterSlaveMapping.${mbsync.create}; + Remove = masterSlaveMapping.${mbsync.remove}; + Expunge = masterSlaveMapping.${mbsync.expunge}; + SyncState = "*"; + } + // mbsync.extraConfig.channel + ) + "\n"; genGroupConfig = name: channels: -- cgit v1.2.3 From 9407b42f97dc7c40a9c3432982d0363d64081a98 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 8 Sep 2018 18:45:29 +0900 Subject: accounts.emails: adding gpg/signature modules --- modules/accounts/email.nix | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index a6e265c40c8..5b1b912f15f 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -6,6 +6,52 @@ let cfg = config.accounts.email; + gpgModule = types.submodule { + options = { + key = mkOption { + type = types.str; + description = '' + The key to use as listed in gpg --list-keys. + ''; + }; + + signByDefault = mkOption { + type = types.bool; + default = false; + description = "Sign messages by default."; + }; + + encryptByDefault = mkOption { + type = types.bool; + default = false; + description = "Encrypt outgoing messages by default."; + }; + }; + }; + + signatureModule = types.submodule { + options = { + text = mkOption { + type = types.str; + default = ""; + example = '' + -- + Luke Skywalker + May the force be with you. + ''; + description = '' + Signature content. + ''; + }; + + showSignature = mkOption { + type = types.enum [ "append" "attach" "none" ]; + default = "none"; + description = "Method to communicate the signature."; + }; + }; + }; + tlsModule = types.submodule { options = { enable = mkOption { @@ -237,6 +283,22 @@ let ''; }; + signature = mkOption { + type = signatureModule; + default = {}; + description = '' + Signature configuration. + ''; + }; + + gpg = mkOption { + type = types.nullOr gpgModule; + default = null; + description = '' + GPG configuration. + ''; + }; + smtp = mkOption { type = types.nullOr smtpModule; default = null; -- cgit v1.2.3 From 7cc36b7703ccd38f392599a4b1eebf3e4586fc65 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 24 Sep 2018 23:19:54 +0200 Subject: xresources: run `xrdb -merge` on change Fixes #400 --- modules/xresources.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index 7afee8bb7c8..96580f575a2 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -69,10 +69,17 @@ in }; config = mkIf (cfg.properties != null || cfg.extraConfig != "") { - home.file.".Xresources".text = - concatStringsSep "\n" ([] - ++ (optional (cfg.extraConfig != "") cfg.extraConfig) - ++ (optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) - ) + "\n"; + home.file.".Xresources" = { + text = + concatStringsSep "\n" ([] + ++ (optional (cfg.extraConfig != "") cfg.extraConfig) + ++ (optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) + ) + "\n"; + onChange = '' + if [[ -v DISPLAY ]] ; then + $DRY_RUN_CMD ${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources + fi + ''; + }; }; } -- cgit v1.2.3 From 695791165769f8ba5c5097af9acd62c2ddeceff7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 24 Sep 2018 23:24:04 +0200 Subject: xresources: remove unnecessary parentheses --- modules/xresources.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/xresources.nix b/modules/xresources.nix index 96580f575a2..384008e2450 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -72,8 +72,8 @@ in home.file.".Xresources" = { text = concatStringsSep "\n" ([] - ++ (optional (cfg.extraConfig != "") cfg.extraConfig) - ++ (optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) + ++ optional (cfg.extraConfig != "") cfg.extraConfig + ++ optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties) ) + "\n"; onChange = '' if [[ -v DISPLAY ]] ; then -- cgit v1.2.3 From a1a7e7cd249da03844601b9163d58dd496fb7d95 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Tue, 25 Sep 2018 16:44:38 -0500 Subject: bash: fix `bashrcExtra` interactive shell test To determine if bash is running interactively test whether "$-" contains "i". See: https://www.gnu.org/software/bash/manual/html_node/Is-this-Shell-Interactive_003f.html --- modules/programs/bash.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index d8359c12f0b..14a158a2423 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -155,7 +155,7 @@ in in mkIf cfg.enable { programs.bash.bashrcExtra = '' # Commands that should be applied only for interactive shells. - if [[ -n $PS1 ]]; then + if [[ $- == *i* ]]; then ${historyControlStr} ${shoptsStr} -- cgit v1.2.3 From 33a2943e8cbbe876e15cc4e6dbb4b5c5ce484bc5 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sat, 22 Sep 2018 19:30:13 +0300 Subject: gtk: add support for wayland --- modules/misc/gtk.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 7f4f537ed97..930823ff48f 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -8,6 +8,8 @@ let cfg2 = config.gtk.gtk2; cfg3 = config.gtk.gtk3; + dag = config.lib.dag; + toGtk3Ini = generators.toINI { mkKeyValue = key: value: let @@ -27,6 +29,16 @@ let in "${n} = ${v'}"; + toDconfIni = generators.toINI { + mkKeyValue = key: value: + let + tweakVal = v: + if isString v then "'${v}'" + else toString v; + in + "${key}=${tweakVal value}"; + }; + fontType = types.submodule { options = { package = mkOption { @@ -141,6 +153,21 @@ in ~/.config/gtk-3.0/gtk.css. ''; }; + + waylandSupport = mkOption { + type = types.bool; + default = false; + description = '' + Support GSettings provider (dconf) in addition to + GtkSettings (INI file). This is needed for Wayland. + + Note, on NixOS the following line must be in the + system configuration: + + services.dbus.packages = [ pkgs.gnome3.dconf ]; + + ''; + }; }; }; }; @@ -159,6 +186,16 @@ in optionalAttrs (cfg.iconTheme != null) { gtk-icon-theme-name = cfg.iconTheme.name; }; + dconfIni = + optionalAttrs (cfg.font != null) + { font-name = cfg.font.name; } + // + optionalAttrs (cfg.theme != null) + { gtk-theme = cfg.theme.name; } + // + optionalAttrs (cfg.iconTheme != null) + { icon-theme = cfg.iconTheme.name; }; + optionalPackage = opt: optional (opt != null && opt.package != null) opt.package; in @@ -178,6 +215,23 @@ in toGtk3Ini { Settings = ini // cfg3.extraConfig; }; xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; + + home.activation = mkIf cfg3.waylandSupport { + gtk3 = dag.entryAfter ["installPackages"] ( + let + iniText = toDconfIni { "/" = dconfIni; }; + iniFile = pkgs.writeText "gtk3.ini" iniText; + dconfPath = "/org/gnome/desktop/interface/"; + in + '' + if [[ -v DRY_RUN ]]; then + echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} + else + ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} + fi + '' + ); + }; } ); } -- cgit v1.2.3 From f44d4a1d8611c8b2f1fce97dc7810722aa10c8cb Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 26 Sep 2018 11:55:51 +0800 Subject: obs-studio: add module --- modules/misc/news.nix | 8 +++++++ modules/modules.nix | 1 + modules/programs/obs-studio.nix | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 modules/programs/obs-studio.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c79962c49e8..c2aefafda55 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -807,6 +807,14 @@ in A new module is available: 'programs.go'. ''; } + + { + time = "2018-09-27T17:48:08+00:00"; + message = '' + A new module is available: 'programs.obs-studio'. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index c5e96b33da3..8da265ce14a 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -51,6 +51,7 @@ let ./programs/newsboat.nix ./programs/noti.nix ./programs/notmuch.nix + ./programs/obs-studio.nix ./programs/offlineimap.nix ./programs/pidgin.nix ./programs/rofi.nix diff --git a/modules/programs/obs-studio.nix b/modules/programs/obs-studio.nix new file mode 100644 index 00000000000..9f9310c9506 --- /dev/null +++ b/modules/programs/obs-studio.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.obs-studio; + package = pkgs.obs-studio; + + mkPluginEnv = packages: + let + pluginDirs = map (pkg: "${pkg}/share/obs/obs-plugins") packages; + plugins = concatMapStringsSep " " (p: "${p}/*") pluginDirs; + in + pkgs.runCommand "obs-studio-plugins" {} '' + mkdir $out + [[ '${plugins}' ]] || exit 0 + for plugin in ${plugins}; do + ln -s "$plugin" $out/ + done + ''; + +in + +{ + meta.maintainers = [ maintainers.adisbladis ]; + + options = { + programs.obs-studio = { + enable = mkEnableOption "obs-studio"; + + plugins = mkOption { + default = []; + example = literalExample "[ pkgs.obs-linuxbrowser ]"; + description = "Optional OBS plugins."; + type = types.listOf types.package; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ package ]; + + xdg.configFile."obs-studio/plugins" = mkIf (cfg.plugins != []) { + source = mkPluginEnv cfg.plugins; + }; + }; +} -- cgit v1.2.3 From 9b3122e92c855ac406f8bb1868a830a42855fd22 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 27 Sep 2018 21:01:13 +0200 Subject: lib: copy module from NixOS Importing the module directly from NixOS causes the documentation to break, in particular the "Declared by" section. Fixes #405 --- modules/misc/lib.nix | 14 ++++++++++++++ modules/modules.nix | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 modules/misc/lib.nix diff --git a/modules/misc/lib.nix b/modules/misc/lib.nix new file mode 100644 index 00000000000..a0907545314 --- /dev/null +++ b/modules/misc/lib.nix @@ -0,0 +1,14 @@ +{ lib, ... }: + +{ + options = { + lib = lib.mkOption { + type = lib.types.attrsOf lib.types.attrs; + default = {}; + description = '' + This option allows modules to define helper functions, + constants, etc. + ''; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 8da265ce14a..1f056aa38ff 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -19,6 +19,7 @@ let ./manual.nix ./misc/fontconfig.nix ./misc/gtk.nix + ./misc/lib.nix ./misc/news.nix ./misc/nixpkgs.nix ./misc/pam.nix @@ -98,7 +99,6 @@ let ./xresources.nix ./xsession.nix - ] ++ -- cgit v1.2.3 From d9c5d3c868763a81db2ec54acddafa02f31bdf74 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 6 Aug 2018 19:05:46 +0900 Subject: alot: add module Alot is a python mail user agent (MUA) built around the Notmuch mail system. --- modules/accounts/email.nix | 1 + modules/misc/news.nix | 6 ++ modules/modules.nix | 1 + modules/programs/alot-accounts.nix | 32 +++++++ modules/programs/alot.nix | 167 +++++++++++++++++++++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 modules/programs/alot-accounts.nix create mode 100644 modules/programs/alot.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 5b1b912f15f..063ffc258f1 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -379,6 +379,7 @@ in accounts = mkOption { type = types.attrsOf (types.submodule [ mailAccountOpts + (import ../programs/alot-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c2aefafda55..3b44bdf77b0 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -815,6 +815,12 @@ in ''; } + { + time = "2018-09-28T21:38:48+00:00"; + message = '' + A new module is available: 'programs.alot'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1f056aa38ff..d8c2732e071 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -25,6 +25,7 @@ let ./misc/pam.nix ./misc/qt.nix ./misc/xdg.nix + ./programs/alot.nix ./programs/autorandr.nix ./programs/bash.nix ./programs/beets.nix diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix new file mode 100644 index 00000000000..ad7be0d887b --- /dev/null +++ b/modules/programs/alot-accounts.nix @@ -0,0 +1,32 @@ +{ config, lib, ... }: + +with lib; + +{ + options.alot = { + sendMailCommand = mkOption { + type = types.nullOr types.str; + description = '' + Command to send a mail. If msmtp is enabled for the account, + then this is set to + msmtpq --read-envelope-from --read-recipients. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra settings to add to this Alot account configuration. + ''; + }; + }; + + config = mkIf config.notmuch.enable { + alot.sendMailCommand = mkOptionDefault ( + if config.msmtp.enable + then "msmtpq --read-envelope-from --read-recipients" + else null + ); + }; +} diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix new file mode 100644 index 00000000000..ea5a5d11b33 --- /dev/null +++ b/modules/programs/alot.nix @@ -0,0 +1,167 @@ +# alot config loader is sensitive to leading space ! +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.alot; + + alotAccounts = filter (a: a.notmuch.enable) + (attrValues config.accounts.email.accounts); + + boolStr = v: if v then "True" else "False"; + + accountStr = account: with account; + concatStringsSep "\n" ( + [ "[[${name}]]" ] + ++ mapAttrsToList (n: v: n + "=" + v) ( + { + address = address; + realname = realName; + sendmail_command = + optionalString (alot.sendMailCommand != null) alot.sendMailCommand; + } + // optionalAttrs (gpg != null) { + gpg_key = gpg.key; + encrypt_by_default = if gpg.encryptByDefault then "all" else "none"; + sign_by_default = boolStr gpg.signByDefault; + } + // optionalAttrs (signature.showSignature != "none") { + signature = pkgs.writeText "signature.txt" signature.text; + signature_as_attachment = + boolStr (signature.showSignature == "attach"); + } + ) + ) + + "\n" + + alot.extraConfig; + + configFile = + let + bindingsToStr = attrSet: + concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${v}") attrSet); + in + '' + # Generated by Home Manager. + # See http://alot.readthedocs.io/en/latest/configuration/config_options.html + + ${cfg.extraConfig} + + [bindings] + ${bindingsToStr cfg.bindings.global} + + [[bufferlist]] + ${bindingsToStr cfg.bindings.bufferlist} + [[search]] + ${bindingsToStr cfg.bindings.search} + [[envelope]] + ${bindingsToStr cfg.bindings.envelope} + [[taglist]] + ${bindingsToStr cfg.bindings.taglist} + [[thread]] + ${bindingsToStr cfg.bindings.thread} + + [accounts] + + ${concatStringsSep "\n\n" (map accountStr alotAccounts)} + ''; + +in + +{ + options.programs.alot = { + enable = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether to enable the Alot mail user agent. Alot uses the + Notmuch email system and will therefore be automatically + enabled for each email account that is managed by Notmuch. + ''; + }; + + hooks = mkOption { + type = types.lines; + default = ""; + description = '' + Content of the hooks file. + ''; + }; + + bindings = mkOption { + type = types.submodule { + options = { + global = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Global keybindings."; + }; + + bufferlist = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Bufferlist mode keybindings."; + }; + + search = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Search mode keybindings."; + }; + + envelope = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Envelope mode keybindings."; + }; + + taglist = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Taglist mode keybindings."; + }; + + thread = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Thread mode keybindings."; + }; + }; + }; + default = {}; + description = '' + Keybindings. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = '' + auto_remove_unread = True + ask_subject = False + handle_mouse = True + initial_command = "search tag:inbox AND NOT tag:killed" + input_timeout = 0.3 + prefer_plaintext = True + thread_indent_replies = 4 + ''; + description = '' + Extra lines added to alot configuration file. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.alot ]; + + xdg.configFile."alot/config".text = configFile; + + xdg.configFile."alot/hooks.py".text = + '' + # Generated by Home Manager. + '' + + cfg.hooks; + }; +} -- cgit v1.2.3 From 782d2fab83fe1964e220f5b343d68659b9dd9cf2 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 30 Sep 2018 18:22:21 +0900 Subject: rofi: fix default path --- modules/programs/rofi.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 19a18fae84f..0a6b3943c85 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -280,7 +280,7 @@ in }; configPath = mkOption { - default = ".config/rofi/config"; + default = "${config.xdg.configHome}/rofi/config"; type = types.string; description = "Path where to put generated configuration file."; }; -- cgit v1.2.3 From 36da7a918f442bd5822152a210f980d3d414eed0 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 2 Oct 2018 07:17:34 +0100 Subject: Correct spelling mistakes --- modules/programs/zathura.nix | 2 +- modules/services/polybar.nix | 2 +- modules/services/window-managers/i3.nix | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/programs/zathura.nix b/modules/programs/zathura.nix index b81d594e610..f01bd501c39 100644 --- a/modules/programs/zathura.nix +++ b/modules/programs/zathura.nix @@ -21,7 +21,7 @@ in options.programs.zathura = { enable = mkEnableOption '' - Zathura, a highly customizable and funtional document viewer + Zathura, a highly customizable and functional document viewer focused on keyboard interaction''; options = mkOption { diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index f75e0890bf2..e94f7f22097 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -59,7 +59,7 @@ in (p: { "section/base" = { include-file = "${p}"; }; }) (types.attrsOf types.attrs); description = '' - Polybar configuration. Can be either path to a file, or set of attibutes + Polybar configuration. Can be either path to a file, or set of attributes that will be used to create the final configuration. ''; default = {}; diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 85fde7dd881..60ab13a31d8 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -376,7 +376,7 @@ let type = types.attrsOf (types.listOf criteriaModule); default = {}; description = '' - An attribute set that assignes applications to workspaces based + An attribute set that assigns applications to workspaces based on criteria. ''; example = literalExample '' @@ -473,7 +473,7 @@ let type = types.attrs; default = {}; description = '' - An attribute set that assignes keypress to an action using key code. + An attribute set that assigns keypress to an action using key code. See . ''; example = { "214" = "exec --no-startup-id /bin/script.sh"; }; -- cgit v1.2.3 From 5770dc58b99b8980ea33973ca1cb4d9170335069 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 3 Oct 2018 13:35:04 -0500 Subject: mbsync: add option to add extra account configuration --- modules/programs/mbsync-accounts.nix | 14 ++++++++++++++ modules/programs/mbsync.nix | 1 + 2 files changed, 15 insertions(+) diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix index 4a1a51c49f0..c586481df4d 100644 --- a/modules/programs/mbsync-accounts.nix +++ b/modules/programs/mbsync-accounts.nix @@ -89,5 +89,19 @@ in Remote store extra configuration. ''; }; + + extraConfig.account = mkOption { + type = extraConfigType; + default = {}; + example = literalExample '' + { + PipelineDepth = 10; + Timeout = 60; + }; + ''; + description = '' + Account section extra configuration. + ''; + }; }; } diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index fc8503778a3..060bec83f55 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -60,6 +60,7 @@ let } // genTlsConfig imap.tls // optionalAttrs (imap.port != null) { Port = toString imap.port; } + // mbsync.extraConfig.account ) + "\n" + genSection "IMAPStore ${name}-remote" ( -- cgit v1.2.3 From 68d3cdd722c86b737cc45d9961ef94baa1299168 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 7 Oct 2018 09:53:40 -0500 Subject: direnv: add stdlib option --- modules/programs/direnv.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index e1654309319..4707c6ce5b8 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -14,6 +14,14 @@ in options.programs.direnv = { enable = mkEnableOption "direnv, the environment switcher"; + stdlib = mkOption { + type = types.lines; + default = ""; + description = '' + Custom stdlib written to ~/.config/direnv/direnvrc. + ''; + }; + enableBashIntegration = mkOption { default = true; type = types.bool; @@ -42,6 +50,10 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.direnv ]; + xdg.configFile."direnv/direnvrc" = mkIf (cfg.stdlib != "") { + text = cfg.stdlib; + }; + programs.bash.initExtra = mkIf cfg.enableBashIntegration ( # Using mkAfter to make it more likely to appear after other -- cgit v1.2.3 From f947fafec9313ade1b87b14e194833836ed261ab Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 7 Oct 2018 10:16:43 -0500 Subject: direnv: add config option --- modules/programs/direnv.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 4707c6ce5b8..bfac5333471 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -5,6 +5,12 @@ with lib; let cfg = config.programs.direnv; + configFile = config: + pkgs.runCommand "config.toml" { buildInputs = [ pkgs.remarshal ]; } '' + remarshal -if json -of toml \ + < ${pkgs.writeText "config.json" (builtins.toJSON config)} \ + > $out + ''; in @@ -14,11 +20,28 @@ in options.programs.direnv = { enable = mkEnableOption "direnv, the environment switcher"; + config = mkOption { + type = types.attrs; + default = {}; + description = '' + Configuration written to + ~/.config/direnv/config.toml. + + See + + direnv.toml + 1 + . + for the full list of options. + ''; + }; + stdlib = mkOption { type = types.lines; default = ""; description = '' - Custom stdlib written to ~/.config/direnv/direnvrc. + Custom stdlib written to + ~/.config/direnv/direnvrc. ''; }; @@ -50,6 +73,10 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.direnv ]; + xdg.configFile."direnv/config.toml" = mkIf (cfg.config != {}) { + source = configFile cfg.config; + }; + xdg.configFile."direnv/direnvrc" = mkIf (cfg.stdlib != "") { text = cfg.stdlib; }; -- cgit v1.2.3 From 52b93637453cb120feb039ecea8f42c949e1abf6 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 12 Oct 2018 10:52:41 +0200 Subject: rofi: set configPath defaultText to avoid rebuilds --- modules/programs/rofi.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 0a6b3943c85..ed21655ba6d 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -281,6 +281,7 @@ in configPath = mkOption { default = "${config.xdg.configHome}/rofi/config"; + defaultText = "$XDG_CONFIG_HOME/rofi/config"; type = types.string; description = "Path where to put generated configuration file."; }; -- cgit v1.2.3 From 05a98b6be06d68c4a6086a0adb0a9b058833b41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sat, 13 Oct 2018 19:19:09 +0200 Subject: mbsync: change service unit type to 'oneshot' The ExecStartPost command is currently started when the mbsync is invoked succesfully. However, we typically want to run something like 'mu index' or 'notmuch new' after mbsync completes. This changes the unit type to oneshot, so that the ExecStartPost command is run after mbsync finishes succesfully. --- modules/services/mbsync.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/mbsync.nix b/modules/services/mbsync.nix index a14e252371c..5c994cc6bc3 100644 --- a/modules/services/mbsync.nix +++ b/modules/services/mbsync.nix @@ -87,7 +87,7 @@ in }; Service = { - Type = "simple"; + Type = "oneshot"; ExecStart = "${cfg.package}/bin/mbsync ${concatStringsSep " " mbsyncOptions}"; } // (optionalAttrs (cfg.postExec != null) { ExecStartPost = cfg.postExec; }) // (optionalAttrs (cfg.preExec != null) { ExecStartPre = cfg.preExec; }); -- cgit v1.2.3 From 0cfd21cc153775126e2deaa3d8689471fa5549bf Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Fri, 12 Oct 2018 13:26:15 -0500 Subject: compton: drop no-dock-blur option, add dock and dnd shadow no-dock-blur doesn't exist in compton and was added by mistake. --- modules/services/compton.nix | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index c282ba474d6..f7a794e4c06 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -24,13 +24,14 @@ let shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; shadow-opacity = ${cfg.shadowOpacity}; shadow-exclude = ${toJSON cfg.shadowExclude}; + no-dock-shadow = ${toJSON cfg.noDockShadow}; + no-dnd-shadow = ${toJSON cfg.noDNDShadow}; '' + optionalString cfg.blur '' # blur blur-background = true; blur-background-exclude = ${toJSON cfg.blurExclude}; - no-dock-blur = ${toJSON cfg.noDockBlur}; '' + '' # opacity @@ -58,14 +59,6 @@ in { ''; }; - noDockBlur = mkOption { - type = types.bool; - default = false; - description = '' - Avoid blur on docks. - ''; - }; - blurExclude = mkOption { type = types.listOf types.str; default = []; @@ -174,6 +167,22 @@ in { ''; }; + noDockShadow = mkOption { + type = types.bool; + default = true; + description = '' + Avoid shadow on docks. + ''; + }; + + noDNDShadow = mkOption { + type = types.bool; + default = true; + description = '' + Avoid shadow on drag-and-drop windows. + ''; + }; + activeOpacity = mkOption { type = types.str; default = "1.0"; -- cgit v1.2.3 From 3b9b897af36c31ee67e848e6583598e5cb655b67 Mon Sep 17 00:00:00 2001 From: Alex Brandt Date: Mon, 1 Oct 2018 21:42:46 -0700 Subject: home-manager: add generation expiration command This adds a new command to the home-manager shell script that allows generations to be removed that are older than an given absolute or relative date. This allows users to manage the expiration of their home-manager generations separately from their system or user profiles via nix-collect-garbage. It is most important if the user desires to have a convenient way to have different expiration times for Home Manager generations than other system or user profiles. --- home-manager/default.nix | 2 ++ home-manager/home-manager | 31 +++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index 394f0e7f2a5..8a577edf117 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -21,6 +21,8 @@ pkgs.stdenv.mkDerivation { substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ --subst-var-by coreutils "${pkgs.coreutils}" \ + --subst-var-by findutils "${pkgs.findutils}" \ + --subst-var-by gnused "${pkgs.gnused}" \ --subst-var-by less "${pkgs.less}" \ --subst-var-by HOME_MANAGER_PATH '${pathStr}' ''; diff --git a/home-manager/home-manager b/home-manager/home-manager index c3f8e0b5e5d..88c8a32cda7 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -1,9 +1,7 @@ #!@bash@/bin/bash -# This code explicitly requires GNU Core Utilities and we therefore -# need to ensure they are prioritized over any other similarly named -# tools on the system. -PATH=@coreutils@/bin:@less@/bin${PATH:+:}$PATH +# Prepare to use tools from Nixpkgs. +PATH=@coreutils@/bin:@findutils@/bin:@gnused@/bin:@less@/bin${PATH:+:}$PATH set -euo pipefail @@ -237,6 +235,23 @@ function doRmGenerations() { popd > /dev/null } +function doExpireGenerations() { + local profileDir="/nix/var/nix/profiles/per-user/$USER" + + local generations + generations="$( \ + find "$profileDir" -name 'home-manager-*-link' -not -newermt "$1" \ + | sed 's/^.*-\([0-9]*\)-link$/\1/' \ + )" + + if [[ -n $generations ]]; then + # shellcheck disable=2086 + doRmGenerations $generations + elif [[ -v VERBOSE ]]; then + echo "No generations to expire" + fi +} + function doListPackages() { local outPath outPath="$(nix-env -q --out-path | grep -o '/.*home-manager-path$')" @@ -349,6 +364,11 @@ function doHelp() { echo " Remove indicated generations. Use 'generations' command to" echo " find suitable generation numbers." echo + echo " expire-generations TIMESTAMP" + echo " Remove generations older than TIMESTAMP where TIMESTAMP is" + echo " interpreted as in the -d argument of the date tool. For" + echo " example \"-30 days\" or \"2018-01-01\"." + echo echo " packages List all packages installed in home-manager-path" echo echo " news Show news entries in a pager" @@ -422,6 +442,9 @@ case "$cmd" in remove-generations) doRmGenerations "$@" ;; + expire-generations) + doExpireGenerations "$@" + ;; packages) doListPackages ;; -- cgit v1.2.3 From 7575e119d68a415a4be62966acbd8970094d7b3e Mon Sep 17 00:00:00 2001 From: Alex Brandt Date: Wed, 17 Oct 2018 21:30:36 -0700 Subject: systemd: add more detail to user unit documentation The current documentation does not provide guidance to users on how systemd units are defined in Home Manager. A user may expect the configuration to be similar to NixOS, when it actually differs. Fixes #418 --- modules/systemd.nix | 54 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 74490691615..ed630b3618a 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -55,6 +55,30 @@ let merge = loc: foldl' (res: def: recursiveUpdate res def.value) {}; }; + unitDescription = type: '' + Definition of systemd per-user ${type} units. Attributes are + merged recursively. + + Note that the attributes follow the capitalization and naming used + by systemd. More details can be found in + + systemd.${type} + 5 + . + ''; + + unitExample = type: literalExample '' + { + Unit = { + Description = "Example description"; + }; + + ${type} = { + … + }; + } + ''; + in { @@ -76,46 +100,36 @@ in services = mkOption { default = {}; type = attrsRecursivelyMerged; - description = '' - Definition of systemd per-user service units. Attributes are - merged recursively. - ''; + description = unitDescription "service"; + example = unitExample "Service"; }; sockets = mkOption { default = {}; type = attrsRecursivelyMerged; - description = '' - Definition of systemd per-user sockets. Attributes are - merged recursively. - ''; + description = unitDescription "socket"; + example = unitExample "Socket"; }; targets = mkOption { default = {}; type = attrsRecursivelyMerged; - description = '' - Definition of systemd per-user targets. Attributes are - merged recursively. - ''; + description = unitDescription "target"; + example = unitExample "Target"; }; timers = mkOption { default = {}; type = attrsRecursivelyMerged; - description = '' - Definition of systemd per-user timers. Attributes are merged - recursively. - ''; + description = unitDescription "timer"; + example = unitExample "Timer"; }; paths = mkOption { default = {}; type = attrsRecursivelyMerged; - description = '' - Definition of systemd per-user path units. Attributes are - merged recursively. - ''; + description = unitDescription "path"; + example = unitExample "Path"; }; startServices = mkOption { -- cgit v1.2.3 From 5013155e582a7265485b29499c7069ee0f8e6c4e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 18 Oct 2018 23:42:15 +0200 Subject: readme: documentation is now hosted on GitLab --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23cc3d45049..949649b4534 100644 --- a/README.md +++ b/README.md @@ -300,4 +300,4 @@ in your Home Manager configuration. [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/ -[configuration options]: https://rycee.github.io/home-manager/options.html +[configuration options]: https://rycee.gitlab.io/home-manager/options.html -- cgit v1.2.3 From a2e09b4c9dabdf3a4481c51091e472f433b4a0be Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Mon, 15 Oct 2018 12:47:13 +0200 Subject: vim: add options --- modules/programs/vim.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index 0caa6dcc350..99dde760d22 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -9,17 +9,25 @@ let knownSettings = { background = types.enum [ "dark" "light" ]; + backupdir = types.listOf types.str; copyindent = types.bool; + directory = types.listOf types.str; expandtab = types.bool; hidden = types.bool; history = types.int; ignorecase = types.bool; modeline = types.bool; + mouse = types.enum [ "n" "v" "i" "c" "h" "a" "r" ]; + mousefocus = types.bool; + mousehide = types.bool; + mousemodel = types.enum [ "extend" "popup" "popup_setpos" ]; number = types.bool; relativenumber = types.bool; shiftwidth = types.int; smartcase = types.bool; tabstop = types.int; + undodir = types.listOf types.str; + undofile = types.bool; }; vimSettingsType = types.submodule { @@ -38,7 +46,12 @@ let let v = if isBool value then (if value then "" else "no") + name - else name + "=" + toString value; + else + "${name}=${ + if isList value + then concatStringsSep "," value + else toString value + }"; in optionalString (value != null) ("set " + v); -- cgit v1.2.3 From c17f37857cdb134f8ffbf5e2ee8c8ab317136e0f Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sun, 14 Oct 2018 12:11:00 +0200 Subject: urxvt: add module --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/urxvt.nix | 156 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 modules/programs/urxvt.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3b44bdf77b0..23f64d8e8f4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -821,6 +821,13 @@ in A new module is available: 'programs.alot'. ''; } + + { + time = "2018-10-20T09:30:57+00:00"; + message = '' + A new module is available: 'programs.urxvt'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d8c2732e071..374edb62071 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -61,6 +61,7 @@ let ./programs/taskwarrior.nix ./programs/termite.nix ./programs/texlive.nix + ./programs/urxvt.nix ./programs/vim.nix ./programs/zathura.nix ./programs/zsh.nix diff --git a/modules/programs/urxvt.nix b/modules/programs/urxvt.nix new file mode 100644 index 00000000000..5ac4f4bd652 --- /dev/null +++ b/modules/programs/urxvt.nix @@ -0,0 +1,156 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.urxvt; + +in + +{ + options.programs.urxvt = { + enable = mkEnableOption "rxvt-unicode terminal emulator"; + + package = mkOption { + type = types.package; + default = pkgs.rxvt_unicode; + defaultText = "pkgs.rxvt_unicode"; + description = "rxvt-unicode package to install."; + }; + + fonts = mkOption { + type = types.listOf types.str; + default = []; + description = "List of fonts to be used."; + example = [ "xft:Droid Sans Mono Nerd Font:size=9" ]; + }; + + keybindings = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Mapping of keybindings to actions"; + example = literalExample '' + { + "Shift-Control-C" = "eval:selection_to_clipboard"; + "Shift-Control-V" = "eval:paste_clipboard"; + } + ''; + }; + + iso14755 = mkOption { + type = types.bool; + default = true; + description = "ISO14755 support for viewing and entering unicode characters."; + }; + + scroll = { + bar = mkOption { + type = types.submodule { + options = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable the scrollbar"; + }; + + style = mkOption { + type = types.enum [ "rxvt" "plain" "next" "xterm" ]; + default = "plain"; + description = "Scrollbar style."; + }; + + align = mkOption { + type = types.enum [ "top" "bottom" "center" ]; + default = "center"; + description = "Scrollbar alignment."; + }; + + position = mkOption { + type = types.enum [ "left" "right" ]; + default = "right"; + description = "Scrollbar position."; + }; + + floating = mkOption { + type = types.bool; + default = true; + description = "Whether to display an rxvt scrollbar without a trough."; + }; + }; + }; + default = {}; + description = "Scrollbar settings."; + }; + + lines = mkOption { + type = types.ints.unsigned; + default = 10000; + description = "Number of lines to save in the scrollback buffer."; + }; + + keepPosition = mkOption { + type = types.bool; + default = true; + description = "Whether to keep a scroll position when TTY receives new lines."; + }; + + scrollOnKeystroke = mkOption { + type = types.bool; + default = true; + description = "Whether to scroll to bottom on keyboard input."; + }; + + scrollOnOutput = mkOption { + type = types.bool; + default = false; + description = "Whether to scroll to bottom on TTY output."; + }; + }; + + transparent = mkOption { + type = types.bool; + default = false; + description = "Whether to enable pseudo-transparency."; + }; + + shading = mkOption { + type = types.ints.between 0 200; + default = 100; + description = "Darken (0 .. 99) or lighten (101 .. 200) the transparent background."; + }; + + extraConfig = mkOption { + default = {}; + type = types.attrs; + description = "Additional configuration to add."; + example = { "shading" = 15; }; + }; + + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + xresources.properties = { + "URxvt.scrollBar" = cfg.scroll.bar.enable; + "URxvt.scrollstyle" = cfg.scroll.bar.style; + "URxvt.scrollBar_align" = cfg.scroll.bar.align; + "URxvt.scrollBar_right" = cfg.scroll.bar.position == "right"; + "URxvt.scrollBar_floating" = cfg.scroll.bar.floating; + "URxvt.saveLines" = cfg.scroll.lines; + "URxvt.scrollWithBuffer" = cfg.scroll.keepPosition; + "URxvt.scrollTtyKeypress" = cfg.scroll.scrollOnKeystroke; + "URxvt.scrollTtyOutput" = cfg.scroll.scrollOnOutput; + "URxvt.transparent" = cfg.transparent; + "URxvt.shading" = cfg.shading; + "URxvt.iso14755" = cfg.iso14755; + } // flip mapAttrs' cfg.keybindings (kb: action: + nameValuePair "URxvt.keysym.${kb}" action + ) // optionalAttrs (cfg.fonts != []) { + "URxvt.font" = concatStringsSep "," cfg.fonts; + } // flip mapAttrs' cfg.extraConfig (k: v: + nameValuePair "URxvt.${k}" v + ); + }; +} -- cgit v1.2.3 From 34bbd0ded16283a874d586bba318a512795e3aee Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sat, 20 Oct 2018 10:54:44 +0200 Subject: vim: remove deprecated options --- modules/programs/vim.nix | 51 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index 99dde760d22..86c6910ec18 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -62,27 +62,6 @@ in programs.vim = { enable = mkEnableOption "Vim"; - lineNumbers = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Whether to show line numbers. DEPRECATED: Use - programs.vim.settings.number. - ''; - }; - - tabSize = mkOption { - type = types.nullOr types.int; - default = null; - example = 4; - description = '' - Set tab size and shift width to a specified number of - spaces. DEPRECATED: Use - programs.vim.settings.tabstop and - programs.vim.settings.shiftwidth. - ''; - }; - plugins = mkOption { type = types.listOf types.str; default = defaultPlugins; @@ -163,31 +142,9 @@ in ]; }; - in mkIf cfg.enable (mkMerge [ - { - programs.vim.package = vim; - home.packages = [ cfg.package ]; - } - - (mkIf (cfg.lineNumbers != null) { - warnings = [ - ("'programs.vim.lineNumbers' is deprecated, " - + "use 'programs.vim.settings.number'") - ]; - - programs.vim.settings.number = cfg.lineNumbers; - }) - - (mkIf (cfg.tabSize != null) { - warnings = [ - ("'programs.vim.tabSize' is deprecated, use " - + "'programs.vim.settings.tabstop' and " - + "'programs.vim.settings.shiftwidth'") - ]; - - programs.vim.settings.tabstop = cfg.tabSize; - programs.vim.settings.shiftwidth = cfg.tabSize; - }) - ]) + in mkIf cfg.enable { + programs.vim.package = vim; + home.packages = [ cfg.package ]; + } ); } -- cgit v1.2.3 From 15a5f3278afab1304e458b18cc44d3d81c39e038 Mon Sep 17 00:00:00 2001 From: Jonas Carpay Date: Sat, 20 Oct 2018 16:05:09 +0200 Subject: Remove tabSize and lineNumbers check from news item --- modules/misc/news.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 23f64d8e8f4..1e1f673c531 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -242,8 +242,7 @@ in { time = "2017-09-30T09:44:18+00:00"; - condition = with config.programs.vim; - enable && (tabSize != null || lineNumbers != null); + condition = with config.programs.vim; enable; message = '' The options 'programs.vim.tabSize' and 'programs.vim.lineNumbers' have been deprecated and will be removed in the near future. -- cgit v1.2.3 From 0435d9c338756a571fa1315bcc3179c7a0c4edc8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 29 Oct 2018 19:42:09 +0100 Subject: news: remove news item about removed vim options --- modules/misc/news.nix | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1e1f673c531..bc0fbca7c14 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -240,24 +240,6 @@ in ''; } - { - time = "2017-09-30T09:44:18+00:00"; - condition = with config.programs.vim; enable; - message = '' - The options 'programs.vim.tabSize' and 'programs.vim.lineNumbers' have - been deprecated and will be removed in the near future. - - The new and preferred way to configure tab size and line numbers is to - use the more general 'programs.vim.settings' option. Specifically, - instead of - - - 'programs.vim.lineNumbers' use 'programs.vim.settings.number', and - - - 'programs.vim.tabSize' use 'programs.vim.settings.tabstop' and - 'programs.vim.settings.shiftwidth'. - ''; - } - { time = "2017-10-02T11:15:03+00:00"; condition = config.services.udiskie.enable; -- cgit v1.2.3 From 8d4c65f259a2f5508d6a1c667f02facafb3b3010 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 30 Oct 2018 00:09:20 +0100 Subject: fzf: only enable when line editing is available Fixes #401 Suggested-by: Alex Vorobiev Suggested-by: Mario Rodas --- modules/programs/fzf.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/programs/fzf.nix b/modules/programs/fzf.nix index 7279d9035f4..832c0bfa3e4 100644 --- a/modules/programs/fzf.nix +++ b/modules/programs/fzf.nix @@ -122,13 +122,17 @@ in ); programs.bash.initExtra = mkIf cfg.enableBashIntegration '' - . ${pkgs.fzf}/share/fzf/completion.bash - . ${pkgs.fzf}/share/fzf/key-bindings.bash + if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then + . ${pkgs.fzf}/share/fzf/completion.bash + . ${pkgs.fzf}/share/fzf/key-bindings.bash + fi ''; programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' - . ${pkgs.fzf}/share/fzf/completion.zsh - . ${pkgs.fzf}/share/fzf/key-bindings.zsh + if [[ $options[zle] = on ]]; then + . ${pkgs.fzf}/share/fzf/completion.zsh + . ${pkgs.fzf}/share/fzf/key-bindings.zsh + fi ''; }; } -- cgit v1.2.3 From 05c93ff3ae13f1a2d90a279a890534cda7dc8ad6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 4 Nov 2018 09:58:00 +0100 Subject: home-manager: remove uninstall activation phase The manual install has been long deprecated so it should be safe to no longer attempt to do an uninstall on each activation. --- modules/programs/home-manager.nix | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index e9d48117da0..0990de85e08 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -39,17 +39,5 @@ in inherit (cfg) path; }) ]; - - # Uninstall manually installed home-manager, if such exists. - # Without this a file collision error will be printed. - home.activation.uninstallHomeManager = - dag.entryBetween [ "installPackages" ] [ "writeBoundary" ] '' - if nix-env -q | grep -q "^home-manager$" ; then - $DRY_RUN_CMD nix-env -e home-manager - - echo "You can now remove the 'home-manager' packageOverride" - echo "or overlay in '~/.config/nixpkgs/', if you want." - fi - ''; }; } -- cgit v1.2.3 From 736e340bde8831e1ffb3e423056a801d0546a83c Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 30 Sep 2018 18:06:02 +0900 Subject: astroid: init Astroid is a notmuch/gtk based MUA: https://github.com/astroidmail/astroid --- modules/accounts/email.nix | 1 + modules/modules.nix | 1 + modules/programs/astroid-accounts.nix | 41 ++++++++ modules/programs/astroid-config-template.json | 136 ++++++++++++++++++++++++++ modules/programs/astroid.nix | 129 ++++++++++++++++++++++++ modules/programs/msmtp.nix | 12 +++ 6 files changed, 320 insertions(+) create mode 100644 modules/programs/astroid-accounts.nix create mode 100644 modules/programs/astroid-config-template.json create mode 100644 modules/programs/astroid.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 063ffc258f1..857622c089c 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -380,6 +380,7 @@ in type = types.attrsOf (types.submodule [ mailAccountOpts (import ../programs/alot-accounts.nix) + (import ../programs/astroid-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) diff --git a/modules/modules.nix b/modules/modules.nix index 374edb62071..5ad6c6a97d9 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -27,6 +27,7 @@ let ./misc/xdg.nix ./programs/alot.nix ./programs/autorandr.nix + ./programs/astroid.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix diff --git a/modules/programs/astroid-accounts.nix b/modules/programs/astroid-accounts.nix new file mode 100644 index 00000000000..0bcf17e9081 --- /dev/null +++ b/modules/programs/astroid-accounts.nix @@ -0,0 +1,41 @@ +{ config, lib, ... }: + +with lib; +{ + + options.astroid = { + enable = mkEnableOption "Astroid"; + + sendMailCommand = mkOption { + type = types.nullOr types.str; + description = '' + Command to send a mail. If msmtp is enabled for the account, + then this is set to + msmtpq --read-envelope-from --read-recipients. + ''; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = '' + { + select_query = ""; + } + ''; + description = '' + Extra settings to add to this astroid account configuration. + ''; + }; + + }; + + + config = mkIf config.notmuch.enable { + astroid.sendMailCommand = mkOptionDefault ( + if config.msmtp.enable + then "msmtpq --read-envelope-from --read-recipients" + else null + ); + }; +} diff --git a/modules/programs/astroid-config-template.json b/modules/programs/astroid-config-template.json new file mode 100644 index 00000000000..25442c0ed76 --- /dev/null +++ b/modules/programs/astroid-config-template.json @@ -0,0 +1,136 @@ +{ + "astroid": { + "config": { + "version": "11" + }, + "notmuch_config": "\/home\/teto\/.notmuch-config", + "debug": { + "dryrun_sending": "false" + }, + "hints": { + "level": "0" + }, + "log": { + "syslog": "false", + "stdout": "true", + "level": "info" + } + }, + "accounts": { + "charlie": { + "name": "Charlie Root", + "email": "root@localhost", + "gpgkey": "", + "always_gpg_sign": "false", + "sendmail": "msmtp -i -t", + "default": "true", + "save_sent": "false", + "save_sent_to": "\/home\/root\/Mail\/sent\/cur\/", + "additional_sent_tags": "", + "save_drafts_to": "\/home\/root\/Mail\/drafts\/", + "signature_separate": "false", + "signature_file": "", + "signature_file_markdown": "", + "signature_default_on": "true", + "signature_attach": "false", + "select_query": "" + } + }, + "startup": { + "queries": { + "inbox": "tag:inbox" + } + }, + "terminal": { + "height": "10", + "font_description": "default" + }, + "thread_index": { + "page_jump_rows": "6", + "sort_order": "newest", + "cell": { + "font_description": "default", + "line_spacing": "2", + "date_length": "10", + "message_count_length": "4", + "authors_length": "20", + "subject_color": "#807d74", + "subject_color_selected": "#000000", + "background_color_selected": "", + "background_color_marked": "#fff584", + "background_color_marked_selected": "#bcb559", + "tags_length": "80", + "tags_upper_color": "#e5e5e5", + "tags_lower_color": "#333333", + "tags_alpha": "0.5", + "hidden_tags": "attachment,flagged,unread" + } + }, + "general": { + "time": { + "clock_format": "local", + "same_year": "%b %-e", + "diff_year": "%x" + } + }, + "editor": { + "cmd": "\/nix\/store\/svbc11jg7aq9c2mdz233cadxnqnqdckx-vim-8.1.0146\/bin\/vim -g --servername %2 --socketid %3 -f -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1", + "external_editor": "false", + "charset": "utf-8", + "save_draft_on_force_quit": "true", + "attachment_words": "attach", + "attachment_directory": "~", + "markdown_processor": "marked" + }, + "mail": { + "reply": { + "quote_line": "Excerpts from %1's message of %2:", + "mailinglist_reply_to_sender": "true" + }, + "forward": { + "quote_line": "Forwarding %1's message of %2:", + "disposition": "inline" + }, + "sent_tags": "sent", + "message_id_fqdn": "", + "message_id_user": "", + "user_agent": "default", + "send_delay": "2", + "close_on_success": "false", + "format_flowed": "false" + }, + "poll": { + "interval": "60", + "always_full_refresh": "false" + }, + "attachment": { + "external_open_cmd": "xdg-open" + }, + "thread_view": { + "open_html_part_external": "false", + "preferred_type": "plain", + "preferred_html_only": "false", + "allow_remote_when_encrypted": "false", + "open_external_link": "xdg-open", + "default_save_directory": "~", + "indent_messages": "false", + "gravatar": { + "enable": "true" + }, + "mark_unread_delay": "0.5", + "expand_flagged": "true" + }, + "crypto": { + "gpg": { + "path": "gpg2", + "always_trust": "true", + "enabled": "true" + } + }, + "saved_searches": { + "show_on_startup": "false", + "save_history": "true", + "history_lines_to_show": "15", + "history_lines": "1000" + } +} diff --git a/modules/programs/astroid.nix b/modules/programs/astroid.nix new file mode 100644 index 00000000000..34bce43d5bc --- /dev/null +++ b/modules/programs/astroid.nix @@ -0,0 +1,129 @@ +# look at dev/get_keys.py to generate a default mappings +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.astroid; + + astroidAccounts = filterAttrs (n: v: v.notmuch.enable) + (config.accounts.email.accounts); + + sendMailCommand = account: + if account.astroid.sendMailCommand != null then account.astroid.sendMailCommand + else + if account.msmtp.enable then cfg.msmtp.sendCommand else ""; + + accountAttr = account: with account; { + email = address; + name = realName; + sendmail = sendMailCommand account; + additional_sent_tags = ""; + default = if primary then "true" else "false"; + save_drafts_to = folders.drafts; + save_sent = "true"; + save_sent_to = folders.sent; + select_query = ""; + } + // optionalAttrs (signature.showSignature != "none") { + signature_attach= if (signature.showSignature == "attach") then "true" else "false"; + signature_default_on = if (signature.showSignature != "none") then "true" else "false"; + signature_file = pkgs.writeText "signature.txt" signature.text; + signature_file_markdown = "false"; + signature_separate = "true"; # prepends '--\n' to the signature + } + // optionalAttrs (gpg != null) { + always_gpg_sign = if gpg.signByDefault then "true" else "false"; + gpgkey = gpg.key; + } + // astroid.extraConfig + ; + + # See https://github.com/astroidmail/astroid/wiki/Configuration-Reference + configFile = mailAccounts: let + template = builtins.fromJSON (builtins.readFile ./astroid-config-template.json); + astroidConfig = + recursiveUpdate (template // { + astroid.notmuch_config = "${config.xdg.configHome}/notmuch/notmuchrc"; + accounts = mapAttrs (name: account: (accountAttr account) ) astroidAccounts; + crypto.gpg.path = "${pkgs.gnupg}/bin/gpg"; + } + // cfg.extraConfig + ) + cfg.externalEditor; + in + builtins.toJSON astroidConfig; + + +in +{ + + options = { + programs.astroid = { + enable = mkEnableOption "Astroid"; + + pollScript = mkOption { + type = types.str; + default = ""; + example = '' + mbsync gmail + ''; + description = '' + Script to run to fetch/update mails. + ''; + }; + + externalEditor = mkOption { + type = types.str; + default = '' + gvim -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1 + ''; + # converts it into json that can be appended to the config + apply = cmd: + { + editor = { + "external_editor" = "true"; + "cmd" = cmd; + }; + }; + + example = '' + nvim-qt -- -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1 + ''; + description = '' + You can use %1 / %2 / %3 to refer respectively to: + - filename + - servername + - socketid + See + ''; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + poll.interval = 0; + } + ''; + description = '' + JSON config that will override the default astroid configuration. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + + home.packages = [ pkgs.astroid ]; + + xdg.configFile."astroid/config".source = pkgs.runCommandNoCC "out.json" + {x = configFile astroidAccounts; } ''echo "$x" | ${pkgs.jq}/bin/jq . > $out''; + + xdg.configFile."astroid/poll.sh" = { + executable = true; + text = "# Generated by home-manager\n" + cfg.pollScript; + }; + }; +} diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index 7f00bbb0a13..5647a5ad41f 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -60,6 +60,18 @@ in ''; }; }; + sendCommand = mkOption { + type = types.str; + default = "msmtpq --read-envelope-from --read-recipients"; + # apply = p: + # if hasPrefix "/" p + # then p + # else "${config.home.homeDirectory}/${p}"; + description = '' + Default command to use to send mail. + ''; + }; + }; config = mkIf cfg.enable { -- cgit v1.2.3 From 8e798e4c28bffa20b9d5f6c44fbcce6d3a3df15e Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 30 Sep 2018 18:34:22 +0900 Subject: alot: change msmtp default command --- modules/programs/alot-accounts.nix | 2 +- modules/programs/msmtp.nix | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix index ad7be0d887b..783b29b6b62 100644 --- a/modules/programs/alot-accounts.nix +++ b/modules/programs/alot-accounts.nix @@ -25,7 +25,7 @@ with lib; config = mkIf config.notmuch.enable { alot.sendMailCommand = mkOptionDefault ( if config.msmtp.enable - then "msmtpq --read-envelope-from --read-recipients" + then cfg.msmtp.sendCommand else null ); }; diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index 5647a5ad41f..7599c5e0a12 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -63,10 +63,6 @@ in sendCommand = mkOption { type = types.str; default = "msmtpq --read-envelope-from --read-recipients"; - # apply = p: - # if hasPrefix "/" p - # then p - # else "${config.home.homeDirectory}/${p}"; description = '' Default command to use to send mail. ''; -- cgit v1.2.3 From 22568a3d2612733accfa828cbb54068a4452f01f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 12 Nov 2018 21:59:02 +0100 Subject: Revert PR #408 This reverts the commits - "alot: change msmtp default command" 8e798e4c28bffa20b9d5f6c44fbcce6d3a3df15e - "astroid: init" 736e340bde8831e1ffb3e423056a801d0546a83c because they include changes that break some configurations and some options that are misplaced. --- modules/accounts/email.nix | 1 - modules/modules.nix | 1 - modules/programs/alot-accounts.nix | 2 +- modules/programs/astroid-accounts.nix | 41 -------- modules/programs/astroid-config-template.json | 136 -------------------------- modules/programs/astroid.nix | 129 ------------------------ modules/programs/msmtp.nix | 8 -- 7 files changed, 1 insertion(+), 317 deletions(-) delete mode 100644 modules/programs/astroid-accounts.nix delete mode 100644 modules/programs/astroid-config-template.json delete mode 100644 modules/programs/astroid.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 857622c089c..063ffc258f1 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -380,7 +380,6 @@ in type = types.attrsOf (types.submodule [ mailAccountOpts (import ../programs/alot-accounts.nix) - (import ../programs/astroid-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) diff --git a/modules/modules.nix b/modules/modules.nix index 5ad6c6a97d9..374edb62071 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -27,7 +27,6 @@ let ./misc/xdg.nix ./programs/alot.nix ./programs/autorandr.nix - ./programs/astroid.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix index 783b29b6b62..ad7be0d887b 100644 --- a/modules/programs/alot-accounts.nix +++ b/modules/programs/alot-accounts.nix @@ -25,7 +25,7 @@ with lib; config = mkIf config.notmuch.enable { alot.sendMailCommand = mkOptionDefault ( if config.msmtp.enable - then cfg.msmtp.sendCommand + then "msmtpq --read-envelope-from --read-recipients" else null ); }; diff --git a/modules/programs/astroid-accounts.nix b/modules/programs/astroid-accounts.nix deleted file mode 100644 index 0bcf17e9081..00000000000 --- a/modules/programs/astroid-accounts.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ config, lib, ... }: - -with lib; -{ - - options.astroid = { - enable = mkEnableOption "Astroid"; - - sendMailCommand = mkOption { - type = types.nullOr types.str; - description = '' - Command to send a mail. If msmtp is enabled for the account, - then this is set to - msmtpq --read-envelope-from --read-recipients. - ''; - }; - - extraConfig = mkOption { - type = types.attrs; - default = {}; - example = '' - { - select_query = ""; - } - ''; - description = '' - Extra settings to add to this astroid account configuration. - ''; - }; - - }; - - - config = mkIf config.notmuch.enable { - astroid.sendMailCommand = mkOptionDefault ( - if config.msmtp.enable - then "msmtpq --read-envelope-from --read-recipients" - else null - ); - }; -} diff --git a/modules/programs/astroid-config-template.json b/modules/programs/astroid-config-template.json deleted file mode 100644 index 25442c0ed76..00000000000 --- a/modules/programs/astroid-config-template.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "astroid": { - "config": { - "version": "11" - }, - "notmuch_config": "\/home\/teto\/.notmuch-config", - "debug": { - "dryrun_sending": "false" - }, - "hints": { - "level": "0" - }, - "log": { - "syslog": "false", - "stdout": "true", - "level": "info" - } - }, - "accounts": { - "charlie": { - "name": "Charlie Root", - "email": "root@localhost", - "gpgkey": "", - "always_gpg_sign": "false", - "sendmail": "msmtp -i -t", - "default": "true", - "save_sent": "false", - "save_sent_to": "\/home\/root\/Mail\/sent\/cur\/", - "additional_sent_tags": "", - "save_drafts_to": "\/home\/root\/Mail\/drafts\/", - "signature_separate": "false", - "signature_file": "", - "signature_file_markdown": "", - "signature_default_on": "true", - "signature_attach": "false", - "select_query": "" - } - }, - "startup": { - "queries": { - "inbox": "tag:inbox" - } - }, - "terminal": { - "height": "10", - "font_description": "default" - }, - "thread_index": { - "page_jump_rows": "6", - "sort_order": "newest", - "cell": { - "font_description": "default", - "line_spacing": "2", - "date_length": "10", - "message_count_length": "4", - "authors_length": "20", - "subject_color": "#807d74", - "subject_color_selected": "#000000", - "background_color_selected": "", - "background_color_marked": "#fff584", - "background_color_marked_selected": "#bcb559", - "tags_length": "80", - "tags_upper_color": "#e5e5e5", - "tags_lower_color": "#333333", - "tags_alpha": "0.5", - "hidden_tags": "attachment,flagged,unread" - } - }, - "general": { - "time": { - "clock_format": "local", - "same_year": "%b %-e", - "diff_year": "%x" - } - }, - "editor": { - "cmd": "\/nix\/store\/svbc11jg7aq9c2mdz233cadxnqnqdckx-vim-8.1.0146\/bin\/vim -g --servername %2 --socketid %3 -f -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1", - "external_editor": "false", - "charset": "utf-8", - "save_draft_on_force_quit": "true", - "attachment_words": "attach", - "attachment_directory": "~", - "markdown_processor": "marked" - }, - "mail": { - "reply": { - "quote_line": "Excerpts from %1's message of %2:", - "mailinglist_reply_to_sender": "true" - }, - "forward": { - "quote_line": "Forwarding %1's message of %2:", - "disposition": "inline" - }, - "sent_tags": "sent", - "message_id_fqdn": "", - "message_id_user": "", - "user_agent": "default", - "send_delay": "2", - "close_on_success": "false", - "format_flowed": "false" - }, - "poll": { - "interval": "60", - "always_full_refresh": "false" - }, - "attachment": { - "external_open_cmd": "xdg-open" - }, - "thread_view": { - "open_html_part_external": "false", - "preferred_type": "plain", - "preferred_html_only": "false", - "allow_remote_when_encrypted": "false", - "open_external_link": "xdg-open", - "default_save_directory": "~", - "indent_messages": "false", - "gravatar": { - "enable": "true" - }, - "mark_unread_delay": "0.5", - "expand_flagged": "true" - }, - "crypto": { - "gpg": { - "path": "gpg2", - "always_trust": "true", - "enabled": "true" - } - }, - "saved_searches": { - "show_on_startup": "false", - "save_history": "true", - "history_lines_to_show": "15", - "history_lines": "1000" - } -} diff --git a/modules/programs/astroid.nix b/modules/programs/astroid.nix deleted file mode 100644 index 34bce43d5bc..00000000000 --- a/modules/programs/astroid.nix +++ /dev/null @@ -1,129 +0,0 @@ -# look at dev/get_keys.py to generate a default mappings -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.programs.astroid; - - astroidAccounts = filterAttrs (n: v: v.notmuch.enable) - (config.accounts.email.accounts); - - sendMailCommand = account: - if account.astroid.sendMailCommand != null then account.astroid.sendMailCommand - else - if account.msmtp.enable then cfg.msmtp.sendCommand else ""; - - accountAttr = account: with account; { - email = address; - name = realName; - sendmail = sendMailCommand account; - additional_sent_tags = ""; - default = if primary then "true" else "false"; - save_drafts_to = folders.drafts; - save_sent = "true"; - save_sent_to = folders.sent; - select_query = ""; - } - // optionalAttrs (signature.showSignature != "none") { - signature_attach= if (signature.showSignature == "attach") then "true" else "false"; - signature_default_on = if (signature.showSignature != "none") then "true" else "false"; - signature_file = pkgs.writeText "signature.txt" signature.text; - signature_file_markdown = "false"; - signature_separate = "true"; # prepends '--\n' to the signature - } - // optionalAttrs (gpg != null) { - always_gpg_sign = if gpg.signByDefault then "true" else "false"; - gpgkey = gpg.key; - } - // astroid.extraConfig - ; - - # See https://github.com/astroidmail/astroid/wiki/Configuration-Reference - configFile = mailAccounts: let - template = builtins.fromJSON (builtins.readFile ./astroid-config-template.json); - astroidConfig = - recursiveUpdate (template // { - astroid.notmuch_config = "${config.xdg.configHome}/notmuch/notmuchrc"; - accounts = mapAttrs (name: account: (accountAttr account) ) astroidAccounts; - crypto.gpg.path = "${pkgs.gnupg}/bin/gpg"; - } - // cfg.extraConfig - ) - cfg.externalEditor; - in - builtins.toJSON astroidConfig; - - -in -{ - - options = { - programs.astroid = { - enable = mkEnableOption "Astroid"; - - pollScript = mkOption { - type = types.str; - default = ""; - example = '' - mbsync gmail - ''; - description = '' - Script to run to fetch/update mails. - ''; - }; - - externalEditor = mkOption { - type = types.str; - default = '' - gvim -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1 - ''; - # converts it into json that can be appended to the config - apply = cmd: - { - editor = { - "external_editor" = "true"; - "cmd" = cmd; - }; - }; - - example = '' - nvim-qt -- -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1 - ''; - description = '' - You can use %1 / %2 / %3 to refer respectively to: - - filename - - servername - - socketid - See - ''; - }; - - extraConfig = mkOption { - type = types.attrs; - default = {}; - example = literalExample '' - { - poll.interval = 0; - } - ''; - description = '' - JSON config that will override the default astroid configuration. - ''; - }; - }; - }; - - config = mkIf cfg.enable { - - home.packages = [ pkgs.astroid ]; - - xdg.configFile."astroid/config".source = pkgs.runCommandNoCC "out.json" - {x = configFile astroidAccounts; } ''echo "$x" | ${pkgs.jq}/bin/jq . > $out''; - - xdg.configFile."astroid/poll.sh" = { - executable = true; - text = "# Generated by home-manager\n" + cfg.pollScript; - }; - }; -} diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index 7599c5e0a12..7f00bbb0a13 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -60,14 +60,6 @@ in ''; }; }; - sendCommand = mkOption { - type = types.str; - default = "msmtpq --read-envelope-from --read-recipients"; - description = '' - Default command to use to send mail. - ''; - }; - }; config = mkIf cfg.enable { -- cgit v1.2.3 From 36ecad6cbefe2690ec0599f88f1c98e1aa662d6f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 13 Nov 2018 23:55:01 +0100 Subject: Add basic gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..d6944e3ddc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result* -- cgit v1.2.3 From f4ebbcbf707e10b17bf450272dba3bad2c885e6f Mon Sep 17 00:00:00 2001 From: Sam Stites Date: Fri, 14 Sep 2018 12:14:39 -0400 Subject: tmux: add module This commit adds the tmux program to Home Manager. In addition to configuring tmux, a user may specify tmux plugins from Nixpkgs. These can be included in the list of `plugins` and can either be a package (all tmux plugins live under `nixpkgs.tmuxPlugins.*`), or an object which includes the plugin and an `extraConfig`, which will be run immediately after sourcing the tmux plugin. Finally, this commit introduces two nested programs which may be enabled which depend on tmux: tmuxp and tmuxinator. These do not have the ability to be configured, although this may be a future contribution. --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/tmux.nix | 148 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 modules/programs/tmux.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index bc0fbca7c14..ff668cabed3 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -809,6 +809,13 @@ in A new module is available: 'programs.urxvt'. ''; } + + { + time = "2018-11-13T23:08:03+00:00"; + message = '' + A new module is available: 'programs.tmux'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 374edb62071..6a508553aed 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -61,6 +61,7 @@ let ./programs/taskwarrior.nix ./programs/termite.nix ./programs/texlive.nix + ./programs/tmux.nix ./programs/urxvt.nix ./programs/vim.nix ./programs/zathura.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix new file mode 100644 index 00000000000..050168bedc8 --- /dev/null +++ b/modules/programs/tmux.nix @@ -0,0 +1,148 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.tmux; + + pluginName = p: if types.package.check p then p.name else p.plugin.name; + + pluginModule = types.submodule { + options = { + plugin = mkOption { + type = types.package; + description = "Path of the configuration file to include."; + }; + + extraConfig = mkOption { + type = types.lines; + description = "Additional configuration for the associated plugin."; + default = ""; + }; + }; + }; + +in + +{ + options = { + programs.tmux = { + enable = mkEnableOption "tmux"; + + package = mkOption { + type = types.package; + default = pkgs.tmux; + defaultText = "pkgs.tmux"; + example = literalExample "pkgs.tmux"; + description = "The tmux package to install"; + }; + + sensibleOnTop = mkOption { + type = types.bool; + default = true; + description = '' + Run the sensible plugin at the top of the configuration. It + is possible to override the sensible settings using the + option. + ''; + }; + + tmuxp.enable = mkEnableOption "tmuxp"; + + tmuxinator.enable = mkEnableOption "tmuxinator"; + + plugins = mkOption { + type = with types; + listOf (either package pluginModule) + // { description = "list of plugin packages or submodules"; }; + description = '' + List of tmux plugins to be included at the end of your tmux + configuration. The sensible plugin, however, is defaulted to + run at the top of your configuration. + ''; + default = [ ]; + example = literalExample '' + with pkgs; [ + tmuxPlugins.cpu + { + plugin = tmuxPlugins.resurrect; + extraConfig = "set -g @resurrect-strategy-nvim 'session'"; + } + { + plugin = tmuxPlugins.continuum; + extraConfig = ''' + set -g @continuum-restore 'on' + set -g @continuum-save-interval '60' # minutes + '''; + } + ] + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Additional configuration to add to + tmux.conf. + ''; + }; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + { + home.packages = [ cfg.package ] + ++ optional cfg.tmuxinator.enable pkgs.tmuxinator + ++ optional cfg.tmuxp.enable pkgs.tmuxp; + + home.file.".tmux.conf".text = cfg.extraConfig; + } + + (mkIf cfg.sensibleOnTop { + home.file.".tmux.conf".text = mkBefore '' + # ============================================= # + # Start with defaults from the Sensible plugin # + # --------------------------------------------- # + run-shell ${pkgs.tmuxPlugins.sensible.rtp} + # ============================================= # + ''; + }) + + (mkIf (cfg.plugins != []) { + assertions = [( + let + hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p)); + badPlugins = filter hasBadPluginName cfg.plugins; + in + { + assertion = badPlugins == []; + message = + "Invalid tmux plugin (not prefixed with \"tmuxplugins\"): " + + concatMapStringsSep ", " pluginName badPlugins; + } + )]; + + home.file.".tmux.conf".text = mkAfter '' + # ============================================= # + # Load plugins with Home Manager # + # --------------------------------------------- # + + ${(concatMapStringsSep "\n\n" (p: '' + # ${pluginName p} + # --------------------- + ${p.extraConfig or ""} + run-shell ${ + if types.package.check p + then p.rtp + else p.plugin.rtp + } + '') cfg.plugins)} + # ============================================= # + ''; + }) + ] + ); +} -- cgit v1.2.3 From 0efda9cd6bcb696e2e420d97bcb51adc117e5783 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 14 Nov 2018 20:59:45 +0100 Subject: Use `preferLocalBuild` with `runCommand` --- modules/programs/direnv.nix | 16 +++++++++++----- modules/programs/obs-studio.nix | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index bfac5333471..e4c17239c58 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -6,11 +6,17 @@ let cfg = config.programs.direnv; configFile = config: - pkgs.runCommand "config.toml" { buildInputs = [ pkgs.remarshal ]; } '' - remarshal -if json -of toml \ - < ${pkgs.writeText "config.json" (builtins.toJSON config)} \ - > $out - ''; + pkgs.runCommand "config.toml" + { + buildInputs = [ pkgs.remarshal ]; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + remarshal -if json -of toml \ + < ${pkgs.writeText "config.json" (builtins.toJSON config)} \ + > $out + ''; in diff --git a/modules/programs/obs-studio.nix b/modules/programs/obs-studio.nix index 9f9310c9506..f0dfecb63cc 100644 --- a/modules/programs/obs-studio.nix +++ b/modules/programs/obs-studio.nix @@ -12,13 +12,18 @@ let pluginDirs = map (pkg: "${pkg}/share/obs/obs-plugins") packages; plugins = concatMapStringsSep " " (p: "${p}/*") pluginDirs; in - pkgs.runCommand "obs-studio-plugins" {} '' - mkdir $out - [[ '${plugins}' ]] || exit 0 - for plugin in ${plugins}; do - ln -s "$plugin" $out/ - done - ''; + pkgs.runCommand "obs-studio-plugins" + { + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + mkdir $out + [[ '${plugins}' ]] || exit 0 + for plugin in ${plugins}; do + ln -s "$plugin" $out/ + done + ''; in -- cgit v1.2.3 From b08e6221e0a227469e992bf4b302edebeedba006 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 9 Nov 2018 10:46:24 -0800 Subject: faq: add instructions on targeting multiple logins Content adapted from https://github.com/rycee/home-manager/issues/394#issuecomment-422958338 --- FAQ.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/FAQ.md b/FAQ.md index f89a34c5109..f4915692f4e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -64,3 +64,43 @@ adding to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. + +How do set up a configuration for multiple users/machines? +---------------------------------------------------------- + +A typical way to prepare a repository of configurations for multiple +logins and machines is to prepare one "top-level" file for each unique +combination. + +For example, if you have two machines, called "kronos" and "rhea" on +which you want to configure your user "jane" then you could create the +files + +- `kronos-jane.nix`, +- `rhea-jane.nix`, and +- `common.nix` + +in your repository. On the kronos and rhea machines you can then make +`~jane/.config/nixpkgs/home.nix` be a symbolic link to the +corresponding file in your configuration repository. + +The `kronos-jane.nix` and `rhea-jane.nix` files follow the format + +```nix +{ ... }: + +{ + imports = [ ./common.nix ]; + + # Various options that are specific for this machine/user. +} +``` + +while the `common.nix` file contains configuration shared across the +two logins. Of course, instead of just a single `common.nix` file you +can have multiple ones, even one per program or service. + +You can get some inspiration from the [Post your home-manager home.nix +file!][1] Reddit thread. + +[1]: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/ -- cgit v1.2.3 From 9a0f388f66f6c7b388fecbbbb84cf0e95ef41fec Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 15 Nov 2018 00:16:02 +0100 Subject: compton: fix corrupt colors under Mesa 18 Fixes #441 --- modules/services/compton.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index f7a794e4c06..136d160bc6a 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -302,6 +302,10 @@ in { ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; Restart = "always"; RestartSec = 3; + } + // optionalAttrs (cfg.backend == "glx") { + # Temporarily fixes corrupt colours with Mesa 18. + Environment = [ "allow_rgb10_configs=false" ]; }; }; }; -- cgit v1.2.3 From abfc37076a278f52abbc26387e1d08d82ba6e062 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 15 Nov 2018 00:16:56 +0100 Subject: compton: minor reformatting --- modules/services/compton.nix | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/modules/services/compton.nix b/modules/services/compton.nix index 136d160bc6a..88b15b43bbc 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -284,29 +284,28 @@ in { }; config = mkIf cfg.enable { - home.packages = [ cfg.package ]; systemd.user.services.compton = { - Unit = { - Description = "Compton X11 compositor"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; - Restart = "always"; - RestartSec = 3; - } - // optionalAttrs (cfg.backend == "glx") { - # Temporarily fixes corrupt colours with Mesa 18. - Environment = [ "allow_rgb10_configs=false" ]; - }; + Unit = { + Description = "Compton X11 compositor"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; + Restart = "always"; + RestartSec = 3; + } + // optionalAttrs (cfg.backend == "glx") { + # Temporarily fixes corrupt colours with Mesa 18. + Environment = [ "allow_rgb10_configs=false" ]; + }; }; }; } -- cgit v1.2.3 From dacc07136c74ebe3e702391eb07112bbc5328e80 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 30 Sep 2018 18:06:02 +0900 Subject: astroid: add module Astroid is a notmuch/gtk based MUA: https://github.com/astroidmail/astroid --- modules/accounts/email.nix | 1 + modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/astroid-accounts.nix | 33 +++++++ modules/programs/astroid-config-template.json | 113 ++++++++++++++++++++++ modules/programs/astroid.nix | 131 ++++++++++++++++++++++++++ 6 files changed, 286 insertions(+) create mode 100644 modules/programs/astroid-accounts.nix create mode 100644 modules/programs/astroid-config-template.json create mode 100644 modules/programs/astroid.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 063ffc258f1..857622c089c 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -380,6 +380,7 @@ in type = types.attrsOf (types.submodule [ mailAccountOpts (import ../programs/alot-accounts.nix) + (import ../programs/astroid-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ff668cabed3..a6c435b93c1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -816,6 +816,13 @@ in A new module is available: 'programs.tmux'. ''; } + + { + time = "2018-11-18T18:55:15+00:00"; + message = '' + A new module is available: 'programs.astroid'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 6a508553aed..d3cf343aa4a 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -27,6 +27,7 @@ let ./misc/xdg.nix ./programs/alot.nix ./programs/autorandr.nix + ./programs/astroid.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix diff --git a/modules/programs/astroid-accounts.nix b/modules/programs/astroid-accounts.nix new file mode 100644 index 00000000000..bc94a301db0 --- /dev/null +++ b/modules/programs/astroid-accounts.nix @@ -0,0 +1,33 @@ +{ config, lib, ... }: + +with lib; + +{ + options.astroid = { + enable = mkEnableOption "Astroid"; + + sendMailCommand = mkOption { + type = types.str; + description = '' + Command to send a mail. If msmtp is enabled for the account, + then this is set to + msmtpq --read-envelope-from --read-recipients. + ''; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = { select_query = ""; }; + description = '' + Extra settings to add to this astroid account configuration. + ''; + }; + }; + + config = mkIf config.notmuch.enable { + astroid.sendMailCommand = mkIf config.msmtp.enable ( + mkOptionDefault "msmtpq --read-envelope-from --read-recipients" + ); + }; +} diff --git a/modules/programs/astroid-config-template.json b/modules/programs/astroid-config-template.json new file mode 100644 index 00000000000..87e3f764f9c --- /dev/null +++ b/modules/programs/astroid-config-template.json @@ -0,0 +1,113 @@ +{ + "astroid": { + "config": { + "version": "11" + }, + "debug": { + "dryrun_sending": "false" + }, + "hints": { + "level": "0" + }, + "log": { + "syslog": "false", + "stdout": "true", + "level": "info" + } + }, + "startup": { + "queries": { + "inbox": "tag:inbox" + } + }, + "terminal": { + "height": "10", + "font_description": "default" + }, + "thread_index": { + "page_jump_rows": "6", + "sort_order": "newest", + "cell": { + "font_description": "default", + "line_spacing": "2", + "date_length": "10", + "message_count_length": "4", + "authors_length": "20", + "subject_color": "#807d74", + "subject_color_selected": "#000000", + "background_color_selected": "", + "background_color_marked": "#fff584", + "background_color_marked_selected": "#bcb559", + "tags_length": "80", + "tags_upper_color": "#e5e5e5", + "tags_lower_color": "#333333", + "tags_alpha": "0.5", + "hidden_tags": "attachment,flagged,unread" + } + }, + "general": { + "time": { + "clock_format": "local", + "same_year": "%b %-e", + "diff_year": "%x" + } + }, + "editor": { + "charset": "utf-8", + "save_draft_on_force_quit": "true", + "attachment_words": "attach", + "attachment_directory": "~", + "markdown_processor": "marked" + }, + "mail": { + "reply": { + "quote_line": "Excerpts from %1's message of %2:", + "mailinglist_reply_to_sender": "true" + }, + "forward": { + "quote_line": "Forwarding %1's message of %2:", + "disposition": "inline" + }, + "sent_tags": "sent", + "message_id_fqdn": "", + "message_id_user": "", + "user_agent": "default", + "send_delay": "2", + "close_on_success": "false", + "format_flowed": "false" + }, + "poll": { + "interval": "60", + "always_full_refresh": "false" + }, + "attachment": { + "external_open_cmd": "xdg-open" + }, + "thread_view": { + "open_html_part_external": "false", + "preferred_type": "plain", + "preferred_html_only": "false", + "allow_remote_when_encrypted": "false", + "open_external_link": "xdg-open", + "default_save_directory": "~", + "indent_messages": "false", + "gravatar": { + "enable": "true" + }, + "mark_unread_delay": "0.5", + "expand_flagged": "true" + }, + "crypto": { + "gpg": { + "path": "gpg2", + "always_trust": "true", + "enabled": "true" + } + }, + "saved_searches": { + "show_on_startup": "false", + "save_history": "true", + "history_lines_to_show": "15", + "history_lines": "1000" + } +} diff --git a/modules/programs/astroid.nix b/modules/programs/astroid.nix new file mode 100644 index 00000000000..45c35fa9546 --- /dev/null +++ b/modules/programs/astroid.nix @@ -0,0 +1,131 @@ +{ config, lib, pkgs, ... }: + +with lib; +with builtins; + +let + + cfg = config.programs.astroid; + + astroidAccounts = + filterAttrs + (n: v: v.astroid.enable) + config.accounts.email.accounts; + + boolOpt = b: if b then "true" else "false"; + + accountAttr = account: with account; { + email = address; + name = realName; + sendmail = astroid.sendMailCommand; + additional_sent_tags = ""; + default = boolOpt primary; + save_drafts_to = folders.drafts; + save_sent = "true"; + save_sent_to = folders.sent; + select_query = ""; + } + // optionalAttrs (signature.showSignature != "none") { + signature_attach = boolOpt (signature.showSignature == "attach"); + signature_default_on = boolOpt (signature.showSignature != "none"); + signature_file = pkgs.writeText "signature.txt" signature.text; + signature_file_markdown = "false"; + signature_separate = "true"; # prepends '--\n' to the signature + } + // optionalAttrs (gpg != null) { + always_gpg_sign = boolOpt gpg.signByDefault; + gpgkey = gpg.key; + } + // astroid.extraConfig; + + # See https://github.com/astroidmail/astroid/wiki/Configuration-Reference + configFile = mailAccounts: + let + template = fromJSON (readFile ./astroid-config-template.json); + astroidConfig = foldl' recursiveUpdate template [ + { + astroid.notmuch_config = "${config.xdg.configHome}/notmuch/notmuchrc"; + accounts = mapAttrs (n: accountAttr) astroidAccounts; + crypto.gpg.path = "${pkgs.gnupg}/bin/gpg"; + } + cfg.extraConfig + cfg.externalEditor + ]; + in + builtins.toJSON astroidConfig; + +in + +{ + options = { + programs.astroid = { + enable = mkEnableOption "Astroid"; + + pollScript = mkOption { + type = types.str; + default = ""; + example = "mbsync gmail"; + description = '' + Script to run to fetch/update mails. + ''; + }; + + externalEditor = mkOption { + type = types.nullOr types.str; + default = null; + # Converts it into JSON that can be merged into the configuration. + apply = cmd: + optionalAttrs (cmd != null) { + editor = { + "external_editor" = "true"; + "cmd" = cmd; + }; + }; + example = "nvim-qt -- -c 'set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' %1"; + description = '' + You can use %1, %2, and + %3 to refer respectively to: + + file name + server name + socket ID + + See . + ''; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = { poll.interval = 0; }; + description = '' + JSON config that will override the default Astroid configuration. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.astroid ]; + + xdg.configFile."astroid/config".source = + pkgs.runCommand "out.json" + { + json = configFile astroidAccounts; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + echo -n "$json" | ${pkgs.jq}/bin/jq . > $out + ''; + + xdg.configFile."astroid/poll.sh" = { + executable = true; + text = '' + # Generated by Home Manager + + ${cfg.pollScript} + ''; + }; + }; +} -- cgit v1.2.3 From 061c7b633f66ff73b281f08991c6c0a541877e66 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 10 Nov 2018 07:55:21 -0800 Subject: afew: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/afew.nix | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 modules/programs/afew.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a6c435b93c1..e7d7f27d7d5 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -823,6 +823,13 @@ in A new module is available: 'programs.astroid'. ''; } + + { + time = "2018-11-18T21:41:51+00:00"; + message = '' + A new module is available: 'programs.afew'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d3cf343aa4a..e8f8dbb9c83 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -26,6 +26,7 @@ let ./misc/qt.nix ./misc/xdg.nix ./programs/alot.nix + ./programs/afew.nix ./programs/autorandr.nix ./programs/astroid.nix ./programs/bash.nix diff --git a/modules/programs/afew.nix b/modules/programs/afew.nix new file mode 100644 index 00000000000..99bae88c0ee --- /dev/null +++ b/modules/programs/afew.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.afew; + +in + +{ + options.programs.afew = { + enable = mkEnableOption "the afew initial tagging script for Notmuch"; + + extraConfig = mkOption { + type = types.lines; + default = '' + [SpamFilter] + [KillThreadsFilter] + [ListMailsFilter] + [ArchiveSentMailsFilter] + [InboxFilter] + ''; + example = '' + [SpamFilter] + + [Filter.0] + query = from:pointyheaded@boss.com + tags = -new;+boss + message = Message from above + + [InboxFilter] + ''; + description = '' + Extra lines added to afew configuration file. Available + configuration options are described in the afew manual: + . + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.afew ]; + + xdg.configFile."afew/config".text = '' + # Generated by Home Manager. + # See https://afew.readthedocs.io/ + + ${cfg.extraConfig} + ''; + }; +} -- cgit v1.2.3 From fa62c5afb67fd8570fbff37d9bdf91357ba8913e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 19 Nov 2018 00:07:29 +0100 Subject: modules: fix list sort order --- modules/modules.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/modules.nix b/modules/modules.nix index e8f8dbb9c83..2af4cec35a5 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -25,10 +25,10 @@ let ./misc/pam.nix ./misc/qt.nix ./misc/xdg.nix - ./programs/alot.nix ./programs/afew.nix - ./programs/autorandr.nix + ./programs/alot.nix ./programs/astroid.nix + ./programs/autorandr.nix ./programs/bash.nix ./programs/beets.nix ./programs/browserpass.nix -- cgit v1.2.3 From f247b3b99ba0b6b69a21d2c765a7002fc40ae103 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Mon, 19 Nov 2018 14:04:34 -0800 Subject: offlineimap: add an extraConfig for the account section --- modules/programs/offlineimap-accounts.nix | 11 +++++++++++ modules/programs/offlineimap.nix | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/programs/offlineimap-accounts.nix b/modules/programs/offlineimap-accounts.nix index 1900617ca11..015a5974ab3 100644 --- a/modules/programs/offlineimap-accounts.nix +++ b/modules/programs/offlineimap-accounts.nix @@ -12,6 +12,17 @@ in options.offlineimap = { enable = mkEnableOption "OfflineIMAP"; + extraConfig.account = mkOption { + type = extraConfigType; + default = {}; + example = { + autorefresh = 20; + }; + description = '' + Extra configuration options to add to the account section. + ''; + }; + extraConfig.local = mkOption { type = extraConfigType; default = {}; diff --git a/modules/programs/offlineimap.nix b/modules/programs/offlineimap.nix index 7a1b5734bbb..82143b630ad 100644 --- a/modules/programs/offlineimap.nix +++ b/modules/programs/offlineimap.nix @@ -88,7 +88,8 @@ let localrepository = "${name}-local"; remoterepository = "${name}-remote"; } - // postSyncHook; + // postSyncHook + // offlineimap.extraConfig.account; "Repository ${name}-local" = { type = localType; -- cgit v1.2.3 From a9a4fb641feb89da9f9d9140b5299cbb4c433d29 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 3 Apr 2018 00:53:08 -0400 Subject: nix-darwin: add system module for nix-darwin --- modules/misc/news.nix | 11 +++++++++++ nix-darwin/default.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 nix-darwin/default.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e7d7f27d7d5..21529f46d79 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -830,6 +830,17 @@ in A new module is available: 'programs.afew'. ''; } + + { + time = "2018-11-19T00:40:34+00:00"; + message = '' + A new nix-darwin module is available. Use it the same way the NixOS + module is used. A major limitation is that Home Manager services don't + work, as they depend explicitly on Linux and systemd user services. + However, 'home.file' and 'home.packages' do work. Everything else is + untested at this time. + ''; + } ]; }; } diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix new file mode 100644 index 00000000000..c2ec350cbc0 --- /dev/null +++ b/nix-darwin/default.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.home-manager; + + hmModule = types.submodule ({name, ...}: { + imports = import ../modules/modules.nix { + inherit lib pkgs; + nixosSubmodule = true; + }; + + config = { + home.username = config.users.users.${name}.name; + home.homeDirectory = config.users.users.${name}.home; + }; + }); + +in + +{ + options = { + home-manager.users = mkOption { + type = types.attrsOf hmModule; + default = {}; + description = '' + Per-user Home Manager configuration. + ''; + }; + }; + + config = mkIf (cfg.users != {}) { + system.activationScripts.extraActivation.text = + lib.concatStringsSep "\n" (lib.mapAttrsToList (username: usercfg: '' + echo Activating home-manager configuration for ${username} + sudo -u ${username} ${usercfg.home.activationPackage}/activate + '') cfg.users); + }; +} -- cgit v1.2.3 From 59448d635c7ac0b73f1517b69e5c9dea1d8a9572 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 23 Nov 2018 00:18:29 +0100 Subject: version: add module --- modules/misc/news.nix | 23 +++++++++++++++++++++++ modules/misc/version.nix | 24 ++++++++++++++++++++++++ modules/modules.nix | 1 + 3 files changed, 48 insertions(+) create mode 100644 modules/misc/version.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 21529f46d79..89ec3b41e9a 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -841,6 +841,29 @@ in untested at this time. ''; } + + { + time = "2018-11-24T16:22:19+00:00"; + message = '' + A new option 'home.stateVersion' is available. Its function + is much like the 'system.stateVersion' option in NixOS. + + Briefly, the state version indicates a stable set of option + defaults. In the future, whenever Home Manager changes an + option default in a way that may cause program breakage it + will do so only for the unstable state version, currently + 19.03. Once 19.03 becomes the stable version only backwards + compatible changes will be made and 19.09 becomes the + unstable state version. + + The default value for this option is 18.09 but it may still + be a good idea to explicitly add + + home.stateVersion = "18.09"; + + to your Home Manager configuration. + ''; + } ]; }; } diff --git a/modules/misc/version.nix b/modules/misc/version.nix new file mode 100644 index 00000000000..42e19e98ac7 --- /dev/null +++ b/modules/misc/version.nix @@ -0,0 +1,24 @@ +{ config, lib, ... }: + +with lib; + +{ + options = { + home.stateVersion = mkOption { + type = types.enum [ "18.09" "19.03" ]; + default = "18.09"; + description = '' + It is occasionally necessary for Home Manager to change + configuration defaults in a way that is incompatible with + stateful data. This could, for example, include switching the + default data format or location of a file. + + The state version indicates which default + settings are in effect and will therefore help avoid breaking + program configurations. Switching to a higher state version + typically requires performing some manual steps, such as data + conversion or moving files. + ''; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 2af4cec35a5..b73bc8ead31 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -24,6 +24,7 @@ let ./misc/nixpkgs.nix ./misc/pam.nix ./misc/qt.nix + ./misc/version.nix ./misc/xdg.nix ./programs/afew.nix ./programs/alot.nix -- cgit v1.2.3 From 9318bd3b0d4d50d5617338bf8153bbc86027dae2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 25 Nov 2018 13:33:09 +0100 Subject: notmuch: replace incorrect use of toJSON --- modules/programs/notmuch.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 2d8478f692e..54242245f5a 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -11,7 +11,7 @@ let tweakVal = v: if isString v then v else if isList v then concatMapStringsSep ";" tweakVal v - else if isBool v then toJSON v + else if isBool v then (if v then "true" else "false") else toString v; in "${key}=${tweakVal value}"; -- cgit v1.2.3 From c21b69e73e4b082c6dde94de76c5ac3bc8e4179d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 25 Nov 2018 01:14:15 +0100 Subject: notmuch: add `maildir.synchronizeFlags` option --- modules/programs/notmuch.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 54242245f5a..a5ded5680e4 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -23,6 +23,10 @@ let path = config.accounts.email.maildirBasePath; }; + maildir = { + synchronize_flags = cfg.maildir.synchronizeFlags; + }; + new = { ignore = cfg.new.ignore; tags = cfg.new.tags; @@ -86,9 +90,7 @@ in extraConfig = mkOption { type = types.attrsOf (types.attrsOf types.str); - default = { - maildir = { synchronize_flags = "true"; }; - }; + default = {}; description = '' Options that should be appended to the notmuch configuration file. ''; @@ -126,6 +128,16 @@ in ''; }; }; + + maildir = { + synchronizeFlags = mkOption { + type = types.bool; + default = true; + description = '' + Whether to synchronize Maildir flags. + ''; + }; + }; }; }; -- cgit v1.2.3 From fa3d1f98e001eab0e0514414a6429e082962915a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 25 Nov 2018 13:36:19 +0100 Subject: astroid: require notmuch synchronize flags --- modules/programs/astroid.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/programs/astroid.nix b/modules/programs/astroid.nix index 45c35fa9546..0463cd15528 100644 --- a/modules/programs/astroid.nix +++ b/modules/programs/astroid.nix @@ -106,6 +106,14 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = config.programs.notmuch.maildir.synchronizeFlags; + message = "The astroid module requires" + + " 'programs.notmuch.maildir.synchronizeFlags = true'."; + } + ]; + home.packages = [ pkgs.astroid ]; xdg.configFile."astroid/config".source = -- cgit v1.2.3 From 456e2d7ed546cf0d5c9b1a9cc01875d36411a3fa Mon Sep 17 00:00:00 2001 From: zimbatm Date: Sat, 24 Nov 2018 23:40:25 +0100 Subject: ssh: add more options --- modules/programs/ssh.nix | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index c62f37eb65c..ce7a700cd1c 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -8,6 +8,8 @@ let yn = flag: if flag then "yes" else "no"; + unwords = builtins.concatStringsSep " "; + matchBlockModule = types.submodule ({ name, ... }: { options = { host = mkOption { @@ -24,6 +26,15 @@ let description = "Specifies port number to connect on remote host."; }; + forwardAgent = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + Whether the connection to the authentication agent (if any) + will be forwarded to the remote machine. + ''; + }; + forwardX11 = mkOption { type = types.bool; default = false; @@ -81,6 +92,15 @@ let "Set timeout in seconds after which response will be requested."; }; + sendEnv = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Environment variables to send from the local host to the + server. + ''; + }; + compression = mkOption { type = types.nullOr types.bool; default = null; @@ -118,12 +138,14 @@ let matchBlockStr = cf: concatStringsSep "\n" ( ["Host ${cf.host}"] ++ optional (cf.port != null) " Port ${toString cf.port}" + ++ optional (cf.forwardAgent != null) " ForwardAgent ${yn cf.forwardAgent}" ++ optional cf.forwardX11 " ForwardX11 yes" ++ optional cf.forwardX11Trusted " ForwardX11Trusted yes" ++ optional cf.identitiesOnly " IdentitiesOnly yes" ++ optional (cf.user != null) " User ${cf.user}" ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" ++ optional (cf.hostname != null) " HostName ${cf.hostname}" + ++ optional (cf.sendEnv != []) " SendEnv ${unwords cf.sendEnv}" ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" ++ optional (cf.compression != null) " Compression ${yn cf.compression}" @@ -144,8 +166,8 @@ in default = false; type = types.bool; description = '' - Whether connection to authentication agent (if any) will be forwarded - to remote machine. + Whether the connection to the authentication agent (if any) + will be forwarded to the remote machine. ''; }; -- cgit v1.2.3 From ffdbefe22c4bc9ab35859e2ebc972f0654a73e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Fri, 23 Nov 2018 10:43:13 +0100 Subject: nextcloud-client: add module Adds the nextcloud-client as a service, simply copying the syntax from owncloud.client. --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/services/nextcloud-client.nix | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 modules/services/nextcloud-client.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 89ec3b41e9a..a6f1efd9b3b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -864,6 +864,13 @@ in to your Home Manager configuration. ''; } + + { + time = "2018-11-25T22:10:15+00:00"; + message = '' + A new module is available: 'services.nextcloud-client'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index b73bc8ead31..7a8dd45334f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -82,6 +82,7 @@ let ./services/mbsync.nix ./services/mpd.nix ./services/network-manager-applet.nix + ./services/nextcloud-client.nix ./services/owncloud-client.nix ./services/parcellite.nix ./services/pasystray.nix diff --git a/modules/services/nextcloud-client.nix b/modules/services/nextcloud-client.nix new file mode 100644 index 00000000000..3d8dc0bc80b --- /dev/null +++ b/modules/services/nextcloud-client.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + services.nextcloud-client = { + enable = mkEnableOption "Nextcloud Client"; + }; + }; + + config = mkIf config.services.nextcloud-client.enable { + systemd.user.services.nextcloud-client = { + Unit = { + Description = "Nextcloud Client"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${pkgs.nextcloud-client}/bin/nextcloud"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 6ab6488e5a63978e8af0c4484b6250b1d5a769ab Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Mon, 19 Nov 2018 17:50:35 +0100 Subject: vscode: add module --- modules/misc/news.nix | 7 ++++++ modules/modules.nix | 1 + modules/programs/vscode.nix | 52 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 modules/programs/vscode.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a6f1efd9b3b..403787c6113 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -871,6 +871,13 @@ in A new module is available: 'services.nextcloud-client'. ''; } + + { + time = "2018-11-25T22:55:12+00:00"; + message = '' + A new module is available: 'programs.vscode'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 7a8dd45334f..3619d0c4647 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -67,6 +67,7 @@ let ./programs/tmux.nix ./programs/urxvt.nix ./programs/vim.nix + ./programs/vscode.nix ./programs/zathura.nix ./programs/zsh.nix ./services/blueman-applet.nix diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix new file mode 100644 index 00000000000..cda18979262 --- /dev/null +++ b/modules/programs/vscode.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.vscode; + +in + +{ + options = { + programs.vscode = { + enable = mkEnableOption "Visual Studio Code"; + + userSettings = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + "update.channel" = "none"; + "[nix]"."editor.tabSize" = 2; + } + ''; + description = '' + Configuration written to + ~/.config/Code/User/settings.json. + ''; + }; + + extensions = mkOption { + type = types.listOf types.package; + default = []; + description = '' + The extensions Visual Studio Code should be started with. + These will override but not delete manually installed ones. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (pkgs.vscode-with-extensions.override { + vscodeExtensions = cfg.extensions; + }) + ]; + + xdg.configFile."Code/User/settings.json".text = + builtins.toJSON cfg.userSettings; + }; +} -- cgit v1.2.3 From 67ebe16b406950651de09448cd5afdb437545be6 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Tue, 20 Nov 2018 19:48:16 +0100 Subject: termite: setup the shell hook This fixes Ctrl+Shift+T not working. --- modules/programs/termite.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/programs/termite.nix b/modules/programs/termite.nix index 7e3288bbcb6..6eab39edb3a 100644 --- a/modules/programs/termite.nix +++ b/modules/programs/termite.nix @@ -6,6 +6,13 @@ let cfg = config.programs.termite; + vteInitStr = '' + # See https://github.com/thestinger/termite#id1 + if [[ $TERM == xterm-termite ]]; then + . ${pkgs.gnome3.vte-ng}/etc/profile.d/vte.sh + fi + ''; + in { @@ -363,6 +370,9 @@ in ${cfg.hintsExtra} ''; + + programs.bash.initExtra = vteInitStr; + programs.zsh.initExtra = vteInitStr; } ); } -- cgit v1.2.3 From 9686d93ff69945b505a04aeb2b976e62381ff39e Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 27 Nov 2018 15:21:25 -0800 Subject: keybase: install the keybase package --- modules/services/keybase.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/services/keybase.nix b/modules/services/keybase.nix index 4262bd0796f..2d0a06b06a7 100644 --- a/modules/services/keybase.nix +++ b/modules/services/keybase.nix @@ -16,6 +16,8 @@ in }; config = mkIf cfg.enable { + home.packages = [ pkgs.keybase ]; + systemd.user.services.keybase = { Unit = { Description = "Keybase service"; -- cgit v1.2.3 From 5d8b08918899c1a655a5bfb537f9a19756d565a4 Mon Sep 17 00:00:00 2001 From: Lee Henson Date: Tue, 27 Nov 2018 11:21:37 +0000 Subject: neovim: support withNodeJs option --- modules/programs/neovim.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 76dcd42d297..304a273b6a0 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -47,6 +47,15 @@ in ''; }; + withNodeJs = mkOption { + type = types.bool; + default = false; + description = '' + Enable node provider. Set to true to + use Node plugins. + ''; + }; + withPython = mkOption { type = types.bool; default = true; @@ -62,7 +71,7 @@ in defaultText = "ps: []"; example = literalExample "(ps: with ps; [ pandas jedi ])"; description = '' - A function in python.withPackages format, which returns a + A function in python.withPackages format, which returns a list of Python 2 packages required for your plugins to work. ''; }; @@ -90,7 +99,7 @@ in defaultText = "ps: []"; example = literalExample "(ps: with ps; [ python-language-server ])"; description = '' - A function in python.withPackages format, which returns a + A function in python.withPackages format, which returns a list of Python 3 packages required for your plugins to work. ''; }; @@ -125,7 +134,7 @@ in inherit (cfg) extraPython3Packages withPython3 extraPythonPackages withPython - withRuby viAlias vimAlias configure; + withNodeJs withRuby viAlias vimAlias configure; }) ]; }; -- cgit v1.2.3 From 40b279e3a33fd47b7e65e0303fcb9be621aeb7d3 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 28 Nov 2018 15:24:19 +0100 Subject: ssh: tweak default controlPath Instead of using the hostname `%h`, which can be changed by the ~/.ssh/config file, use the commandline-given hostname `%n`. This allows to alias a host with different hostnames, which then point to different configurations. A common use-case for this is if you have multiple accounts on github with each access to different private repos: Host github.com IdentitiesOnly yes User git IdentityFile ~/.ssh/id_rsa Host customer.github.com IdentitiesOnly yes User git IdentityFile ~/.ssh/customer HostName github.com Without this change, if a connection was established with the first github.com alias, then the user would try to pull a repo from the second account, ssh would re-use the SSH connection which doesn't have access to that repository. --- modules/programs/ssh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index ce7a700cd1c..6423315dba5 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -219,7 +219,7 @@ in controlPath = mkOption { type = types.str; - default = "~/.ssh/master-%r@%h:%p"; + default = "~/.ssh/master-%r@%n:%p"; description = '' Specify path to the control socket used for connection sharing. ''; -- cgit v1.2.3 From 6d2f16a7ae839438b0d67886bf8fd58192968bf0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 30 Nov 2018 23:43:26 +0100 Subject: pasystray: add paprefs and pavucontrol This enables the "volume control" and "control local sound server" menu options. Fixes #461 --- modules/services/pasystray.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/services/pasystray.nix b/modules/services/pasystray.nix index da0436b665a..8f92f34c091 100644 --- a/modules/services/pasystray.nix +++ b/modules/services/pasystray.nix @@ -24,6 +24,11 @@ with lib; }; Service = { + Environment = + let + toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ]; + in + [ "PATH=${toolPaths}" ]; ExecStart = "${pkgs.pasystray}/bin/pasystray"; }; }; -- cgit v1.2.3 From 71f6bc41eb408f1ee53a128d24feffb18248f6fc Mon Sep 17 00:00:00 2001 From: dsx Date: Thu, 29 Nov 2018 19:52:32 -0500 Subject: i3: support for bar tray_output option --- modules/services/window-managers/i3.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 60ab13a31d8..fcc0c4f1b51 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -230,6 +230,12 @@ let See . ''; }; + + trayOutput = mkOption { + type = types.string; + default = "primary"; + description = "Where to output tray."; + }; }; }; @@ -671,7 +677,7 @@ let barStr = { id, fonts, mode, hiddenState, position, workspaceButtons, - workspaceNumbers, command, statusCommand, colors, ... + workspaceNumbers, command, statusCommand, colors, trayOutput, ... }: '' bar { ${optionalString (id != null) "id ${id}"} @@ -683,6 +689,7 @@ let i3bar_command ${command} workspace_buttons ${if workspaceButtons then "yes" else "no"} strip_workspace_numbers ${if !workspaceNumbers then "yes" else "no"} + tray_output ${trayOutput} colors { background ${colors.background} statusline ${colors.statusline} -- cgit v1.2.3 From 15bca92b2c7d8f0a709bbc9fcb8a005c7c38c092 Mon Sep 17 00:00:00 2001 From: dsx Date: Fri, 30 Nov 2018 18:19:03 -0500 Subject: i3: support for workspace_layout option --- modules/services/window-managers/i3.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index fcc0c4f1b51..1d3fe0dcdee 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -400,6 +400,16 @@ let example = "Mod4"; }; + workspaceLayout = mkOption { + type = types.enum [ "default" "stacked" "tabbed" ]; + default = "default"; + example = "tabbed"; + description = '' + The mode in which new containers on workspace level will + start. + ''; + }; + keybindings = mkOption { type = types.attrs; default = { @@ -734,6 +744,7 @@ let focus_follows_mouse ${if focus.followMouse then "yes" else "no"} focus_on_window_activation ${focus.newWindow} mouse_warping ${if focus.mouseWarping then "output" else "none"} + workspace_layout ${workspaceLayout} client.focused ${colorSetStr colors.focused} client.focused_inactive ${colorSetStr colors.focusedInactive} -- cgit v1.2.3 From ef29f321e071cc4ebea35560ef93aec66a1032f2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 3 Dec 2018 01:06:12 +0100 Subject: readme: switch stable channel to 18.09 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 949649b4534..56a0e9bc2a0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwrite was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] unstable and NixOS version 18.03 (the +Home Manager targets [NixOS][] unstable and NixOS version 18.09 (the current stable version), it may or may not work on other Linux distributions and NixOS versions. @@ -64,10 +64,10 @@ Currently the easiest way to install Home Manager is as follows: if you are following Nixpkgs master or an unstable channel and ```console - $ HM_PATH=https://github.com/rycee/home-manager/archive/release-18.03.tar.gz + $ HM_PATH=https://github.com/rycee/home-manager/archive/release-18.09.tar.gz ``` - if you follow a Nixpkgs version 18.03 channel. + if you follow a Nixpkgs version 18.09 channel. 3. Create an initial Home Manager configuration file: -- cgit v1.2.3 From 30f3baabafabc25e003dfef5a13f2ea57ef668ab Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sat, 1 Dec 2018 23:48:00 -0800 Subject: home-manager: import modules using relative path --- home-manager/home-manager.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-manager/home-manager.nix b/home-manager/home-manager.nix index a4b3c44390f..7a6748942c8 100644 --- a/home-manager/home-manager.nix +++ b/home-manager/home-manager.nix @@ -9,7 +9,7 @@ with pkgs.lib; let - env = import { + env = import ../modules { configuration = if confAttr == "" then confPath -- cgit v1.2.3 From a37b5c9c61d10911b4f094bd9357b4618eb7fa65 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 3 Dec 2018 00:48:07 +0100 Subject: Change installation instructions to use nix-channel This avoids the uncontrollable nature of fetching the tarball as part of the evaluation. Instead the user can decide when to update and also perform rollbacks, if necessary. --- .travis.yml | 2 -- README.md | 39 ++++++++++++++------------------------- home-manager/install.nix | 19 ++++++++++++++++++- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56f9599d5ee..a9f775579ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,6 @@ os: before_script: - mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER - - mkdir -p ~/.config/nixpkgs - - echo "{}" > ~/.config/nixpkgs/home.nix script: nix-shell . -A install diff --git a/README.md b/README.md index 56a0e9bc2a0..65fd09382db 100644 --- a/README.md +++ b/README.md @@ -54,42 +54,32 @@ Currently the easiest way to install Home Manager is as follows: NixOS you can control this option using the [`nix.allowedUsers`][nixosAllowedUsers] system option. -2. Assign a temporary variable holding the URL to the appropriate - archive. Typically this is +2. Add the appropriate Home Manager channel. Typically this is ```console - $ HM_PATH=https://github.com/rycee/home-manager/archive/master.tar.gz + $ nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager + $ nix-channel --update ``` if you are following Nixpkgs master or an unstable channel and ```console - $ HM_PATH=https://github.com/rycee/home-manager/archive/release-18.09.tar.gz + $ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager + $ nix-channel --update ``` if you follow a Nixpkgs version 18.09 channel. -3. Create an initial Home Manager configuration file: +3. Install Home Manager and create the first Home Manager generation: ```console - $ cat > ~/.config/nixpkgs/home.nix <' -A install ``` -4. Install Home Manager and create the first Home Manager generation: + Once finished, Home Manager should be active and available in your + user environment. - ```console - $ nix-shell $HM_PATH -A install - ``` - - Home Manager should now be active and available in your user - environment. - -5. If you do not plan on having Home Manager manage your shell +3. If you do not plan on having Home Manager manage your shell configuration then you must source the ``` @@ -107,11 +97,10 @@ Currently the easiest way to install Home Manager is as follows: to your `~/.profile` file. -Note, because the `HM_PATH` variable above points to the live Home -Manager repository you will automatically get updates whenever you -build a new generation. If you dislike automatic updates then perform -a Git clone of the desired branch and instead do the above steps with -`HM_PATH` set to the _absolute path_ of your clone. +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 ----- diff --git a/home-manager/install.nix b/home-manager/install.nix index be9f17df067..28ffe221bad 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -7,6 +7,23 @@ pkgs.runCommand preferLocalBuild = true; allowSubstitutes = false; shellHook = '' + confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" + + if [[ ! -e $confFile ]]; then + echo + echo "Creating initial Home Manager configuration..." + + mkdir -p "$(dirname "$confFile")" + cat > $confFile < Date: Tue, 4 Dec 2018 23:00:11 +0100 Subject: beets: add enable option --- modules/misc/news.nix | 17 +++++++++++++++++ modules/programs/beets.nix | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 403787c6113..e937a788e61 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -878,6 +878,23 @@ in A new module is available: 'programs.vscode'. ''; } + + { + time = "2018-12-04T21:54:38+00:00"; + condition = config.programs.beets.settings != {}; + message = '' + A new option 'programs.beets.enable' has been added. + Starting with state version 19.03 this option defaults to + false. For earlier versions it defaults to true if + 'programs.beets.settings' is non-empty. + + It is recommended to explicitly add + + programs.beets.enable = true; + + to your configuration. + ''; + } ]; }; } diff --git a/modules/programs/beets.nix b/modules/programs/beets.nix index 40e06a6b389..152bfd304a4 100644 --- a/modules/programs/beets.nix +++ b/modules/programs/beets.nix @@ -13,6 +13,21 @@ in options = { programs.beets = { + enable = mkOption { + type = types.bool; + default = + if versionAtLeast config.home.stateVersion "19.03" + then false + else cfg.settings != {}; + defaultText = "false"; + description = '' + Whether to enable the beets music library manager. This + defaults to false for state + version ≥ 19.03. For earlier versions beets is enabled if + is non-empty. + ''; + }; + settings = mkOption { type = types.attrs; default = {}; @@ -24,7 +39,7 @@ in }; }; - config = mkIf (cfg.settings != {}) { + config = mkIf cfg.enable { home.packages = [ pkgs.beets ]; xdg.configFile."beets/config.yaml".text = -- cgit v1.2.3 From 571e17410a173824c5b8c65468da02f7b2b335b8 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 3 Dec 2018 11:19:22 +0100 Subject: home-manager: add edit command With this change, running home-manager edit opens `$HOME_MANAGER_CONFIG` in `$EDITOR`. This is mainly for convenience. Users should not have to remember the exact location of the Home Manager configuration. --- home-manager/home-manager | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index 88c8a32cda7..65c54c63712 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -129,6 +129,17 @@ function presentNews() { fi } +function doEdit() { + if [[ ! -v EDITOR || -z $EDITOR ]]; then + errorEcho "Please set the \$EDITOR environment variable" + return 1 + fi + + setConfigFile + + exec "$EDITOR" "$HOME_MANAGER_CONFIG" +} + function doBuild() { if [[ ! -w . ]]; then errorEcho "Cannot run build in read-only directory"; @@ -354,6 +365,8 @@ function doHelp() { echo echo " help Print this help" echo + echo " edit Open the home configuration in \$EDITOR" + echo echo " build Build configuration into result directory" echo echo " switch Build and activate configuration" @@ -430,6 +443,9 @@ cmd="$1" shift 1 case "$cmd" in + edit) + doEdit + ;; build) doBuild ;; -- cgit v1.2.3 From cd7b6fdbc1ff7eff4f8308b0f04ef63fb70b01e7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 4 Dec 2018 23:41:42 +0100 Subject: autorandr: switch from types.string to types.str --- modules/programs/autorandr.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix index 034675e2fe1..73c855f623b 100644 --- a/modules/programs/autorandr.nix +++ b/modules/programs/autorandr.nix @@ -9,7 +9,7 @@ let profileModule = types.submodule { options = { fingerprint = mkOption { - type = types.attrsOf types.string; + type = types.attrsOf types.str; description = '' Output name to EDID mapping. Use autorandr --fingerprint to get current setup values. @@ -46,28 +46,28 @@ let }; position = mkOption { - type = types.string; + type = types.str; description = "Output position"; default = ""; example = "5760x0"; }; mode = mkOption { - type = types.string; + type = types.str; description = "Output resolution."; default = ""; example = "3840x2160"; }; rate = mkOption { - type = types.string; + type = types.str; description = "Output framerate."; default = ""; example = "60.00"; }; gamma = mkOption { - type = types.string; + type = types.str; description = "Output gamma configuration."; default = ""; example = "1.0:0.909:0.833"; -- cgit v1.2.3 From fd3692b36fa6a1eb50cfeeb6b4532952a4e3d9a6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 4 Dec 2018 23:42:30 +0100 Subject: newsboat: switch from types.string to types.str --- modules/programs/newsboat.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/newsboat.nix b/modules/programs/newsboat.nix index 05b8b260084..84c64dfa607 100644 --- a/modules/programs/newsboat.nix +++ b/modules/programs/newsboat.nix @@ -45,13 +45,13 @@ in }; browser = mkOption { - type = types.string; + type = types.str; default = "${pkgs.xdg_utils}/bin/xdg-open"; description = "External browser to use."; }; queries = mkOption { - type = types.attrsOf types.string; + type = types.attrsOf types.str; default = {}; example = { "foo" = "rssurl =~ \"example.com\""; -- cgit v1.2.3 From ea9d44bedead7ceda543418ddf79826534fc110e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 4 Dec 2018 23:43:12 +0100 Subject: rofi: switch from types.string to types.str --- modules/programs/rofi.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index ed21655ba6d..7fd69dc7247 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -8,7 +8,7 @@ let cfg = config.programs.rofi; colorOption = description: mkOption { - type = types.string; + type = types.str; description = description; }; @@ -175,7 +175,7 @@ in font = mkOption { default = null; - type = types.nullOr types.string; + type = types.nullOr types.str; example = "Droid Sans Mono 14"; description = "Font to use."; }; @@ -188,7 +188,7 @@ in terminal = mkOption { default = null; - type = types.nullOr types.string; + type = types.nullOr types.str; description = '' Path to the terminal which will be used to run console applications ''; @@ -282,7 +282,7 @@ in configPath = mkOption { default = "${config.xdg.configHome}/rofi/config"; defaultText = "$XDG_CONFIG_HOME/rofi/config"; - type = types.string; + type = types.str; description = "Path where to put generated configuration file."; }; -- cgit v1.2.3 From 7a28f68ad00930257d2392d3bf522cd78e0f2eb2 Mon Sep 17 00:00:00 2001 From: dsx Date: Mon, 3 Dec 2018 20:36:52 -0500 Subject: dunst: use 'icon_path' instead of 'icon_folders' The 'icon_folders' option is deprecated. --- modules/services/dunst.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 1273ef39de7..c636439a2fb 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -90,7 +90,7 @@ in xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source = "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; - services.dunst.settings.global.icon_folders = + services.dunst.settings.global.icon_path = let useCustomTheme = cfg.iconTheme.package != hicolorTheme.package -- cgit v1.2.3 From 5fe62660aa5facec72d8787da73115ed54ad7545 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 5 Dec 2018 00:14:15 +0100 Subject: ssh: realign options --- modules/programs/ssh.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 6423315dba5..0f88c538aae 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -137,20 +137,20 @@ let matchBlockStr = cf: concatStringsSep "\n" ( ["Host ${cf.host}"] - ++ optional (cf.port != null) " Port ${toString cf.port}" - ++ optional (cf.forwardAgent != null) " ForwardAgent ${yn cf.forwardAgent}" - ++ optional cf.forwardX11 " ForwardX11 yes" - ++ optional cf.forwardX11Trusted " ForwardX11Trusted yes" - ++ optional cf.identitiesOnly " IdentitiesOnly yes" - ++ optional (cf.user != null) " User ${cf.user}" - ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" - ++ optional (cf.hostname != null) " HostName ${cf.hostname}" - ++ optional (cf.sendEnv != []) " SendEnv ${unwords cf.sendEnv}" + ++ optional (cf.port != null) " Port ${toString cf.port}" + ++ optional (cf.forwardAgent != null) " ForwardAgent ${yn cf.forwardAgent}" + ++ optional cf.forwardX11 " ForwardX11 yes" + ++ optional cf.forwardX11Trusted " ForwardX11Trusted yes" + ++ optional cf.identitiesOnly " IdentitiesOnly yes" + ++ optional (cf.user != null) " User ${cf.user}" + ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" + ++ optional (cf.hostname != null) " HostName ${cf.hostname}" + ++ optional (cf.sendEnv != []) " SendEnv ${unwords cf.sendEnv}" ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" - ++ optional (cf.compression != null) " Compression ${yn cf.compression}" - ++ optional (!cf.checkHostIP) " CheckHostIP no" - ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" + ++ optional (cf.compression != null) " Compression ${yn cf.compression}" + ++ optional (!cf.checkHostIP) " CheckHostIP no" + ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); -- cgit v1.2.3 From 6826521ec5ce3e723d0f00dec6ddf3d75cce108a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 5 Dec 2018 00:14:15 +0100 Subject: ssh: add certificateFile option --- modules/programs/ssh.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 0f88c538aae..b0d07f518f2 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -125,6 +125,14 @@ let description = "The command to use to connect to the server."; }; + certificateFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Specifies a file from which the user certificate is read. + ''; + }; + extraOptions = mkOption { type = types.attrsOf types.str; default = {}; @@ -144,6 +152,7 @@ let ++ optional cf.identitiesOnly " IdentitiesOnly yes" ++ optional (cf.user != null) " User ${cf.user}" ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" + ++ optional (cf.certificateFile != null) " CertificateFile ${cf.certificateFile}" ++ optional (cf.hostname != null) " HostName ${cf.hostname}" ++ optional (cf.sendEnv != []) " SendEnv ${unwords cf.sendEnv}" ++ optional (cf.serverAliveInterval != 0) -- cgit v1.2.3 From 6ce3ce69b98cc4f931d803fde2f52243746e0168 Mon Sep 17 00:00:00 2001 From: dsx Date: Mon, 3 Dec 2018 23:05:58 -0500 Subject: ssh: add addressFamily option --- modules/programs/ssh.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index b0d07f518f2..874ae9af049 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -133,6 +133,14 @@ let ''; }; + addressFamily = mkOption { + default = null; + type = types.nullOr (types.enum ["any" "inet" "inet6"]); + description = '' + Specifies which address family to use when connecting. + ''; + }; + extraOptions = mkOption { type = types.attrsOf types.str; default = {}; @@ -154,6 +162,7 @@ let ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" ++ optional (cf.certificateFile != null) " CertificateFile ${cf.certificateFile}" ++ optional (cf.hostname != null) " HostName ${cf.hostname}" + ++ optional (cf.addressFamily != null) " AddressFamily ${cf.addressFamily}" ++ optional (cf.sendEnv != []) " SendEnv ${unwords cf.sendEnv}" ++ optional (cf.serverAliveInterval != 0) " ServerAliveInterval ${toString cf.serverAliveInterval}" -- cgit v1.2.3 From c108eaba425cccf7512e02f173043ee2fb536f85 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 5 Dec 2018 11:38:14 +0100 Subject: i3: switch from attrs to attrsOf --- modules/services/window-managers/i3.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 1d3fe0dcdee..db41774a190 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -255,7 +255,7 @@ let }; }; - criteriaModule = types.attrs; + criteriaModule = types.attrsOf types.str; configModule = types.submodule { options = { @@ -411,7 +411,7 @@ let }; keybindings = mkOption { - type = types.attrs; + type = types.attrsOf types.str; default = { "${cfg.config.modifier}+Return" = "exec i3-sensible-terminal"; "${cfg.config.modifier}+Shift+q" = "kill"; @@ -486,7 +486,7 @@ let }; keycodebindings = mkOption { - type = types.attrs; + type = types.attrsOf types.str; default = {}; description = '' An attribute set that assigns keypress to an action using key code. @@ -571,7 +571,7 @@ let }; modes = mkOption { - type = types.attrsOf types.attrs; + type = types.attrsOf (types.attrsOf types.str); default = { resize = { "Left" = "resize shrink width 10 px or 10 ppt"; -- cgit v1.2.3 From b085344b91834004c35d5de7dde0715c870bf424 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 5 Dec 2018 11:53:17 +0100 Subject: dunst: switch from attrs to attrsOf --- modules/services/dunst.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index c636439a2fb..0e82d43b61e 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -5,6 +5,9 @@ with lib; let cfg = config.services.dunst; + + eitherStrBoolIntList = with types; either str (either bool (either int (listOf str))); + toDunstIni = generators.toINI { mkKeyValue = key: value: let @@ -61,7 +64,7 @@ in }; settings = mkOption { - type = types.attrsOf types.attrs; + type = with types; attrsOf (attrsOf eitherStrBoolIntList); default = {}; description = "Configuration written to ~/.config/dunstrc"; example = literalExample '' -- cgit v1.2.3 From d67835260dbdbc0fc3fc735871ec26a2421ac1b2 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 5 Dec 2018 11:54:52 +0100 Subject: polybar: switch from attrs to attrsOf --- modules/services/polybar.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index e94f7f22097..82ae27b1661 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -6,6 +6,8 @@ let cfg = config.services.polybar; + eitherStrBoolIntList = with types; either str (either bool (either int (listOf str))); + toPolybarIni = generators.toINI { mkKeyValue = key: value: let @@ -57,7 +59,7 @@ in type = types.coercedTo types.path (p: { "section/base" = { include-file = "${p}"; }; }) - (types.attrsOf types.attrs); + (types.attrsOf (types.attrsOf eitherStrBoolIntList)); description = '' Polybar configuration. Can be either path to a file, or set of attributes that will be used to create the final configuration. -- cgit v1.2.3 From 6e67bb7ae611ee37bd94638f90a3f001467a7ba3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 15 Sep 2018 13:27:21 +0200 Subject: doc: add installation instructions to manual Also minor cleanups in README. --- README.md | 11 ++-- doc/installation.xml | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++ doc/manual.xml | 1 + 3 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 doc/installation.xml diff --git a/README.md b/README.md index 65fd09382db..a599ce3c2ef 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,11 @@ Currently the easiest way to install Home Manager is as follows: Also 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`. 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 + 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. 2. Add the appropriate Home Manager channel. Typically this is @@ -83,7 +84,7 @@ Currently the easiest way to install Home Manager is as follows: configuration then you must source the ``` - "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh ``` file in your shell configuration. Unfortunately, we currently only diff --git a/doc/installation.xml b/doc/installation.xml new file mode 100644 index 00000000000..532947554b0 --- /dev/null +++ b/doc/installation.xml @@ -0,0 +1,149 @@ + + Installing Home Manager + + Home Manager can be used in three primary ways: + + + + 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 + for instructions on how to + perform this installation. + + + + + 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 + for a description of this + setup. + + + + + 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 + for a description of this + setup. + + + + +
+ Standalone installation + + + + + Make sure you have a working Nix installation. If you are not using NixOS + then it may be necessary to run + + +$ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER + + + since Home Manager uses these directories to manage your profile + generations. On NixOS these should already be available. + + + Also 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 '<nixpkgs>' -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 + Nix option. On NixOS you can control this option using the + nix.allowedUsers + system option. + + + + + Add the Home Manager channel that you wish to follow. This is done by + running + + +$ nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager +$ nix-channel --update + + + if you are following Nixpkgs master or an unstable channel and + + +$ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager +$ nix-channel --update + + + if you follow a Nixpkgs version 18.09 channel. + + + + + Run the Home Manager installation command and create the first Home + Manager generation: + + +$ nix-shell '<home-manager>' -A install + + + Once finished, Home Manager should be active and available in your user + environment. + + + + + If you do not plan on having Home Manager manage your shell configuration + then you must source the + + +$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh + + + file in your shell configuration. Unfortunately, we currently only support + POSIX.2-like shells such as + Bash or + Z shell. + + + For example, if you use Bash then add + + +. "$HOME/.nix-profile/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. + +
+
+ NixOS module + + + To be done. + +
+
+ nix-darwin module + + + To be done. + +
+
diff --git a/doc/manual.xml b/doc/manual.xml index f076f833886..f0431092b2a 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -24,6 +24,7 @@
+ Configuration Options -- cgit v1.2.3 From 5d63abb473d930a78661a74e26b9f997d7b3ccd6 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 7 Dec 2018 15:45:46 +0100 Subject: i3: fix default keybindings override All default keybindings should have a default priority attached to them. This will allow users to redefine some of the default keybindings without using mkForce. Fixes #485. --- modules/services/window-managers/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index db41774a190..19f9cbde814 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -412,7 +412,7 @@ let keybindings = mkOption { type = types.attrsOf types.str; - default = { + default = mapAttrs (n: mkOptionDefault) { "${cfg.config.modifier}+Return" = "exec i3-sensible-terminal"; "${cfg.config.modifier}+Shift+q" = "kill"; "${cfg.config.modifier}+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; -- cgit v1.2.3 From 6d56abcec1d3f742c83d684927e8255bc676a995 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 11 Dec 2018 00:51:48 +0100 Subject: tests: add initial test framework --- .travis.yml | 3 +- default.nix | 4 +++ tests/default.nix | 23 +++++++++++++ tests/modules/programs/git-expected.conf | 23 +++++++++++++ .../git-with-str-extra-config-expected.conf | 5 +++ .../modules/programs/git-with-str-extra-config.nix | 22 ++++++++++++ tests/modules/programs/git.nix | 40 ++++++++++++++++++++++ tests/modules/xresources-expected.conf | 5 +++ tests/modules/xresources.nix | 22 ++++++++++++ 9 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/default.nix create mode 100644 tests/modules/programs/git-expected.conf create mode 100644 tests/modules/programs/git-with-str-extra-config-expected.conf create mode 100644 tests/modules/programs/git-with-str-extra-config.nix create mode 100644 tests/modules/programs/git.nix create mode 100644 tests/modules/xresources-expected.conf create mode 100644 tests/modules/xresources.nix diff --git a/.travis.yml b/.travis.yml index a9f775579ca..80dde569d88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,5 @@ before_script: - mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER script: - nix-shell . -A install + - nix-shell . -A install + - nix-shell . -A tests.run.all diff --git a/default.nix b/default.nix index 9ae18232316..bedc57779b4 100644 --- a/default.nix +++ b/default.nix @@ -11,4 +11,8 @@ rec { }; nixos = import ./nixos; + + tests = import ./tests { + inherit pkgs; + }; } diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 00000000000..a17bdadbbb5 --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,23 @@ +{ pkgs ? import {} }: + +let + + nmt = pkgs.fetchFromGitLab { + owner = "rycee"; + repo = "nmt"; + rev = "4d7b4bb34ed9df333b5aa54509e50881f3a59939"; + sha256 = "1rha4n5xafxwa5gbrjwnm63z944jr27gv71krkzzmb5wapi1r36m"; + }; + +in + +import nmt { + inherit pkgs; + modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; }; + testedAttrPath = [ "home" "activationPackage" ]; + tests = { + "git/with-most-options" = ./modules/programs/git.nix; + "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; + xresources = ./modules/xresources.nix; + }; +} diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf new file mode 100644 index 00000000000..d2c48f76e91 --- /dev/null +++ b/tests/modules/programs/git-expected.conf @@ -0,0 +1,23 @@ +[alias] +a1=foo +a2=bar + +[commit] +gpgSign=true + +[extra] +name=value + +[gpg] +program=path-to-gpg + +[user] +email=user@example.org +name=John Doe +signingKey=00112233445566778899AABBCCDDEEFF + +[include] +path = ~/path/to/config.inc + +[includeIf "gitdir:~/src/dir"] +path = ~/path/to/conditional.inc diff --git a/tests/modules/programs/git-with-str-extra-config-expected.conf b/tests/modules/programs/git-with-str-extra-config-expected.conf new file mode 100644 index 00000000000..957438de13a --- /dev/null +++ b/tests/modules/programs/git-with-str-extra-config-expected.conf @@ -0,0 +1,5 @@ +This can be anything. + +[user] +email=user@example.org +name=John Doe diff --git a/tests/modules/programs/git-with-str-extra-config.nix b/tests/modules/programs/git-with-str-extra-config.nix new file mode 100644 index 00000000000..734c5ee764c --- /dev/null +++ b/tests/modules/programs/git-with-str-extra-config.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.git = { + enable = true; + extraConfig = '' + This can be anything. + ''; + userEmail = "user@example.org"; + userName = "John Doe"; + }; + + nmt.script = '' + assertFileExists home-files/.config/git/config + assertFileContent home-files/.config/git/config \ + ${./git-with-str-extra-config-expected.conf} + ''; + }; +} diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix new file mode 100644 index 00000000000..29f3d17ebd5 --- /dev/null +++ b/tests/modules/programs/git.nix @@ -0,0 +1,40 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.git = { + enable = true; + aliases = { + a1 = "foo"; + a2 = "bar"; + }; + extraConfig = { + extra = { + name = "value"; + }; + }; + ignores = [ "*~" "*.swp" ]; + includes = [ + { path = "~/path/to/config.inc"; } + { + path = "~/path/to/conditional.inc"; + condition = "gitdir:~/src/dir"; + } + ]; + signing = { + gpgPath = "path-to-gpg"; + key = "00112233445566778899AABBCCDDEEFF"; + signByDefault = true; + }; + userEmail = "user@example.org"; + userName = "John Doe"; + }; + + nmt.script = '' + assertFileExists home-files/.config/git/config + assertFileContent home-files/.config/git/config ${./git-expected.conf} + ''; + }; +} diff --git a/tests/modules/xresources-expected.conf b/tests/modules/xresources-expected.conf new file mode 100644 index 00000000000..20b47e5080b --- /dev/null +++ b/tests/modules/xresources-expected.conf @@ -0,0 +1,5 @@ +Test*boolean1: true +Test*boolean2: false +Test*int: 10 +Test*list: list-str, true, false, 10 +Test*string: test-string diff --git a/tests/modules/xresources.nix b/tests/modules/xresources.nix new file mode 100644 index 00000000000..f73e326f31e --- /dev/null +++ b/tests/modules/xresources.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + xresources = { + properties = { + "Test*string" = "test-string"; + "Test*boolean1" = true; + "Test*boolean2" = false; + "Test*int" = 10; + "Test*list" = [ "list-str" true false 10 ]; + }; + }; + + nmt.script = '' + assertFileExists home-files/.Xresources + assertFileContent home-files/.Xresources ${./xresources-expected.conf} + ''; + }; +} -- cgit v1.2.3 From 4971e3735e860ac05a7aa50103c13a8dcc469dc1 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Tue, 11 Dec 2018 16:22:13 -0500 Subject: readme: clarify bash/zsh compatibility Makes it clearer that the compatibility mentioned only relates to the manual loading approach. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a599ce3c2ef..292c49f313f 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,9 @@ Currently the easiest way to install Home Manager is as follows: $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh ``` - file in your shell configuration. Unfortunately, we currently only - support POSIX.2-like shells such as [Bash][] or [Z shell][]. + file in your shell configuration. Unfortunately, in this specific + case we currently only support POSIX.2-like shells such as + [Bash][] or [Z shell][]. For example, if you use Bash then add -- cgit v1.2.3 From 93b10bcf3cf09df990908f4ca428b18eab34aa3f Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Mon, 10 Dec 2018 16:16:34 -0500 Subject: readme: fix .gitconfig example The example was referencing `~/.gitconfig`, which isn't being checked anymore since 356c0bf751a55878c448461d8ef1d17f43911acd. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 292c49f313f..856eab5edc1 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ such collision is detected the activation will terminate before changing anything on your computer. For example, suppose you have a wonderful, painstakingly created -`~/.gitconfig` and add +`~/.config/git/config` and add ```nix { -- cgit v1.2.3 From dc72aa230596c5e10f4bfaf519392999dfd343cd Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 9 Dec 2018 15:36:21 +0200 Subject: jq: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/jq.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 modules/programs/jq.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e937a788e61..e609cadb200 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -895,6 +895,13 @@ in to your configuration. ''; } + + { + time = "2018-12-12T21:02:05+00:00"; + message = '' + A new module is available: 'programs.jq'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 3619d0c4647..c3298d251ff 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -47,6 +47,7 @@ let ./programs/home-manager.nix ./programs/htop.nix ./programs/info.nix + ./programs/jq.nix ./programs/lesspipe.nix ./programs/man.nix ./programs/mbsync.nix diff --git a/modules/programs/jq.nix b/modules/programs/jq.nix new file mode 100644 index 00000000000..56c3adf0654 --- /dev/null +++ b/modules/programs/jq.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.jq; + + colorType = mkOption { + type = types.str; + description = "ANSI color definition"; + example = "1;31"; + visible = false; + }; + + colorsType = types.submodule { + options = { + null = colorType; + false = colorType; + true = colorType; + numbers = colorType; + strings = colorType; + arrays = colorType; + objects = colorType; + }; + }; + +in + +{ + options = { + programs.jq = { + enable = mkEnableOption "the jq command-line JSON processor"; + + colors = mkOption { + description = '' + The colors used in colored JSON output. + + See . + ''; + + example = literalExample '' + { + null = "1;30"; + false = "0;31"; + true = "0;32"; + numbers = "0;36"; + strings = "0;33"; + arrays = "1;35"; + objects = "1;37"; + } + ''; + + default = { + null = "1;30"; + false = "0;39"; + true = "0;39"; + numbers = "0;39"; + strings = "0;32"; + arrays = "1;39"; + objects = "1;39"; + }; + + type = colorsType; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.jq ]; + + home.sessionVariables = let c = cfg.colors; in { + JQ_COLORS = "${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}"; + }; + }; +} -- cgit v1.2.3 From e68d6e7924925b28ddd46bd7748be7aa3e5c57bd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 17 Dec 2018 23:01:43 +0100 Subject: emacs: add `overrides` option This option enables overriding packages within the generated Emacs package set. Fixes #486 --- modules/programs/emacs.nix | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 87f47a76ab7..751fc435579 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -6,8 +6,13 @@ let cfg = config.programs.emacs; - # Copied from all-packages.nix. - emacsPackages = pkgs.emacsPackagesNgGen cfg.package; + # Copied from all-packages.nix, with modifications to support + # overrides. + emacsPackages = + let + epkgs = pkgs.emacsPackagesNgGen cfg.package; + in + epkgs.overrideScope' cfg.overrides; emacsWithPackages = emacsPackages.emacsWithPackages; in @@ -34,6 +39,20 @@ in description = "Extra packages available to Emacs."; }; + overrides = mkOption { + default = self: super: {}; + defaultText = "self: super: {}"; + example = literalExample '' + self: super: rec { + haskell-mode = self.melpaPackages.haskell-mode; + # ... + }; + ''; + description = '' + Allows overriding packages within the Emacs package set. + ''; + }; + finalPackage = mkOption { type = types.package; internal = true; -- cgit v1.2.3 From 218a8c4d9010538fc6b3d533b32142bb68f5e874 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 16 Dec 2018 12:23:01 +0100 Subject: modules: support conditional module inclusion Also make use of this functionality for the `programs.chromium` module. See #501 --- modules/misc/news.nix | 4 +- modules/modules.nix | 209 ++++++++++++++++++++++++++------------------------ 2 files changed, 112 insertions(+), 101 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e609cadb200..9594855134e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -6,6 +6,8 @@ let cfg = config.news; + hostPlatform = pkgs.stdenv.hostPlatform; + entryModule = types.submodule ({ config, ... }: { options = { id = mkOption { @@ -734,7 +736,7 @@ in { time = "2018-08-19T20:46:09+00:00"; - condition = pkgs.stdenv.isLinux; + condition = hostPlatform.isLinux; message = '' A new modules is available: 'programs.chromium'. ''; diff --git a/modules/modules.nix b/modules/modules.nix index c3298d251ff..aa9c4583a10 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -12,106 +12,115 @@ with lib; let - modules = [ - ./accounts/email.nix - ./files.nix - ./home-environment.nix - ./manual.nix - ./misc/fontconfig.nix - ./misc/gtk.nix - ./misc/lib.nix - ./misc/news.nix - ./misc/nixpkgs.nix - ./misc/pam.nix - ./misc/qt.nix - ./misc/version.nix - ./misc/xdg.nix - ./programs/afew.nix - ./programs/alot.nix - ./programs/astroid.nix - ./programs/autorandr.nix - ./programs/bash.nix - ./programs/beets.nix - ./programs/browserpass.nix - ./programs/command-not-found/command-not-found.nix - ./programs/direnv.nix - ./programs/eclipse.nix - ./programs/emacs.nix - ./programs/feh.nix - ./programs/firefox.nix - ./programs/fish.nix - ./programs/fzf.nix - ./programs/git.nix - ./programs/gnome-terminal.nix - ./programs/go.nix - ./programs/home-manager.nix - ./programs/htop.nix - ./programs/info.nix - ./programs/jq.nix - ./programs/lesspipe.nix - ./programs/man.nix - ./programs/mbsync.nix - ./programs/mercurial.nix - ./programs/msmtp.nix - ./programs/neovim.nix - ./programs/newsboat.nix - ./programs/noti.nix - ./programs/notmuch.nix - ./programs/obs-studio.nix - ./programs/offlineimap.nix - ./programs/pidgin.nix - ./programs/rofi.nix - ./programs/ssh.nix - ./programs/taskwarrior.nix - ./programs/termite.nix - ./programs/texlive.nix - ./programs/tmux.nix - ./programs/urxvt.nix - ./programs/vim.nix - ./programs/vscode.nix - ./programs/zathura.nix - ./programs/zsh.nix - ./services/blueman-applet.nix - ./services/compton.nix - ./services/dunst.nix - ./services/flameshot.nix - ./services/gnome-keyring.nix - ./services/gpg-agent.nix - ./services/kbfs.nix - ./services/kdeconnect.nix - ./services/keepassx.nix - ./services/keybase.nix - ./services/mbsync.nix - ./services/mpd.nix - ./services/network-manager-applet.nix - ./services/nextcloud-client.nix - ./services/owncloud-client.nix - ./services/parcellite.nix - ./services/pasystray.nix - ./services/polybar.nix - ./services/random-background.nix - ./services/redshift.nix - ./services/screen-locker.nix - ./services/stalonetray.nix - ./services/status-notifier-watcher.nix - ./services/syncthing.nix - ./services/taffybar.nix - ./services/tahoe-lafs.nix - ./services/udiskie.nix - ./services/unclutter.nix - ./services/window-managers/awesome.nix - ./services/window-managers/i3.nix - ./services/window-managers/xmonad.nix - ./services/xscreensaver.nix - ./systemd.nix - ./xcursor.nix - ./xresources.nix - ./xsession.nix - - - ] - ++ - optional pkgs.stdenv.isLinux ./programs/chromium.nix; + hostPlatform = pkgs.stdenv.hostPlatform; + + checkPlatform = any (meta.platformMatch pkgs.stdenv.hostPlatform); + + loadModule = file: { condition ? true }: { + inherit file condition; + }; + + allModules = [ + (loadModule ./accounts/email.nix { }) + (loadModule ./files.nix { }) + (loadModule ./home-environment.nix { }) + (loadModule ./manual.nix { }) + (loadModule ./misc/fontconfig.nix { }) + (loadModule ./misc/gtk.nix { }) + (loadModule ./misc/lib.nix { }) + (loadModule ./misc/news.nix { }) + (loadModule ./misc/nixpkgs.nix { }) + (loadModule ./misc/pam.nix { }) + (loadModule ./misc/qt.nix { }) + (loadModule ./misc/version.nix { }) + (loadModule ./misc/xdg.nix { }) + (loadModule ./programs/afew.nix { }) + (loadModule ./programs/alot.nix { }) + (loadModule ./programs/astroid.nix { }) + (loadModule ./programs/autorandr.nix { }) + (loadModule ./programs/bash.nix { }) + (loadModule ./programs/beets.nix { }) + (loadModule ./programs/browserpass.nix { }) + (loadModule ./programs/chromium.nix { condition = hostPlatform.isLinux; }) + (loadModule ./programs/command-not-found/command-not-found.nix { }) + (loadModule ./programs/direnv.nix { }) + (loadModule ./programs/eclipse.nix { }) + (loadModule ./programs/emacs.nix { }) + (loadModule ./programs/feh.nix { }) + (loadModule ./programs/firefox.nix { }) + (loadModule ./programs/fish.nix { }) + (loadModule ./programs/fzf.nix { }) + (loadModule ./programs/git.nix { }) + (loadModule ./programs/gnome-terminal.nix { }) + (loadModule ./programs/go.nix { }) + (loadModule ./programs/home-manager.nix { }) + (loadModule ./programs/htop.nix { }) + (loadModule ./programs/info.nix { }) + (loadModule ./programs/jq.nix { }) + (loadModule ./programs/lesspipe.nix { }) + (loadModule ./programs/man.nix { }) + (loadModule ./programs/mbsync.nix { }) + (loadModule ./programs/mercurial.nix { }) + (loadModule ./programs/msmtp.nix { }) + (loadModule ./programs/neovim.nix { }) + (loadModule ./programs/newsboat.nix { }) + (loadModule ./programs/noti.nix { }) + (loadModule ./programs/notmuch.nix { }) + (loadModule ./programs/obs-studio.nix { }) + (loadModule ./programs/offlineimap.nix { }) + (loadModule ./programs/pidgin.nix { }) + (loadModule ./programs/rofi.nix { }) + (loadModule ./programs/ssh.nix { }) + (loadModule ./programs/taskwarrior.nix { }) + (loadModule ./programs/termite.nix { }) + (loadModule ./programs/texlive.nix { }) + (loadModule ./programs/tmux.nix { }) + (loadModule ./programs/urxvt.nix { }) + (loadModule ./programs/vim.nix { }) + (loadModule ./programs/vscode.nix { }) + (loadModule ./programs/zathura.nix { }) + (loadModule ./programs/zsh.nix { }) + (loadModule ./services/blueman-applet.nix { }) + (loadModule ./services/compton.nix { }) + (loadModule ./services/dunst.nix { }) + (loadModule ./services/flameshot.nix { }) + (loadModule ./services/gnome-keyring.nix { }) + (loadModule ./services/gpg-agent.nix { }) + (loadModule ./services/kbfs.nix { }) + (loadModule ./services/kdeconnect.nix { }) + (loadModule ./services/keepassx.nix { }) + (loadModule ./services/keybase.nix { }) + (loadModule ./services/mbsync.nix { }) + (loadModule ./services/mpd.nix { }) + (loadModule ./services/network-manager-applet.nix { }) + (loadModule ./services/nextcloud-client.nix { }) + (loadModule ./services/owncloud-client.nix { }) + (loadModule ./services/parcellite.nix { }) + (loadModule ./services/pasystray.nix { }) + (loadModule ./services/polybar.nix { }) + (loadModule ./services/random-background.nix { }) + (loadModule ./services/redshift.nix { }) + (loadModule ./services/screen-locker.nix { }) + (loadModule ./services/stalonetray.nix { }) + (loadModule ./services/status-notifier-watcher.nix { }) + (loadModule ./services/syncthing.nix { }) + (loadModule ./services/taffybar.nix { }) + (loadModule ./services/tahoe-lafs.nix { }) + (loadModule ./services/udiskie.nix { }) + (loadModule ./services/unclutter.nix { }) + (loadModule ./services/window-managers/awesome.nix { }) + (loadModule ./services/window-managers/i3.nix { }) + (loadModule ./services/window-managers/xmonad.nix { }) + (loadModule ./services/xscreensaver.nix { }) + (loadModule ./systemd.nix { }) + (loadModule ./xcursor.nix { }) + (loadModule ./xresources.nix { }) + (loadModule ./xsession.nix { }) + (loadModule { }) + (loadModule { }) + ]; + + modules = map (getAttr "file") (filter (getAttr "condition") allModules); pkgsModule = { options.nixosSubmodule = mkOption { -- cgit v1.2.3 From 235a6617c46b4267d4f67cde9a93dbef0f12bd3f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 23 Dec 2018 10:47:12 +0100 Subject: readme: add notice that relog may be needed Also add instructions for non-NixOS users to add the user channel directory to `NIX_PATH`. --- README.md | 9 +++++++++ doc/installation.xml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 856eab5edc1..2386829fe51 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,15 @@ Currently the easiest way to install Home Manager is as follows: if you follow a Nixpkgs version 18.09 channel. + 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: ```console diff --git a/doc/installation.xml b/doc/installation.xml index 532947554b0..ea3c49fa40b 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -85,6 +85,15 @@ $ nix-channel --update if you follow a Nixpkgs version 18.09 channel. + + 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 + +export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH + + to your shell (see + nix#2033). + -- cgit v1.2.3 From b2cc186d22a664a0e07233b7921320601b1b1016 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 4 Nov 2018 19:51:40 +0100 Subject: dconf: add module This module allows unified configuration of dconf settings. --- modules/misc/dconf.nix | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + 3 files changed, 91 insertions(+) create mode 100644 modules/misc/dconf.nix diff --git a/modules/misc/dconf.nix b/modules/misc/dconf.nix new file mode 100644 index 00000000000..8c28fe9cd00 --- /dev/null +++ b/modules/misc/dconf.nix @@ -0,0 +1,83 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.dconf; + dag = config.lib.dag; + + toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; + + mkIniKeyValue = key: value: + let + tweakVal = v: + if isString v then "'${v}'" + else if isList v then "[" + concatMapStringsSep "," tweakVal v + "]" + else if isBool v then (if v then "true" else "false") + else toString v; + in + "${key}=${tweakVal value}"; + + primitive = with types; either bool (either int str); + +in + +{ + meta.maintainers = [ maintainers.gnidorah maintainers.rycee ]; + + options = { + dconf = { + enable = mkOption { + type = types.bool; + default = true; + visible = false; + description = '' + Whether to enable dconf settings. + ''; + }; + + settings = mkOption { + type = with types; + attrsOf (attrsOf (either primitive (listOf primitive))); + default = {}; + example = literalExample '' + { + "org/gnome/calculator" = { + button-mode = "programming"; + show-thousands = true; + base = 10; + word-size = 64; + }; + } + ''; + description = '' + Settings to write to the dconf configuration system. + ''; + }; + }; + }; + + config = mkIf (cfg.enable && cfg.settings != {}) { + home.activation.dconfSettings = dag.entryAfter ["installPackages"] ( + let + iniFile = pkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings); + in + '' + if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then + DCONF_DBUS_RUN_SESSION="" + else + DCONF_DBUS_RUN_SESSION="${pkgs.dbus}/bin/dbus-run-session" + fi + + if [[ -v DRY_RUN ]]; then + echo $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / "<" ${iniFile} + else + $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / < ${iniFile} + fi + + unset DCONF_DBUS_RUN_SESSION + '' + ); + }; +} diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 9594855134e..344f569cf20 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -904,6 +904,13 @@ in A new module is available: 'programs.jq'. ''; } + + { + time = "2018-12-24T16:26:16+00:00"; + message = '' + A new module is available: 'dconf'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index aa9c4583a10..45ab16a3648 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -25,6 +25,7 @@ let (loadModule ./files.nix { }) (loadModule ./home-environment.nix { }) (loadModule ./manual.nix { }) + (loadModule ./misc/dconf.nix { }) (loadModule ./misc/fontconfig.nix { }) (loadModule ./misc/gtk.nix { }) (loadModule ./misc/lib.nix { }) -- cgit v1.2.3 From a0162dacf66f9f87e346f8cfe7b4a4759670eb4e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 4 Nov 2018 20:56:43 +0100 Subject: gnome-terminal: use dconf module for settings --- modules/programs/gnome-terminal.nix | 63 ++++++++++--------------------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index fa379464394..afe12849d08 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -6,8 +6,6 @@ let cfg = config.programs.gnome-terminal; - dag = config.lib.dag; - profileColorsSubModule = types.submodule ( { ... }: { options = { @@ -91,19 +89,6 @@ let } ); - toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; - - mkIniKeyValue = key: value: - let - tweakVal = v: - if isString v then "'${v}'" - else if isList v then "[" + concatStringsSep "," (map tweakVal v) + "]" - else if isBool v && v then "true" - else if isBool v && !v then "false" - else toString v; - in - "${key}=${tweakVal value}"; - buildProfileSet = pcfg: { visible-name = pcfg.visibleName; @@ -136,25 +121,6 @@ let ) ); - buildIniSet = cfg: - { - "/" = { - default-show-menubar = cfg.showMenubar; - schema-version = 3; - }; - } - // - { - "profiles:" = { - default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile)); - list = attrNames cfg.profile; - }; - } - // - mapAttrs' (name: value: - nameValuePair ("profiles:/:${name}") (buildProfileSet value) - ) cfg.profile; - in { @@ -181,20 +147,23 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.gnome3.gnome_terminal ]; - # The dconf service needs to be installed and prepared. - home.activation.gnomeTerminal = dag.entryAfter ["installPackages"] ( + dconf.settings = let - iniText = toDconfIni (buildIniSet cfg); - iniFile = pkgs.writeText "gnome-terminal.ini" iniText; - dconfPath = "/org/gnome/terminal/legacy/"; + dconfPath = "org/gnome/terminal/legacy"; in - '' - if [[ -v DRY_RUN ]]; then - echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} - else - ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} - fi - '' - ); + { + "${dconfPath}" = { + default-show-menubar = cfg.showMenubar; + schema-version = 3; + }; + + "${dconfPath}/profiles:" = { + default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile)); + list = attrNames cfg.profile; + }; + } + // mapAttrs' (n: v: + nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v) + ) cfg.profile; }; } -- cgit v1.2.3 From 4104ff2b6a60cb35dd5713327e73f0a9502fcaa3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 4 Nov 2018 21:10:40 +0100 Subject: gtk: use dconf module for settings --- modules/misc/gtk.nix | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 930823ff48f..9f7513d1014 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -8,8 +8,6 @@ let cfg2 = config.gtk.gtk2; cfg3 = config.gtk.gtk3; - dag = config.lib.dag; - toGtk3Ini = generators.toINI { mkKeyValue = key: value: let @@ -29,16 +27,6 @@ let in "${n} = ${v'}"; - toDconfIni = generators.toINI { - mkKeyValue = key: value: - let - tweakVal = v: - if isString v then "'${v}'" - else toString v; - in - "${key}=${tweakVal value}"; - }; - fontType = types.submodule { options = { package = mkOption { @@ -216,21 +204,8 @@ in xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; - home.activation = mkIf cfg3.waylandSupport { - gtk3 = dag.entryAfter ["installPackages"] ( - let - iniText = toDconfIni { "/" = dconfIni; }; - iniFile = pkgs.writeText "gtk3.ini" iniText; - dconfPath = "/org/gnome/desktop/interface/"; - in - '' - if [[ -v DRY_RUN ]]; then - echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} - else - ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} - fi - '' - ); + dconf.settings = mkIf cfg3.waylandSupport { + "org/gnome/desktop/interface" = dconfIni; }; } ); -- cgit v1.2.3 From 370a84192ef576d0c7ae3a4623ff8131a9f4482b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 24 Dec 2018 12:07:26 +0100 Subject: gtk: make gtk.gtk2 and gtk.gtk3 not submodules --- modules/misc/gtk.nix | 96 +++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 9f7513d1014..6542091c069 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -100,63 +100,51 @@ in description = "The GTK+2/3 theme to use."; }; - gtk2 = mkOption { - description = "Options specific to GTK+ 2"; - default = {}; - type = types.submodule { - options = { - extraConfig = mkOption { - type = types.lines; - default = ""; - example = "gtk-can-change-accels = 1"; - description = '' - Extra configuration lines to add verbatim to - ~/.gtkrc-2.0. - ''; - }; - }; + gtk2 = { + extraConfig = mkOption { + type = types.lines; + default = ""; + example = "gtk-can-change-accels = 1"; + description = '' + Extra configuration lines to add verbatim to + ~/.gtkrc-2.0. + ''; }; }; - gtk3 = mkOption { - description = "Options specific to GTK+ 3"; - default = {}; - type = types.submodule { - options = { - extraConfig = mkOption { - type = types.attrs; - default = {}; - example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; - description = '' - Extra configuration options to add to - ~/.config/gtk-3.0/settings.ini. - ''; - }; - - extraCss = mkOption { - type = types.lines; - default = ""; - description = '' - Extra configuration lines to add verbatim to - ~/.config/gtk-3.0/gtk.css. - ''; - }; - - waylandSupport = mkOption { - type = types.bool; - default = false; - description = '' - Support GSettings provider (dconf) in addition to - GtkSettings (INI file). This is needed for Wayland. - - Note, on NixOS the following line must be in the - system configuration: - - services.dbus.packages = [ pkgs.gnome3.dconf ]; - - ''; - }; - }; + gtk3 = { + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; + description = '' + Extra configuration options to add to + ~/.config/gtk-3.0/settings.ini. + ''; + }; + + extraCss = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration lines to add verbatim to + ~/.config/gtk-3.0/gtk.css. + ''; + }; + + waylandSupport = mkOption { + type = types.bool; + default = false; + description = '' + Support GSettings provider (dconf) in addition to + GtkSettings (INI file). This is needed for Wayland. + + Note, on NixOS the following line must be in the + system configuration: + + services.dbus.packages = [ pkgs.gnome3.dconf ]; + + ''; }; }; }; -- cgit v1.2.3 From cc964b4609616e4dffbe67a6e8c8924540ceae6e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 24 Dec 2018 12:05:28 +0100 Subject: gtk: remove option gtk.gtk3.waylandSupport --- modules/misc/gtk.nix | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 6542091c069..c88ee4c000b 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -76,6 +76,12 @@ in { meta.maintainers = [ maintainers.rycee ]; + imports = [ + (mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] '' + This options is not longer needed and can be removed. + '') + ]; + options = { gtk = { enable = mkEnableOption "GTK 2/3 configuration"; @@ -131,21 +137,6 @@ in ~/.config/gtk-3.0/gtk.css. ''; }; - - waylandSupport = mkOption { - type = types.bool; - default = false; - description = '' - Support GSettings provider (dconf) in addition to - GtkSettings (INI file). This is needed for Wayland. - - Note, on NixOS the following line must be in the - system configuration: - - services.dbus.packages = [ pkgs.gnome3.dconf ]; - - ''; - }; }; }; }; @@ -176,7 +167,6 @@ in optional (opt != null && opt.package != null) opt.package; in { - home.packages = optionalPackage cfg.font ++ optionalPackage cfg.theme @@ -192,9 +182,7 @@ in xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; - dconf.settings = mkIf cfg3.waylandSupport { - "org/gnome/desktop/interface" = dconfIni; - }; + dconf.settings."org/gnome/desktop/interface" = dconfIni; } ); } -- cgit v1.2.3 From 40b3443c8f2e94ae5b8f6e1cf1e973f3b5ee8e2a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 24 Dec 2018 18:36:55 +0100 Subject: dconf: add some information of use under NixOS --- modules/misc/news.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 344f569cf20..1ef1fe13887 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -909,6 +909,17 @@ in time = "2018-12-24T16:26:16+00:00"; message = '' A new module is available: 'dconf'. + + Note, on NixOS you may need to add + + services.dbus.packages = with pkgs; [ gnome3.dconf ]; + + to the system configuration for this module to work as + expected. In particular if you get the error message + + The name ca.desrt.dconf was not provided by any .service files + + when activating your Home Manager configuration. ''; } ]; -- cgit v1.2.3 From 7afefcf75dcebb55e895b8818a90b5d6d16524a2 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Fri, 28 Dec 2018 07:00:00 -0500 Subject: opam: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/opam.nix | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 modules/programs/opam.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1ef1fe13887..4af6d6aa5ed 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -922,6 +922,13 @@ in when activating your Home Manager configuration. ''; } + + { + time = "2018-12-28T12:32:30+00:00"; + message = '' + A new module is available: 'programs.opam'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 45ab16a3648..45cb8d51842 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -69,6 +69,7 @@ let (loadModule ./programs/notmuch.nix { }) (loadModule ./programs/obs-studio.nix { }) (loadModule ./programs/offlineimap.nix { }) + (loadModule ./programs/opam.nix { }) (loadModule ./programs/pidgin.nix { }) (loadModule ./programs/rofi.nix { }) (loadModule ./programs/ssh.nix { }) diff --git a/modules/programs/opam.nix b/modules/programs/opam.nix new file mode 100644 index 00000000000..d62b50dd377 --- /dev/null +++ b/modules/programs/opam.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.opam; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.opam = { + enable = mkEnableOption "Opam"; + + package = mkOption { + type = types.package; + default = pkgs.opam; + defaultText = "pkgs.opam"; + description = "Opam package to install."; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + eval "$(${cfg.package}/bin/opam env --shell=bash)" + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${cfg.package}/bin/opam env --shell=zsh)" + ''; + }; +} -- cgit v1.2.3 From 20a60be550de62ef48b4787688c1f5076b97c90f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 3 Jan 2019 02:15:17 +0100 Subject: emacs: make finalPackage option more accessible Instead of "internal" mark it as "invisible". --- modules/programs/emacs.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 751fc435579..12c7a5a9191 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -55,9 +55,11 @@ in finalPackage = mkOption { type = types.package; - internal = true; + visible = false; readOnly = true; - description = "The Emacs package including any extra packages."; + description = '' + The Emacs package including any overrides and extra packages. + ''; }; }; }; -- cgit v1.2.3 From a4383075af86c46a812f982b270023d9e943f898 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 16 Dec 2018 16:23:08 +0200 Subject: zsh: add default keymap configuration --- modules/programs/zsh.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index f4605fc6587..f46b6f6619a 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -19,6 +19,12 @@ let zdotdir = "$HOME/" + cfg.dotDir; + bindkeyCommands = { + emacs = "bindkey -e"; + viins = "bindkey -v"; + vicmd = "bindkey -a"; + }; + historyModule = types.submodule ({ config, ... }: { options = { size = mkOption { @@ -186,6 +192,13 @@ in description = "Options related to commands history configuration."; }; + defaultKeymap = mkOption { + type = types.nullOr (types.enum [ "emacs" "viins" "vicmd" ]); + default = null; + example = "emacs"; + description = "The default base keymap to use"; + }; + sessionVariables = mkOption { default = {}; type = types.attrs; @@ -303,6 +316,9 @@ in HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" + ${if cfg.defaultKeymap != null && hasAttr cfg.defaultKeymap bindkeyCommands + then getAttr cfg.defaultKeymap bindkeyCommands else ""} + ${concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}" -- cgit v1.2.3 From 16946a6f008afa13911805418217dbd92f1fedde Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 23 Dec 2018 12:53:01 +0200 Subject: Address review comments --- modules/programs/zsh.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index f46b6f6619a..b710f95376f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -193,10 +193,10 @@ in }; defaultKeymap = mkOption { - type = types.nullOr (types.enum [ "emacs" "viins" "vicmd" ]); + type = types.nullOr (types.enum (attrNames bindkeyCommands)); default = null; example = "emacs"; - description = "The default base keymap to use"; + description = "The default base keymap to use."; }; sessionVariables = mkOption { @@ -316,8 +316,10 @@ in HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" - ${if cfg.defaultKeymap != null && hasAttr cfg.defaultKeymap bindkeyCommands - then getAttr cfg.defaultKeymap bindkeyCommands else ""} + ${optionalString (cfg.defaultKeymap != null) '' + # Use ${cfg.defaultKeymap} keymap as the default. + ${getAttr cfg.defaultKeymap bindkeyCommands} + ''} ${concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" -- cgit v1.2.3 From b3d73e0affc1f5e0899d6fce55ee39df180cd66f Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Thu, 3 Jan 2019 17:35:15 +0200 Subject: gnome-terminal: enable VTE OSC7 support for bash and zsh --- modules/programs/gnome-terminal.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index afe12849d08..fa5ce43b154 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -6,6 +6,11 @@ let cfg = config.programs.gnome-terminal; + vteInitStr = '' + # gnome-terminal: Show current directory in the terminal window title. + . ${pkgs.gnome3.vte}/etc/profile.d/vte.sh + ''; + profileColorsSubModule = types.submodule ( { ... }: { options = { @@ -165,5 +170,8 @@ in // mapAttrs' (n: v: nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v) ) cfg.profile; + + programs.bash.initExtra = mkBefore vteInitStr; + programs.zsh.initExtra = vteInitStr; }; } -- cgit v1.2.3 From e150dd4a66f0747241d4b77b997a6eed964a59d6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 9 Jan 2019 02:09:23 +0100 Subject: texlive: always require at least one extra package Fixes #526 --- modules/programs/texlive.nix | 17 ++++++++++++++--- tests/default.nix | 1 + tests/modules/programs/texlive-minimal.nix | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/modules/programs/texlive-minimal.nix diff --git a/modules/programs/texlive.nix b/modules/programs/texlive.nix index e857a062590..0f8953e9f91 100644 --- a/modules/programs/texlive.nix +++ b/modules/programs/texlive.nix @@ -6,6 +6,8 @@ let cfg = config.programs.texlive; + texlivePkgs = cfg.extraPackages pkgs.texlive; + in { @@ -16,7 +18,8 @@ in enable = mkEnableOption "Texlive"; extraPackages = mkOption { - default = self: {}; + default = tpkgs: { inherit (tpkgs) collection-basic; }; + defaultText = "tpkgs: { inherit (tpkgs) collection-basic; }"; example = literalExample '' tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; } ''; @@ -32,8 +35,16 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = texlivePkgs != {}; + message = "Must provide at least one extra package in" + + " 'programs.texlive.extraPackages'."; + } + ]; + home.packages = [ cfg.package ]; - programs.texlive.package = - pkgs.texlive.combine (cfg.extraPackages pkgs.texlive); + + programs.texlive.package = pkgs.texlive.combine texlivePkgs; }; } diff --git a/tests/default.nix b/tests/default.nix index a17bdadbbb5..1935a37c602 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -18,6 +18,7 @@ import nmt { tests = { "git/with-most-options" = ./modules/programs/git.nix; "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; + texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; }; } diff --git a/tests/modules/programs/texlive-minimal.nix b/tests/modules/programs/texlive-minimal.nix new file mode 100644 index 00000000000..df143dbc660 --- /dev/null +++ b/tests/modules/programs/texlive-minimal.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.texlive.enable = true; + + nmt.script = '' + assertFileExists home-path/bin/tex + ''; + }; +} -- cgit v1.2.3 From c48fd9d8422519d6f171e7cfc301743d28d08631 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Mon, 7 Jan 2019 08:38:41 -0800 Subject: autorandr: add support for xrandr transformation --- modules/programs/autorandr.nix | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix index 73c855f623b..05a086eb58c 100644 --- a/modules/programs/autorandr.nix +++ b/modules/programs/autorandr.nix @@ -6,6 +6,21 @@ let cfg = config.programs.autorandr; + matrixOf = n: m: elemType: mkOptionType rec { + name = "matrixOf"; + description = "${toString n}×${toString m} matrix of ${elemType.description}s"; + check = xss: + let + listOfSize = l: xs: isList xs && length xs == l; + in + listOfSize n xss && all (xs: listOfSize m xs && all elemType.check xs) xss; + merge = mergeOneOption; + getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["*" "*"]); + getSubModules = elemType.getSubModules; + substSubModules = mod: matrixOf n m (elemType.substSubModules mod); + functor = (defaultFunctor name) // { wrapped = elemType; }; + }; + profileModule = types.submodule { options = { fingerprint = mkOption { @@ -79,6 +94,26 @@ let default = null; example = "left"; }; + + transform = mkOption { + type = types.nullOr (matrixOf 3 3 types.float); + default = null; + example = literalExample '' + [ + [ 0.6 0.0 0.0 ] + [ 0.0 0.6 0.0 ] + [ 0.0 0.0 1.0 ] + ] + ''; + description = '' + Refer to + + xrandr + 1 + + for the documentation of the transform matrix. + ''; + }; }; }; @@ -150,6 +185,9 @@ let ${optionalString (config.mode != "") "mode ${config.mode}"} ${optionalString (config.rate != "") "rate ${config.rate}"} ${optionalString (config.rotate != null) "rotate ${config.rotate}"} + ${optionalString (config.transform != null) ( + "transform " + concatMapStringsSep "," toString (flatten config.transform) + )} '' else '' output ${name} off -- cgit v1.2.3 From 62eb7ebebaba32afc09b96a3c6b464352e86ee1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Thu, 13 Dec 2018 15:19:07 +0100 Subject: lib.zsh: add module Added utilities to generate export statements and definitions for zsh scripts. Currently, there is only lib.shell which generates export statements in bash syntax. However, this does not allow to generate export statements for zsh arrays (syntax: NAME=(elem1 elem2 ...) ), which would be the natural representation of lists in the nix language. --- modules/lib/default.nix | 1 + modules/lib/zsh.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 modules/lib/zsh.nix diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 8291be0b2ee..9ca0dad6b88 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -17,4 +17,5 @@ }; shell = import ./shell.nix { inherit lib; }; + zsh = import ./zsh.nix { inherit lib; }; } diff --git a/modules/lib/zsh.nix b/modules/lib/zsh.nix new file mode 100644 index 00000000000..1d3e96b54bb --- /dev/null +++ b/modules/lib/zsh.nix @@ -0,0 +1,28 @@ +{ lib }: + +rec { + # Produces a Zsh shell like value + toZshValue = v: if builtins.isBool v then + if v then "true" else "false" + else if builtins.isString v then + "\"${v}\"" + else if builtins.isList v then + "(${lib.concatStringsSep " " (map toZshValue v)})" + else "\"${toString v}\""; + + # Produces a Zsh shell like definition statement + define = n: v: "${n}=${toZshValue v}"; + + # Given an attribute set containing shell variable names and their + # assignments, this function produces a string containing a definition + # statement for each set entry. + defineAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList define vars); + + # Produces a Zsh shell like export statement + export = n: v: "export ${define n v}"; + + # Given an attribute set containing shell variable names and their + # assignments, this function produces a string containing an export + # statement for each set entry. + exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars); +} -- cgit v1.2.3 From 6b5e0efd1e183368a5c30889954a9da321f1fece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Thu, 13 Dec 2018 15:23:27 +0100 Subject: programs.zsh: generate export statements in zsh syntax Use the new module lib.zsh to generate export statements in zsh syntax, using zsh arrays for lists. Being a zsh script, this seems more intuitive for .zshrc --- modules/programs/zsh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index b710f95376f..d6e15e6220f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -11,7 +11,7 @@ let pluginsDir = if cfg.dotDir != null then relToDotDir "plugins" else ".zsh/plugins"; - envVarsStr = config.lib.shell.exportAll cfg.sessionVariables; + envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases -- cgit v1.2.3 From 9052131aef8f2654ebcf39f0949ba28e104d959b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Thu, 13 Dec 2018 15:25:09 +0100 Subject: programs.zsh: option localVariables Add option "extraLocalVars" for additional local variable definitions in .zshrc, at the top of the file. Some zsh plugins/themes expect configuration in local variables before they are loaded (example: https://github.com/bhilburn/powerlevel9k). Exporting those clutters the environment and is unnecessary. --- modules/programs/zsh.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index d6e15e6220f..1b7ccf7a6fc 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -12,6 +12,7 @@ let relToDotDir "plugins" else ".zsh/plugins"; envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables; + localVarsStr = config.lib.zsh.defineAll cfg.localVariables; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases @@ -265,6 +266,15 @@ in default = {}; description = "Options to configure oh-my-zsh."; }; + + localVariables = mkOption { + type = types.attrs; + default = {}; + example = { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=["dir" "vcs"]; }; + description = '' + Extra local variables defined at the top of .zshrc. + ''; + }; }; }; @@ -321,6 +331,8 @@ in ${getAttr cfg.defaultKeymap bindkeyCommands} ''} + ${localVarsStr} + ${concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}" -- cgit v1.2.3 From a7affc93ba4b68fb65927a5761e36667b09a4b4d Mon Sep 17 00:00:00 2001 From: David Guibert Date: Wed, 12 Dec 2018 14:28:33 +0100 Subject: msmtp: add extraConfig account option This patch allow to define custom msmtp options per email account. For example: to change the "auth" method from "on" to "login", add `msmtp.extraConfig.auth="login"`. --- modules/programs/msmtp-accounts.nix | 11 +++++++++++ modules/programs/msmtp.nix | 1 + 2 files changed, 12 insertions(+) diff --git a/modules/programs/msmtp-accounts.nix b/modules/programs/msmtp-accounts.nix index d4d4663f8ab..1730232da16 100644 --- a/modules/programs/msmtp-accounts.nix +++ b/modules/programs/msmtp-accounts.nix @@ -21,5 +21,16 @@ with lib; primary account will be used. ''; }; + + extraConfig = mkOption { + type = types.attrsOf types.str; + default = { }; + example = { auth = "login"; }; + description = '' + Extra configuration options to add to ~/.msmtprc. + See for + examples. + ''; + }; }; } diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index 7f00bbb0a13..b19c49863e3 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -31,6 +31,7 @@ let # msmtp requires the password to finish with a newline. passwordeval = ''${pkgs.bash}/bin/bash -c "${toString passwordCommand}; echo"''; } + // msmtp.extraConfig ) ++ optional primary "\naccount default : ${name}" ); -- cgit v1.2.3 From 6f422785c3402102f444092c1d871b87a1311a80 Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Mon, 17 Dec 2018 12:57:30 +0100 Subject: fish: autogenerate completions from man pages --- modules/programs/fish.nix | 74 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 61e74c45a8a..0b46c17c122 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -21,6 +21,15 @@ in programs.fish = { enable = mkEnableOption "fish friendly interactive shell"; + package = mkOption { + default = pkgs.fish; + defaultText = "pkgs.fish"; + description = '' + The fish package to install. May be used to change the version. + ''; + type = types.package; + }; + shellAliases = mkOption { default = {}; description = '' @@ -74,7 +83,70 @@ in }; config = mkIf cfg.enable { - home.packages = [ pkgs.fish ]; + home.packages = [ cfg.package ]; + + xdg.dataFile."fish/home-manager_generated_completions".source = + let + # paths later in the list will overwrite those already linked + destructiveSymlinkJoin = + args_@{ name + , paths + , preferLocalBuild ? true + , allowSubstitutes ? false + , postBuild ? "" + , ... + }: + let + args = removeAttrs args_ [ "name" "postBuild" ] + // { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults + in pkgs.runCommand name args + '' + mkdir -p $out + for i in $paths; do + if [ -z "$(find $i -prune -empty)" ]; then + cp -srf $i/* $out + fi + done + ${postBuild} + ''; + generateCompletions = package: pkgs.runCommand + "${package.name}-fish-completions" + { + src = package; + nativeBuildInputs = [ pkgs.python2 ]; + buildInputs = [ cfg.package ]; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + mkdir -p $out + if [ -d $src/share/man ]; then + find $src/share/man -type f \ + | xargs python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out \ + > /dev/null + fi + ''; + in + destructiveSymlinkJoin { + name = "${config.home.username}-fish-completions"; + paths = + let + cmp = (a: b: (a.meta.priority or 0) > (b.meta.priority or 0)); + in + map generateCompletions (sort cmp config.home.packages); + }; + + programs.fish.interactiveShellInit = '' + # add completions generated by Home Manager to $fish_complete_path + begin + set -l joined (string join " " $fish_complete_path) + set -l prev_joined (string replace --regex "[^\s]*generated_completions.*" "" $joined) + set -l post_joined (string replace $prev_joined "" $joined) + set -l prev (string split " " (string trim $prev_joined)) + set -l post (string split " " (string trim $post_joined)) + set fish_complete_path $prev "${config.xdg.dataHome}/fish/home-manager_generated_completions" $post + end + ''; xdg.configFile."fish/config.fish".text = '' # ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated automatically. -- cgit v1.2.3 From faee57185015dca770ebdab320dbdcf624e6c565 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 13 Jan 2019 23:48:20 +0100 Subject: dunst: kill daemon on configuration change Since Dunst is DBus activated it is OK to simply kill it since DBus will restart it when necessary. --- modules/services/dunst.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 0e82d43b61e..0a5daf3810b 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -155,7 +155,17 @@ in } (mkIf (cfg.settings != {}) { - xdg.configFile."dunst/dunstrc".text = toDunstIni cfg.settings; + xdg.configFile."dunst/dunstrc" = { + text = toDunstIni cfg.settings; + onChange = '' + pkillVerbose="" + if [[ -v VERBOSE ]]; then + pkillVerbose="-e" + fi + $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst + unset pkillVerbose + ''; + }; }) ] ); -- cgit v1.2.3 From 55100918ccb1fa703144005ac3b310f36c40dc5c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 14 Jan 2019 00:04:50 +0100 Subject: dunst: avoid error on missing dunst process --- modules/services/dunst.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 0a5daf3810b..96b1f71a2fa 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -162,7 +162,7 @@ in if [[ -v VERBOSE ]]; then pkillVerbose="-e" fi - $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst + $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst || true unset pkillVerbose ''; }; -- cgit v1.2.3 From d5cc53a4e1a0804b426a9882cfee809ee86fd9a5 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 5 Jan 2019 22:43:44 +0100 Subject: i3: reallow using null to disable a keybinding --- modules/services/window-managers/i3.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 19f9cbde814..e7cc49a9134 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -411,7 +411,7 @@ let }; keybindings = mkOption { - type = types.attrsOf types.str; + type = types.attrsOf (types.nullOr types.str); default = mapAttrs (n: mkOptionDefault) { "${cfg.config.modifier}+Return" = "exec i3-sensible-terminal"; "${cfg.config.modifier}+Shift+q" = "kill"; @@ -486,7 +486,7 @@ let }; keycodebindings = mkOption { - type = types.attrsOf types.str; + type = types.attrsOf (types.nullOr types.str); default = {}; description = '' An attribute set that assigns keypress to an action using key code. -- cgit v1.2.3 From bb64012914f15fbd89e0a88453e0462e348be54a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 14 Jan 2019 22:48:59 +0100 Subject: tests: bump nmt to latest --- tests/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index 1935a37c602..0fd71a8f529 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -5,8 +5,8 @@ let nmt = pkgs.fetchFromGitLab { owner = "rycee"; repo = "nmt"; - rev = "4d7b4bb34ed9df333b5aa54509e50881f3a59939"; - sha256 = "1rha4n5xafxwa5gbrjwnm63z944jr27gv71krkzzmb5wapi1r36m"; + rev = "2ed3897e22ee0e1d343ba2c33122d57d888dedfe"; + sha256 = "1k4qapinsvrf40ccpva6rfp11b90h413xrf5h57v84m88fcgac7n"; }; in -- cgit v1.2.3 From c42206db028b25e689a52c3a74c15397312effdb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 14 Jan 2019 22:50:11 +0100 Subject: i3: add test of keybinding merge logic --- tests/default.nix | 2 ++ .../services/window-managers/i3-keybindings.nix | 34 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/modules/services/window-managers/i3-keybindings.nix diff --git a/tests/default.nix b/tests/default.nix index 0fd71a8f529..f7873f4b84a 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -20,5 +20,7 @@ import nmt { "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; + } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + "i3/keybindings" = ./modules/services/window-managers/i3-keybindings.nix; }; } diff --git a/tests/modules/services/window-managers/i3-keybindings.nix b/tests/modules/services/window-managers/i3-keybindings.nix new file mode 100644 index 00000000000..b5ee4fd8765 --- /dev/null +++ b/tests/modules/services/window-managers/i3-keybindings.nix @@ -0,0 +1,34 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + xsession.windowManager.i3 = { + enable = true; + + config.keybindings = + let + modifier = config.xsession.windowManager.i3.config.modifier; + in + lib.mkOptionDefault { + "${modifier}+Left" = "overridden-command"; + "${modifier}+Right" = null; + "${modifier}+Invented" = "invented-key-command"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + + assertFileRegex home-files/.config/i3/config \ + 'bindsym Mod1+Left overridden-command' + + assertFileNotRegex home-files/.config/i3/config \ + 'Mod1+Right' + + assertFileRegex home-files/.config/i3/config \ + 'bindsym Mod1+Invented invented-key-command' + ''; + }; +} -- cgit v1.2.3 From f6ec26075d6d617b1ed7e82cabdfcb6f92ab9da7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 14 Jan 2019 23:02:33 +0100 Subject: tests: simplify test names --- tests/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index f7873f4b84a..9946b4e3e7b 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -16,11 +16,11 @@ import nmt { modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; }; testedAttrPath = [ "home" "activationPackage" ]; tests = { - "git/with-most-options" = ./modules/programs/git.nix; - "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; + git-with-most-options = ./modules/programs/git.nix; + git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { - "i3/keybindings" = ./modules/services/window-managers/i3-keybindings.nix; + i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; }; } -- cgit v1.2.3 From df8a14e12a4fbaf547303e053a03e13416ff9f7b Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 14 Jan 2019 21:22:02 +0100 Subject: i3: add bar.extraConfig option --- modules/services/window-managers/i3.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index e7cc49a9134..1a21d12af66 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -104,6 +104,12 @@ let options = { inherit (commonOptions) fonts; + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Extra configuration lines for this bar."; + }; + id = mkOption { type = types.nullOr types.string; default = null; @@ -687,7 +693,7 @@ let barStr = { id, fonts, mode, hiddenState, position, workspaceButtons, - workspaceNumbers, command, statusCommand, colors, trayOutput, ... + workspaceNumbers, command, statusCommand, colors, trayOutput, extraConfig, ... }: '' bar { ${optionalString (id != null) "id ${id}"} @@ -710,6 +716,7 @@ let urgent_workspace ${barColorSetStr colors.urgentWorkspace} binding_mode ${barColorSetStr colors.bindingMode} } + ${extraConfig} } ''; -- cgit v1.2.3 From 3cf8b9ea86640b8c4c4f1427419eef5b75ec691e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 15 Jan 2019 13:09:16 -0800 Subject: ssh: add `proxyJump` option --- modules/programs/ssh.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 874ae9af049..d888a04ec66 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -125,6 +125,12 @@ let description = "The command to use to connect to the server."; }; + proxyJump = mkOption { + type = types.nullOr types.str; + default = null; + description = "The proxy host to use to connect to the server."; + }; + certificateFile = mkOption { type = types.nullOr types.path; default = null; @@ -169,6 +175,7 @@ let ++ optional (cf.compression != null) " Compression ${yn cf.compression}" ++ optional (!cf.checkHostIP) " CheckHostIP no" ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" + ++ optional (cf.proxyJump != null) " ProxyJump ${cf.proxyJump}" ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); -- cgit v1.2.3 From 6a244b3a8d9fc283c418fe10cb8d2b49d2f21dac Mon Sep 17 00:00:00 2001 From: Adam Washington Date: Fri, 11 Jan 2019 14:53:50 +0000 Subject: matplotlib: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/matplotlib.nix | 64 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 modules/programs/matplotlib.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 4af6d6aa5ed..fe48aa1f03e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -929,6 +929,13 @@ in A new module is available: 'programs.opam'. ''; } + + { + time = "2019-01-18T00:21:56+00:00"; + message = '' + A new module is available: 'programs.matplotlib'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 45cb8d51842..1ca4cee5014 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -60,6 +60,7 @@ let (loadModule ./programs/jq.nix { }) (loadModule ./programs/lesspipe.nix { }) (loadModule ./programs/man.nix { }) + (loadModule ./programs/matplotlib.nix { }) (loadModule ./programs/mbsync.nix { }) (loadModule ./programs/mercurial.nix { }) (loadModule ./programs/msmtp.nix { }) diff --git a/modules/programs/matplotlib.nix b/modules/programs/matplotlib.nix new file mode 100644 index 00000000000..48ff6e60d68 --- /dev/null +++ b/modules/programs/matplotlib.nix @@ -0,0 +1,64 @@ +{ config, lib, ... }: + +with lib; + +let + + cfg = config.programs.matplotlib; + + formatLine = o: n: v: + let + formatValue = v: + if isBool v then (if v then "True" else "False") + else toString v; + in + if isAttrs v + then concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v) + else (if v == "" then "" else "${o}${n}: ${formatValue v}"); + +in + +{ + meta.maintainers = [ maintainers.rprospero ]; + + options.programs.matplotlib = { + enable = mkEnableOption "matplotlib, a plotting library for python"; + + config = mkOption { + default = { }; + type = types.attrs; + description = '' + Add terms to the matplotlibrc file to + control the default matplotlib behavior. + ''; + example = literalExample '' + { + backend = "Qt5Agg"; + axes = { + grid = true; + facecolor = "black"; + edgecolor = "FF9900"; + }; + grid.color = "FF9900"; + } + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Additional commands for matplotlib that will be added to the + matplotlibrc file. + ''; + }; + }; + + config = mkIf cfg.enable { + xdg.configFile."matplotlib/matplotlibrc".text = + concatStringsSep "\n" ([] + ++ mapAttrsToList (formatLine "") cfg.config + ++ optional (cfg.extraConfig != "") cfg.extraConfig + ) + "\n"; + }; +} -- cgit v1.2.3 From 46f787950ab7cd76e02a0e15af12756321f926c9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 19 Jan 2019 12:41:33 +0100 Subject: tests: bump nmt version --- tests/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index 9946b4e3e7b..4e7858a9bc2 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -5,8 +5,8 @@ let nmt = pkgs.fetchFromGitLab { owner = "rycee"; repo = "nmt"; - rev = "2ed3897e22ee0e1d343ba2c33122d57d888dedfe"; - sha256 = "1k4qapinsvrf40ccpva6rfp11b90h413xrf5h57v84m88fcgac7n"; + rev = "02a01605021df3d8d43346076bd065109b10e4f9"; + sha256 = "1b5f534xskp4qdnh0nmflqm6v1a014a883x3abscf4xd0pxb8cj7"; }; in -- cgit v1.2.3 From 7c04351a57bb36133e6cf3b609e573b9e18b8eec Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 16 Jan 2019 02:14:14 +0100 Subject: files: allow a wider range of source file names In particular support source files whose name start with `.` or contain characters not allowed in the nix store, such as spaces. Also add some test cases for `home.file`. --- modules/files.nix | 27 +++++++++++---------------- modules/lib/default.nix | 2 ++ modules/lib/file-type.nix | 24 ++---------------------- modules/lib/strings.nix | 27 +++++++++++++++++++++++++++ tests/default.nix | 4 ++++ tests/modules/files/.hidden | 1 + tests/modules/files/executable.nix | 17 +++++++++++++++++ tests/modules/files/hidden-source.nix | 16 ++++++++++++++++ tests/modules/files/source with spaces! | 1 + tests/modules/files/source-with-spaces.nix | 20 ++++++++++++++++++++ tests/modules/files/text-expected.txt | 2 ++ tests/modules/files/text.nix | 18 ++++++++++++++++++ 12 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 modules/lib/strings.nix create mode 100644 tests/modules/files/.hidden create mode 100644 tests/modules/files/executable.nix create mode 100644 tests/modules/files/hidden-source.nix create mode 100644 tests/modules/files/source with spaces! create mode 100644 tests/modules/files/source-with-spaces.nix create mode 100644 tests/modules/files/text-expected.txt create mode 100644 tests/modules/files/text.nix diff --git a/modules/files.nix b/modules/files.nix index a9b8740dbb7..1f79d5c1575 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -14,6 +14,15 @@ let inherit homeDirectory lib pkgs; }).fileType; + sourceStorePath = file: + let + sourcePath = toString file.source; + sourceName = config.lib.strings.storeFileName (baseNameOf sourcePath); + in + if builtins.hasContext sourcePath + then file.source + else builtins.path { path = file.source; name = sourceName; }; + # A symbolic link whose target path matches this pattern will be # considered part of a Home Manager generation. homeFilePattern = "${builtins.storeDir}/*-home-manager-files/*"; @@ -36,20 +45,6 @@ in }; config = { - assertions = [ - (let - badFiles = - filter (f: hasPrefix "." (baseNameOf f)) - (map (v: toString v.source) - (attrValues cfg)); - badFilesStr = toString badFiles; - in - { - assertion = badFiles == []; - message = "Source file names must not start with '.': ${badFilesStr}"; - }) - ]; - # This verifies that the links we are about to create will not # overwrite an existing file. home.activation.checkLinkTargets = dag.entryBefore ["writeBoundary"] ( @@ -201,7 +196,7 @@ in '' declare -A changedFiles '' + concatMapStrings (v: '' - cmp --quiet "${v.source}" "${config.home.homeDirectory}/${v.target}" \ + cmp --quiet "${sourceStorePath v}" "${homeDirectory}/${v.target}" \ && changedFiles["${v.target}"]=0 \ || changedFiles["${v.target}"]=1 '') (filter (v: v.onChange != "") (attrValues cfg)) @@ -277,7 +272,7 @@ in } '' + concatStrings ( mapAttrsToList (n: v: '' - insertFile "${v.source}" \ + insertFile "${sourceStorePath v}" \ "${v.target}" \ "${if v.executable == null then "inherit" diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 9ca0dad6b88..754713cab5d 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -16,6 +16,8 @@ entryBefore = d.dagEntryBefore; }; + strings = import ./strings.nix { inherit lib; }; + shell = import ./shell.nix { inherit lib; }; zsh = import ./zsh.nix { inherit lib; }; } diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index 0c435aaa908..efbb33b231d 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -4,27 +4,7 @@ with lib; let - # Figures out a valid Nix store name for the given path. - storeFileName = path: - let - # All characters that are considered safe. Note "-" is not - # included to avoid "-" followed by digit being interpreted as a - # version. - safeChars = - [ "+" "." "_" "?" "=" ] - ++ lowerChars - ++ upperChars - ++ stringToCharacters "0123456789"; - - empties = l: genList (x: "") (length l); - - unsafeInName = stringToCharacters ( - replaceStrings safeChars (empties safeChars) path - ); - - safeName = replaceStrings unsafeInName (empties unsafeInName) path; - in - "home_file_" + safeName; + stringsExtra = import ./strings.nix { inherit lib; }; in @@ -113,7 +93,7 @@ in source = mkIf (config.text != null) ( mkDefault (pkgs.writeTextFile { inherit (config) executable text; - name = storeFileName name; + name = stringsExtra.storeFileName name; }) ); }; diff --git a/modules/lib/strings.nix b/modules/lib/strings.nix new file mode 100644 index 00000000000..13d6bb03be6 --- /dev/null +++ b/modules/lib/strings.nix @@ -0,0 +1,27 @@ +{ lib }: + +with lib; + +{ + # Figures out a valid Nix store name for the given path. + storeFileName = path: + let + # All characters that are considered safe. Note "-" is not + # included to avoid "-" followed by digit being interpreted as a + # version. + safeChars = + [ "+" "." "_" "?" "=" ] + ++ lowerChars + ++ upperChars + ++ stringToCharacters "0123456789"; + + empties = l: genList (x: "") (length l); + + unsafeInName = stringToCharacters ( + replaceStrings safeChars (empties safeChars) path + ); + + safeName = replaceStrings unsafeInName (empties unsafeInName) path; + in + "hm_" + safeName; +} diff --git a/tests/default.nix b/tests/default.nix index 4e7858a9bc2..1da2abf1727 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -16,6 +16,10 @@ import nmt { modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; }; testedAttrPath = [ "home" "activationPackage" ]; tests = { + files-executable = ./modules/files/executable.nix; + files-hidden-source = ./modules/files/hidden-source.nix; + files-source-with-spaces = ./modules/files/source-with-spaces.nix; + files-text = ./modules/files/text.nix; git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; diff --git a/tests/modules/files/.hidden b/tests/modules/files/.hidden new file mode 100644 index 00000000000..ca05448e7a0 --- /dev/null +++ b/tests/modules/files/.hidden @@ -0,0 +1 @@ +The name of this file has a dot prefix. diff --git a/tests/modules/files/executable.nix b/tests/modules/files/executable.nix new file mode 100644 index 00000000000..b286c2b499f --- /dev/null +++ b/tests/modules/files/executable.nix @@ -0,0 +1,17 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.file."executable" = { + text = ""; + executable = true; + }; + + nmt.script = '' + assertFileExists home-files/executable + assertFileIsExecutable home-files/executable; + ''; + }; +} diff --git a/tests/modules/files/hidden-source.nix b/tests/modules/files/hidden-source.nix new file mode 100644 index 00000000000..a8635398f48 --- /dev/null +++ b/tests/modules/files/hidden-source.nix @@ -0,0 +1,16 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.file.".hidden".source = ./.hidden; + + nmt.script = '' + assertFileExists home-files/.hidden; + assertFileContent home-files/.hidden ${ + builtins.path { path = ./.hidden; name = "expected"; } + } + ''; + }; +} diff --git a/tests/modules/files/source with spaces! b/tests/modules/files/source with spaces! new file mode 100644 index 00000000000..e1ace404174 --- /dev/null +++ b/tests/modules/files/source with spaces! @@ -0,0 +1 @@ +Source with spaces! diff --git a/tests/modules/files/source-with-spaces.nix b/tests/modules/files/source-with-spaces.nix new file mode 100644 index 00000000000..1d593c64256 --- /dev/null +++ b/tests/modules/files/source-with-spaces.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.file."source with spaces!".source = ./. + "/source with spaces!"; + + nmt.script = '' + assertFileExists 'home-files/source with spaces!'; + assertFileContent 'home-files/source with spaces!' \ + ${ + builtins.path { + path = ./. + "/source with spaces!"; + name = "source-with-spaces-expected"; + } + } + ''; + }; +} diff --git a/tests/modules/files/text-expected.txt b/tests/modules/files/text-expected.txt new file mode 100644 index 00000000000..b3a0ff2db12 --- /dev/null +++ b/tests/modules/files/text-expected.txt @@ -0,0 +1,2 @@ +This is the +expected text. diff --git a/tests/modules/files/text.nix b/tests/modules/files/text.nix new file mode 100644 index 00000000000..6fc9a26fcb4 --- /dev/null +++ b/tests/modules/files/text.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.file."using-text".text = '' + This is the + expected text. + ''; + + nmt.script = '' + assertFileExists home-files/using-text + assertFileIsNotExecutable home-files/using-text + assertFileContent home-files/using-text ${./text-expected.txt} + ''; + }; +} -- cgit v1.2.3 From 59a4ac71f94339b01c7bdb66542d1cc3b46a841c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 15 Jan 2019 19:46:00 +0100 Subject: i3: replace use of types.string by types.str --- modules/services/window-managers/i3.nix | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 1a21d12af66..059c7a8a932 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -8,7 +8,7 @@ let commonOptions = { fonts = mkOption { - type = types.listOf types.string; + type = types.listOf types.str; default = ["monospace 8"]; description = '' Font list used for window titles. Only FreeType fonts are supported. @@ -21,7 +21,7 @@ let startupModule = types.submodule { options = { command = mkOption { - type = types.string; + type = types.str; description = "Command that will be executed on startup."; }; @@ -41,7 +41,7 @@ let }; workspace = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; description = '' Launch application on a particular workspace. DEPRECATED: @@ -55,17 +55,17 @@ let barColorSetModule = types.submodule { options = { border = mkOption { - type = types.string; + type = types.str; visible = false; }; background = mkOption { - type = types.string; + type = types.str; visible = false; }; text = mkOption { - type = types.string; + type = types.str; visible = false; }; }; @@ -74,27 +74,27 @@ let colorSetModule = types.submodule { options = { border = mkOption { - type = types.string; + type = types.str; visible = false; }; childBorder = mkOption { - type = types.string; + type = types.str; visible = false; }; background = mkOption { - type = types.string; + type = types.str; visible = false; }; text = mkOption { - type = types.string; + type = types.str; visible = false; }; indicator = mkOption { - type = types.string; + type = types.str; visible = false; }; }; @@ -111,7 +111,7 @@ let }; id = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; description = '' Specifies the bar ID for the configured bar instance. @@ -151,7 +151,7 @@ let }; command = mkOption { - type = types.string; + type = types.str; default = "${cfg.package}/bin/i3bar"; defaultText = "i3bar"; description = "Command that will be used to start a bar."; @@ -159,7 +159,7 @@ let }; statusCommand = mkOption { - type = types.string; + type = types.str; default = "${pkgs.i3status}/bin/i3status"; description = "Command that will be used to get status lines."; }; @@ -168,19 +168,19 @@ let type = types.submodule { options = { background = mkOption { - type = types.string; + type = types.str; default = "#000000"; description = "Background color of the bar."; }; statusline = mkOption { - type = types.string; + type = types.str; default = "#ffffff"; description = "Text color to be used for the statusline."; }; separator = mkOption { - type = types.string; + type = types.str; default = "#666666"; description = "Text color to be used for the separator."; }; @@ -238,7 +238,7 @@ let }; trayOutput = mkOption { - type = types.string; + type = types.str; default = "primary"; description = "Where to output tray."; }; @@ -248,7 +248,7 @@ let windowCommandModule = types.submodule { options = { command = mkOption { - type = types.string; + type = types.str; description = "i3wm command to execute."; example = "border pixel 1"; }; @@ -505,7 +505,7 @@ let type = types.submodule { options = { background = mkOption { - type = types.string; + type = types.str; default = "#ffffff"; description = '' Background color of the window. Only applications which do not cover -- cgit v1.2.3 From e15cd64ac95863962d03e37903ff7a49e8ddac7b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 19 Jan 2019 22:12:55 +0100 Subject: Update LICENSE file for 2019 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index cce91e4e0ed..a7566dbf194 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2018 Robert Helgesson +Copyright (c) 2017-2019 Robert Helgesson and Home Manager contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal -- cgit v1.2.3 From c03504699969127715dfc666f6aa00da74a94203 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 20 Jan 2019 17:38:34 +0100 Subject: doc: add basic release notes --- doc/default.nix | 1 + doc/manual.xml | 1 + doc/release-notes/release-notes.xml | 13 +++++++ doc/release-notes/rl-1809.xml | 11 ++++++ doc/release-notes/rl-1903.xml | 67 +++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 doc/release-notes/release-notes.xml create mode 100644 doc/release-notes/rl-1809.xml create mode 100644 doc/release-notes/rl-1903.xml diff --git a/doc/default.nix b/doc/default.nix index f55163d8aa3..e65e904df8e 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -119,6 +119,7 @@ let + ''; diff --git a/doc/manual.xml b/doc/manual.xml index f0431092b2a..4eef9892364 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -29,4 +29,5 @@ Configuration Options + diff --git a/doc/release-notes/release-notes.xml b/doc/release-notes/release-notes.xml new file mode 100644 index 00000000000..bb63ce6c85b --- /dev/null +++ b/doc/release-notes/release-notes.xml @@ -0,0 +1,13 @@ + + Release Notes + + This section lists the release notes for stable versions of Home Manager and + the current unstable version. + + + + diff --git a/doc/release-notes/rl-1809.xml b/doc/release-notes/rl-1809.xml new file mode 100644 index 00000000000..e19a4776a46 --- /dev/null +++ b/doc/release-notes/rl-1809.xml @@ -0,0 +1,11 @@ +
+ Release 18.09 + + + The 18.09 release branch became the stable branch in September, 2018. + +
diff --git a/doc/release-notes/rl-1903.xml b/doc/release-notes/rl-1903.xml new file mode 100644 index 00000000000..d260dbc2b09 --- /dev/null +++ b/doc/release-notes/rl-1903.xml @@ -0,0 +1,67 @@ +
+ Release 19.03 (unstable) + + + This is the current unstable branch and the information in this section is + therefore not final. + + + + Scheduled released is March, 2019. + + +
+ Highlights + + + This release has the following notable changes: + + + + + + The now allows source + files to be hidden, that is, having a name starting with the + . character. It also allows the source file name to + contain characters not typically allowed for Nix store paths. For example, + your configuration can now contain things such as + +home.file."my file".source = ./. + "/file with spaces!"; + + + + +
+ +
+ State Version Changes + + + The state version in this release includes the changes below. These changes + are only active if the option is set to + "19.03" or later. + + + + + + There is now an option that + defaults to false. Before the module would be active if + the option was non-empty. + + + +
+
-- cgit v1.2.3 From f3f7c5cc57bb6b0e357fa076ea0a2416122687c8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 20 Jan 2019 18:01:22 +0100 Subject: doc: reformat XML files --- doc/installation.xml | 4 ++-- doc/man-configuration.xml | 11 ++++----- doc/man-home-manager.xml | 57 ++++++++++++++++++++++++++++++----------------- doc/man-pages.xml | 6 ++--- doc/manual.xml | 7 +++--- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/doc/installation.xml b/doc/installation.xml index ea3c49fa40b..ab24e8a472c 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -86,8 +86,8 @@ $ nix-channel --update if you follow a Nixpkgs version 18.09 channel. - 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 + 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 export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH diff --git a/doc/man-configuration.xml b/doc/man-configuration.xml index c36cf619d33..835ba3213da 100644 --- a/doc/man-configuration.xml +++ b/doc/man-configuration.xml @@ -7,22 +7,19 @@ Home Manager - home-configuration.nix Home Manager configuration specification - Description - The file ~/.config/nixpkgs/home.nix contains - the declarative specification of your Home Manager configuration. - The command home-manager takes this file and - realises the user environment configuration specified therein. + The file ~/.config/nixpkgs/home.nix contains the + declarative specification of your Home Manager configuration. The command + home-manager takes this file and realises the user + environment configuration specified therein. - Options diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index 79ae5b45713..093c3ae1a0c 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -7,54 +7,71 @@ Home Manager - home-manager reconfigure a user environment - - home-manager - - - - - - - - + home-manager + + + + + + + + + + + + + + + + + + + + + + + + + + + - Description - This command updates the user environment so that it corresponds to the configuration - specified in ~/.config/nixpkgs/home.nix. + This command updates the user environment so that it corresponds to the + configuration specified in ~/.config/nixpkgs/home.nix. - Files - ~/.local/share/home-manager/news-read-ids + + ~/.local/share/home-manager/news-read-ids + - Identifiers of news items that have been shown. Can be deleted - to reset the read news indicator. + Identifiers of news items that have been shown. Can be deleted to reset + the read news indicator. - Bugs - Please report any bugs on the project issue tracker. diff --git a/doc/man-pages.xml b/doc/man-pages.xml index b94b01413b2..5c2d73c9b2b 100644 --- a/doc/man-pages.xml +++ b/doc/man-pages.xml @@ -3,12 +3,10 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> Home Manager Reference Pages - - Home Manager contributors + Home Manager contributors Author - - 2017-2018Home Manager contributors + 2017-2018Home Manager contributors diff --git a/doc/manual.xml b/doc/manual.xml index 4eef9892364..c4493254b7c 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -9,12 +9,13 @@ Preface - This manual will eventually describes how to install, use, and - extend Home Manager. + This manual will eventually describes how to install, use, and extend Home + Manager. If you encounter problems or bugs then please report them on the - Home Manager issue tracker. + Home Manager + issue tracker. -- cgit v1.2.3 From 4aa07c3547773b798e15666d8599d5650aaf110b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 20 Jan 2019 18:03:04 +0100 Subject: doc: bump copyright year to 2019 in man pages --- doc/man-pages.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man-pages.xml b/doc/man-pages.xml index 5c2d73c9b2b..d9bb7df2890 100644 --- a/doc/man-pages.xml +++ b/doc/man-pages.xml @@ -6,7 +6,7 @@ Home Manager contributors Author - 2017-2018Home Manager contributors + 2017–2019Home Manager contributors -- cgit v1.2.3 From 601619660de5a86ae6eb95936b7bffc03227dbc2 Mon Sep 17 00:00:00 2001 From: Jonas Holst Damtoft Date: Wed, 23 Jan 2019 21:19:23 +0100 Subject: fish: use global for abbr Makes fish use global scope for abbreviations. This makes it so that they don't stick across config changes. Before, an abbreviation would still exist even if removed from the config. --- modules/programs/fish.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 0b46c17c122..2328f9b94a6 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -7,7 +7,7 @@ let cfg = config.programs.fish; abbrsStr = concatStringsSep "\n" ( - mapAttrsToList (k: v: "abbr --add ${k} '${v}'") cfg.shellAbbrs + mapAttrsToList (k: v: "abbr --add --global ${k} '${v}'") cfg.shellAbbrs ); aliasesStr = concatStringsSep "\n" ( -- cgit v1.2.3 From 008d93928f2d53cbf70f9735efb2c08893420d2c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 26 Jan 2019 14:18:07 +0100 Subject: xembed-sni-proxy: add module --- modules/misc/news.nix | 8 ++++++ modules/modules.nix | 1 + modules/services/xembed-sni-proxy.nix | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 modules/services/xembed-sni-proxy.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index fe48aa1f03e..203f524995b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -936,6 +936,14 @@ in A new module is available: 'programs.matplotlib'. ''; } + + { + time = "2019-01-26T13:20:37+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.xembed-sni-proxy'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1ca4cee5014..1a4f3bb5e76 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -114,6 +114,7 @@ let (loadModule ./services/window-managers/awesome.nix { }) (loadModule ./services/window-managers/i3.nix { }) (loadModule ./services/window-managers/xmonad.nix { }) + (loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xscreensaver.nix { }) (loadModule ./systemd.nix { }) (loadModule ./xcursor.nix { }) diff --git a/modules/services/xembed-sni-proxy.nix b/modules/services/xembed-sni-proxy.nix new file mode 100644 index 00000000000..0854365da13 --- /dev/null +++ b/modules/services/xembed-sni-proxy.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.xembed-sni-proxy; + +in + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + services.xembed-sni-proxy = { + enable = mkEnableOption "XEmbed SNI Proxy"; + + package = mkOption { + type = types.package; + default = pkgs.plasma-workspace; + defaultText = "pkgs.plasma-workspace"; + description = '' + Package containing the xembedsniproxy + program. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.xembed-sni-proxy = { + Unit = { + Description = "XEmbed SNI Proxy"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${cfg.package}/bin/xembedsniproxy"; + Restart = "on-abort"; + }; + }; + }; +} -- cgit v1.2.3 From 604fc929432597147ff8e8a1586d995c74e4e8aa Mon Sep 17 00:00:00 2001 From: wedens Date: Mon, 31 Dec 2018 19:01:48 +0700 Subject: polybar: add /run/wrappers/bin to PATH Without this the network module in polybar is unable to check connection as it invokes 'ping' command directly. --- modules/services/polybar.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 82ae27b1661..547c7b90ff7 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -129,7 +129,7 @@ in Service = { Type = "forking"; - Environment = "PATH=${cfg.package}/bin"; + Environment = "PATH=${cfg.package}/bin:/run/wrappers/bin"; ExecStart = ''${pkgs.writeScriptBin "polybar-start" script}/bin/polybar-start''; }; -- cgit v1.2.3 From a68c8cf5f1567faf02631c6d815daad2166bf26b Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 21 Jan 2019 17:14:22 +0900 Subject: git: generate identities from mail accounts --- modules/programs/git.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index e8018dc185e..9b7858bfa3c 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -63,7 +63,10 @@ in type = types.package; default = pkgs.git; defaultText = "pkgs.git"; - description = "Git package to install."; + description = '' + Git package to install. Use pkgs.gitAndTools.gitFull + to gain access to git send-email for instance. + ''; }; userName = mkOption { @@ -142,6 +145,26 @@ in }; } + { + programs.git.iniContent = + let + hasSmtp = name: account: account.smtp != null; + + genIdentity = name: account: with account; + nameValuePair "sendemail.${name}" ({ + smtpEncryption = if smtp.tls.enable then "tls" else ""; + smtpServer = smtp.host; + smtpUser = userName; + from = address; + } + // optionalAttrs (smtp.port != null) { + smtpServerPort = smtp.port; + }); + in + mapAttrs' genIdentity + (filterAttrs hasSmtp config.accounts.email.accounts); + } + (mkIf (cfg.signing != null) { programs.git.iniContent = { user.signingKey = cfg.signing.key; -- cgit v1.2.3 From 98f534e172750efb8c0f80f7fc80eabea34cb9bc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 28 Jan 2019 23:50:36 +0100 Subject: flameshot: add bars to systemd After Fixes #544 --- modules/services/flameshot.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix index d4cf90d59db..aaeecdb0c95 100644 --- a/modules/services/flameshot.nix +++ b/modules/services/flameshot.nix @@ -24,7 +24,12 @@ in systemd.user.services.flameshot = { Unit = { Description = "Powerful yet simple to use screenshot software"; - After = [ "graphical-session-pre.target" ]; + After = [ + "graphical-session-pre.target" + "polybar.service" + "stalonetray.service" + "taffybar.service" + ]; PartOf = [ "graphical-session.target" ]; }; -- cgit v1.2.3 From 02a5a678f6f2057423c6121ea62ac2f9666070da Mon Sep 17 00:00:00 2001 From: Amarandus Date: Thu, 24 Jan 2019 13:00:11 +0100 Subject: irssi: add module irssi is a cli IRC client. --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/irssi.nix | 211 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 modules/programs/irssi.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 203f524995b..a6f81570d3b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -944,6 +944,13 @@ in A new module is available: 'services.xembed-sni-proxy'. ''; } + + { + time = "2019-01-28T23:36:10+00:00"; + message = '' + A new module is available: 'programs.irssi'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1a4f3bb5e76..4e3e6fe3719 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -57,6 +57,7 @@ let (loadModule ./programs/home-manager.nix { }) (loadModule ./programs/htop.nix { }) (loadModule ./programs/info.nix { }) + (loadModule ./programs/irssi.nix { }) (loadModule ./programs/jq.nix { }) (loadModule ./programs/lesspipe.nix { }) (loadModule ./programs/man.nix { }) diff --git a/modules/programs/irssi.nix b/modules/programs/irssi.nix new file mode 100644 index 00000000000..ad9a642ebee --- /dev/null +++ b/modules/programs/irssi.nix @@ -0,0 +1,211 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.irssi; + + boolStr = b: if b then "yes" else "no"; + quoteStr = s: escape ["\""] s; + + assignFormat = set: + concatStringsSep "\n" + (mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set); + + chatnetString = + concatStringsSep "\n" + (flip mapAttrsToList cfg.networks + (k: v: '' + ${k} = { + type = "${v.type}"; + nick = "${quoteStr v.nick}"; + autosendcmd = "${concatMapStringsSep ";" quoteStr v.autoCommands}"; + }; + '')); + + serversString = + concatStringsSep ",\n" + (flip mapAttrsToList cfg.networks + (k: v: '' + { + chatnet = "${k}"; + address = "${v.server.address}"; + port = "${toString v.server.port}"; + use_ssl = "${boolStr v.server.ssl.enable}"; + ssl_verify = "${boolStr v.server.ssl.verify}"; + autoconnect = "${boolStr v.server.autoConnect}"; + } + '')); + + channelString = + concatStringsSep ",\n" + (flip mapAttrsToList cfg.networks + (k: v: + concatStringsSep ",\n" + (flip mapAttrsToList v.channels + (c: cv: '' + { + chatnet = "${k}"; + name = "${c}"; + autojoin = "${boolStr cv.autoJoin}"; + } + '')))); + + channelType = types.submodule { + options = { + name = mkOption { + type = types.nullOr types.str; + visible = false; + default = null; + description = "Name of the channel."; + }; + + autoJoin = mkOption { + type = types.bool; + default = false; + description = "Whether to join this channel on connect."; + }; + }; + }; + + networkType = types.submodule ({ name, ...}: { + options = { + name = mkOption { + visible = false; + default = name; + type = types.str; + }; + + nick = mkOption { + type = types.str; + description = "Nickname in that network."; + }; + + type = mkOption { + type = types.str; + description = "Type of the network."; + default = "IRC"; + }; + + autoCommands = mkOption { + type = types.listOf types.str; + default = []; + description = "List of commands to execute on connect."; + }; + + server = { + address = mkOption { + type = types.str; + description = "Address of the chat server."; + }; + + port = mkOption { + type = types.int; + default = 6667; + description = "Port of the chat server."; + }; + + ssl = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether SSL should be used."; + }; + + verify = mkOption { + type = types.bool; + default = true; + description = "Whether the SSL certificate should be verified."; + }; + }; + + autoConnect = mkOption { + type = types.bool; + default = false; + description = "Whether Irssi connects to the server on launch."; + }; + }; + + channels = mkOption { + description = "Channels for the given network."; + type = types.attrsOf channelType; + default = {}; + }; + }; + }); + +in + +{ + + options = { + programs.irssi = { + enable = mkEnableOption "the Irssi chat client"; + + extraConfig = mkOption { + default = ""; + description = "These lines are appended to the Irssi configuration."; + type = types.str; + }; + + aliases = mkOption { + default = {}; + example = { J = "join"; BYE = "quit";}; + description = "An attribute set that maps aliases to commands."; + type = types.attrsOf types.str; + }; + + networks = mkOption { + default = {}; + example = literalExample '' + { + freenode = { + nick = "hmuser"; + server = { + address = "chat.freenode.net"; + port = 6697; + autoConnect = true; + }; + channels = { + nixos.autoJoin = true; + }; + }; + } + ''; + description = "An attribute set of chat networks."; + type = types.attrsOf networkType; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.irssi ]; + + home.file.".irssi/config".text = '' + settings = { + core = { + settings_autosave = "no"; + }; + }; + + aliases = { + ${assignFormat cfg.aliases} + }; + + chatnets = { + ${chatnetString} + }; + + servers = ( + ${serversString} + ); + + channels = ( + ${channelString} + ); + + ${cfg.extraConfig} + ''; + }; +} -- cgit v1.2.3 From 45cadbd4f304a3dcb7b3fcd47032a39fac715f6f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 29 Jan 2019 18:17:24 +0100 Subject: git: quote sendemail section header This will allow, e.g., the character `@` in the email identity. Also adds a test case. Fixes #557 --- modules/programs/git.nix | 2 +- tests/default.nix | 1 + tests/modules/accounts/email-test-accounts.nix | 27 ++++++++++++++++++ .../modules/programs/git-with-email-expected.conf | 15 ++++++++++ tests/modules/programs/git-with-email.nix | 33 ++++++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/modules/accounts/email-test-accounts.nix create mode 100644 tests/modules/programs/git-with-email-expected.conf create mode 100644 tests/modules/programs/git-with-email.nix diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 9b7858bfa3c..4c962e99c54 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -151,7 +151,7 @@ in hasSmtp = name: account: account.smtp != null; genIdentity = name: account: with account; - nameValuePair "sendemail.${name}" ({ + nameValuePair "sendemail \"${name}\"" ({ smtpEncryption = if smtp.tls.enable then "tls" else ""; smtpServer = smtp.host; smtpUser = userName; diff --git a/tests/default.nix b/tests/default.nix index 1da2abf1727..279fc631833 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -20,6 +20,7 @@ import nmt { files-hidden-source = ./modules/files/hidden-source.nix; files-source-with-spaces = ./modules/files/source-with-spaces.nix; files-text = ./modules/files/text.nix; + git-with-email = ./modules/programs/git-with-email.nix; git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; diff --git a/tests/modules/accounts/email-test-accounts.nix b/tests/modules/accounts/email-test-accounts.nix new file mode 100644 index 00000000000..9c9c90cf8fe --- /dev/null +++ b/tests/modules/accounts/email-test-accounts.nix @@ -0,0 +1,27 @@ +{ ... }: + +{ + accounts.email = { + maildirBasePath = "Mail"; + + accounts = { + "hm@example.com" = { + address = "hm@example.com"; + userName = "home.manager"; + realName = "H. M. Test"; + passwordCommand = "password-command"; + imap.host = "imap.example.com"; + smtp.host = "smtp.example.com"; + }; + + hm-account = { + address = "hm@example.org"; + userName = "home.manager.jr"; + realName = "H. M. Test Jr."; + passwordCommand = "password-command 2"; + imap.host = "imap.example.org"; + smtp.host = "smtp.example.org"; + }; + }; + }; +} diff --git a/tests/modules/programs/git-with-email-expected.conf b/tests/modules/programs/git-with-email-expected.conf new file mode 100644 index 00000000000..01c1eec5823 --- /dev/null +++ b/tests/modules/programs/git-with-email-expected.conf @@ -0,0 +1,15 @@ +[sendemail "hm-account"] +from=hm@example.org +smtpEncryption=tls +smtpServer=smtp.example.org +smtpUser=home.manager.jr + +[sendemail "hm@example.com"] +from=hm@example.com +smtpEncryption=tls +smtpServer=smtp.example.com +smtpUser=home.manager + +[user] +email=hm@example.com +name=H. M. Test diff --git a/tests/modules/programs/git-with-email.nix b/tests/modules/programs/git-with-email.nix new file mode 100644 index 00000000000..f8a762dcceb --- /dev/null +++ b/tests/modules/programs/git-with-email.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../accounts/email-test-accounts.nix ]; + + config = { + programs.git = { + enable = true; + userEmail = "hm@example.com"; + userName = "H. M. Test"; + }; + + nmt.script = '' + function assertGitConfig() { + local value + value=$(${pkgs.git}/bin/git config \ + --file $TESTED/home-files/.config/git/config \ + --get $1) + if [[ $value != $2 ]]; then + fail "Expected option '$1' to have value '$2' but it was '$value'" + fi + } + + assertFileExists home-files/.config/git/config + assertFileContent home-files/.config/git/config ${./git-with-email-expected.conf} + + assertGitConfig "sendemail.hm@example.com.from" "hm@example.com" + assertGitConfig "sendemail.hm-account.from" "hm@example.org" + ''; + }; +} -- cgit v1.2.3 From 2410bc603bd13746bc0c0591d1e70ced55bd0f85 Mon Sep 17 00:00:00 2001 From: Yurii Rashkovskii Date: Mon, 28 Jan 2019 13:09:28 +0700 Subject: nixpkgs: fix installation on non-x86 On non-x86 architectures (for example, aarch64) the installation of home-manager fails indicating that it is attempting to select i686 packages for Linux and those aren't available. Solution: make the condition for choosing these packages stricter --- modules/misc/nixpkgs.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index 287a74b201e..150cbe74093 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -144,7 +144,10 @@ in config = { _module.args = { pkgs = _pkgs; - pkgs_i686 = if _pkgs.stdenv.isLinux then _pkgs.pkgsi686Linux else {}; + pkgs_i686 = + if _pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86 + then _pkgs.pkgsi686Linux + else { }; }; }; } -- cgit v1.2.3 From 81ec856a0fc4fa9ebc007b6c92ed6eb024269467 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 15 Jan 2019 21:39:33 +0100 Subject: mbsync: add some required assertions --- modules/programs/mbsync.nix | 52 ++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 060bec83f55..bb81992ddeb 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -34,24 +34,24 @@ let let escapeValue = escape [ "\"" ]; hasSpace = v: builtins.match ".* .*" v != null; - genValue = v: + genValue = n: v: if isList v - then concatMapStringsSep " " genValue v + then concatMapStringsSep " " (genValue n) v else if isBool v then (if v then "yes" else "no") else if isInt v then toString v - else if hasSpace v then "\"${escapeValue v}\"" - else v; + else if isString v && hasSpace v then "\"${escapeValue v}\"" + else if isString v then v + else + let prettyV = lib.generators.toPretty {} v; + in throw "mbsync: unexpected value for option ${n}: '${prettyV}'"; in '' ${header} ${concatStringsSep "\n" - (mapAttrsToList (n: v: "${n} ${genValue v}") entries)} + (mapAttrsToList (n: v: "${n} ${genValue n v}") entries)} ''; genAccountConfig = account: with account; - if (imap == null || maildir == null) - then "" - else genSection "IMAPAccount ${name}" ( { Host = imap.host; @@ -144,29 +144,23 @@ in }; config = mkIf cfg.enable { - assertions = [ - ( - let - badAccounts = filter (a: a.maildir == null) mbsyncAccounts; - in - { - assertion = badAccounts == []; - message = "mbsync: Missing maildir configuration for accounts: " - + concatMapStringsSep ", " (a: a.name) badAccounts; - } - ) - - ( - let - badAccounts = filter (a: a.imap == null) mbsyncAccounts; - in - { + assertions = + let + checkAccounts = pred: msg: + let + badAccounts = filter pred mbsyncAccounts; + in { assertion = badAccounts == []; - message = "mbsync: Missing IMAP configuration for accounts: " + message = "mbsync: ${msg} for accounts: " + concatMapStringsSep ", " (a: a.name) badAccounts; - } - ) - ]; + }; + in + [ + (checkAccounts (a: a.maildir == null) "Missing maildir configuration") + (checkAccounts (a: a.imap == null) "Missing IMAP configuration") + (checkAccounts (a: a.passwordCommand == null) "Missing passwordCommand") + (checkAccounts (a: a.userName == null) "Missing username") + ]; home.packages = [ cfg.package ]; -- cgit v1.2.3 From 0590c2a4f64871d00487639220d04955194bc172 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 31 Jan 2019 02:08:40 +0100 Subject: mbsync: add basic test of result configuration --- modules/programs/mbsync.nix | 2 +- tests/default.nix | 1 + tests/modules/programs/mbsync-expected.conf | 55 +++++++++++++++++++++++++++++ tests/modules/programs/mbsync.nix | 35 ++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/mbsync-expected.conf create mode 100644 tests/modules/programs/mbsync.nix diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index bb81992ddeb..209db0dc04f 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -176,7 +176,7 @@ in ++ accountsConfig ++ groupsConfig ++ optional (cfg.extraConfig != "") cfg.extraConfig - ); + ) + "\n"; home.activation.createMaildir = dag.entryBetween [ "linkGeneration" ] [ "writeBoundary" ] '' diff --git a/tests/default.nix b/tests/default.nix index 279fc631833..5002ae2caa7 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -23,6 +23,7 @@ import nmt { git-with-email = ./modules/programs/git-with-email.nix; git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; + mbsync = ./modules/programs/mbsync.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { diff --git a/tests/modules/programs/mbsync-expected.conf b/tests/modules/programs/mbsync-expected.conf new file mode 100644 index 00000000000..f1ca79fe738 --- /dev/null +++ b/tests/modules/programs/mbsync-expected.conf @@ -0,0 +1,55 @@ +# Generated by Home Manager. + +IMAPAccount hm-account +CertificateFile /etc/ssl/certs/ca-certificates.crt +Host imap.example.org +PassCmd "password-command 2" +SSLType IMAPS +User home.manager.jr + +IMAPStore hm-account-remote +Account hm-account + +MaildirStore hm-account-local +Inbox /home/hm-user/Mail/hm-account/Inbox +Path /home/hm-user/Mail/hm-account/ +SubFolders Verbatim + +Channel hm-account +Create None +Expunge None +Master :hm-account-remote: +Patterns * +Remove None +Slave :hm-account-local: +SyncState * + + +IMAPAccount hm@example.com +CertificateFile /etc/ssl/certs/ca-certificates.crt +Host imap.example.com +PassCmd password-command +SSLType IMAPS +User home.manager + +IMAPStore hm@example.com-remote +Account hm@example.com + +MaildirStore hm@example.com-local +Inbox /home/hm-user/Mail/hm@example.com/Inbox +Path /home/hm-user/Mail/hm@example.com/ +SubFolders Verbatim + +Channel hm@example.com +Create None +Expunge None +Master :hm@example.com-remote: +Patterns * +Remove None +Slave :hm@example.com-local: +SyncState * + + +Group inboxes +Channel hm-account:Inbox +Channel hm@example.com:Inbox1,Inbox2 diff --git a/tests/modules/programs/mbsync.nix b/tests/modules/programs/mbsync.nix new file mode 100644 index 00000000000..fa9768a2fe1 --- /dev/null +++ b/tests/modules/programs/mbsync.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../accounts/email-test-accounts.nix ]; + + config = { + home.username = "hm-user"; + home.homeDirectory = "/home/hm-user"; + + programs.mbsync = { + enable = true; + groups.inboxes = { + "hm@example.com" = [ "Inbox1" "Inbox2" ]; + hm-account = [ "Inbox" ]; + }; + }; + + accounts.email.accounts = { + "hm@example.com".mbsync = { + enable = true; + }; + + hm-account.mbsync = { + enable = true; + }; + }; + + nmt.script = '' + assertFileExists home-files/.mbsyncrc + assertFileContent home-files/.mbsyncrc ${./mbsync-expected.conf} + ''; + }; +} -- cgit v1.2.3 From 445c0b1482c38172a9f8294ee16a7ca7462388e5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 1 Feb 2019 01:06:18 +0100 Subject: git: use `attrsOf` instead of `attrs` This makes sure that values added to programs.git.aliases or programs.git.extraConfig are merged as expected. Also add a few option examples. --- modules/programs/git.nix | 16 +++++++-- tests/modules/programs/git-expected.conf | 4 ++- tests/modules/programs/git.nix | 60 ++++++++++++++++++-------------- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 4c962e99c54..001d02b2a26 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -6,6 +6,12 @@ let cfg = config.programs.git; + gitIniType = with types; + let + primitiveType = either bool (either int str); + in + attrsOf (attrsOf primitiveType); + signModule = types.submodule { options = { key = mkOption { @@ -80,8 +86,9 @@ in }; aliases = mkOption { - type = types.attrs; + type = types.attrsOf types.str; default = {}; + example = { co = "checkout"; }; description = "Git aliases to define."; }; @@ -92,13 +99,16 @@ in }; extraConfig = mkOption { - type = types.either types.attrs types.lines; + type = types.either types.lines gitIniType; default = {}; + example = { + core = { whitespace = "trailing-space,space-before-tab"; }; + }; description = "Additional configuration to add."; }; iniContent = mkOption { - type = types.attrsOf types.attrs; + type = gitIniType; internal = true; }; diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf index d2c48f76e91..2b0f3caf437 100644 --- a/tests/modules/programs/git-expected.conf +++ b/tests/modules/programs/git-expected.conf @@ -1,11 +1,13 @@ [alias] a1=foo -a2=bar +a2=baz [commit] gpgSign=true [extra] +boolean=true +integer=38 name=value [gpg] diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix index 29f3d17ebd5..f642bede2a9 100644 --- a/tests/modules/programs/git.nix +++ b/tests/modules/programs/git.nix @@ -4,33 +4,41 @@ with lib; { config = { - programs.git = { - enable = true; - aliases = { - a1 = "foo"; - a2 = "bar"; - }; - extraConfig = { - extra = { - name = "value"; + programs.git = mkMerge [ + { + enable = true; + aliases = { + a1 = "foo"; + a2 = "bar"; }; - }; - ignores = [ "*~" "*.swp" ]; - includes = [ - { path = "~/path/to/config.inc"; } - { - path = "~/path/to/conditional.inc"; - condition = "gitdir:~/src/dir"; - } - ]; - signing = { - gpgPath = "path-to-gpg"; - key = "00112233445566778899AABBCCDDEEFF"; - signByDefault = true; - }; - userEmail = "user@example.org"; - userName = "John Doe"; - }; + extraConfig = { + extra = { + name = "value"; + }; + }; + ignores = [ "*~" "*.swp" ]; + includes = [ + { path = "~/path/to/config.inc"; } + { + path = "~/path/to/conditional.inc"; + condition = "gitdir:~/src/dir"; + } + ]; + signing = { + gpgPath = "path-to-gpg"; + key = "00112233445566778899AABBCCDDEEFF"; + signByDefault = true; + }; + userEmail = "user@example.org"; + userName = "John Doe"; + } + + { + aliases.a2 = mkForce "baz"; + extraConfig.extra.boolean = true; + extraConfig.extra.integer = 38; + } + ]; nmt.script = '' assertFileExists home-files/.config/git/config -- cgit v1.2.3 From c18984c452013ff0edb3d67ab0a1a245333dd4ce Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 4 Feb 2019 14:57:26 +0900 Subject: neovim: allow to override package If you want to run a development version for instance, it is easier to set neovim.package rather than work around the wrapping mechanism etc. --- modules/programs/neovim.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 304a273b6a0..7f2a9aaa115 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -104,6 +104,13 @@ in ''; }; + package = mkOption { + type = types.package; + default = pkgs.neovim-unwrapped; + defaultText = "pkgs.neovim-unwrapped"; + description = "The package to use for the neovim binary."; + }; + configure = mkOption { type = types.attrs; default = {}; @@ -130,7 +137,7 @@ in config = mkIf cfg.enable { home.packages = [ - (pkgs.neovim.override { + (pkgs.wrapNeovim cfg.package { inherit (cfg) extraPython3Packages withPython3 extraPythonPackages withPython -- cgit v1.2.3 From 0ca1bf3cfd5bd7f250bc34150b57e692d6f8b8c4 Mon Sep 17 00:00:00 2001 From: Jonas Holst Damtoft Date: Sat, 29 Dec 2018 20:11:48 +0100 Subject: emacs: add service module --- modules/misc/news.nix | 15 +++++++++++++++ modules/modules.nix | 1 + modules/programs/emacs.nix | 1 - modules/services/emacs.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 modules/services/emacs.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a6f81570d3b..9405e4c2c17 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -951,6 +951,21 @@ in A new module is available: 'programs.irssi'. ''; } + + { + time = "2019-02-09T14:09:58+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.emacs'. + + This module provides a user service that runs the Emacs + configured in + + programs.emacs + + as an Emacs daemon. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 4e3e6fe3719..2fed3a9bdea 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -87,6 +87,7 @@ let (loadModule ./services/blueman-applet.nix { }) (loadModule ./services/compton.nix { }) (loadModule ./services/dunst.nix { }) + (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/flameshot.nix { }) (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 12c7a5a9191..a7f8b94cd81 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -66,7 +66,6 @@ in config = mkIf cfg.enable { home.packages = [ cfg.finalPackage ]; - programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages; }; } diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix new file mode 100644 index 00000000000..f33968c8759 --- /dev/null +++ b/modules/services/emacs.nix @@ -0,0 +1,44 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.emacs; + emacsCfg = config.programs.emacs; + emacsBinPath = "${emacsCfg.finalPackage}/bin"; + +in + +{ + options.services.emacs = { + enable = mkEnableOption "the Emacs daemon"; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = emacsCfg.enable; + message = "The Emacs service module requires" + + " 'programs.emacs.enable = true'."; + } + ]; + + systemd.user.services.emacs = { + Unit = { + Description = "Emacs: the extensible, self-documenting text editor"; + Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/"; + }; + + Service = { + ExecStart = "${pkgs.stdenv.shell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'"; + ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs)'"; + Restart = "on-failure"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 99d79d0a808c69ab2142c523fd84981b817253a8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 10 Feb 2019 00:37:23 +0100 Subject: doc: move home-manager man page to section 1 This is not really a system administration tool so 8 is unsuitable. --- doc/man-home-manager.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index 093c3ae1a0c..1e2aa084b75 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -3,7 +3,7 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> home-manager - 8 + 1 Home Manager -- cgit v1.2.3 From 7f8e139413e1bca2d7fd26da6022b85d5b645c86 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Sat, 9 Feb 2019 17:06:51 +0100 Subject: doc: remove extraneous contrib element `contrib` is "A summary of the contributions made to a document by a credited source", which we don't need in this case. --- doc/man-pages.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/man-pages.xml b/doc/man-pages.xml index d9bb7df2890..616c2ef291b 100644 --- a/doc/man-pages.xml +++ b/doc/man-pages.xml @@ -3,9 +3,7 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> Home Manager Reference Pages - Home Manager contributors - Author - + Home Manager contributors 2017–2019Home Manager contributors -- cgit v1.2.3 From 524ce43e233be08d77b4ad813e4e79a7fef65cee Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Sat, 9 Feb 2019 17:08:21 +0100 Subject: doc: add "See also" section to manpages Pointing to each other. --- doc/man-configuration.xml | 9 +++++++++ doc/man-home-manager.xml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/man-configuration.xml b/doc/man-configuration.xml index 835ba3213da..1ddd31317ee 100644 --- a/doc/man-configuration.xml +++ b/doc/man-configuration.xml @@ -28,4 +28,13 @@ + + See also + + + home-manager + 1 + + + diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index 1e2aa084b75..deb2a3baf88 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -76,4 +76,13 @@ issue tracker. + + See also + + + home-configuration.nix + 5 + + + -- cgit v1.2.3 From 2f372ab4d670c2b685a8f603d078cf3ddfa7e6cd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 9 Feb 2019 15:08:16 +0100 Subject: Clean up support code for Home Manager as a submodule This removes the `nixosSubmodule` option in favor of a new option `submoduleSupport.enable`. This name better indicates that the submodule mode applies to both NixOS and nix-darwin. --- modules/misc/submodule-support.nix | 19 +++++++++++++++++++ modules/modules.nix | 11 +---------- modules/programs/home-manager.nix | 2 +- nix-darwin/default.nix | 6 ++---- nixos/default.nix | 6 ++---- 5 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 modules/misc/submodule-support.nix diff --git a/modules/misc/submodule-support.nix b/modules/misc/submodule-support.nix new file mode 100644 index 00000000000..cffdcb9e95c --- /dev/null +++ b/modules/misc/submodule-support.nix @@ -0,0 +1,19 @@ +{ lib, ... }: + +with lib; + +{ + meta.maintainers = [ maintainers.rycee ]; + + options.submoduleSupport = { + enable = mkOption { + type = types.bool; + default = false; + internal = true; + description = '' + Whether the Home Manager module system is used as a submodule + in, for example, NixOS or nix-darwin. + ''; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 2fed3a9bdea..b96cc319b4d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -3,9 +3,6 @@ # Whether to enable module type checking. , check ? true - - # Whether these modules are inside a NixOS submodule. -, nixosSubmodule ? false }: with lib; @@ -33,6 +30,7 @@ let (loadModule ./misc/nixpkgs.nix { }) (loadModule ./misc/pam.nix { }) (loadModule ./misc/qt.nix { }) + (loadModule ./misc/submodule-support.nix { }) (loadModule ./misc/version.nix { }) (loadModule ./misc/xdg.nix { }) (loadModule ./programs/afew.nix { }) @@ -129,17 +127,10 @@ let modules = map (getAttr "file") (filter (getAttr "condition") allModules); pkgsModule = { - options.nixosSubmodule = mkOption { - type = types.bool; - internal = true; - readOnly = true; - }; - config._module.args.baseModules = modules; config._module.args.pkgs = lib.mkDefault pkgs; config._module.check = check; config.lib = import ./lib { inherit lib; }; - config.nixosSubmodule = nixosSubmodule; config.nixpkgs.system = mkDefault pkgs.system; }; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 0990de85e08..cc76b0110e2 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -32,7 +32,7 @@ in }; }; - config = mkIf (cfg.enable && !config.nixosSubmodule) { + config = mkIf (cfg.enable && !config.submoduleSupport.enable) { home.packages = [ (import ../../home-manager { inherit pkgs; diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index c2ec350cbc0..810b3e5ee90 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -7,12 +7,10 @@ let cfg = config.home-manager; hmModule = types.submodule ({name, ...}: { - imports = import ../modules/modules.nix { - inherit lib pkgs; - nixosSubmodule = true; - }; + imports = import ../modules/modules.nix { inherit lib pkgs; }; config = { + submoduleSupport.enable = true; home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; }; diff --git a/nixos/default.nix b/nixos/default.nix index c101f5a981d..b8cea735e92 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -7,12 +7,10 @@ let cfg = config.home-manager; hmModule = types.submodule ({name, ...}: { - imports = import ../modules/modules.nix { - inherit lib pkgs; - nixosSubmodule = true; - }; + imports = import ../modules/modules.nix { inherit lib pkgs; }; config = { + submoduleSupport.enable = true; home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; }; -- cgit v1.2.3 From fbdb5beb5941f79fc38c5c3d92b0029c4aa40ab5 Mon Sep 17 00:00:00 2001 From: Ingolf Wanger Date: Fri, 8 Feb 2019 19:58:26 +0100 Subject: nixos: use correct username for systemd service --- nixos/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/default.nix b/nixos/default.nix index b8cea735e92..1e1131f9cc7 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -38,7 +38,7 @@ in after = [ "nix-daemon.socket" ]; serviceConfig = { - User = username; + User = usercfg.home.username; Type = "oneshot"; RemainAfterExit = "yes"; SyslogIdentifier = "hm-activate-${username}"; -- cgit v1.2.3 From 1cdb8abf301f5c5ac99849d3754d1477b5d2b3e5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 3 Feb 2019 23:54:29 +0100 Subject: git: add basic support for LFS Fixes #542 --- modules/programs/git.nix | 33 ++++++++++++++++++++++++++++++++ tests/modules/programs/git-expected.conf | 6 ++++++ tests/modules/programs/git.nix | 1 + 3 files changed, 40 insertions(+) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 001d02b2a26..1abf56281c7 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -133,6 +133,20 @@ in ''; description = "List of configuration files to include."; }; + + lfs = { + enable = mkEnableOption "Git Large File Storage"; + + skipSmudge = mkOption { + type = types.bool; + default = false; + description = '' + Skip automatic downloading of objects on clone or pull. + This requires a manual git lfs pull + every time a new commit is checked out on your repository. + ''; + }; + }; }; }; @@ -204,6 +218,25 @@ in '') cfg.includes); }) + + (mkIf cfg.lfs.enable { + home.packages = [ pkgs.git-lfs ]; + + programs.git.iniContent."filter \"lfs\"" = + let + skipArg = optional cfg.lfs.skipSmudge "--skip"; + in + { + clean = "git-lfs clean -- %f"; + process = concatStringsSep " " ( + [ "git-lfs" "filter-process" ] ++ skipArg + ); + required = true; + smudge = concatStringsSep " " ( + [ "git-lfs" "smudge" ] ++ skipArg ++ [ "--" "%f" ] + ); + }; + }) ] ); } diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf index 2b0f3caf437..020fa8f0be8 100644 --- a/tests/modules/programs/git-expected.conf +++ b/tests/modules/programs/git-expected.conf @@ -10,6 +10,12 @@ boolean=true integer=38 name=value +[filter "lfs"] +clean=git-lfs clean -- %f +process=git-lfs filter-process +required=true +smudge=git-lfs smudge -- %f + [gpg] program=path-to-gpg diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix index f642bede2a9..be393d47135 100644 --- a/tests/modules/programs/git.nix +++ b/tests/modules/programs/git.nix @@ -31,6 +31,7 @@ with lib; }; userEmail = "user@example.org"; userName = "John Doe"; + lfs.enable = true; } { -- cgit v1.2.3 From a334a941c40bf1618da86bb12517fd47c4836800 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 10 Feb 2019 12:09:47 +0100 Subject: tests: bump to latest nmt version --- tests/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index 5002ae2caa7..aa14fc24817 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -5,8 +5,8 @@ let nmt = pkgs.fetchFromGitLab { owner = "rycee"; repo = "nmt"; - rev = "02a01605021df3d8d43346076bd065109b10e4f9"; - sha256 = "1b5f534xskp4qdnh0nmflqm6v1a014a883x3abscf4xd0pxb8cj7"; + rev = "b6ab61e707ec1ca3839fef42f9960a1179d543c4"; + sha256 = "097fm1hmsyhy8chf73wwrvafcxny37414fna3haxf0q5fvpv4jfb"; }; in -- cgit v1.2.3 From a3462daeb10ba908396aaa3aee521042a239d7ca Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 10 Feb 2019 18:53:33 +0200 Subject: msmtp: use XDG config directory --- modules/programs/msmtp.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index b19c49863e3..eff2019cf2b 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -66,7 +66,7 @@ in config = mkIf cfg.enable { home.packages = [ pkgs.msmtp ]; - home.file.".msmtprc".text = configFile msmtpAccounts; + xdg.configFile."msmtp/config".text = configFile msmtpAccounts; home.sessionVariables = { MSMTP_QUEUE = "${config.xdg.dataHome}/msmtp/queue"; -- cgit v1.2.3 From 2093cf425ff6af786a2effc776d3ac89b6787c0a Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Sat, 9 Feb 2019 17:19:56 -0800 Subject: tmux: general improvements and added options See #575 for discussion. --- modules/programs/tmux.nix | 173 +++++++++++++++++++-- tests/default.nix | 2 +- tests/modules/programs/tmux/default.nix | 5 + .../modules/programs/tmux/emacs-with-plugins.conf | 52 +++++++ tests/modules/programs/tmux/emacs-with-plugins.nix | 41 +++++ tests/modules/programs/tmux/not-enabled.nix | 13 ++ tests/modules/programs/tmux/vi-all-true.conf | 29 ++++ tests/modules/programs/tmux/vi-all-true.nix | 30 ++++ 8 files changed, 334 insertions(+), 11 deletions(-) create mode 100644 tests/modules/programs/tmux/default.nix create mode 100644 tests/modules/programs/tmux/emacs-with-plugins.conf create mode 100644 tests/modules/programs/tmux/emacs-with-plugins.nix create mode 100644 tests/modules/programs/tmux/not-enabled.nix create mode 100644 tests/modules/programs/tmux/vi-all-true.conf create mode 100644 tests/modules/programs/tmux/vi-all-true.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index 050168bedc8..b436948bba2 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -23,13 +23,136 @@ let }; }; + defaultKeyMode = "emacs"; + defaultResize = 5; + defaultShortcut = "b"; + defaultTerminal = "screen"; + + boolToStr = value: if value then "on" else "off"; + + tmuxConf = '' + set -g default-terminal "${cfg.terminal}" + set -g base-index ${toString cfg.baseIndex} + setw -g pane-base-index ${toString cfg.baseIndex} + + ${optionalString cfg.newSession "new-session"} + + ${optionalString cfg.reverseSplit '' + bind v split-window -h + bind s split-window -v + ''} + + set -g status-keys ${cfg.keyMode} + set -g mode-keys ${cfg.keyMode} + + ${optionalString (cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) '' + bind h select-pane -L + bind j select-pane -D + bind k select-pane -U + bind l select-pane -R + + bind -r H resize-pane -L ${toString cfg.resizeAmount} + bind -r J resize-pane -D ${toString cfg.resizeAmount} + bind -r K resize-pane -U ${toString cfg.resizeAmount} + bind -r L resize-pane -R ${toString cfg.resizeAmount} + ''} + + ${optionalString (cfg.shortcut != defaultShortcut) '' + # rebind main key: C-${cfg.shortcut} + unbind C-${defaultShortcut} + set -g prefix C-${cfg.shortcut} + bind ${cfg.shortcut} send-prefix + bind C-${cfg.shortcut} last-window + ''} + + setw -g aggressive-resize ${boolToStr cfg.aggressiveResize} + setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"} + set -s escape-time ${toString cfg.escapeTime} + set -g history-limit ${toString cfg.historyLimit} + + ${cfg.extraConfig} + ''; + in { options = { programs.tmux = { + aggressiveResize = mkOption { + default = false; + type = types.bool; + description = '' + Resize the window to the size of the smallest session for + which it is the current window. + ''; + }; + + baseIndex = mkOption { + default = 0; + example = 1; + type = types.ints.unsigned; + description = "Base index for windows and panes."; + }; + + clock24 = mkOption { + default = false; + type = types.bool; + description = "Use 24 hour clock."; + }; + + customPaneNavigationAndResize = mkOption { + default = false; + type = types.bool; + description = '' + Override the hjkl and HJKL bindings for pane navigation and + resizing in VI mode. + ''; + }; + enable = mkEnableOption "tmux"; + escapeTime = mkOption { + default = 500; + example = 0; + type = types.ints.unsigned; + description = '' + Time in milliseconds for which tmux waits after an escape is + input. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Additional configuration to add to + tmux.conf. + ''; + }; + + historyLimit = mkOption { + default = 2000; + example = 5000; + type = types.ints.positive; + description = "Maximum number of lines held in window history."; + }; + + keyMode = mkOption { + default = defaultKeyMode; + example = "vi"; + type = types.enum [ "emacs" "vi" ]; + description = "VI or Emacs style shortcuts."; + }; + + newSession = mkOption { + default = false; + type = types.bool; + description = '' + Automatically spawn a session if trying to attach and none + are running. + ''; + }; + package = mkOption { type = types.package; default = pkgs.tmux; @@ -38,6 +161,19 @@ in description = "The tmux package to install"; }; + reverseSplit = mkOption { + default = false; + type = types.bool; + description = "Reverse the window split shortcuts."; + }; + + resizeAmount = mkOption { + default = defaultResize; + example = 10; + type = types.ints.positive; + description = "Number of lines/columns when resizing."; + }; + sensibleOnTop = mkOption { type = types.bool; default = true; @@ -48,6 +184,32 @@ in ''; }; + shortcut = mkOption { + default = defaultShortcut; + example = "a"; + type = types.str; + description = '' + CTRL following by this key is used as the main shortcut. + ''; + }; + + terminal = mkOption { + default = defaultTerminal; + example = "screen-256color"; + type = types.str; + description = "Set the $TERM variable."; + }; + + secureSocket = mkOption { + default = true; + type = types.bool; + description = '' + Store tmux socket under /run, which is more + secure than /tmp, but as a downside it doesn't + survive user logout. + ''; + }; + tmuxp.enable = mkEnableOption "tmuxp"; tmuxinator.enable = mkEnableOption "tmuxinator"; @@ -79,15 +241,6 @@ in ] ''; }; - - extraConfig = mkOption { - type = types.lines; - default = ""; - description = '' - Additional configuration to add to - tmux.conf. - ''; - }; }; }; @@ -98,7 +251,7 @@ in ++ optional cfg.tmuxinator.enable pkgs.tmuxinator ++ optional cfg.tmuxp.enable pkgs.tmuxp; - home.file.".tmux.conf".text = cfg.extraConfig; + home.file.".tmux.conf".text = tmuxConf; } (mkIf cfg.sensibleOnTop { diff --git a/tests/default.nix b/tests/default.nix index aa14fc24817..42c1781974c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -28,5 +28,5 @@ import nmt { xresources = ./modules/xresources.nix; } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; - }; + } // import ./modules/programs/tmux; } diff --git a/tests/modules/programs/tmux/default.nix b/tests/modules/programs/tmux/default.nix new file mode 100644 index 00000000000..5bc31177298 --- /dev/null +++ b/tests/modules/programs/tmux/default.nix @@ -0,0 +1,5 @@ +{ + tmux-emacs-with-plugins = ./emacs-with-plugins.nix; + tmux-not-enabled = ./not-enabled.nix; + tmux-vi-all-true = ./vi-all-true.nix; +} diff --git a/tests/modules/programs/tmux/emacs-with-plugins.conf b/tests/modules/programs/tmux/emacs-with-plugins.conf new file mode 100644 index 00000000000..039ae740fc0 --- /dev/null +++ b/tests/modules/programs/tmux/emacs-with-plugins.conf @@ -0,0 +1,52 @@ +# ============================================= # +# Start with defaults from the Sensible plugin # +# --------------------------------------------- # +run-shell @tmuxplugin_sensible_rtp@ +# ============================================= # + +set -g default-terminal "screen" +set -g base-index 0 +setw -g pane-base-index 0 + +new-session + +bind v split-window -h +bind s split-window -v + + +set -g status-keys emacs +set -g mode-keys emacs + + + + + +setw -g aggressive-resize on +setw -g clock-mode-style 24 +set -s escape-time 500 +set -g history-limit 2000 + + + +# ============================================= # +# Load plugins with Home Manager # +# --------------------------------------------- # + +# tmuxplugin-logging +# --------------------- + +run-shell @tmuxplugin_logging@/share/tmux-plugins/logging/logging.tmux + + +# tmuxplugin-prefix-highlight +# --------------------- + +run-shell @tmuxplugin_prefix_highlight@/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux + + +# tmuxplugin-fzf-tmux-url +# --------------------- + +run-shell @tmuxplugin_fzf_tmux_url@/share/tmux-plugins/fzf-tmux-url/fzf-url.tmux + +# ============================================= # diff --git a/tests/modules/programs/tmux/emacs-with-plugins.nix b/tests/modules/programs/tmux/emacs-with-plugins.nix new file mode 100644 index 00000000000..5e147b7290e --- /dev/null +++ b/tests/modules/programs/tmux/emacs-with-plugins.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + substituteExpected = path: pkgs.substituteAll { + src = path; + + tmuxplugin_fzf_tmux_url = pkgs.tmuxPlugins.fzf-tmux-url; + tmuxplugin_logging = pkgs.tmuxPlugins.logging; + tmuxplugin_prefix_highlight = pkgs.tmuxPlugins.prefix-highlight; + tmuxplugin_sensible_rtp = pkgs.tmuxPlugins.sensible.rtp; + }; + +in + +{ + config = { + programs.tmux = { + aggressiveResize = true; + clock24 = true; + enable = true; + keyMode = "emacs"; + newSession = true; + reverseSplit = true; + + plugins = with pkgs.tmuxPlugins; [ + logging + prefix-highlight + fzf-tmux-url + ]; + }; + + nmt.script = '' + assertFileExists home-files/.tmux.conf + assertFileContent home-files/.tmux.conf \ + ${substituteExpected ./emacs-with-plugins.conf} + ''; + }; +} diff --git a/tests/modules/programs/tmux/not-enabled.nix b/tests/modules/programs/tmux/not-enabled.nix new file mode 100644 index 00000000000..d74f30648b0 --- /dev/null +++ b/tests/modules/programs/tmux/not-enabled.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.tmux = { enable = false; }; + + nmt.script = '' + assertFileNotExists home-files/.tmux.conf + ''; + }; +} diff --git a/tests/modules/programs/tmux/vi-all-true.conf b/tests/modules/programs/tmux/vi-all-true.conf new file mode 100644 index 00000000000..15bbc9107f6 --- /dev/null +++ b/tests/modules/programs/tmux/vi-all-true.conf @@ -0,0 +1,29 @@ +# ============================================= # +# Start with defaults from the Sensible plugin # +# --------------------------------------------- # +run-shell @sensible_rtp@ +# ============================================= # + +set -g default-terminal "screen" +set -g base-index 0 +setw -g pane-base-index 0 + +new-session + +bind v split-window -h +bind s split-window -v + + +set -g status-keys vi +set -g mode-keys vi + + + + + +setw -g aggressive-resize on +setw -g clock-mode-style 24 +set -s escape-time 500 +set -g history-limit 2000 + + diff --git a/tests/modules/programs/tmux/vi-all-true.nix b/tests/modules/programs/tmux/vi-all-true.nix new file mode 100644 index 00000000000..e88ed587c03 --- /dev/null +++ b/tests/modules/programs/tmux/vi-all-true.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + substituteExpected = path: pkgs.substituteAll { + src = path; + + sensible_rtp = pkgs.tmuxPlugins.sensible.rtp; + }; + +in { + config = { + programs.tmux = { + aggressiveResize = true; + clock24 = true; + enable = true; + keyMode = "vi"; + newSession = true; + reverseSplit = true; + }; + + nmt.script = '' + assertFileExists home-files/.tmux.conf + assertFileContent home-files/.tmux.conf \ + ${substituteExpected ./vi-all-true.conf} + ''; + }; +} -- cgit v1.2.3 From ef168979bf88310459464e5fe3fbcf2d3cbe49b5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 19 Dec 2017 15:43:40 +0100 Subject: nixos module: support NixOS user packages install When using the NixOS module we cannot guarantee that the Nix store will be writable during startup. Installing the user packages through `nix-env -i` will fail in these cases. This commit adds a NixOS option `home-manager.useUserPackages` that, when enabled, installs user packages through the NixOS users.users..packages option. Note, when submodule support and external package install is enabled then the installed packages are not available in `~/.nix-profile`. We therefore set `home.profileDirectory` directly to the HM profile packages. --- modules/home-environment.nix | 36 ++++++++++++++++++++++++++++++++---- modules/misc/news.nix | 18 ++++++++++++++++++ modules/misc/submodule-support.nix | 13 +++++++++++++ nixos/default.nix | 24 +++++++++++++++++++----- 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index c98cb9ea966..6e8c7cf9620 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -269,7 +269,11 @@ in home.username = mkDefault (builtins.getEnv "USER"); home.homeDirectory = mkDefault (builtins.getEnv "HOME"); - home.profileDirectory = cfg.homeDirectory + "/.nix-profile"; + home.profileDirectory = + if config.submoduleSupport.enable + && config.submoduleSupport.externalPackageInstall + then config.home.path + else cfg.homeDirectory + "/.nix-profile"; home.sessionVariables = let @@ -307,9 +311,33 @@ in home.activation.writeBoundary = dag.entryAnywhere ""; # Install packages to the user environment. - home.activation.installPackages = dag.entryAfter ["writeBoundary"] '' - $DRY_RUN_CMD nix-env -i ${cfg.path} - ''; + # + # Note, sometimes our target may not allow modification of the Nix + # store and then we cannot rely on `nix-env -i`. This is the case, + # for example, if we are running as a NixOS module and building a + # virtual machine. Then we must instead rely on an external + # mechanism for installing packages, which in NixOS is provided by + # the `users.users..packages` option. The activation + # command is still needed since some modules need to run their + # activation commands after the packages are guaranteed to be + # installed. + # + # In case the user has moved from a user-install of Home Manager + # to a submodule managed one we attempt to uninstall the + # `home-manager-path` package if it is installed. + home.activation.installPackages = dag.entryAfter ["writeBoundary"] ( + if config.submoduleSupport.externalPackageInstall + then + '' + if nix-env -q | grep '^home-manager-path$'; then + $DRY_RUN_CMD nix-env -e home-manager-path + fi + '' + else + '' + $DRY_RUN_CMD nix-env -i ${cfg.path} + '' + ); home.activationPackage = let diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 9405e4c2c17..ee09b9ad826 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -966,6 +966,24 @@ in as an Emacs daemon. ''; } + + { + time = "2019-02-16T20:33:56+00:00"; + condition = hostPlatform.isLinux; + message = '' + When using Home Manager as a NixOS submodule it is now + possible to install packages using the NixOS + + users.users..packages + + option. This is enabled by adding + + home-manager.useUserPackages = true; + + to your NixOS system configuration. This mode of operation + is necessary if you want to use 'nixos-rebuild build-vm'. + ''; + } ]; }; } diff --git a/modules/misc/submodule-support.nix b/modules/misc/submodule-support.nix index cffdcb9e95c..d6138c7ccd8 100644 --- a/modules/misc/submodule-support.nix +++ b/modules/misc/submodule-support.nix @@ -15,5 +15,18 @@ with lib; in, for example, NixOS or nix-darwin. ''; }; + + externalPackageInstall = mkOption { + type = types.bool; + default = false; + internal = true; + description = '' + Whether the packages of are + installed separately from the Home Manager activation script. + In NixOS, for example, this may be accomplished by installing + the packages through + . + ''; + }; }; } diff --git a/nixos/default.nix b/nixos/default.nix index 1e1131f9cc7..5dec943b946 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -11,6 +11,7 @@ let config = { submoduleSupport.enable = true; + submoduleSupport.externalPackageInstall = cfg.useUserPackages; home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; }; @@ -20,16 +21,29 @@ in { options = { - home-manager.users = mkOption { - type = types.attrsOf hmModule; - default = {}; - description = '' - Per-user Home Manager configuration. + home-manager = { + useUserPackages = mkEnableOption '' + installation of user packages through the + option. ''; + + users = mkOption { + type = types.attrsOf hmModule; + default = {}; + description = '' + Per-user Home Manager configuration. + ''; + }; }; }; config = mkIf (cfg.users != {}) { + users.users = mkIf cfg.useUserPackages ( + mapAttrs (username: usercfg: { + packages = usercfg.home.packages; + }) cfg.users + ); + systemd.services = mapAttrs' (username: usercfg: nameValuePair ("home-manager-${utils.escapeSystemdPath username}") { description = "Home Manager environment for ${username}"; -- cgit v1.2.3 From 799a90ecfaa717bc617ffad19383d1cddd4c99ad Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Dec 2017 12:19:07 +0100 Subject: fontconfig: make fonts accessible when in NixOS module --- nixos/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index 5dec943b946..2134175bc90 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -12,6 +12,12 @@ let config = { submoduleSupport.enable = true; submoduleSupport.externalPackageInstall = cfg.useUserPackages; + + # The per-user directory inside /etc/profiles is not known by + # fontconfig by default. + fonts.fontconfig.enableProfileFonts = + cfg.useUserPackages && config.fonts.fontconfig.enable; + home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; }; -- cgit v1.2.3 From 62e73b17d2e9ecdfd8a8d069fd04c72c13991525 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Thu, 7 Feb 2019 23:21:54 -0500 Subject: keychain: add module --- modules/modules.nix | 1 + modules/programs/keychain.nix | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 modules/programs/keychain.nix diff --git a/modules/modules.nix b/modules/modules.nix index b96cc319b4d..85ee166a75f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -57,6 +57,7 @@ let (loadModule ./programs/info.nix { }) (loadModule ./programs/irssi.nix { }) (loadModule ./programs/jq.nix { }) + (loadModule ./programs/keychain.nix { }) (loadModule ./programs/lesspipe.nix { }) (loadModule ./programs/man.nix { }) (loadModule ./programs/matplotlib.nix { }) diff --git a/modules/programs/keychain.nix b/modules/programs/keychain.nix new file mode 100644 index 00000000000..c39c852011a --- /dev/null +++ b/modules/programs/keychain.nix @@ -0,0 +1,88 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.keychain; + + flags = cfg.extraFlags + ++ optional (cfg.agents != []) "--agents ${concatStringsSep "," cfg.agents}" + ++ optional (cfg.inheritType != null) "--inherit ${cfg.inheritType}"; + + shellCommand = '' + eval "$(${cfg.package}/bin/keychain --eval ${concatStringsSep " " flags} ${concatStringsSep " " cfg.keys})" + ''; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.keychain = { + enable = mkEnableOption "keychain"; + + package = mkOption { + type = types.package; + default = pkgs.keychain; + defaultText = "pkgs.keychain"; + description = '' + Keychain package to install. + ''; + }; + + keys = mkOption { + type = types.listOf types.str; + default = [ "id_rsa" ]; + description = '' + Keys to add to keychain. + ''; + }; + + agents = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Agents to add. + ''; + }; + + inheritType = mkOption { + type = types.nullOr (types.enum ["local" "any" "local-once" "any-once"]); + default = null; + description = '' + Inherit type to attempt from agent variables from the environment. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = [ "--quiet" ]; + description = '' + Extra flags to pass to keychain. + ''; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + programs.bash.initExtra = mkIf cfg.enableBashIntegration shellCommand; + programs.zsh.initExtra = mkIf cfg.enableZshIntegration shellCommand; + }; +} -- cgit v1.2.3 From e0e8d5061d1dbcc70b18a1773ca27acfeb622293 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 17 Feb 2019 22:12:25 +0100 Subject: keychain: add news entry --- modules/misc/news.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ee09b9ad826..2d18442ff3b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -984,6 +984,13 @@ in is necessary if you want to use 'nixos-rebuild build-vm'. ''; } + + { + time = "2019-02-17T21:11:24+00:00"; + message = '' + A new module is available: 'programs.keychain'. + ''; + } ]; }; } -- cgit v1.2.3 From 6da88339f53f72eed62dedfbfb2e33acd0aa16da Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Tue, 29 Jan 2019 06:33:10 -0500 Subject: git: allow contents in git.includes --- modules/programs/git.nix | 18 +++++++++++++++--- tests/modules/programs/git-expected.conf | 3 +++ tests/modules/programs/git.nix | 25 +++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 1abf56281c7..71d79b0194c 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -34,7 +34,7 @@ let }; }; - includeModule = types.submodule { + includeModule = types.submodule ({ config, ... }: { options = { condition = mkOption { type = types.nullOr types.str; @@ -50,11 +50,23 @@ let }; path = mkOption { - type = types.str; + type = with types; either str path; description = "Path of the configuration file to include."; }; + + contents = mkOption { + type = types.attrs; + default = {}; + description = '' + Configuration to include. If empty then a path must be given. + ''; + }; }; - }; + + config.path = mkIf (config.contents != {}) ( + mkDefault (pkgs.writeText "contents" (generators.toINI {} config.contents)) + ); + }); in diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf index 020fa8f0be8..e6d23d11692 100644 --- a/tests/modules/programs/git-expected.conf +++ b/tests/modules/programs/git-expected.conf @@ -29,3 +29,6 @@ path = ~/path/to/config.inc [includeIf "gitdir:~/src/dir"] path = ~/path/to/conditional.inc + +[includeIf "gitdir:~/src/dir"] +path = @git_include_path@ diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix index be393d47135..71573c38428 100644 --- a/tests/modules/programs/git.nix +++ b/tests/modules/programs/git.nix @@ -1,7 +1,24 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; +let + + gitInclude = { + user = { + name = "John Doe"; + email = "user@example.org"; + }; + }; + + substituteExpected = path: pkgs.substituteAll { + src = path; + + git_include_path = pkgs.writeText "contents" (generators.toINI {} gitInclude); + }; + +in + { config = { programs.git = mkMerge [ @@ -23,6 +40,10 @@ with lib; path = "~/path/to/conditional.inc"; condition = "gitdir:~/src/dir"; } + { + condition = "gitdir:~/src/dir"; + contents = gitInclude; + } ]; signing = { gpgPath = "path-to-gpg"; @@ -43,7 +64,7 @@ with lib; nmt.script = '' assertFileExists home-files/.config/git/config - assertFileContent home-files/.config/git/config ${./git-expected.conf} + assertFileContent home-files/.config/git/config ${substituteExpected ./git-expected.conf} ''; }; } -- cgit v1.2.3 From 03f1aea069f11a2dbf32381aa6dc73e23fcb1f2b Mon Sep 17 00:00:00 2001 From: Terje Larsen Date: Mon, 11 Feb 2019 21:23:07 +0100 Subject: autorandr: add support for xrandr scale and dpi --- modules/programs/autorandr.nix | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix index 05a086eb58c..e24edbbd617 100644 --- a/modules/programs/autorandr.nix +++ b/modules/programs/autorandr.nix @@ -114,6 +114,61 @@ let for the documentation of the transform matrix. ''; }; + + dpi = mkOption { + type = types.nullOr types.ints.positive; + description = "Output DPI configuration."; + default = null; + example = 96; + }; + + scale = mkOption { + type = types.nullOr (types.submodule { + options = { + method = mkOption { + type = types.enum ["factor" "pixel" ]; + description = "Output scaling method."; + default = "factor"; + example = "pixel"; + }; + + x = mkOption { + type = types.either types.float types.ints.positive; + description = "Horizontal scaling factor/pixels."; + }; + + y = mkOption { + type = types.either types.float types.ints.positive; + description = "Vertical scaling factor/pixels."; + }; + }; + }); + description = '' + Output scale configuration. + + Either configure by pixels or a scaling factor. When using pixel method the + + xrandr + 1 + + option + --scale-from + will be used; when using factor method the option + --scale + will be used. + + This option is a shortcut version of the transform option and they are mutually + exclusive. + ''; + default = null; + example = literalExample '' + { + method = "factor"; + x = 1.25; + y = 1.25; + } + ''; + }; }; }; @@ -181,10 +236,15 @@ let output ${name} ${optionalString (config.position != "") "pos ${config.position}"} ${optionalString config.primary "primary"} + ${optionalString (config.dpi != null) "dpi ${toString config.dpi}"} ${optionalString (config.gamma != "") "gamma ${config.gamma}"} ${optionalString (config.mode != "") "mode ${config.mode}"} ${optionalString (config.rate != "") "rate ${config.rate}"} ${optionalString (config.rotate != null) "rotate ${config.rotate}"} + ${optionalString (config.scale != null) ( + (if config.scale.method == "factor" then "scale" else "scale-from") + + " ${toString config.scale.x}x${toString config.scale.y}" + )} ${optionalString (config.transform != null) ( "transform " + concatMapStringsSep "," toString (flatten config.transform) )} @@ -264,6 +324,19 @@ in }; config = mkIf cfg.enable { + assertions = flatten (mapAttrsToList ( + profile: { config, ... }: mapAttrsToList ( + output: opts: { + assertion = opts.scale == null || opts.transform == null; + message = '' + Cannot use the profile output options 'scale' and 'transform' simultaneously. + Check configuration for: programs.autorandr.profiles.${profile}.config.${output} + ''; + }) + config + ) + cfg.profiles); + home.packages = [ pkgs.autorandr ]; xdg.configFile = mkMerge ([ (mapAttrs' (hookToFile "postswitch.d") cfg.hooks.postswitch) -- cgit v1.2.3 From 92d4e3e75a6b205d21ddfa4d32e2aba49b97debe Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 17 Feb 2019 23:06:39 +0100 Subject: autorandr: remove unnecessary `method` attribute I mistakenly added this before noticing that it was already defaulted to "factory". Sorry! --- modules/programs/autorandr.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/programs/autorandr.nix b/modules/programs/autorandr.nix index e24edbbd617..4514a5b5d58 100644 --- a/modules/programs/autorandr.nix +++ b/modules/programs/autorandr.nix @@ -163,7 +163,6 @@ let default = null; example = literalExample '' { - method = "factor"; x = 1.25; y = 1.25; } -- cgit v1.2.3 From 93f5fcae1e5c664050d3e75bd3cba5e6a6a95e53 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 17 Feb 2019 23:25:42 +0100 Subject: msmtp: use `` for CLI options in description --- modules/programs/msmtp-accounts.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/programs/msmtp-accounts.nix b/modules/programs/msmtp-accounts.nix index 1730232da16..fedddb69b03 100644 --- a/modules/programs/msmtp-accounts.nix +++ b/modules/programs/msmtp-accounts.nix @@ -11,14 +11,14 @@ with lib; Whether to enable msmtp. If enabled then it is possible to use the - command line option to send a - message for a given account using the msmtp - or msmtpq tool. For example, - msmtp --account=private - would send using the account defined in + --account command line + option to send a message for a given account using the + msmtp or msmtpq tool. + For example, msmtp --account=private would + send using the account defined in . If the - option is not given then the - primary account will be used. + --account option is not + given then the primary account will be used. ''; }; -- cgit v1.2.3 From 74811679b7f102a7e379e1f0f4160cc3c0643de6 Mon Sep 17 00:00:00 2001 From: Douglas Wilson Date: Tue, 19 Feb 2019 07:10:04 +0000 Subject: systemd: sanitize unit derivation names To allow a few special characters such as "@". This is taken from https://github.com/NixOS/nixpkgs/blob/c414e5bd080836376d3a0305535644423dc2cbbb/nixos/modules/system/boot/systemd-lib.nix#L14 --- modules/systemd.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index ed630b3618a..f7325b41f1a 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -27,11 +27,17 @@ let buildService = style: name: serviceCfg: let filename = "${name}.${style}"; + pathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] + ["-" "-" "-" "" "" ] + filename; # Needed because systemd derives unit names from the ultimate # link target. - source = pkgs.writeTextDir filename (toSystemdIni serviceCfg) - + "/" + filename; + source = pkgs.writeTextFile { + name = pathSafeName; + text = toSystemdIni serviceCfg; + destination = "/${filename}"; + } + "/${filename}"; wantedBy = target: { -- cgit v1.2.3 From 81dae2f88eaff306f36b9072d2cb752f82dbc60a Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 5 Feb 2019 15:03:04 +0900 Subject: alot: support contact completion Make choice of contact completion easier. --- modules/accounts/email.nix | 4 ++-- modules/programs/alot-accounts.nix | 29 +++++++++++++++++++++++++++++ modules/programs/alot.nix | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 857622c089c..ea9955d12a4 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -379,7 +379,7 @@ in accounts = mkOption { type = types.attrsOf (types.submodule [ mailAccountOpts - (import ../programs/alot-accounts.nix) + (import ../programs/alot-accounts.nix pkgs) (import ../programs/astroid-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix index ad7be0d887b..2def5fd1a75 100644 --- a/modules/programs/alot-accounts.nix +++ b/modules/programs/alot-accounts.nix @@ -1,3 +1,4 @@ +pkgs: { config, lib, ... }: with lib; @@ -13,6 +14,34 @@ with lib; ''; }; + contactCompletion = mkOption { + type = types.attrsOf types.str; + default = { + type = "shellcommand"; + command = "'${pkgs.notmuch}/bin/notmuch address --format=json --output=recipients date:6M..'"; + regexp = + "'\[?{" + + ''"name": "(?P.*)", '' + + ''"address": "(?P.+)", '' + + ''"name-addr": ".*"'' + + "}[,\]]?'"; + shellcommand_external_filtering = "False"; + }; + example = literalExample '' + { + type = "shellcommand"; + command = "abook --mutt-query"; + regexp = "'^(?P[^@]+@[^\t]+)\t+(?P[^\t]+)'"; + ignorecase = "True"; + } + ''; + description = '' + Contact completion configuration as expected per alot. + See alot's wiki for + explanation about possible values. + ''; + }; + extraConfig = mkOption { type = types.lines; default = ""; diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix index ea5a5d11b33..39c701e5c77 100644 --- a/modules/programs/alot.nix +++ b/modules/programs/alot.nix @@ -33,6 +33,8 @@ let boolStr (signature.showSignature == "attach"); } ) + ++ [ "[[[abook]]]" ] + ++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion ) + "\n" + alot.extraConfig; -- cgit v1.2.3 From b8b391ad18b2ec47d1e95e247301edd4e8326154 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 23 Feb 2019 22:17:59 +0100 Subject: tests: remove tests attribute from root default.nix Having it there prevented, e.g., `nix-env -qaP` from working in some cases. Fixes #509 --- .travis.yml | 2 +- default.nix | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80dde569d88..df9c468be64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ before_script: script: - nix-shell . -A install - - nix-shell . -A tests.run.all + - nix-shell tests -A run.all diff --git a/default.nix b/default.nix index bedc57779b4..9ae18232316 100644 --- a/default.nix +++ b/default.nix @@ -11,8 +11,4 @@ rec { }; nixos = import ./nixos; - - tests = import ./tests { - inherit pkgs; - }; } -- cgit v1.2.3 From f07510e2b63075a5e334e603f666c5c5838563ce Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 20 Feb 2019 08:38:40 -0700 Subject: mpdris2: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/services/mpdris2.nix | 101 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 modules/services/mpdris2.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 2d18442ff3b..9684c3a7052 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -991,6 +991,13 @@ in A new module is available: 'programs.keychain'. ''; } + + { + time = "2019-02-24T00:32:23+00:00"; + message = '' + A new service is available: 'services.mpdris2'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 85ee166a75f..16517ccfc01 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -96,6 +96,7 @@ let (loadModule ./services/keybase.nix { }) (loadModule ./services/mbsync.nix { }) (loadModule ./services/mpd.nix { }) + (loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/network-manager-applet.nix { }) (loadModule ./services/nextcloud-client.nix { }) (loadModule ./services/owncloud-client.nix { }) diff --git a/modules/services/mpdris2.nix b/modules/services/mpdris2.nix new file mode 100644 index 00000000000..14c8902308b --- /dev/null +++ b/modules/services/mpdris2.nix @@ -0,0 +1,101 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.mpdris2; + + toIni = generators.toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "True" else "False") + else toString value; + in + "${key} = ${value'}"; + }; + + mpdris2Conf = { + Connection = { + host = cfg.mpd.host; + port = cfg.mpd.port; + music_dir = cfg.mpd.musicDirectory; + }; + + Bling = { + notify = cfg.notifications; + mmkeys = cfg.multimediaKeys; + }; + }; + +in + +{ + meta.maintainers = [ maintainers.pjones ]; + + options.services.mpdris2 = { + enable = mkEnableOption "mpDris2 the MPD to MPRIS2 bridge"; + notifications = mkEnableOption "song change notifications"; + multimediaKeys = mkEnableOption "multimedia key support"; + + package = mkOption { + type = types.package; + default = pkgs.mpdris2; + defaultText = "pkgs.mpdris2"; + description = "The mpDris2 package to use."; + }; + + mpd = { + host = mkOption { + type = types.str; + default = config.services.mpd.network.listenAddress; + defaultText = "config.services.mpd.network.listenAddress"; + example = "192.168.1.1"; + description = "The address where MPD is listening for connections."; + }; + + port = mkOption { + type = types.ints.positive; + default = config.services.mpd.network.port; + defaultText = "config.services.mpd.network.port"; + description = '' + The port number where MPD is listening for connections. + ''; + }; + + musicDirectory = mkOption { + type = types.nullOr types.path; + default = config.services.mpd.musicDirectory; + defaultText = "config.services.mpd.musicDirectory"; + description = '' + If set, mpDris2 will use this directory to access music artwork. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = config.services.mpd.enable; + message = "The mpdris2 module requires 'services.mpd.enable = true'."; + } + ]; + + xdg.configFile."mpDris2/mpDris2.conf".text = toIni mpdris2Conf; + + systemd.user.services.mpdris2 = { + Unit = { + Description = "MPRIS 2 support for MPD"; + After = [ "graphical-session-pre.target" "mpd.service" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/mpDris2"; + }; + }; + }; +} -- cgit v1.2.3 From 465d08d99f5b72b38cecb7ca1865b7255de3ee86 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 28 Feb 2019 11:29:16 +0100 Subject: programs/zsh: properly escape shell aliases Otherwise all aliases break that use single quotes inside. Already fixed in the nixpkgs module in 1e211a70cbdaf230a18ea4cb67a959039d5c2ddb. --- modules/programs/zsh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 1b7ccf7a6fc..e7631309164 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -15,7 +15,7 @@ let localVarsStr = config.lib.zsh.defineAll cfg.localVariables; aliasesStr = concatStringsSep "\n" ( - mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases + mapAttrsToList (k: v: "alias ${k}=${lib.escapeShellArg v}") cfg.shellAliases ); zdotdir = "$HOME/" + cfg.dotDir; -- cgit v1.2.3 From 848b8b983e36c0cfe3c12cff8389307f14c6185f Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Tue, 5 Mar 2019 18:53:48 +0200 Subject: pam: enclose session variable values in quotes --- modules/misc/pam.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index 91b75f5b5ec..6ace2bfdaac 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -30,7 +30,7 @@ in config = mkIf (vars != {}) { home.file.".pam_environment".text = concatStringsSep "\n" ( - mapAttrsToList (n: v: "${n} OVERRIDE=${toString v}") vars + mapAttrsToList (n: v: "${n} OVERRIDE=\"${toString v}\"") vars ) + "\n"; }; } -- cgit v1.2.3 From 0898b6b48277de277a9ce0a06602cce1a9881fcb Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 28 Feb 2019 01:52:48 +0100 Subject: nixos module: evaluate assertions from Home Manager modules --- nixos/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index 2134175bc90..5328e578124 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -44,6 +44,16 @@ in }; config = mkIf (cfg.users != {}) { + assertions = + flatten (flip mapAttrsToList cfg.users (user: config: + flip map config.assertions (assertion: + { + inherit (assertion) assertion; + message = "${user} profile: ${assertion.message}"; + } + ) + )); + users.users = mkIf cfg.useUserPackages ( mapAttrs (username: usercfg: { packages = usercfg.home.packages; -- cgit v1.2.3 From 1d8997633c685f8b432da812efe157fdd25bc49b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 24 Feb 2019 20:39:51 +0100 Subject: docs: use for terminal interaction --- doc/installation.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/installation.xml b/doc/installation.xml index ab24e8a472c..835b69962f8 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -47,9 +47,9 @@ Make sure you have a working Nix installation. If you are not using NixOS then it may be necessary to run - -$ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER - + +$ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER + since Home Manager uses these directories to manage your profile generations. On NixOS these should already be available. @@ -71,17 +71,17 @@ $ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER Add the Home Manager channel that you wish to follow. This is done by running - -$ nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager -$ nix-channel --update - + +$ nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager +$ nix-channel --update + if you are following Nixpkgs master or an unstable channel and - -$ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager -$ nix-channel --update - + +$ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager +$ nix-channel --update + if you follow a Nixpkgs version 18.09 channel. @@ -100,9 +100,9 @@ export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH Run the Home Manager installation command and create the first Home Manager generation: - -$ nix-shell '<home-manager>' -A install - + +$ nix-shell '<home-manager>' -A install + Once finished, Home Manager should be active and available in your user environment. -- cgit v1.2.3 From a09196c4ae18195a2a8d11f6179e4b2e44430e62 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 24 Feb 2019 20:40:45 +0100 Subject: docs: add language attribute to program listings --- doc/installation.xml | 4 ++-- modules/home-environment.nix | 4 ++-- modules/misc/nixpkgs.nix | 2 +- modules/programs/zsh.nix | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/installation.xml b/doc/installation.xml index 835b69962f8..281f5067964 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -88,7 +88,7 @@ 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 - + export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH to your shell (see @@ -113,7 +113,7 @@ export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH If you do not plan on having Home Manager manage your shell configuration then you must source the - + $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 6e8c7cf9620..49b8727559c 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -163,7 +163,7 @@ in Note, these variables may be set in any order so no session variable may have a runtime dependency on another session variable. In particular code like - + home.sessionVariables = { FOO = "Hello"; BAR = "$FOO World!"; @@ -172,7 +172,7 @@ in may not work as expected. If you need to reference another session variable, then do so inside Nix instead. The above example then becomes - + home.sessionVariables = { FOO = "Hello"; BAR = "''${config.home.sessionVariables.FOO} World!"; diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index 150cbe74093..b59e0d1ddaa 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -80,7 +80,7 @@ in inside and outside Home Manager you can put it in a separate file and include something like - + nixpkgs.config = import ./nixpkgs-config.nix; xdg.configFile."nixpkgs/config.nix".source = ./nixpkgs-config.nix; diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index e7631309164..55ed4757d4b 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -174,7 +174,7 @@ in default = true; description = '' Enable zsh completion. Don't forget to add - + environment.pathsToLink = [ "/share/zsh" ]; to your system configuration to get completion for system packages (e.g. systemd). -- cgit v1.2.3 From 52fdf5b7ecab93eaf2a2ee83777b73f8ee126614 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 26 Feb 2019 22:32:18 +0100 Subject: docs: add NixOS module installation instructions --- doc/installation.xml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/doc/installation.xml b/doc/installation.xml index 281f5067964..b0109398369 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -145,8 +145,86 @@ $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh NixOS module - To be done. + Home Manager provides a NixOS module that allows you to prepare user + environments directly from the system configuration file, which often is + more convenient than using the home-manager tool. It also + opens up additional possibilities, for example, to automatically configure + user environments in NixOS declarative containers or on systems deployed + through NixOps. + + + + To make the NixOS module available for use you must + it into your system configuration. This is most conveniently done by adding + a Home Manager channel, for example + + + +# nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager +# nix-channel --update + + + + if you are following Nixpkgs master or an unstable channel and + + + +# nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager +# nix-channel --update + + + + if you follow a Nixpkgs version 18.09 channel. + + + + It is then possible to add + + +imports = [ <home-manager/nixos> ]; + + + + to your system configuration.nix file, which will + introduce a new NixOS option called + whose type is an attribute set that maps user names to Home Manager + configurations. + + + + For example, a NixOS configuration may include the lines + + + +users.users.eve.isNormalUser = true; +home-manager.users.eve = { pkgs, ... }: { + home.packages = [ pkgs.atool pkgs.httpie ]; + programs.bash.enable = true; +}; + + + + and after a nixos-rebuild switch the user eve's + environment should include a basic Bash configuration and the packages atool + and httpie. + + + + + By default packages will be installed to + $HOME/.nix-profile but they can be installed to + /etc/profiles if + + +home-manager.useUserPackages = true; + + + is added to the system configuration. This is necessary if, for example, + you wish to use nixos-rebuild build-vm. This option may + become the default value in the future. + +
nix-darwin module -- cgit v1.2.3 From 0fa19ed55565ceca8cbbce9e9416fe4c06097115 Mon Sep 17 00:00:00 2001 From: Robert Prije Date: Sun, 24 Feb 2019 15:53:46 +1100 Subject: gnome-terminal: add support for light/dark theme variants --- modules/programs/gnome-terminal.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index fa5ce43b154..d520ef044c3 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -141,6 +141,12 @@ in description = "Whether to show the menubar by default"; }; + themeVariant = mkOption { + default = "default"; + type = types.enum [ "default" "light" "dark" ]; + description = "The theme variation to request"; + }; + profile = mkOption { default = {}; type = types.attrsOf profileSubModule; @@ -159,6 +165,7 @@ in { "${dconfPath}" = { default-show-menubar = cfg.showMenubar; + theme-variant = cfg.themeVariant; schema-version = 3; }; -- cgit v1.2.3 From d3fd287efbba3b67b2566341683289b6116eaa16 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Tue, 19 Feb 2019 10:05:47 -0800 Subject: nix-darwin: activate home-manager through postActivation --- nix-darwin/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 810b3e5ee90..b637d34b9a7 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -30,8 +30,8 @@ in }; config = mkIf (cfg.users != {}) { - system.activationScripts.extraActivation.text = - lib.concatStringsSep "\n" (lib.mapAttrsToList (username: usercfg: '' + system.activationScripts.postActivation.text = + concatStringsSep "\n" (mapAttrsToList (username: usercfg: '' echo Activating home-manager configuration for ${username} sudo -u ${username} ${usercfg.home.activationPackage}/activate '') cfg.users); -- cgit v1.2.3 From efc795920b2ea1b157c321005336a0e8c0d6cd4e Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 20 Feb 2019 23:39:49 -0800 Subject: nix-darwin: support package install through user packages --- nix-darwin/default.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index b637d34b9a7..3e4bcb38d5f 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -11,6 +11,8 @@ let config = { submoduleSupport.enable = true; + submoduleSupport.externalPackageInstall = cfg.useUserPackages; + home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; }; @@ -20,12 +22,19 @@ in { options = { - home-manager.users = mkOption { - type = types.attrsOf hmModule; - default = {}; - description = '' - Per-user Home Manager configuration. + home-manager = { + useUserPackages = mkEnableOption '' + installation of user packages through the + option. ''; + + users = mkOption { + type = types.attrsOf hmModule; + default = {}; + description = '' + Per-user Home Manager configuration. + ''; + }; }; }; -- cgit v1.2.3 From 7ec153889c05a840e372c04bca420298e5403dff Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Wed, 20 Feb 2019 23:37:03 -0800 Subject: nix-darwin: login as the user when activating --- nix-darwin/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 3e4bcb38d5f..8e318029938 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -42,7 +42,7 @@ in system.activationScripts.postActivation.text = concatStringsSep "\n" (mapAttrsToList (username: usercfg: '' echo Activating home-manager configuration for ${username} - sudo -u ${username} ${usercfg.home.activationPackage}/activate + sudo -u ${username} -i ${usercfg.home.activationPackage}/activate '') cfg.users); }; } -- cgit v1.2.3 From 267afa5a3b2851e9948adacb21013bb0656c1370 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 11 Mar 2019 00:55:32 +0100 Subject: firefox: add support for add-on packages Since no official source of packages exist the option is hidden for now. For adventurous people there is an overlay of a few selected add-ons available at https://rycee.gitlab.io/nixpkgs-firefox-addons/overlay.tar.gz This overlay is automatically built daily using the REST API available on https://addons.mozilla.org/. --- modules/programs/firefox.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index d51849e4033..97991a13ab2 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -6,6 +6,8 @@ let cfg = config.programs.firefox; + extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; + in { @@ -22,6 +24,23 @@ in description = "The unwrapped Firefox package to use."; }; + extensions = mkOption { + type = types.listOf types.package; + default = []; + example = literalExample '' + with pkgs.firefox-addons; [ + https-everywhere + privacy-badger + ] + ''; + description = '' + List of Firefox add-on packages to install. Note, it is + necessary to manually enable these extensions inside Firefox + after the first installation. + ''; + visible = false; + }; + enableAdobeFlash = mkOption { type = types.bool; default = false; @@ -60,5 +79,18 @@ in }; in [ (wrapper cfg.package { }) ]; + + home.file.".mozilla/${extensionPath}" = mkIf (cfg.extensions != []) ( + let + extensionsEnv = pkgs.buildEnv { + name = "hm-firefox-extensions"; + paths = cfg.extensions; + }; + in + { + source = "${extensionsEnv}/share/mozilla/${extensionPath}"; + recursive = true; + } + ); }; } -- cgit v1.2.3 From fd2bc150d85ef3eb2aa1c6d43f2db9e67516c9f4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 17 Mar 2019 15:29:32 +0100 Subject: faq: add entry about missing `ca.desrt.dconf` --- FAQ.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/FAQ.md b/FAQ.md index f4915692f4e..141ecc6ea6b 100644 --- a/FAQ.md +++ b/FAQ.md @@ -104,3 +104,18 @@ You can get some inspiration from the [Post your home-manager home.nix file!][1] Reddit thread. [1]: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/ + +Why do I get an error message about `ca.desrt.dconf`? +----------------------------------------------------- + +You are most likely trying to configure the GTK or Gnome Terminal but +the DBus session is not aware of the dconf service. The full error you +might get is + + error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files + +The solution on NixOS is to add + + services.dbus.packages = with pkgs; [ gnome3.dconf ]; + +to your system configuration. -- cgit v1.2.3 From 52692e299d72b5b42cf0451f9769d6f82229d692 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 12 Mar 2019 01:36:17 -0700 Subject: git: make `userName` and `userEmail` options optional --- modules/programs/git.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 71d79b0194c..a71169cec40 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -88,12 +88,14 @@ in }; userName = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = "Default user name to use."; }; userEmail = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; description = "Default user email to use."; }; @@ -168,8 +170,8 @@ in home.packages = [ cfg.package ]; programs.git.iniContent.user = { - name = cfg.userName; - email = cfg.userEmail; + name = mkIf (cfg.userName != null) cfg.userName; + email = mkIf (cfg.userEmail != null) cfg.userEmail; }; xdg.configFile = { -- cgit v1.2.3 From 70d4cf2cd9fe5d96050324bf89c555922258ec73 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 18 Mar 2019 01:25:14 +0100 Subject: Remove some use of `mkDerivation` Instead use `runCommand`, which by default uses `stdenvNoCC` resulting in a reduced dependency footprint. Fixes #612 --- home-manager/default.nix | 29 +++++++++++++++-------------- modules/files.nix | 24 +++++++++++------------- modules/home-environment.nix | 15 +++++++-------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/home-manager/default.nix b/home-manager/default.nix index 8a577edf117..c823e319fe5 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -12,11 +12,20 @@ let in -pkgs.stdenv.mkDerivation { - name = "home-manager"; - - buildCommand = '' - install -v -D -m755 ${./home-manager} $out/bin/home-manager +pkgs.runCommand + "home-manager" + { + preferLocalBuild = true; + allowSubstitutes = false; + meta = with pkgs.stdenv.lib; { + description = "A user environment configurator"; + maintainers = [ maintainers.rycee ]; + platforms = platforms.unix; + license = licenses.mit; + }; + } + '' + install -v -D -m755 ${./home-manager} $out/bin/home-manager substituteInPlace $out/bin/home-manager \ --subst-var-by bash "${pkgs.bash}" \ @@ -25,12 +34,4 @@ pkgs.stdenv.mkDerivation { --subst-var-by gnused "${pkgs.gnused}" \ --subst-var-by less "${pkgs.less}" \ --subst-var-by HOME_MANAGER_PATH '${pathStr}' - ''; - - meta = with pkgs.stdenv.lib; { - description = "A user environment configurator"; - maintainers = [ maintainers.rycee ]; - platforms = platforms.unix; - license = licenses.mit; - }; -} + '' diff --git a/modules/files.nix b/modules/files.nix index 1f79d5c1575..2e1171847b7 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -210,17 +210,16 @@ in '') (filter (v: v.onChange != "") (attrValues cfg)) ); - home-files = pkgs.stdenv.mkDerivation { - name = "home-manager-files"; - - nativeBuildInputs = [ pkgs.xlibs.lndir ]; - - preferLocalBuild = true; - allowSubstitutes = false; - - # Symlink directories and files that have the right execute bit. - # Copy files that need their execute bit changed. - buildCommand = '' + # Symlink directories and files that have the right execute bit. + # Copy files that need their execute bit changed. + home-files = pkgs.runCommand + "home-manager-files" + { + nativeBuildInputs = [ pkgs.xlibs.lndir ]; + preferLocalBuild = true; + allowSubstitutes = false; + } + ('' mkdir -p $out function insertFile() { @@ -279,7 +278,6 @@ in else builtins.toString v.executable}" \ "${builtins.toString v.recursive}" '') cfg - ); - }; + )); }; } diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 49b8727559c..e1087f8d489 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -383,13 +383,13 @@ in ${activationCmds} ''; in - pkgs.stdenv.mkDerivation { - name = "home-manager-generation"; - - preferLocalBuild = true; - allowSubstitutes = false; - - buildCommand = '' + pkgs.runCommand + "home-manager-generation" + { + preferLocalBuild = true; + allowSubstitutes = false; + } + '' mkdir -p $out cp ${activationScript} $out/activate @@ -402,7 +402,6 @@ in ${cfg.extraBuilderCommands} ''; - }; home.path = pkgs.buildEnv { name = "home-manager-path"; -- cgit v1.2.3 From eec78fbd1e1af465d6de4cf13d7e3c7101bb671d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 19 Mar 2019 22:35:13 +0100 Subject: ssh: support multiple identity files in a match block Fixes #625 --- modules/programs/ssh.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index d888a04ec66..bf6677cd9c6 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -66,10 +66,15 @@ let }; identityFile = mkOption { - type = types.nullOr types.str; - default = null; + type = with types; either (listOf str) (nullOr str); + default = []; + apply = p: + if p == null then [] + else if isString p then [p] + else p; description = '' - Specifies a file from which the user identity is read. + Specifies files from which the user identity is read. + Identities will be tried in the given order. ''; }; @@ -165,7 +170,6 @@ let ++ optional cf.forwardX11Trusted " ForwardX11Trusted yes" ++ optional cf.identitiesOnly " IdentitiesOnly yes" ++ optional (cf.user != null) " User ${cf.user}" - ++ optional (cf.identityFile != null) " IdentityFile ${cf.identityFile}" ++ optional (cf.certificateFile != null) " CertificateFile ${cf.certificateFile}" ++ optional (cf.hostname != null) " HostName ${cf.hostname}" ++ optional (cf.addressFamily != null) " AddressFamily ${cf.addressFamily}" @@ -176,6 +180,7 @@ let ++ optional (!cf.checkHostIP) " CheckHostIP no" ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ optional (cf.proxyJump != null) " ProxyJump ${cf.proxyJump}" + ++ map (file: " IdentityFile ${file}") cf.identityFile ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); -- cgit v1.2.3 From 989e636d98fc41467650d514d8e1fb5c5342cfa3 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 19 Mar 2019 23:00:17 +0100 Subject: ssh: add some basic tests --- tests/default.nix | 7 +++-- .../programs/ssh/default-config-expected.conf | 15 ++++++++++ tests/modules/programs/ssh/default-config.nix | 16 ++++++++++ tests/modules/programs/ssh/default.nix | 4 +++ .../programs/ssh/match-blocks-attrs-expected.conf | 25 ++++++++++++++++ tests/modules/programs/ssh/match-blocks-attrs.nix | 34 ++++++++++++++++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 tests/modules/programs/ssh/default-config-expected.conf create mode 100644 tests/modules/programs/ssh/default-config.nix create mode 100644 tests/modules/programs/ssh/default.nix create mode 100644 tests/modules/programs/ssh/match-blocks-attrs-expected.conf create mode 100644 tests/modules/programs/ssh/match-blocks-attrs.nix diff --git a/tests/default.nix b/tests/default.nix index 42c1781974c..cf1226d2ec0 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -26,7 +26,10 @@ import nmt { mbsync = ./modules/programs/mbsync.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; - } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + } + // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; - } // import ./modules/programs/tmux; + } + // import ./modules/programs/tmux + // import ./modules/programs/ssh; } diff --git a/tests/modules/programs/ssh/default-config-expected.conf b/tests/modules/programs/ssh/default-config-expected.conf new file mode 100644 index 00000000000..55748ea6c82 --- /dev/null +++ b/tests/modules/programs/ssh/default-config-expected.conf @@ -0,0 +1,15 @@ + + + + +Host * + ForwardAgent no + Compression no + ServerAliveInterval 0 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + diff --git a/tests/modules/programs/ssh/default-config.nix b/tests/modules/programs/ssh/default-config.nix new file mode 100644 index 00000000000..e43ee3dc769 --- /dev/null +++ b/tests/modules/programs/ssh/default-config.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + }; + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContent home-files/.ssh/config ${./default-config-expected.conf} + ''; + }; +} diff --git a/tests/modules/programs/ssh/default.nix b/tests/modules/programs/ssh/default.nix new file mode 100644 index 00000000000..d385e4ee921 --- /dev/null +++ b/tests/modules/programs/ssh/default.nix @@ -0,0 +1,4 @@ +{ + ssh-defaults = ./default-config.nix; + ssh-match-blocks = ./match-blocks-attrs.nix; +} diff --git a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf new file mode 100644 index 00000000000..76bbe2e32f1 --- /dev/null +++ b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf @@ -0,0 +1,25 @@ + + +Host * !github.com + Port 516 + IdentityFile file1 + IdentityFile file2 + +Host abc + ProxyJump jump-host + +Host xyz + ServerAliveInterval 60 + IdentityFile file + +Host * + ForwardAgent no + Compression no + ServerAliveInterval 0 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + diff --git a/tests/modules/programs/ssh/match-blocks-attrs.nix b/tests/modules/programs/ssh/match-blocks-attrs.nix new file mode 100644 index 00000000000..cb554db24bf --- /dev/null +++ b/tests/modules/programs/ssh/match-blocks-attrs.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + abc = { + identityFile = null; + proxyJump = "jump-host"; + }; + + xyz = { + identityFile = "file"; + serverAliveInterval = 60; + }; + + "* !github.com" = { + identityFile = ["file1" "file2"]; + port = 516; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContent \ + home-files/.ssh/config \ + ${./match-blocks-attrs-expected.conf} + ''; + }; +} -- cgit v1.2.3 From 24b5f620907ab57b3c01d00dd1045b2485e067bf Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 11 Feb 2019 00:57:10 -0500 Subject: bat: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/bat.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 modules/programs/bat.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 9684c3a7052..4bb80ba4f9a 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -998,6 +998,13 @@ in A new service is available: 'services.mpdris2'. ''; } + + { + time = "2019-03-19T22:56:20+00:00"; + message = '' + A new module is available: 'programs.bat'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 16517ccfc01..e1022f7f6e2 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -38,6 +38,7 @@ let (loadModule ./programs/astroid.nix { }) (loadModule ./programs/autorandr.nix { }) (loadModule ./programs/bash.nix { }) + (loadModule ./programs/bat.nix { }) (loadModule ./programs/beets.nix { }) (loadModule ./programs/browserpass.nix { }) (loadModule ./programs/chromium.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/programs/bat.nix b/modules/programs/bat.nix new file mode 100644 index 00000000000..860c5e82f54 --- /dev/null +++ b/modules/programs/bat.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.bat; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.bat = { + enable = mkEnableOption "bat, a cat clone with wings"; + + config = mkOption { + type = types.attrsOf types.str; + default = {}; + example = { + theme = "TwoDark"; + pager = "less -FR"; + }; + description = '' + Bat configuration. + ''; + }; + + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.bat ]; + + xdg.configFile."bat/config" = mkIf (cfg.config != {}) { + text = concatStringsSep "\n" ( + mapAttrsToList (n: v: ''--${n}="${v}"'') cfg.config + ); + }; + }; +} -- cgit v1.2.3 From 95e36dfe74b8d161c28601e33646e2d636026f83 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 17 Mar 2019 16:37:21 -0500 Subject: lsd: add module --- modules/misc/news.nix | 7 +++++++ modules/modules.nix | 1 + modules/programs/lsd.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 modules/programs/lsd.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 4bb80ba4f9a..131c43e5eca 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1005,6 +1005,13 @@ in A new module is available: 'programs.bat'. ''; } + + { + time = "2019-03-19T23:07:34+00:00"; + message = '' + A new module is available: 'programs.lsd'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index e1022f7f6e2..1c2015f72d7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -60,6 +60,7 @@ let (loadModule ./programs/jq.nix { }) (loadModule ./programs/keychain.nix { }) (loadModule ./programs/lesspipe.nix { }) + (loadModule ./programs/lsd.nix { }) (loadModule ./programs/man.nix { }) (loadModule ./programs/matplotlib.nix { }) (loadModule ./programs/mbsync.nix { }) diff --git a/modules/programs/lsd.nix b/modules/programs/lsd.nix new file mode 100644 index 00000000000..5e145e8c69b --- /dev/null +++ b/modules/programs/lsd.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.lsd; + + aliases = { + ls = "${pkgs.lsd}/bin/lsd"; + ll = "ls -l"; + la = "ls -a"; + lt = "ls --tree"; + lla ="ls -la"; + }; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.lsd = { + enable = mkEnableOption "lsd"; + + enableAliases = mkOption { + default = false; + type = types.bool; + description = '' + Whether to enable recommended lsd aliases. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.lsd ]; + + programs.bash.shellAliases = mkIf cfg.enableAliases aliases; + + programs.zsh.shellAliases = mkIf cfg.enableAliases aliases; + }; +} -- cgit v1.2.3 From 86af599a18e4f3cd1d4301ee55996a6ded91903b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 20 Mar 2019 23:41:02 +0100 Subject: firefox: make the extensions option visible Also change the example to use the firefox-addons available on NUR. --- modules/programs/firefox.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 97991a13ab2..1a8454916fd 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -28,7 +28,7 @@ in type = types.listOf types.package; default = []; example = literalExample '' - with pkgs.firefox-addons; [ + with pkgs.nur.repos.rycee.firefox-addons; [ https-everywhere privacy-badger ] @@ -38,7 +38,6 @@ in necessary to manually enable these extensions inside Firefox after the first installation. ''; - visible = false; }; enableAdobeFlash = mkOption { -- cgit v1.2.3 From 41356ac2673156697833d9bba32f2caa9cc1fed0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Mar 2019 00:39:36 +0100 Subject: polybar: use writeShellScriptBin --- modules/services/polybar.nix | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 547c7b90ff7..1951f685040 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -27,12 +27,6 @@ let configFile = pkgs.writeText "polybar.conf" (toPolybarIni cfg.config + "\n" + cfg.extraConfig); - script = '' - #!${pkgs.stdenv.shell} - - ${cfg.script} - ''; - in { @@ -130,7 +124,11 @@ in Service = { Type = "forking"; Environment = "PATH=${cfg.package}/bin:/run/wrappers/bin"; - ExecStart = ''${pkgs.writeScriptBin "polybar-start" script}/bin/polybar-start''; + ExecStart = + let + scriptPkg = pkgs.writeShellScriptBin "polybar-start" cfg.script; + in + "${scriptPkg}/bin/polybar-start"; }; Install = { -- cgit v1.2.3 From 5d81cb6ac772e9ef5cb285f51dfbfd13b19af854 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 21 Mar 2019 00:39:54 +0100 Subject: manual: use writeShellScriptBin --- modules/manual.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/manual.nix b/modules/manual.nix index 5e60b98faf3..d597d002dbf 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -36,7 +36,7 @@ let manualHtmlRoot = "${homeManagerManual.manual}/share/doc/home-manager/index.html"; - helpScript = pkgs.writeScriptBin "home-manager-help" '' + helpScript = pkgs.writeShellScriptBin "home-manager-help" '' #!${pkgs.bash}/bin/bash -e if [ -z "$BROWSER" ]; then -- cgit v1.2.3 From a974ce6257a3101af7ba88f629231c7670039eb1 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 22 Mar 2019 19:10:43 +0100 Subject: readme: add contact section with the IRC channel --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2386829fe51..8a03fe5ef36 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,11 @@ on how to manually perform a rollback. Now when your expectations have been built up and you are eager to try all this out you can go ahead and read the rest of this text. +Contact +------- + +You can chat with us on IRC in the channel [#home-manager][]. + Installation ------------ @@ -301,3 +306,4 @@ in your Home Manager configuration. [nixosAllowedUsers]: https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers [Z shell]: http://zsh.sourceforge.net/ [configuration options]: https://rycee.gitlab.io/home-manager/options.html +[#home-manager]: https://webchat.freenode.net/?url=irc%3A%2F%2Firc.freenode.net%2Fhome-manager -- cgit v1.2.3 From 2e1c825b90ce7a7bec6bcd8fc7e2f58404c415ce Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 23 Mar 2019 23:20:22 +0100 Subject: readme: expand contact section slightly In particular, mention that the channel is hosted by freenode and the channel logs are hosted by samueldr. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a03fe5ef36..c308724f5b1 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ all this out you can go ahead and read the rest of this text. Contact ------- -You can chat with us on IRC in the channel [#home-manager][]. +You can chat with us on IRC in the channel [#home-manager][] on +[freenode][]. The [channel logs][] are hosted courtesy of +[samueldr][]. Installation ------------ @@ -307,3 +309,6 @@ in your Home Manager configuration. [Z shell]: http://zsh.sourceforge.net/ [configuration options]: https://rycee.gitlab.io/home-manager/options.html [#home-manager]: https://webchat.freenode.net/?url=irc%3A%2F%2Firc.freenode.net%2Fhome-manager +[freenode]: https://freenode.net/ +[channel logs]: https://logs.nix.samueldr.com/home-manager/ +[samueldr]: https://github.com/samueldr/ -- cgit v1.2.3 From cf5dac9563d9376abc5e81eb9f92ac533e80d531 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 24 Mar 2019 15:26:54 +0100 Subject: random-background: minor documentation improvements --- modules/services/random-background.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index 4f0a4c43121..2af7af0b126 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -17,22 +17,22 @@ in imageDirectory = mkOption { type = types.str; - description = - '' - The directory of images from which a background should be - chosen. Should be formatted in a way understood by - systemd, e.g., '%h' is the home directory. - ''; + example = "%h/backgrounds"; + description = '' + The directory of images from which a background should be + chosen. Should be formatted in a way understood by systemd, + e.g., '%h' is the home directory. + ''; }; interval = mkOption { default = null; type = types.nullOr types.str; + example = "1h"; description = '' The duration between changing background image, set to null - to only set background when logging in. - - Should be formatted as a duration understood by systemd. + to only set background when logging in. Should be formatted + as a duration understood by systemd. ''; }; }; -- cgit v1.2.3 From 6ebf14143aee10d8a62eb660bb56ebed3ed674e2 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 24 Mar 2019 15:52:30 +0100 Subject: systemd: add some basic tests --- tests/default.nix | 13 +++++++----- tests/modules/systemd/default.nix | 4 ++++ tests/modules/systemd/services-expected.conf | 5 +++++ tests/modules/systemd/services.nix | 23 +++++++++++++++++++++ tests/modules/systemd/timers-expected.conf | 8 +++++++ tests/modules/systemd/timers.nix | 31 ++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 tests/modules/systemd/default.nix create mode 100644 tests/modules/systemd/services-expected.conf create mode 100644 tests/modules/systemd/services.nix create mode 100644 tests/modules/systemd/timers-expected.conf create mode 100644 tests/modules/systemd/timers.nix diff --git a/tests/default.nix b/tests/default.nix index cf1226d2ec0..2a0e5338847 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -27,9 +27,12 @@ import nmt { texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } - // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { - i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; - } - // import ./modules/programs/tmux - // import ./modules/programs/ssh; + // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux ( + { + i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; + } + // import ./modules/systemd + ) + // import ./modules/programs/ssh + // import ./modules/programs/tmux; } diff --git a/tests/modules/systemd/default.nix b/tests/modules/systemd/default.nix new file mode 100644 index 00000000000..cc1d5b6baa3 --- /dev/null +++ b/tests/modules/systemd/default.nix @@ -0,0 +1,4 @@ +{ + systemd-services = ./services.nix; + systemd-timers = ./timers.nix; +} diff --git a/tests/modules/systemd/services-expected.conf b/tests/modules/systemd/services-expected.conf new file mode 100644 index 00000000000..34b9618d6d3 --- /dev/null +++ b/tests/modules/systemd/services-expected.conf @@ -0,0 +1,5 @@ +[Service] +ExecStart=/some/exec/start/command --with-arguments "%i" + +[Unit] +Description=A basic test service diff --git a/tests/modules/systemd/services.nix b/tests/modules/systemd/services.nix new file mode 100644 index 00000000000..f1f7a42bb1a --- /dev/null +++ b/tests/modules/systemd/services.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + systemd.user.services."test-service@" = { + Unit = { + Description = "A basic test service"; + }; + + Service = { + ExecStart = ''/some/exec/start/command --with-arguments "%i"''; + }; + }; + + nmt.script = '' + local serviceFile=home-files/.config/systemd/user/test-service@.service + assertFileExists $serviceFile + assertFileContent $serviceFile ${./services-expected.conf} + ''; + }; +} diff --git a/tests/modules/systemd/timers-expected.conf b/tests/modules/systemd/timers-expected.conf new file mode 100644 index 00000000000..b19f044cc0b --- /dev/null +++ b/tests/modules/systemd/timers-expected.conf @@ -0,0 +1,8 @@ +[Install] +WantedBy=timers.target + +[Timer] +OnUnitActiveSec=1h 30m + +[Unit] +Description=A basic test timer diff --git a/tests/modules/systemd/timers.nix b/tests/modules/systemd/timers.nix new file mode 100644 index 00000000000..0fa0070cd77 --- /dev/null +++ b/tests/modules/systemd/timers.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + systemd.user.timers.test-timer = { + Unit = { + Description = "A basic test timer"; + }; + + Timer = { + OnUnitActiveSec = "1h 30m"; + }; + + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + + nmt.script = '' + local unitDir=home-files/.config/systemd/user + local timerFile=$unitDir/test-timer.timer + + assertFileExists $timerFile + assertFileContent $timerFile ${./timers-expected.conf} + + assertFileExists $unitDir/timers.target.wants/test-timer.timer + ''; + }; +} -- cgit v1.2.3 From 1fdb16866b377b7365768c86c9b4ac45e30bca6c Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Fri, 22 Mar 2019 13:47:49 +0200 Subject: systemd: add support for session variables Via environment.d(5). --- modules/systemd.nix | 35 ++++++++++++++++++---- tests/modules/systemd/default.nix | 1 + .../systemd/session-variables-expected.conf | 2 ++ tests/modules/systemd/session-variables.nix | 18 +++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tests/modules/systemd/session-variables-expected.conf create mode 100644 tests/modules/systemd/session-variables.nix diff --git a/modules/systemd.nix b/modules/systemd.nix index f7325b41f1a..051aee94180 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -12,7 +12,8 @@ let || cfg.sockets != {} || cfg.targets != {} || cfg.timers != {} - || cfg.paths != {}; + || cfg.paths != {} + || cfg.sessionVariables != {}; toSystemdIni = generators.toINI { mkKeyValue = key: value: @@ -85,6 +86,13 @@ let } ''; + sessionVariables = mkIf (cfg.sessionVariables != {}) { + "environment.d/10-home-manager.conf".text = + concatStringsSep "\n" ( + mapAttrsToList (n: v: "${n}=${toString v}") cfg.sessionVariables + ) + "\n"; + }; + in { @@ -156,6 +164,20 @@ in start is considered successful. ''; }; + + sessionVariables = mkOption { + default = {}; + type = with types; attrsOf (either int str); + example = { EDITOR = "vim"; }; + description = '' + Environment variables that will be set for the user session. + The variable values must be as described in + + environment.d + 5 + . + ''; + }; }; }; @@ -168,7 +190,7 @@ in let names = concatStringsSep ", " ( attrNames ( - cfg.services // cfg.sockets // cfg.targets // cfg.timers // cfg.paths + cfg.services // cfg.sockets // cfg.targets // cfg.timers // cfg.paths // cfg.sessionVariables ) ); in @@ -180,8 +202,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 { - xdg.configFile = - listToAttrs ( + xdg.configFile = mkMerge [ + (listToAttrs ( (buildServices "service" cfg.services) ++ (buildServices "socket" cfg.sockets) @@ -191,7 +213,10 @@ in (buildServices "timer" cfg.timers) ++ (buildServices "path" cfg.paths) - ); + )) + + sessionVariables + ]; # Run systemd service reload if user is logged in. If we're # running this from the NixOS module then XDG_RUNTIME_DIR is not diff --git a/tests/modules/systemd/default.nix b/tests/modules/systemd/default.nix index cc1d5b6baa3..c1779ac59fb 100644 --- a/tests/modules/systemd/default.nix +++ b/tests/modules/systemd/default.nix @@ -1,4 +1,5 @@ { systemd-services = ./services.nix; + systemd-session-variables = ./session-variables.nix; systemd-timers = ./timers.nix; } diff --git a/tests/modules/systemd/session-variables-expected.conf b/tests/modules/systemd/session-variables-expected.conf new file mode 100644 index 00000000000..5b6e80bc32b --- /dev/null +++ b/tests/modules/systemd/session-variables-expected.conf @@ -0,0 +1,2 @@ +V_int=1 +V_str=2 diff --git a/tests/modules/systemd/session-variables.nix b/tests/modules/systemd/session-variables.nix new file mode 100644 index 00000000000..7cfb4a6c7c3 --- /dev/null +++ b/tests/modules/systemd/session-variables.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + systemd.user.sessionVariables = { + V_int = 1; + V_str = "2"; + }; + + nmt.script = '' + local envFile=home-files/.config/environment.d/10-home-manager.conf + assertFileExists $envFile + assertFileContent $envFile ${./session-variables-expected.conf} + ''; + }; +} -- cgit v1.2.3 From f77d6b7a2d8e404a9ad125ea2409af7f6e4b7fbc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 26 Mar 2019 18:05:44 +0100 Subject: taffybar: restart the service on failure --- modules/services/taffybar.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index 3ccec98a448..23af231ef7a 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -35,6 +35,7 @@ in Service = { ExecStart = "${cfg.package}/bin/taffybar"; + Restart = "on-failure"; }; Install = { -- cgit v1.2.3 From bc2b7d4f0972412f6f0d5792560a90adc4f2d4c1 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Wed, 27 Mar 2019 13:51:29 -0600 Subject: qt: use xdg.configHome instead of hard-coding --- modules/misc/qt.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index c644c70409a..c814f0ddecd 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -35,7 +35,7 @@ in home.activation.useGtkThemeInQt4 = dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ - --set $HOME/.config/Trolltech.conf Qt style GTK+ + --set "${config.xdg.configHome}/Trolltech.conf" Qt style GTK+ ''; }; } -- cgit v1.2.3 From 03162970cd6dadfac58f169cd50aed5a5aeec14f Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Tue, 26 Mar 2019 18:26:47 +0200 Subject: gnome-terminal: add cursor and highlight color settings --- modules/programs/gnome-terminal.nix | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix index d520ef044c3..9a44364491d 100644 --- a/modules/programs/gnome-terminal.nix +++ b/modules/programs/gnome-terminal.nix @@ -11,6 +11,22 @@ let . ${pkgs.gnome3.vte}/etc/profile.d/vte.sh ''; + backForeSubModule = types.submodule ( + { ... }: { + options = { + foreground = mkOption { + type = types.str; + description = "The foreground color."; + }; + + background = mkOption { + type = types.str; + description = "The background color."; + }; + }; + } + ); + profileColorsSubModule = types.submodule ( { ... }: { options = { @@ -34,6 +50,18 @@ let type = types.listOf types.str; description = "The terminal palette."; }; + + cursor = mkOption { + default = null; + type = types.nullOr backForeSubModule; + description = "The color for the terminal cursor."; + }; + + highlight = mkOption { + default = null; + type = types.nullOr backForeSubModule; + description = "The colors for the terminal’s highlighted area."; + }; }; } ); @@ -70,6 +98,15 @@ let description = "The font name, null to use system default."; }; + allowBold = mkOption { + default = null; + type = types.nullOr types.bool; + description = '' + If true, allow applications in the + terminal to make text boldface. + ''; + }; + scrollOnOutput = mkOption { default = true; type = types.bool; @@ -115,6 +152,9 @@ let background-color = pcfg.colors.backgroundColor; palette = pcfg.colors.palette; } + // optionalAttrs (pcfg.allowBold != null) { + allow-bold = pcfg.allowBold; + } // ( if (pcfg.colors.boldColor == null) then { bold-color-same-as-fg = true; } @@ -123,6 +163,24 @@ let bold-color = pcfg.colors.boldColor; } ) + // ( + if (pcfg.colors.cursor != null) + then { + cursor-colors-set = true; + cursor-foreground-color = pcfg.colors.cursor.foreground; + cursor-background-color = pcfg.colors.cursor.background; + } + else { cursor-colors-set = false; } + ) + // ( + if (pcfg.colors.highlight != null) + then { + highlight-colors-set = true; + highlight-foreground-color = pcfg.colors.highlight.foreground; + highlight-background-color = pcfg.colors.highlight.background; + } + else { highlight-colors-set = false; } + ) ) ); -- cgit v1.2.3 From e26ad2026c5d2571d914335f5671c8ea7eaae6d5 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 12:57:08 +0200 Subject: gtk: use attrsOf instead of attrs --- modules/misc/gtk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index c88ee4c000b..1222db4ecab 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -120,7 +120,7 @@ in gtk3 = { extraConfig = mkOption { - type = types.attrs; + type = with types; attrsOf (either bool (either int str)); default = {}; example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; description = '' -- cgit v1.2.3 From e85804efa290d1ac5de3ecb64b6686437a314982 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 12:57:34 +0200 Subject: feh: use attrsOf instead of attrs --- modules/programs/feh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/feh.nix b/modules/programs/feh.nix index 12d828ec583..4342181fa4a 100644 --- a/modules/programs/feh.nix +++ b/modules/programs/feh.nix @@ -17,7 +17,7 @@ in keybindings = mkOption { default = {}; - type = types.attrs; + type = types.attrsOf types.str; example = { zoom_in = "plus"; zoom_out = "minus"; }; description = '' Set keybindings. -- cgit v1.2.3 From b690a8be2f179e2ab242d010e65b910cc66e9a4b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 13:00:02 +0200 Subject: bash: use attrsOf instead of attrs --- modules/programs/bash.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 14a158a2423..92ce18d25bb 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -72,7 +72,7 @@ in sessionVariables = mkOption { default = {}; - type = types.attrs; + type = with types; attrsOf (either int str); example = { MAILCHECK = 30; }; description = '' Environment variables that will be set for the Bash session. @@ -81,12 +81,12 @@ in shellAliases = mkOption { default = {}; + type = types.attrsOf types.str; example = { ll = "ls -l"; ".." = "cd .."; }; description = '' An attribute set that maps aliases (the top level attribute names in this option) to command strings or directly to build outputs. ''; - type = types.attrs; }; enableAutojump = mkOption { -- cgit v1.2.3 From 13d2c470be30622108609635cda79c09cd11429f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 13:00:09 +0200 Subject: home-environment: use attrsOf instead of attrs --- modules/home-environment.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index e1087f8d489..a25501fd7f2 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -146,7 +146,7 @@ in home.sessionVariables = mkOption { default = {}; - type = types.attrs; + type = with types; attrsOf (either int str); example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; description = '' Environment variables to always set at login. -- cgit v1.2.3 From fd50f5465f979516d32c1d89a5984412a99b9506 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 13:22:27 +0200 Subject: zsh: use attrsOf instead of attrs --- modules/programs/zsh.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 55ed4757d4b..ad59ad74934 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -167,7 +167,7 @@ in An attribute set that maps aliases (the top level attribute names in this option) to command strings or directly to build outputs. ''; - type = types.attrs; + type = types.attrsOf types.str; }; enableCompletion = mkOption { @@ -202,7 +202,7 @@ in sessionVariables = mkOption { default = {}; - type = types.attrs; + type = with types; attrsOf (either int str); example = { MAILCHECK = 30; }; description = "Environment variables that will be set for zsh session."; }; -- cgit v1.2.3 From 4323b35198b2327c3f714cc6915bd5d694d7576c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 31 Mar 2019 13:29:30 +0200 Subject: pam: use attrsOf instead of attrs --- modules/misc/pam.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index 6ace2bfdaac..9cebc0a8b43 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -14,7 +14,7 @@ in options = { pam.sessionVariables = mkOption { default = {}; - type = types.attrs; + type = with types; attrsOf (either int str); example = { EDITOR = "vim"; }; description = '' Environment variables that will be set for the PAM session. -- cgit v1.2.3 From 995fa3af36a6555dcf302117b71edbee0d7542f5 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 31 Mar 2019 17:01:41 +0300 Subject: qt: add option platformTheme This deprecates `useGtkTheme=true` with the intention of replacing it with the `platformTheme` selection. --- modules/misc/qt.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index c814f0ddecd..bb59044dd90 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -12,27 +12,64 @@ in { meta.maintainers = [ maintainers.rycee ]; + imports = [ + (mkChangedOptionModule + [ "qt" "useGtkTheme" ] + [ "qt" "platformTheme" ] + (config: + if getAttrFromPath [ "qt" "useGtkTheme" ] config + then "gtk" + else null)) + ]; + options = { qt = { enable = mkEnableOption "Qt 4 and 5 configuration"; - useGtkTheme = mkOption { - type = types.bool; - default = false; + platformTheme = mkOption { + type = types.nullOr (types.enum [ "gtk" "gnome" ]); + default = null; + example = "gnome"; + relatedPackages = [ + "qgnomeplatform" + ["libsForQt5" "qtstyleplugins"] + ]; description = '' - Whether Qt 4 and 5 should be set up to use the GTK theme - settings. + Selects the platform theme to use for Qt applications. + The options are + + + gtk + Use GTK theme with + qtstyleplugins + + + + gnome + Use GNOME theme with + qgnomeplatform + + + ''; }; }; }; - config = mkIf (cfg.enable && cfg.useGtkTheme) { - home.sessionVariables.QT_QPA_PLATFORMTHEME = "gtk2"; - home.packages = [ pkgs.libsForQt5.qtstyleplugins ]; + config = mkIf (cfg.enable && cfg.platformTheme != null) { + home.sessionVariables.QT_QPA_PLATFORMTHEME = + if cfg.platformTheme == "gnome" then "gnome" else "gtk2"; + + home.packages = + if cfg.platformTheme == "gnome" + then [ pkgs.qgnomeplatform ] + else [ pkgs.libsForQt5.qtstyleplugins ]; + xsession.profileExtra = "systemctl --user import-environment QT_QPA_PLATFORMTHEME"; + # Enable GTK+ style for Qt4 in either case. + # It doesn’t support the platform theme packages. home.activation.useGtkThemeInQt4 = dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ --set "${config.xdg.configHome}/Trolltech.conf" Qt style GTK+ -- cgit v1.2.3 From 652c69424411e332fb9caaa6e1d8ee05aff90af4 Mon Sep 17 00:00:00 2001 From: "Wael M. Nasreddine" Date: Thu, 4 Apr 2019 15:04:24 -0700 Subject: programs.tmux: implement secureSocket --- modules/programs/tmux.nix | 8 +++++++- tests/modules/programs/tmux/default.nix | 1 + tests/modules/programs/tmux/hm-session-vars.sh | 5 +++++ tests/modules/programs/tmux/secure-socket-enabled.nix | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/tmux/hm-session-vars.sh create mode 100644 tests/modules/programs/tmux/secure-socket-enabled.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index b436948bba2..b65da1b14e7 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -251,7 +251,7 @@ in ++ optional cfg.tmuxinator.enable pkgs.tmuxinator ++ optional cfg.tmuxp.enable pkgs.tmuxp; - home.file.".tmux.conf".text = tmuxConf; + home.file.".tmux.conf".text = tmuxConf; } (mkIf cfg.sensibleOnTop { @@ -264,6 +264,12 @@ in ''; }) + (mkIf cfg.secureSocket { + home.sessionVariables = { + TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}''; + }; + }) + (mkIf (cfg.plugins != []) { assertions = [( let diff --git a/tests/modules/programs/tmux/default.nix b/tests/modules/programs/tmux/default.nix index 5bc31177298..16d6d63e438 100644 --- a/tests/modules/programs/tmux/default.nix +++ b/tests/modules/programs/tmux/default.nix @@ -2,4 +2,5 @@ tmux-emacs-with-plugins = ./emacs-with-plugins.nix; tmux-not-enabled = ./not-enabled.nix; tmux-vi-all-true = ./vi-all-true.nix; + tmux-secure-socket-enabled = ./secure-socket-enabled.nix; } diff --git a/tests/modules/programs/tmux/hm-session-vars.sh b/tests/modules/programs/tmux/hm-session-vars.sh new file mode 100644 index 00000000000..40d9c24b50d --- /dev/null +++ b/tests/modules/programs/tmux/hm-session-vars.sh @@ -0,0 +1,5 @@ +# Only source this once. +if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi +export __HM_SESS_VARS_SOURCED=1 + +export TMUX_TMPDIR="${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}" diff --git a/tests/modules/programs/tmux/secure-socket-enabled.nix b/tests/modules/programs/tmux/secure-socket-enabled.nix new file mode 100644 index 00000000000..34e9129c5a4 --- /dev/null +++ b/tests/modules/programs/tmux/secure-socket-enabled.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.tmux = { + enable = true; + secureSocket = true; + }; + + nmt.script = '' + assertFileExists home-path/etc/profile.d/hm-session-vars.sh + assertFileContent home-path/etc/profile.d/hm-session-vars.sh ${./hm-session-vars.sh} + ''; + }; +} -- cgit v1.2.3 From 2c07829be2bcae55e04997b19719ff902a44016d Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 2 Apr 2019 21:21:38 -0700 Subject: home-manager: use `callPackage` where appropriate --- default.nix | 7 +++---- home-manager/default.nix | 16 ++++++++-------- home-manager/install.nix | 4 ++-- modules/programs/home-manager.nix | 3 +-- overlay.nix | 4 +++- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/default.nix b/default.nix index 9ae18232316..1e3ff09e0bc 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,12 @@ { pkgs ? import {} }: rec { - home-manager = import ./home-manager { - inherit pkgs; + home-manager = pkgs.callPackage ./home-manager { path = toString ./.; }; - install = import ./home-manager/install.nix { - inherit home-manager pkgs; + install = pkgs.callPackage ./home-manager/install.nix { + inherit home-manager; }; nixos = import ./nixos; diff --git a/home-manager/default.nix b/home-manager/default.nix index c823e319fe5..82acb2fab63 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,4 +1,4 @@ -{ pkgs +{ runCommand, lib, bash, coreutils, findutils, gnused, less # Extra path to Home Manager. If set then this path will be tried # before `$HOME/.config/nixpkgs/home-manager` and @@ -12,12 +12,12 @@ let in -pkgs.runCommand +runCommand "home-manager" { preferLocalBuild = true; allowSubstitutes = false; - meta = with pkgs.stdenv.lib; { + meta = with lib; { description = "A user environment configurator"; maintainers = [ maintainers.rycee ]; platforms = platforms.unix; @@ -28,10 +28,10 @@ pkgs.runCommand install -v -D -m755 ${./home-manager} $out/bin/home-manager substituteInPlace $out/bin/home-manager \ - --subst-var-by bash "${pkgs.bash}" \ - --subst-var-by coreutils "${pkgs.coreutils}" \ - --subst-var-by findutils "${pkgs.findutils}" \ - --subst-var-by gnused "${pkgs.gnused}" \ - --subst-var-by less "${pkgs.less}" \ + --subst-var-by bash "${bash}" \ + --subst-var-by coreutils "${coreutils}" \ + --subst-var-by findutils "${findutils}" \ + --subst-var-by gnused "${gnused}" \ + --subst-var-by less "${less}" \ --subst-var-by HOME_MANAGER_PATH '${pathStr}' '' diff --git a/home-manager/install.nix b/home-manager/install.nix index 28ffe221bad..8abf6af9e15 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -1,6 +1,6 @@ -{ home-manager, pkgs }: +{ home-manager, runCommand }: -pkgs.runCommand +runCommand "home-manager-install" { propagatedBuildInputs = [ home-manager ]; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index cc76b0110e2..42e3c8a384f 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -34,8 +34,7 @@ in config = mkIf (cfg.enable && !config.submoduleSupport.enable) { home.packages = [ - (import ../../home-manager { - inherit pkgs; + (pkgs.callPackage ../../home-manager { inherit (cfg) path; }) ]; diff --git a/overlay.nix b/overlay.nix index 6c64fa6b191..fa779fe0370 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,3 +1,5 @@ self: super: { - home-manager = import ./home-manager { pkgs = super; }; + home-manager = super.callPackage ./home-manager { + path = toString ./.; + }; } -- cgit v1.2.3 From f8b03f5750679d6686eefa60d5de8cfd932b8997 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Apr 2019 13:14:15 +0200 Subject: modules: register the base modules path This is needed, for example, to support relative paths when disabling modules. --- modules/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/default.nix b/modules/default.nix index 4d0e9cc71b1..9f6404ff9cc 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -23,6 +23,9 @@ let modules = [ configuration ] ++ (import ./modules.nix { inherit check lib pkgs; }); + specialArgs = { + modulesPath = builtins.toString ./.; + }; }; module = showWarnings ( -- cgit v1.2.3 From c48db4fbba204365c2750bef1665e26fae156590 Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Tue, 9 Apr 2019 16:12:36 +0100 Subject: xcape: add service --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/services/xcape.nix | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 modules/services/xcape.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 131c43e5eca..29523c92505 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1012,6 +1012,13 @@ in A new module is available: 'programs.lsd'. ''; } + + { + time = "2019-04-09T20:10:22+00:00"; + message = '' + A new module is available: 'services.xcape'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1c2015f72d7..9153bb26210 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -118,6 +118,7 @@ let (loadModule ./services/window-managers/awesome.nix { }) (loadModule ./services/window-managers/i3.nix { }) (loadModule ./services/window-managers/xmonad.nix { }) + (loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xscreensaver.nix { }) (loadModule ./systemd.nix { }) diff --git a/modules/services/xcape.nix b/modules/services/xcape.nix new file mode 100644 index 00000000000..26115a93062 --- /dev/null +++ b/modules/services/xcape.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.xcape; + +in + +{ + meta.maintainers = [ maintainers.nickhu ]; + + options = { + services.xcape = { + enable = mkEnableOption "xcape"; + + timeout = mkOption { + type = types.nullOr types.int; + default = null; + example = 500; + description = '' + If you hold a key longer than this timeout, xcape will not + generate a key event. Default is 500 ms. + ''; + }; + + mapExpression = mkOption { + type = types.attrsOf types.str; + default = {}; + example = { Shift_L = "Escape"; Control_L = "Control_L|O"; }; + description = '' + The value has the grammar Key[|OtherKey]. + + + The list of key names is found in the header file + X11/keysymdef.h (remove the + XK_ prefix). Note that due to limitations + of X11 shifted keys must be specified as a shift key + followed by the key to be pressed rather than the actual + name of the character. For example to generate "{" the + expression Shift_L|bracketleft could be + used (assuming that you have a key with "{" above "["). + + + You can also specify keys in decimal (prefix #), octal (#0), + or hexadecimal (#0x). They will be interpreted as keycodes + unless no corresponding key name is found. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.xcape = { + Unit = { + Description = "xcape"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "forking"; + ExecStart = "${pkgs.xcape}/bin/xcape" + + optionalString (cfg.timeout != null) " -t ${toString cfg.timeout}" + + optionalString (cfg.mapExpression != {}) + " -e '${builtins.concatStringsSep ";" + (attrsets.mapAttrsToList (n: v: "${n}=${v}") cfg.mapExpression)}'"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 67aee78fdf44c15a41b88270cd52e5a8a7e39e31 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 10 Apr 2019 01:31:22 +0200 Subject: home-manager: remove unnecessary error message An error message about the erroneous option is already printed by `getopts` so there is no need to print it again. --- home-manager/home-manager | 1 - 1 file changed, 1 deletion(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 65c54c63712..0cf65676cfd 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -424,7 +424,6 @@ while getopts 2f:I:A:vnh opt; do exit 0 ;; *) - errorEcho "Unknown option -$OPTARG" doHelp >&2 exit 1 ;; -- cgit v1.2.3 From 6cd5c8fca5ed00099060317a9fa99c1ceed72a83 Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Wed, 10 Apr 2019 13:39:25 +0100 Subject: alot: fix address book completion regex --- modules/programs/alot-accounts.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix index 2def5fd1a75..8f3ffdfb31e 100644 --- a/modules/programs/alot-accounts.nix +++ b/modules/programs/alot-accounts.nix @@ -20,11 +20,11 @@ with lib; type = "shellcommand"; command = "'${pkgs.notmuch}/bin/notmuch address --format=json --output=recipients date:6M..'"; regexp = - "'\[?{" + "'\\[?{" + ''"name": "(?P.*)", '' + ''"address": "(?P.+)", '' + ''"name-addr": ".*"'' - + "}[,\]]?'"; + + "}[,\\]]?'"; shellcommand_external_filtering = "False"; }; example = literalExample '' -- cgit v1.2.3 From b6e1d826850fdcd79e067677ec0d5ec20fdf12b7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 11 Apr 2019 01:09:27 +0200 Subject: home-environment: make `home.keyboard` optional When set to `null` then the `xsession` module will not attempt to manage the keyboard settings. --- modules/home-environment.nix | 7 +++-- modules/xsession.nix | 66 +++++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index a25501fd7f2..c577c3072ac 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -139,9 +139,12 @@ in }; home.keyboard = mkOption { - type = keyboardSubModule; + type = types.nullOr keyboardSubModule; default = {}; - description = "Keyboard configuration."; + description = '' + Keyboard configuration. Set to null to + disable Home Manager keyboard management. + ''; }; home.sessionVariables = mkOption { diff --git a/modules/xsession.nix b/modules/xsession.nix index 1c562dd0dfc..42fe45bb18a 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -66,39 +66,43 @@ in }; config = mkIf cfg.enable { - systemd.user.services.setxkbmap = { - Unit = { - Description = "Set up keyboard in X"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; + systemd.user = { + services = mkIf (config.home.keyboard != null) { + setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; + }; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - ExecStart = - let - args = concatStringsSep " " ( - [ - "-layout '${config.home.keyboard.layout}'" - "-variant '${config.home.keyboard.variant}'" - ] ++ - (map (v: "-option '${v}'") config.home.keyboard.options) - ); - in - "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; - }; - }; - - # A basic graphical session target for Home Manager. - systemd.user.targets.hm-graphical-session = { - Unit = { - Description = "Home Manager X session"; - Requires = [ "graphical-session-pre.target" ]; - BindsTo = [ "graphical-session.target" ]; + # A basic graphical session target for Home Manager. + targets.hm-graphical-session = { + Unit = { + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; + }; }; }; -- cgit v1.2.3 From d49b514aa610f7412e4d030b159daf978ee2281e Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Wed, 10 Apr 2019 14:24:35 +0100 Subject: make notmuch search.exclude_tags configurable --- modules/programs/notmuch.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index a5ded5680e4..1886aee3942 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -46,7 +46,7 @@ let }; search = { - exclude_tags = [ "deleted" "spam" ]; + exclude_tags = cfg.search.excludeTags; }; } cfg.extraConfig; @@ -138,6 +138,19 @@ in ''; }; }; + + search = { + excludeTags = mkOption { + type = types.listOf types.str; + default = [ "deleted" "spam" ]; + example = [ "trash" "spam" ]; + description = '' + A list of tags that will be excluded from search results by + default. Using an excluded tag in a query will override that + exclusion. + ''; + }; + }; }; }; -- cgit v1.2.3 From 12cb82af912c3aa1c664c018c8f08cf17bc34c08 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 10 Apr 2019 00:40:45 +0200 Subject: systemd: make the unit option type more robust This should allow more sensible merging behavior. In particular, with this change it is possible to use, for example, `mkForce` for greater control of merging. Fixes #543 --- modules/misc/news.nix | 30 ++++++++++++++++++++++++++++++ modules/systemd.nix | 22 ++++++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 29523c92505..b2ce52960a8 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1019,6 +1019,36 @@ in A new module is available: 'services.xcape'. ''; } + + { + time = "2019-04-11T22:50:10+00:00"; + condition = hostPlatform.isLinux; + message = '' + The type used for the systemd unit options under + + systemd.user.services, systemd.user.sockets, etc. + + has been changed to offer more robust merging of configurations. + + If you don't override values within systemd units then you are not + affected by this change. Unfortunately, if you do override unit values + you may encounter errors due to this change. + + In particular, if you get an error saying that a "unique option" is + "defined multiple times" then you need to use 'lib.mkForce'. For + example, + + systemd.user.services.foo.Service.ExecStart = "/foo/bar"; + + becomes + + systemd.user.services.foo.Service.ExecStart = lib.mkForce "/foo/bar"; + + We had to make this change because the old merging was causing too + many confusing situations for people. Apologies for potentially + breaking your configuration! + ''; + } ]; }; } diff --git a/modules/systemd.nix b/modules/systemd.nix index 051aee94180..2a67bb31848 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -58,9 +58,14 @@ let servicesStartTimeoutMs = builtins.toString cfg.servicesStartTimeoutMs; - attrsRecursivelyMerged = types.attrs // { - merge = loc: foldl' (res: def: recursiveUpdate res def.value) {}; - }; + unitType = unitKind: with types; + let + primitive = either bool (either int str); + in + attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) + // { + description = "systemd ${unitKind} unit configuration"; + }; unitDescription = type: '' Definition of systemd per-user ${type} units. Attributes are @@ -78,6 +83,7 @@ let { Unit = { Description = "Example description"; + Documentation = [ "man:example(1)" "man:example(5)" ]; }; ${type} = { @@ -113,35 +119,35 @@ in services = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "service"; description = unitDescription "service"; example = unitExample "Service"; }; sockets = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "socket"; description = unitDescription "socket"; example = unitExample "Socket"; }; targets = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "target"; description = unitDescription "target"; example = unitExample "Target"; }; timers = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "timer"; description = unitDescription "timer"; example = unitExample "Timer"; }; paths = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "path"; description = unitDescription "path"; example = unitExample "Path"; }; -- cgit v1.2.3 From 3db46fa9bf08e22c0d1615a4ba2325b6af64dc76 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 12 Apr 2019 00:51:54 +0200 Subject: news: limit mpdris2 and xcape news to Linux These modules are limited to Linux since they define systemd services. --- modules/misc/news.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b2ce52960a8..f9b5eba7107 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -994,6 +994,7 @@ in { time = "2019-02-24T00:32:23+00:00"; + condition = hostPlatform.isLinux; message = '' A new service is available: 'services.mpdris2'. ''; @@ -1015,6 +1016,7 @@ in { time = "2019-04-09T20:10:22+00:00"; + condition = hostPlatform.isLinux; message = '' A new module is available: 'services.xcape'. ''; -- cgit v1.2.3 From 30a16e3a87d509735731706379dce9c0223fe5b9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 12 Apr 2019 17:56:14 +0200 Subject: polybar: change restart trigger to contain a string The systemd unit type is a bit more strict now and needs an explicit string in this position. --- modules/services/polybar.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 1951f685040..8bc4539d769 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -118,7 +118,9 @@ in Description = "Polybar status bar"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; - X-Restart-Triggers = [ config.xdg.configFile."polybar/config".source ]; + X-Restart-Triggers = [ + "${config.xdg.configFile."polybar/config".source}" + ]; }; Service = { -- cgit v1.2.3 From a6f0fa90f73eab34744bd1dadbc73490e86be057 Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Wed, 10 Apr 2019 12:50:44 +0100 Subject: email: add facility for email aliases Also update the notmuch and alot modules to include support for email aliases. --- modules/accounts/email.nix | 7 +++++++ modules/programs/alot.nix | 3 +++ modules/programs/notmuch.nix | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index ea9955d12a4..6bde6da0be9 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -207,6 +207,13 @@ let description = "The email address of this account."; }; + aliases = mkOption { + type = types.listOf (types.strMatching ".*@.*"); + default = []; + example = [ "webmaster@example.org" "admin@example.org" ]; + description = "Alternative email addresses of this account."; + }; + realName = mkOption { type = types.str; example = "Jane Doe"; diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix index 39c701e5c77..341bb04a98e 100644 --- a/modules/programs/alot.nix +++ b/modules/programs/alot.nix @@ -22,6 +22,9 @@ let sendmail_command = optionalString (alot.sendMailCommand != null) alot.sendMailCommand; } + // optionalAttrs (aliases != []) { + aliases = concatStringsSep "," aliases; + } // optionalAttrs (gpg != null) { gpg_key = gpg.key; encrypt_by_default = if gpg.encryptByDefault then "all" else "none"; diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 1886aee3942..e39747c8bab 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -42,7 +42,9 @@ let in { name = catAttrs "realName" primary; primary_email = catAttrs "address" primary; - other_email = catAttrs "address" secondaries; + other_email = catAttrs "aliases" primary + ++ catAttrs "address" secondaries + ++ catAttrs "aliases" secondaries; }; search = { -- cgit v1.2.3 From cb93316fed4f7002f332392c70b9e9844fab1a57 Mon Sep 17 00:00:00 2001 From: ash lea Date: Sat, 13 Apr 2019 22:52:10 -0400 Subject: browserpass: update app id --- modules/programs/browserpass.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/programs/browserpass.nix b/modules/programs/browserpass.nix index deb29b64d58..de549513a61 100644 --- a/modules/programs/browserpass.nix +++ b/modules/programs/browserpass.nix @@ -31,11 +31,11 @@ in { else ".config/google-chrome/NativeMessagingHosts"; in [ { - target = "${dir}/com.dannyvankooten.browserpass.json"; + target = "${dir}/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-host.json"; } { - target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + target = "${dir}/../policies/managed/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-policy.json"; } ] @@ -45,11 +45,11 @@ in { else ".config/chromium/NativeMessagingHosts"; in [ { - target = "${dir}/com.dannyvankooten.browserpass.json"; + target = "${dir}/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-host.json"; } { - target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + target = "${dir}/../policies/managed/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-policy.json"; } ] @@ -58,8 +58,8 @@ in { target = (if isDarwin then "Library/Application Support/Mozilla/NativeMessagingHosts" else ".mozilla/native-messaging-hosts") - + "/com.dannyvankooten.browserpass.json"; - source = "${pkgs.browserpass}/lib/mozilla/native-messaging-hosts/com.dannyvankooten.browserpass.json"; + + "/com.github.browserpass.native.json"; + source = "${pkgs.browserpass}/lib/mozilla/native-messaging-hosts/com.github.browserpass.native.json"; } ] else if x == "vivaldi" then let dir = if isDarwin @@ -67,11 +67,11 @@ in { else ".config/vivaldi/NativeMessagingHosts"; in [ { - target = "${dir}/com.dannyvankooten.browserpass.json"; + target = "${dir}/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-host.json"; } { - target = "${dir}/../policies/managed/com.dannyvankooten.browserpass.json"; + target = "${dir}/../policies/managed/com.github.browserpass.native.json"; source = "${pkgs.browserpass}/etc/chrome-policy.json"; } ] -- cgit v1.2.3 From 1806e5511efb06cd64c4bdd4e0a98ab1b5ad1542 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 14 Apr 2019 13:49:55 +0300 Subject: skim: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/skim.nix | 128 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 modules/programs/skim.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f9b5eba7107..0083b661a29 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1051,6 +1051,13 @@ in breaking your configuration! ''; } + + { + time = "2019-04-14T15:35:16+00:00"; + message = '' + A new module is available: 'programs.skim'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 9153bb26210..4822f8428b4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -75,6 +75,7 @@ let (loadModule ./programs/opam.nix { }) (loadModule ./programs/pidgin.nix { }) (loadModule ./programs/rofi.nix { }) + (loadModule ./programs/skim.nix { }) (loadModule ./programs/ssh.nix { }) (loadModule ./programs/taskwarrior.nix { }) (loadModule ./programs/termite.nix { }) diff --git a/modules/programs/skim.nix b/modules/programs/skim.nix new file mode 100644 index 00000000000..4b8f8ee37e0 --- /dev/null +++ b/modules/programs/skim.nix @@ -0,0 +1,128 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.skim; + +in + +{ + options.programs.skim = { + enable = mkEnableOption "skim - a command-line fuzzy finder"; + + defaultCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type f"; + description = '' + The command that gets executed as the default source for skim + when running. + ''; + }; + + defaultOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--height 40%" "--prompt ⟫" ]; + description = '' + Extra command line options given to skim by default. + ''; + }; + + fileWidgetCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type f"; + description = '' + The command that gets executed as the source for skim for the + CTRL-T keybinding. + ''; + }; + + fileWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--preview 'head {}'" ]; + description = '' + Command line options for the CTRL-T keybinding. + ''; + }; + + changeDirWidgetCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "fd --type d" ; + description = '' + The command that gets executed as the source for skim for the + ALT-C keybinding. + ''; + }; + + changeDirWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--preview 'tree -C {} | head -200'" ]; + description = '' + Command line options for the ALT-C keybinding. + ''; + }; + + historyWidgetOptions = mkOption { + type = types.listOf types.str; + default = []; + example = [ "--tac" "--exact" ]; + description = '' + Command line options for the CTRL-R keybinding. + ''; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.skim ]; + + home.sessionVariables = + mapAttrs (n: v: toString v) ( + filterAttrs (n: v: v != [] && v != null) { + SKIM_ALT_C_COMMAND = cfg.changeDirWidgetCommand; + SKIM_ALT_C_OPTS = cfg.changeDirWidgetOptions; + SKIM_CTRL_R_OPTS = cfg.historyWidgetOptions; + SKIM_CTRL_T_COMMAND = cfg.fileWidgetCommand; + SKIM_CTRL_T_OPTS = cfg.fileWidgetOptions; + SKIM_DEFAULT_COMMAND = cfg.defaultCommand; + SKIM_DEFAULT_OPTS = cfg.defaultOptions; + } + ); + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then + . ${pkgs.skim}/share/skim/completion.bash + . ${pkgs.skim}/share/skim/key-bindings.bash + fi + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + if [[ $options[zle] = on ]]; then + . ${pkgs.skim}/share/skim/completion.zsh + . ${pkgs.skim}/share/skim/key-bindings.zsh + fi + ''; + }; +} -- cgit v1.2.3 From ff602cb906e3dd5d5f89c7c1d0fae65bc67119a0 Mon Sep 17 00:00:00 2001 From: Alex Ameen Date: Sat, 13 Apr 2019 02:39:14 -0500 Subject: manual: add option `manual.json.enable` Make it possible to install a JSON file containing the available Home Manager options. --- modules/manual.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/manual.nix b/modules/manual.nix index d597d002dbf..0c2681b3acf 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -83,13 +83,26 @@ in Thanks! ''; }; + + manual.json.enable = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether to install a JSON formatted list of all Home Manager + options. This can be located at + <profile directory>/share/doc/home-manager/options.json, + and may be used for navigating definitions, auto-completing, + and other miscellaneous tasks. + ''; + }; }; config = { home.packages = mkMerge [ (mkIf cfg.html.enable [ helpScript homeManagerManual.manual ]) - (mkIf cfg.manpages.enable [ homeManagerManual.manpages ]) + (mkIf cfg.json.enable [ homeManagerManual.optionsJSON ]) ]; }; -- cgit v1.2.3 From c5f35b7ff942d7f5875c0b772b7551c03b431c91 Mon Sep 17 00:00:00 2001 From: Benjamin Staffin Date: Tue, 16 Apr 2019 17:01:14 -0400 Subject: dconf: allow values to be floats Technically dconf calls these "double" but nix floats ought to work. --- modules/misc/dconf.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/dconf.nix b/modules/misc/dconf.nix index 8c28fe9cd00..7d3a9731d0e 100644 --- a/modules/misc/dconf.nix +++ b/modules/misc/dconf.nix @@ -19,7 +19,7 @@ let in "${key}=${tweakVal value}"; - primitive = with types; either bool (either int str); + primitive = with types; either bool (either int (either float str)); in -- cgit v1.2.3 From 0d246aa43555d8a0bd3805a2e3a355b9eec35020 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 18 Apr 2019 01:19:58 +0200 Subject: systemd: escape unit names in systemctl commands --- modules/systemd-activate.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb index 517de40df4b..18ec833f765 100644 --- a/modules/systemd-activate.rb +++ b/modules/systemd-activate.rb @@ -1,5 +1,6 @@ require 'set' require 'open3' +require 'shellwords' @dry_run = ENV['DRY_RUN'] @verbose = ENV['VERBOSE'] @@ -143,14 +144,15 @@ end def get_units_by_activity(units, active) return [] if units.empty? units = units.to_a - is_active = `systemctl --user is-active #{units.join(' ')}`.split + is_active = `systemctl --user is-active #{units.shelljoin}`.split units.select.with_index do |_, i| (is_active[i] == 'active') == active end end def get_restricted_units(units) - infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.to_a.join(' ')}` + units = units.to_a + infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.shelljoin}` .split("\n\n") no_manual_start = [] no_manual_stop = [] @@ -173,7 +175,7 @@ end def show_failed_services_status(services) puts services.each do |service| - run_cmd("systemctl --user status #{service}") + run_cmd("systemctl --user status #{service.shellescape}") puts end end -- cgit v1.2.3 From 6b42bd7abf9e768e2ca450ff3d6618240752e0d7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Apr 2019 02:04:52 +0200 Subject: systemd: support `X-RestartIfChanged = false` Having this in the unit file will prevent the file from being restarted if a change is detected. This is useful if data loss may occur if the unit is suddenly restarted. For example, restarting the Emacs service may result in the loss of unsaved open buffers. --- modules/systemd-activate.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb index 18ec833f765..c0cf87457f5 100644 --- a/modules/systemd-activate.rb +++ b/modules/systemd-activate.rb @@ -41,11 +41,13 @@ def setup_services(old_gen_path, new_gen_path, start_timeout_ms_string) raise "daemon-reload failed" unless run_cmd('systemctl --user daemon-reload') # Exclude services that aren't allowed to be manually started or stopped - no_manual_start, no_manual_stop = get_restricted_units(to_stop + to_restart + to_start) - to_stop -= no_manual_stop - to_restart -= no_manual_stop + no_manual_start + no_manual_start, no_manual_stop, no_restart = get_restricted_units(to_stop + to_restart + to_start) + to_stop -= no_manual_stop + no_restart + to_restart -= no_manual_stop + no_manual_start + no_restart to_start -= no_manual_start + puts "Not restarting: #{no_restart.join(' ')}" unless no_restart.empty? + if to_stop.empty? && to_start.empty? && to_restart.empty? print_service_msg("All services are already running", services_to_run) else @@ -154,6 +156,7 @@ def get_restricted_units(units) units = units.to_a infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.shelljoin}` .split("\n\n") + no_restart = [] no_manual_start = [] no_manual_stop = [] infos.zip(units).each do |info, unit| @@ -161,7 +164,15 @@ def get_restricted_units(units) no_manual_start << unit if no_start.end_with?('yes') no_manual_stop << unit if no_stop.end_with?('yes') end - [no_manual_start, no_manual_stop] + # Regular expression that indicates that a service should not be + # restarted even if a change has been detected. + restartRe = /^[ \t]*X-RestartIfChanged[ \t]*=[ \t]*false[ \t]*(?:#.*)?$/ + units.each do |unit| + if `systemctl --user cat #{unit.shellescape}` =~ restartRe + no_restart << unit + end + end + [no_manual_start, no_manual_stop, no_restart] end def wait_and_get_failed_services(services, start_timeout_ms) -- cgit v1.2.3 From 9c0536deda9f72ed736cbb35b4ab806ab192035f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 14 Apr 2019 02:06:47 +0200 Subject: emacs: prevent service restart on change Fixes #668 --- modules/services/emacs.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index f33968c8759..216645475a9 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -28,6 +28,10 @@ in Unit = { Description = "Emacs: the extensible, self-documenting text editor"; Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/"; + + # Avoid killing the Emacs session, which may be full of + # unsaved buffers. + X-RestartIfChanged = false; }; Service = { -- cgit v1.2.3 From e3831d8ecc5d2a4bab94a34367ab73bc03fff305 Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Mon, 11 Mar 2019 00:45:49 +0100 Subject: alacritty: add module --- modules/misc/news.nix | 7 ++++++ modules/modules.nix | 1 + modules/programs/alacritty.nix | 50 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 modules/programs/alacritty.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0083b661a29..7001dd41878 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1058,6 +1058,13 @@ in A new module is available: 'programs.skim'. ''; } + + { + time = "2019-04-22T12:43:20+00:00"; + message = '' + A new module is available: 'programs.alacritty'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 4822f8428b4..03443912585 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -34,6 +34,7 @@ let (loadModule ./misc/version.nix { }) (loadModule ./misc/xdg.nix { }) (loadModule ./programs/afew.nix { }) + (loadModule ./programs/alacritty.nix { }) (loadModule ./programs/alot.nix { }) (loadModule ./programs/astroid.nix { }) (loadModule ./programs/autorandr.nix { }) diff --git a/modules/programs/alacritty.nix b/modules/programs/alacritty.nix new file mode 100644 index 00000000000..a4e5e6056d6 --- /dev/null +++ b/modules/programs/alacritty.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.alacritty; + +in + +{ + options = { + programs.alacritty = { + enable = mkEnableOption "Alacritty"; + + settings = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + window.dimensions = { + lines = 3; + columns = 200; + }; + key_bindings = [ + { + key = "K"; + mods = "Control"; + chars = "\\x0c"; + } + ]; + } + ''; + description = '' + Configuration written to + ~/.config/alacritty/alacritty.yml. See + + for the default configuration. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.alacritty ]; + + xdg.configFile."alacritty/alacritty.yml".text = + replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings); + }; +} -- cgit v1.2.3 From 8ecc311bccc70dc2caddc73aa7b9258726790f5c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 22 Apr 2019 18:55:28 +0200 Subject: Update stable version to 19.03 Also prepares for 19.09. --- README.md | 6 +++--- doc/installation.xml | 8 ++++---- doc/release-notes/release-notes.xml | 1 + doc/release-notes/rl-1903.xml | 9 ++------- doc/release-notes/rl-1909.xml | 12 ++++++++++++ modules/misc/version.nix | 2 +- 6 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 doc/release-notes/rl-1909.xml diff --git a/README.md b/README.md index c308724f5b1..58593f7b374 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ will write to your dconf store and cannot tell whether a configuration that it is about to be overwrite was from a previous Home Manager generation or from manual configuration. -Home Manager targets [NixOS][] unstable and NixOS version 18.09 (the +Home Manager targets [NixOS][] unstable and NixOS version 19.03 (the current stable version), it may or may not work on other Linux distributions and NixOS versions. @@ -72,11 +72,11 @@ Currently the easiest way to install Home Manager is as follows: if you are following Nixpkgs master or an unstable channel and ```console - $ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager + $ nix-channel --add https://github.com/rycee/home-manager/archive/release-19.03.tar.gz home-manager $ nix-channel --update ``` - if you follow a Nixpkgs version 18.09 channel. + if you follow a Nixpkgs version 19.03 channel. 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 diff --git a/doc/installation.xml b/doc/installation.xml index b0109398369..77f6e167e74 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -79,11 +79,11 @@ if you are following Nixpkgs master or an unstable channel and -$ nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager +$ nix-channel --add https://github.com/rycee/home-manager/archive/release-19.03.tar.gz home-manager $ nix-channel --update - if you follow a Nixpkgs version 18.09 channel. + if you follow a Nixpkgs version 19.03 channel. On NixOS you may need to log out and back in for the channel to become @@ -169,12 +169,12 @@ $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh -# nix-channel --add https://github.com/rycee/home-manager/archive/release-18.09.tar.gz home-manager +# nix-channel --add https://github.com/rycee/home-manager/archive/release-19.03.tar.gz home-manager # nix-channel --update - if you follow a Nixpkgs version 18.09 channel. + if you follow a Nixpkgs version 19.03 channel. diff --git a/doc/release-notes/release-notes.xml b/doc/release-notes/release-notes.xml index bb63ce6c85b..4675f0bfa5c 100644 --- a/doc/release-notes/release-notes.xml +++ b/doc/release-notes/release-notes.xml @@ -8,6 +8,7 @@ This section lists the release notes for stable versions of Home Manager and the current unstable version. + diff --git a/doc/release-notes/rl-1903.xml b/doc/release-notes/rl-1903.xml index d260dbc2b09..f2868dea486 100644 --- a/doc/release-notes/rl-1903.xml +++ b/doc/release-notes/rl-1903.xml @@ -3,15 +3,10 @@ xmlns:xi="http://www.w3.org/2001/XInclude" version="5.0" xml:id="sec-release-19.03"> - Release 19.03 (unstable) + Release 19.03 - This is the current unstable branch and the information in this section is - therefore not final. - - - - Scheduled released is March, 2019. + The 19.03 release branch became the stable branch in April, 2019.
+ Release 19.09 (unreleased) + + + This is the current unstable branch and the information in this section is + therefore not final. + +
diff --git a/modules/misc/version.nix b/modules/misc/version.nix index 42e19e98ac7..18bb28f7603 100644 --- a/modules/misc/version.nix +++ b/modules/misc/version.nix @@ -5,7 +5,7 @@ with lib; { options = { home.stateVersion = mkOption { - type = types.enum [ "18.09" "19.03" ]; + type = types.enum [ "18.09" "19.03" "19.09" ]; default = "18.09"; description = '' It is occasionally necessary for Home Manager to change -- cgit v1.2.3 From 13ad532412c7564b8f0104090ff30130bce3b1bc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 22 Apr 2019 22:42:42 +0200 Subject: xscreensaver: add option `settings` --- modules/services/xscreensaver.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/services/xscreensaver.nix b/modules/services/xscreensaver.nix index 23df90c4d57..4001c294e86 100644 --- a/modules/services/xscreensaver.nix +++ b/modules/services/xscreensaver.nix @@ -2,19 +2,41 @@ with lib; +let + + cfg = config.services.xscreensaver; + +in + { meta.maintainers = [ maintainers.rycee ]; options = { services.xscreensaver = { enable = mkEnableOption "XScreenSaver"; + + settings = mkOption { + type = with types; attrsOf (either bool (either int str)); + default = {}; + example = { + mode = "blank"; + lock = false; + fadeTicks = 20; + }; + description = '' + The settings to use for XScreenSaver. + ''; + }; }; }; - config = mkIf config.services.xscreensaver.enable { + config = mkIf cfg.enable { # To make the xscreensaver-command tool available. home.packages = [ pkgs.xscreensaver ]; + xresources.properties = + mapAttrs' (n: nameValuePair "xscreensaver.${n}") cfg.settings; + systemd.user.services.xscreensaver = { Unit = { Description = "XScreenSaver"; -- cgit v1.2.3 From ba0375bf06e0e0c3b2377edf913b7fddfd5a0b40 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 23 Apr 2019 22:02:29 +0200 Subject: docs: add systemd type change to 19.03 release notes --- doc/release-notes/rl-1903.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/release-notes/rl-1903.xml b/doc/release-notes/rl-1903.xml index f2868dea486..b3c45370f6b 100644 --- a/doc/release-notes/rl-1903.xml +++ b/doc/release-notes/rl-1903.xml @@ -33,6 +33,32 @@ home.file."my file".source = ./. + "/file with spaces!"; + + + The type used for the systemd unit options under + , + , etc. has been changed to offer more + robust merging of configurations. If you don't override values within + systemd units then you are not affected by this change. Unfortunately, if + you do override unit values you may encounter errors. + + + In particular, if you get an error saying that a unique + option is defined multiple times then you need to + use the + mkForce + function. For example, + +systemd.user.services.foo.Service.ExecStart = "/foo/bar"; + + becomes + +systemd.user.services.foo.Service.ExecStart = lib.mkForce "/foo/bar"; + + We had to make this change because the old merging was causing too many + confusing situations for people. + +
-- cgit v1.2.3 From c5f230e68219252ecda608fcd1f5e85869687d09 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 17 Mar 2019 14:26:02 +0100 Subject: vscode.haskell: add module - Haskell IDE Engine integration - Syntax highlighting --- modules/misc/news.nix | 11 +++++++ modules/modules.nix | 1 + modules/programs/vscode/haskell.nix | 66 +++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 modules/programs/vscode/haskell.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 7001dd41878..69299ba83af 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1065,6 +1065,17 @@ in A new module is available: 'programs.alacritty'. ''; } + + { + time = "2019-04-26T22:53:48+00:00"; + condition = config.programs.vscode.enable; + message = '' + A new module is available: 'programs.vscode.haskell'. + + Enable to add Haskell IDE Engine and syntax highlighting + support to your VSCode. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 03443912585..5674588b6af 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -85,6 +85,7 @@ let (loadModule ./programs/urxvt.nix { }) (loadModule ./programs/vim.nix { }) (loadModule ./programs/vscode.nix { }) + (loadModule ./programs/vscode/haskell.nix { }) (loadModule ./programs/zathura.nix { }) (loadModule ./programs/zsh.nix { }) (loadModule ./services/blueman-applet.nix { }) diff --git a/modules/programs/vscode/haskell.nix b/modules/programs/vscode/haskell.nix new file mode 100644 index 00000000000..c8ea10d473e --- /dev/null +++ b/modules/programs/vscode/haskell.nix @@ -0,0 +1,66 @@ +{ pkgs, config, lib, ... }: + +with lib; + +let + + cfg = config.programs.vscode.haskell; + + defaultHieNixExe = hie-nix.hies + "/bin/hie-wrapper"; + defaultHieNixExeText = literalExample + "\"\${pkgs.hie-nix.hies}/bin/hie-wrapper\""; + + hie-nix = pkgs.hie-nix or (abort '' + vscode.haskell: pkgs.hie-nix missing. Please add an overlay such as: + ${exampleOverlay} + ''); + + exampleOverlay = '' + nixpkgs.overlays = [ + (self: super: { hie-nix = import ~/src/hie-nix {}; }) + ] + ''; + +in + +{ + options.programs.vscode.haskell = { + enable = mkEnableOption "Haskell integration for Visual Studio Code"; + + hie.enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable Haskell IDE engine integration."; + }; + + hie.executablePath = mkOption { + type = types.path; + default = defaultHieNixExe; + defaultText = defaultHieNixExeText; + description = '' + The path to the Haskell IDE Engine executable. +
+ Because hie-nix is not packaged in Nixpkgs, you need to add it as an + overlay or set this option. Example overlay configuration: + ${exampleOverlay} + ''; + example = literalExample '' + (import ~/src/haskell-ide-engine {}).hies + "/bin/hie-wrapper"; + ''; + }; + }; + + config = mkIf cfg.enable { + programs.vscode.userSettings = mkIf cfg.hie.enable { + "languageServerHaskell.enableHIE" = true; + "languageServerHaskell.hieExecutablePath" = cfg.hie.executablePath; + }; + + programs.vscode.extensions = + [ + pkgs.vscode-extensions.justusadam.language-haskell + ] + ++ lib.optional cfg.hie.enable + pkgs.vscode-extensions.alanz.vscode-hie-server; + }; +} -- cgit v1.2.3 From b6e613c7711fcab0adbc582f1db0b83c11840fba Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Apr 2019 00:21:18 +0200 Subject: Fix type of various `sessionVariables` options Unfortunately, using `attrsOf` is not possible since it results in too eager evaluation. In particular, the home.sessionVariables = { FOO = "Hello"; BAR = "${config.home.sessionVariables.FOO} World!"; }; example will cause an infinite recursion. This commit restores the option type of - `home.sessionVariables`, - `pam.sessionVariables`, - `programs.bash.sessionVariables`, and - `programs.zsh.sessionVariables` to `attrs`. It also adds test cases for the above options to avoid regressions. Fixes #659 --- modules/home-environment.nix | 18 +++++++------- modules/misc/pam.nix | 2 +- modules/programs/bash.nix | 2 +- modules/programs/zsh.nix | 2 +- tests/default.nix | 6 ++++- tests/modules/home-environment/default.nix | 3 +++ .../session-variables-expected.txt | 6 +++++ .../modules/home-environment/session-variables.nix | 19 +++++++++++++++ tests/modules/misc/pam/default.nix | 3 +++ .../misc/pam/session-variables-expected.txt | 2 ++ tests/modules/misc/pam/session-variables.nix | 19 +++++++++++++++ tests/modules/programs/bash/default.nix | 3 +++ .../programs/bash/session-variables-expected.txt | 8 +++++++ tests/modules/programs/bash/session-variables.nix | 28 ++++++++++++++++++++++ tests/modules/programs/zsh/default.nix | 3 +++ tests/modules/programs/zsh/session-variables.nix | 22 +++++++++++++++++ 16 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 tests/modules/home-environment/default.nix create mode 100644 tests/modules/home-environment/session-variables-expected.txt create mode 100644 tests/modules/home-environment/session-variables.nix create mode 100644 tests/modules/misc/pam/default.nix create mode 100644 tests/modules/misc/pam/session-variables-expected.txt create mode 100644 tests/modules/misc/pam/session-variables.nix create mode 100644 tests/modules/programs/bash/default.nix create mode 100644 tests/modules/programs/bash/session-variables-expected.txt create mode 100644 tests/modules/programs/bash/session-variables.nix create mode 100644 tests/modules/programs/zsh/default.nix create mode 100644 tests/modules/programs/zsh/session-variables.nix diff --git a/modules/home-environment.nix b/modules/home-environment.nix index c577c3072ac..7f51cd8a3df 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -149,7 +149,7 @@ in home.sessionVariables = mkOption { default = {}; - type = with types; attrsOf (either int str); + type = types.attrs; example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; description = '' Environment variables to always set at login. @@ -167,19 +167,19 @@ in variable may have a runtime dependency on another session variable. In particular code like - home.sessionVariables = { - FOO = "Hello"; - BAR = "$FOO World!"; - }; + home.sessionVariables = { + FOO = "Hello"; + BAR = "$FOO World!"; + }; may not work as expected. If you need to reference another session variable, then do so inside Nix instead. The above example then becomes - home.sessionVariables = { - FOO = "Hello"; - BAR = "''${config.home.sessionVariables.FOO} World!"; - }; + home.sessionVariables = { + FOO = "Hello"; + BAR = "''${config.home.sessionVariables.FOO} World!"; + }; ''; }; diff --git a/modules/misc/pam.nix b/modules/misc/pam.nix index 9cebc0a8b43..6ace2bfdaac 100644 --- a/modules/misc/pam.nix +++ b/modules/misc/pam.nix @@ -14,7 +14,7 @@ in options = { pam.sessionVariables = mkOption { default = {}; - type = with types; attrsOf (either int str); + type = types.attrs; example = { EDITOR = "vim"; }; description = '' Environment variables that will be set for the PAM session. diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 92ce18d25bb..98f14906631 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -72,7 +72,7 @@ in sessionVariables = mkOption { default = {}; - type = with types; attrsOf (either int str); + type = types.attrs; example = { MAILCHECK = 30; }; description = '' Environment variables that will be set for the Bash session. diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index ad59ad74934..3e0e4062d1d 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -202,7 +202,7 @@ in sessionVariables = mkOption { default = {}; - type = with types; attrsOf (either int str); + type = types.attrs; example = { MAILCHECK = 30; }; description = "Environment variables that will be set for zsh session."; }; diff --git a/tests/default.nix b/tests/default.nix index 2a0e5338847..39353e48263 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -31,8 +31,12 @@ import nmt { { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; } + // import ./modules/misc/pam // import ./modules/systemd ) + // import ./modules/home-environment + // import ./modules/programs/bash // import ./modules/programs/ssh - // import ./modules/programs/tmux; + // import ./modules/programs/tmux + // import ./modules/programs/zsh; } diff --git a/tests/modules/home-environment/default.nix b/tests/modules/home-environment/default.nix new file mode 100644 index 00000000000..2a1201a2f0a --- /dev/null +++ b/tests/modules/home-environment/default.nix @@ -0,0 +1,3 @@ +{ + home-session-variables = ./session-variables.nix; +} diff --git a/tests/modules/home-environment/session-variables-expected.txt b/tests/modules/home-environment/session-variables-expected.txt new file mode 100644 index 00000000000..5c3868c3901 --- /dev/null +++ b/tests/modules/home-environment/session-variables-expected.txt @@ -0,0 +1,6 @@ +# Only source this once. +if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi +export __HM_SESS_VARS_SOURCED=1 + +export V1="v1" +export V2="v2-v1" diff --git a/tests/modules/home-environment/session-variables.nix b/tests/modules/home-environment/session-variables.nix new file mode 100644 index 00000000000..9f326ebc1b8 --- /dev/null +++ b/tests/modules/home-environment/session-variables.nix @@ -0,0 +1,19 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.sessionVariables = { + V1 = "v1"; + V2 = "v2-${config.home.sessionVariables.V1}"; + }; + + nmt.script = '' + assertFileExists home-path/etc/profile.d/hm-session-vars.sh + assertFileContent \ + home-path/etc/profile.d/hm-session-vars.sh \ + ${./session-variables-expected.txt} + ''; + }; +} diff --git a/tests/modules/misc/pam/default.nix b/tests/modules/misc/pam/default.nix new file mode 100644 index 00000000000..8a64f831caf --- /dev/null +++ b/tests/modules/misc/pam/default.nix @@ -0,0 +1,3 @@ +{ + pam-session-variables = ./session-variables.nix; +} diff --git a/tests/modules/misc/pam/session-variables-expected.txt b/tests/modules/misc/pam/session-variables-expected.txt new file mode 100644 index 00000000000..b84a12b7675 --- /dev/null +++ b/tests/modules/misc/pam/session-variables-expected.txt @@ -0,0 +1,2 @@ +V1 OVERRIDE="v1" +V2 OVERRIDE="v2-v1" diff --git a/tests/modules/misc/pam/session-variables.nix b/tests/modules/misc/pam/session-variables.nix new file mode 100644 index 00000000000..4fbec4163b5 --- /dev/null +++ b/tests/modules/misc/pam/session-variables.nix @@ -0,0 +1,19 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + pam.sessionVariables = { + V1 = "v1"; + V2 = "v2-${config.pam.sessionVariables.V1}"; + }; + + nmt.script = '' + assertFileExists home-files/.pam_environment + assertFileContent \ + home-files/.pam_environment \ + ${./session-variables-expected.txt} + ''; + }; +} diff --git a/tests/modules/programs/bash/default.nix b/tests/modules/programs/bash/default.nix new file mode 100644 index 00000000000..0d361adf7b0 --- /dev/null +++ b/tests/modules/programs/bash/default.nix @@ -0,0 +1,3 @@ +{ + bash-session-variables = ./session-variables.nix; +} diff --git a/tests/modules/programs/bash/session-variables-expected.txt b/tests/modules/programs/bash/session-variables-expected.txt new file mode 100644 index 00000000000..c586477ec4d --- /dev/null +++ b/tests/modules/programs/bash/session-variables-expected.txt @@ -0,0 +1,8 @@ +# -*- mode: sh -*- + +. "@homeDirectory@/.nix-profile/etc/profile.d/hm-session-vars.sh" + +export V1="v1" +export V2="v2-v1" + + diff --git a/tests/modules/programs/bash/session-variables.nix b/tests/modules/programs/bash/session-variables.nix new file mode 100644 index 00000000000..a7a69a2a1f8 --- /dev/null +++ b/tests/modules/programs/bash/session-variables.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bash = { + enable = true; + + sessionVariables = { + V1 = "v1"; + V2 = "v2-${config.programs.bash.sessionVariables.V1}"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.profile + assertFileContent \ + home-files/.profile \ + ${ + pkgs.substituteAll { + src = ./session-variables-expected.txt; + inherit (config.home) homeDirectory; + } + } + ''; + }; +} diff --git a/tests/modules/programs/zsh/default.nix b/tests/modules/programs/zsh/default.nix new file mode 100644 index 00000000000..da5dd5b55ed --- /dev/null +++ b/tests/modules/programs/zsh/default.nix @@ -0,0 +1,3 @@ +{ + zsh-session-variables = ./session-variables.nix; +} diff --git a/tests/modules/programs/zsh/session-variables.nix b/tests/modules/programs/zsh/session-variables.nix new file mode 100644 index 00000000000..a87d39820cf --- /dev/null +++ b/tests/modules/programs/zsh/session-variables.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.zsh = { + enable = true; + + sessionVariables = { + V1 = "v1"; + V2 = "v2-${config.programs.zsh.sessionVariables.V1}"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.zshrc + assertFileRegex home-files/.zshrc 'export V1="v1"' + assertFileRegex home-files/.zshrc 'export V2="v2-v1"' + ''; + }; +} -- cgit v1.2.3 From a16439e38efec5a47a3d920f0b06b57de2548e9e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Apr 2019 10:01:30 +0200 Subject: firefox: deprecate Google Talk and IcedTea options --- modules/programs/firefox.nix | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 1a8454916fd..e1594a9464e 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -49,13 +49,33 @@ in enableGoogleTalk = mkOption { type = types.bool; default = false; - description = "Whether to enable the unfree Google Talk plugin."; + description = '' + Whether to enable the unfree Google Talk plugin. This option + is deprecated and will only work if + + + programs.firefox.package = pkgs.firefox-esr-52-unwrapped; + + + and the Firefox + option has been disabled. + ''; }; enableIcedTea = mkOption { type = types.bool; default = false; - description = "Whether to enable the Java applet plugin."; + description = '' + Whether to enable the Java applet plugin. This option is + deprecated and will only work if + + + programs.firefox.package = pkgs.firefox-esr-52-unwrapped; + + + and the Firefox + option has been disabled. + ''; }; }; }; -- cgit v1.2.3 From c94eaa0e6c2cba37e38ff5e137d87b97d67b79b9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 27 Apr 2019 13:48:57 +0200 Subject: files: replace unnecessary use of xargs --- modules/files.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 2e1171847b7..46e796ed1c5 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -74,8 +74,8 @@ in function checkNewGenCollision() { local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${check} "$newGenFiles" + find "$newGenFiles" -type f -or -type l \ + -exec bash ${check} "$newGenFiles" {} + } checkNewGenCollision || exit 1 @@ -155,8 +155,8 @@ in local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -print0 -or -type l -print0 \ - | xargs -0 bash ${link} "$newGenFiles" + find "$newGenFiles" -type f -or -type l \ + -exec bash ${link} "$newGenFiles" {} + } function cleanOldGen() { -- cgit v1.2.3 From 3bb7c75db3bfa229fc71ce381f95447fcd46a4f9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 28 Apr 2019 00:33:41 +0200 Subject: home-manager: add uninstall command --- home-manager/home-manager | 86 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 11 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 0cf65676cfd..85feaae400d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -10,6 +10,20 @@ function errorEcho() { echo $* >&2 } +function setVerboseAndDryRun() { + if [[ -v VERBOSE ]]; then + export VERBOSE_ARG="--verbose" + else + export VERBOSE_ARG="" + fi + + if [[ -v DRY_RUN ]] ; then + export DRY_RUN_CMD=echo + else + export DRY_RUN_CMD="" + fi +} + function setWorkDir() { if [[ ! -v WORK_DIR ]]; then WORK_DIR="$(mktemp --tmpdir -d home-manager-build.XXXXXXXXXX)" @@ -216,17 +230,7 @@ function doListGens() { # Removes linked generations. Takes as arguments identifiers of # generations to remove. function doRmGenerations() { - if [[ -v VERBOSE ]]; then - export VERBOSE_ARG="--verbose" - else - export VERBOSE_ARG="" - fi - - if [[ -v DRY_RUN ]] ; then - export DRY_RUN_CMD=echo - else - export DRY_RUN_CMD="" - fi + setVerboseAndDryRun pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null @@ -246,6 +250,11 @@ function doRmGenerations() { popd > /dev/null } +function doRmAllGenerations() { + $DRY_RUN_CMD rm $VERBOSE_ARG \ + "/nix/var/nix/profiles/per-user/$USER/home-manager"* +} + function doExpireGenerations() { local profileDir="/nix/var/nix/profiles/per-user/$USER" @@ -347,6 +356,56 @@ function doShowNews() { fi } +function doUninstall() { + setVerboseAndDryRun + + echo "This will remove Home Manager from your system." + + if [[ -v DRY_RUN ]]; then + echo "This is a dry run, nothing will actually be uninstalled." + fi + + local confirmation + read -r -n 1 -p "Really uninstall Home Manager? [y/n] " confirmation + echo + + case $confirmation in + y|Y) + echo "Switching to empty Home Manager configuration..." + HOME_MANAGER_CONFIG="$(mktemp --tmpdir home-manager.XXXXXXXXXX)" + echo "{}" > "$HOME_MANAGER_CONFIG" + doSwitch + rm "$HOME_MANAGER_CONFIG" + $DRY_RUN_CMD rm $VERBOSE_ARG -r \ + "${XDG_DATA_HOME:-$HOME/.local/share}/home-manager" + $DRY_RUN_CMD rm $VERBOSE_ARG \ + "/nix/var/nix/gcroots/per-user/$USER/current-home" + ;; + *) + echo "Yay!" + exit 0 + ;; + esac + + local deleteProfiles + read -r -n 1 \ + -p 'Remove all Home Manager generations? [y/n] ' \ + deleteProfiles + echo + + case $deleteProfiles in + y|Y) + doRmAllGenerations + echo "All generations are now eligible for garbage collection." + ;; + *) + echo "Leaving generations but they may still be garbage collected." + ;; + esac + + echo "Home Manager is uninstalled but your home.nix is left untouched." +} + function doHelp() { echo "Usage: $0 [OPTION] COMMAND" echo @@ -385,6 +444,8 @@ function doHelp() { echo " packages List all packages installed in home-manager-path" echo echo " news Show news entries in a pager" + echo + echo " uninstall Remove Home Manager" } EXTRA_NIX_PATH=() @@ -466,6 +527,9 @@ case "$cmd" in news) doShowNews --all ;; + uninstall) + doUninstall + ;; help|--help) doHelp ;; -- cgit v1.2.3 From 821df406c9726270bf6faf35be95c56593080711 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 20 Jan 2019 13:02:55 -0500 Subject: z-lua: add module --- modules/modules.nix | 1 + modules/programs/z-lua.nix | 86 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 modules/programs/z-lua.nix diff --git a/modules/modules.nix b/modules/modules.nix index 5674588b6af..e2fc86df74b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -86,6 +86,7 @@ let (loadModule ./programs/vim.nix { }) (loadModule ./programs/vscode.nix { }) (loadModule ./programs/vscode/haskell.nix { }) + (loadModule ./programs/z-lua.nix { }) (loadModule ./programs/zathura.nix { }) (loadModule ./programs/zsh.nix { }) (loadModule ./services/blueman-applet.nix { }) diff --git a/modules/programs/z-lua.nix b/modules/programs/z-lua.nix new file mode 100644 index 00000000000..245eff6a51e --- /dev/null +++ b/modules/programs/z-lua.nix @@ -0,0 +1,86 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.z-lua; + + aliases = { + zz = "z -c"; # restrict matches to subdirs of $PWD + zi = "z -i"; # cd with interactive selection + zf = "z -I"; # use fzf to select in multiple matches + zb = "z -b"; # quickly cd to the parent directory + zh = "z -I -t ."; # fzf + }; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.z-lua = { + enable = mkEnableOption "z.lua"; + + options = mkOption { + type = types.listOf types.str; + default = []; + example = [ "enhanced" "once" "fzf" ]; + description = '' + List of options to pass to z.lua. + ''; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + + enableFishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Fish integration. + ''; + }; + + enableAliases = mkOption { + default = false; + type = types.bool; + description = '' + Whether to enable recommended z.lua aliases. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.z-lua ]; + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + eval "$(${pkgs.z-lua}/bin/z --init bash ${concatStringsSep " " cfg.options})" + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${pkgs.z-lua}/bin/z --init zsh ${concatStringsSep " " cfg.options})" + ''; + + programs.fish.shellInit = mkIf cfg.enableFishIntegration '' + source (${pkgs.z-lua}/bin/z --init fish ${concatStringsSep " " cfg.options} | psub) + ''; + + programs.bash.shellAliases = mkIf cfg.enableAliases aliases; + + programs.zsh.shellAliases = mkIf cfg.enableAliases aliases; + }; +} -- cgit v1.2.3 From 2f819d1647d4c73aad6ca8fec8348beaae4bb870 Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Tue, 9 Apr 2019 18:34:44 +0100 Subject: imapnotify: add service --- modules/modules.nix | 1 + modules/services/imapnotify-accounts.nix | 30 +++++++++ modules/services/imapnotify.nix | 105 +++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 modules/services/imapnotify-accounts.nix create mode 100644 modules/services/imapnotify.nix diff --git a/modules/modules.nix b/modules/modules.nix index e2fc86df74b..e4d350888c6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -96,6 +96,7 @@ let (loadModule ./services/flameshot.nix { }) (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) + (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/kbfs.nix { }) (loadModule ./services/kdeconnect.nix { }) (loadModule ./services/keepassx.nix { }) diff --git a/modules/services/imapnotify-accounts.nix b/modules/services/imapnotify-accounts.nix new file mode 100644 index 00000000000..75b3ecd1ea5 --- /dev/null +++ b/modules/services/imapnotify-accounts.nix @@ -0,0 +1,30 @@ +{ lib, ... }: + +with lib; + +{ + options.imapnotify = { + enable = mkEnableOption "imapnotify"; + + onNotify = mkOption { + type = with types; either str (attrsOf str); + default = ""; + example = "\${pkgs.mbsync}/bin/mbsync test-%s"; + description = "Shell commands to run on any event."; + }; + + onNotifyPost = mkOption { + type = with types; either str (attrsOf str); + default = ""; + example = { mail = "\${pkgs.notmuch}/bin/notmuch new && \${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; }; + description = "Shell commands to run after onNotify event."; + }; + + boxes = mkOption { + type = types.listOf types.str; + default = []; + example = [ "Inbox" "[Gmail]/MyLabel" ]; + description = "IMAP folders to watch."; + }; + }; +} diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix new file mode 100644 index 00000000000..9c77cbd27b3 --- /dev/null +++ b/modules/services/imapnotify.nix @@ -0,0 +1,105 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.imapnotify; + + safeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; + + imapnotifyAccounts = + filter (a: a.imapnotify.enable) + (attrValues config.accounts.email.accounts); + + genAccountUnit = account: + let + name = safeName account.name; + in + { + name = "imapnotify-${name}"; + value = { + Unit = { + Description = "imapnotify for ${name}"; + }; + + Service = { + ExecStart = "${pkgs.imapnotify}/bin/imapnotify -c ${genAccountConfig account}"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; + + genAccountConfig = account: + pkgs.writeText "imapnotify-${safeName account.name}-config.js" ( + let + port = + if account.imap.port != null then account.imap.port + else if account.imap.tls.enable then 993 + else 143; + + toJSON = builtins.toJSON; + in + '' + var child_process = require('child_process'); + + function getStdout(cmd) { + var stdout = child_process.execSync(cmd); + return stdout.toString().trim(); + } + + exports.host = ${toJSON account.imap.host} + exports.port = ${toJSON port}; + exports.tls = ${toJSON account.imap.tls.enable}; + exports.username = ${toJSON account.userName}; + exports.password = getStdout("${toString account.passwordCommand}"); + exports.onNotify = ${toJSON account.imapnotify.onNotify}; + exports.onNotifyPost = ${toJSON account.imapnotify.onNotifyPost}; + exports.boxes = ${toJSON account.imapnotify.boxes}; + '' + ); + +in + +{ + meta.maintainers = [ maintainers.nickhu ]; + + options = { + services.imapnotify = { + enable = mkEnableOption "imapnotify"; + }; + + accounts.email.accounts = mkOption { + type = with types; attrsOf (submodule ( + import ./imapnotify-accounts.nix + )); + }; + }; + + config = mkIf cfg.enable { + assertions = + let + checkAccounts = pred: msg: + let + badAccounts = filter pred imapnotifyAccounts; + in + { + assertion = badAccounts == []; + message = "imapnotify: Missing ${msg} for accounts: " + + concatMapStringsSep ", " (a: a.name) badAccounts; + }; + in + [ + (checkAccounts (a: a.maildir == null) "maildir configuration") + (checkAccounts (a: a.imap == null) "IMAP configuration") + (checkAccounts (a: a.passwordCommand == null) "password command") + (checkAccounts (a: a.userName == null) "username") + ]; + + systemd.user.services = + listToAttrs (map genAccountUnit imapnotifyAccounts); + }; +} -- cgit v1.2.3 From f18e2933d485d1d93d399b9637e26a0de1510747 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 21 Apr 2019 19:31:44 +0200 Subject: fontconfig: generate font cache files Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The configuration is now always generated if `fonts.fontconfig.enable` is set. Fixes #520 --- modules/misc/fontconfig.nix | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index 9ad8b195f72..2b989c8fc3e 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -6,36 +6,74 @@ let cfg = config.fonts.fontconfig; + profileDirectory = config.home.profileDirectory; + in { meta.maintainers = [ maintainers.rycee ]; + imports = [ + (mkRenamedOptionModule + [ "fonts" "fontconfig" "enableProfileFonts" ] + [ "fonts" "fontconfig" "enable" ]) + ]; + options = { fonts.fontconfig = { - enableProfileFonts = mkOption { + enable = mkOption { type = types.bool; default = false; - example = true; description = '' - Configure fontconfig to discover fonts installed through + Whether to enable fontconfig configuration. This will, for + example, allow fontconfig to discover fonts and + configurations installed through home.packages and nix-env. - - Note, this is only necessary on non-NixOS systems. ''; }; }; }; - config = mkIf cfg.enableProfileFonts { - xdg.configFile."fontconfig/conf.d/10-nix-profile-fonts.conf".text = '' + config = mkIf cfg.enable { + home.extraProfileCommands = '' + export FONTCONFIG_FILE=$(pwd)/fonts.conf + + cat > $FONTCONFIG_FILE << EOF - ${config.home.profileDirectory}/lib/X11/fonts - ${config.home.profileDirectory}/share/fonts + $out/lib/X11/fonts + $out/share/fonts + $out/lib/fontconfig/cache + EOF + + ${getBin pkgs.fontconfig}/bin/fc-cache -f + rm $out/lib/fontconfig/cache/CACHEDIR.TAG + + unset FONTCONFIG_FILE ''; + + xdg.configFile = { + "fontconfig/conf.d/10-hm-fonts.conf".text = '' + + + + + + + ${config.home.path}/etc/fonts/conf.d + ${config.home.path}/etc/fonts/fonts.conf + + ${config.home.path}/lib/X11/fonts + ${config.home.path}/share/fonts + ${profileDirectory}/lib/X11/fonts + ${profileDirectory}/share/fonts + + ${config.home.path}/lib/fontconfig/cache + + ''; + }; }; } -- cgit v1.2.3 From f56256f4883f941028a7f08ecaae939232406c65 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 30 Apr 2019 07:52:44 -0500 Subject: files: fix `find` invocation broken in c94eaa0e Add parens to expression so the `-exec` includes files matching both. Otherwise (before this change) the `-exec` is only invoked for links (`-type l`): file or (link -> doexec) => (file or link) -> doexec --- modules/files.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 46e796ed1c5..0e8297f795d 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -74,7 +74,7 @@ in function checkNewGenCollision() { local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -or -type l \ + find "$newGenFiles" \( -type f -or -type l \) \ -exec bash ${check} "$newGenFiles" {} + } @@ -155,7 +155,7 @@ in local newGenFiles newGenFiles="$(readlink -e "$newGenPath/home-files")" - find "$newGenFiles" -type f -or -type l \ + find "$newGenFiles" \( -type f -or -type l \) \ -exec bash ${link} "$newGenFiles" {} + } -- cgit v1.2.3 From 1f4e9681f7fd9ab57e13d1335a0e0af1ce14bae9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 30 Apr 2019 18:43:58 +0200 Subject: fontconfig: fix error on missing cachedir file Fixes #699 --- modules/misc/fontconfig.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index 2b989c8fc3e..9f3def775f5 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -50,7 +50,7 @@ in EOF ${getBin pkgs.fontconfig}/bin/fc-cache -f - rm $out/lib/fontconfig/cache/CACHEDIR.TAG + rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG unset FONTCONFIG_FILE ''; -- cgit v1.2.3 From f99d4ba7c4d02a2b46c45ec3ee1f0d3112a51dd8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 1 May 2019 13:13:38 +0200 Subject: flameshot: fix service description --- modules/services/flameshot.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix index aaeecdb0c95..87b494d0fcd 100644 --- a/modules/services/flameshot.nix +++ b/modules/services/flameshot.nix @@ -23,7 +23,7 @@ in systemd.user.services.flameshot = { Unit = { - Description = "Powerful yet simple to use screenshot software"; + Description = "Flameshot screenshot tool"; After = [ "graphical-session-pre.target" "polybar.service" -- cgit v1.2.3 From be4b100ae5a2e99daf5df9cc4d226842b7548777 Mon Sep 17 00:00:00 2001 From: Jos van Bakel Date: Mon, 29 Apr 2019 19:22:37 +0200 Subject: rsibreak: add module --- modules/misc/news.nix | 8 ++++++++ modules/modules.nix | 1 + modules/services/rsibreak.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 modules/services/rsibreak.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 69299ba83af..698c37ca39c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1076,6 +1076,14 @@ in support to your VSCode. ''; } + + { + time = "2019-05-04T23:56:39+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.rsibreak'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index e4d350888c6..d7bbd8dd65c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -112,6 +112,7 @@ let (loadModule ./services/polybar.nix { }) (loadModule ./services/random-background.nix { }) (loadModule ./services/redshift.nix { }) + (loadModule ./services/rsibreak.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/screen-locker.nix { }) (loadModule ./services/stalonetray.nix { }) (loadModule ./services/status-notifier-watcher.nix { }) diff --git a/modules/services/rsibreak.nix b/modules/services/rsibreak.nix new file mode 100644 index 00000000000..242e03432e8 --- /dev/null +++ b/modules/services/rsibreak.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.rsibreak; + +in + +{ + options.services.rsibreak = { + + enable = mkEnableOption "rsibreak"; + + }; + + config = mkIf cfg.enable { + systemd.user.services.rsibreak = { + Unit = { + Description = "RSI break timer"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${pkgs.rsibreak}/bin/rsibreak"; + }; + }; + }; +} -- cgit v1.2.3 From 939274281aa9ee6b11d41aa252806ab31c02555b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 6 May 2019 00:17:30 +0200 Subject: tests: bump nmt version --- tests/default.nix | 4 ++-- tests/modules/programs/tmux/not-enabled.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index 39353e48263..d186ee04d25 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -5,8 +5,8 @@ let nmt = pkgs.fetchFromGitLab { owner = "rycee"; repo = "nmt"; - rev = "b6ab61e707ec1ca3839fef42f9960a1179d543c4"; - sha256 = "097fm1hmsyhy8chf73wwrvafcxny37414fna3haxf0q5fvpv4jfb"; + rev = "89fb12a2aaa8ec671e22a033162c7738be714305"; + sha256 = "07yc1jkgw8vhskzk937k9hfba401q8rn4sgj9baw3fkjl9zrbcyf"; }; in diff --git a/tests/modules/programs/tmux/not-enabled.nix b/tests/modules/programs/tmux/not-enabled.nix index d74f30648b0..b7c675a83a2 100644 --- a/tests/modules/programs/tmux/not-enabled.nix +++ b/tests/modules/programs/tmux/not-enabled.nix @@ -7,7 +7,7 @@ with lib; programs.tmux = { enable = false; }; nmt.script = '' - assertFileNotExists home-files/.tmux.conf + assertPathNotExists home-files/.tmux.conf ''; }; } -- cgit v1.2.3 From b256e3a44f9d9c10b1554c01cada888eb66312ab Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 6 May 2019 00:27:25 +0200 Subject: fontconfig: fix build error This fixes a build error occurring when building a configuration having fontconfig enabled and `home.packages` only containing one package installing things to `/lib`. Also adds a number of test cases to verify the fontconfig cache generation functionality. Fixes #703 --- modules/misc/fontconfig.nix | 36 +++++++++++++++++++--- tests/default.nix | 1 + tests/modules/misc/fontconfig/default.nix | 5 +++ .../misc/fontconfig/multiple-font-packages.nix | 15 +++++++++ tests/modules/misc/fontconfig/no-font-package.nix | 17 ++++++++++ .../misc/fontconfig/single-font-package.nix | 15 +++++++++ 6 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 tests/modules/misc/fontconfig/default.nix create mode 100644 tests/modules/misc/fontconfig/multiple-font-packages.nix create mode 100644 tests/modules/misc/fontconfig/no-font-package.nix create mode 100644 tests/modules/misc/fontconfig/single-font-package.nix diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index 9f3def775f5..8dbcce53c22 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -36,10 +36,29 @@ in }; config = mkIf cfg.enable { + # Create two dummy files in /lib/fontconfig to make sure that + # buildEnv creates a real directory path. These files are removed + # in home.extraProfileCommands below so the packages will not + # become "runtime" dependencies. + home.packages = [ + (pkgs.writeTextFile { + name = "hm-dummy1"; + destination = "/lib/fontconfig/hm-dummy1"; + text = "dummy"; + }) + + (pkgs.writeTextFile { + name = "hm-dummy2"; + destination = "/lib/fontconfig/hm-dummy2"; + text = "dummy"; + }) + ]; + home.extraProfileCommands = '' - export FONTCONFIG_FILE=$(pwd)/fonts.conf + if [[ -d $out/lib/X11/fonts || -d $out/share/fonts ]]; then + export FONTCONFIG_FILE="$(pwd)/fonts.conf" - cat > $FONTCONFIG_FILE << EOF + cat > $FONTCONFIG_FILE << EOF @@ -49,10 +68,17 @@ in EOF - ${getBin pkgs.fontconfig}/bin/fc-cache -f - rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG + ${getBin pkgs.fontconfig}/bin/fc-cache -f + rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG + rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig/cache + + rm "$FONTCONFIG_FILE" + unset FONTCONFIG_FILE + fi - unset FONTCONFIG_FILE + # Remove hacky dummy files. + rm $out/lib/fontconfig/hm-dummy? + rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig ''; xdg.configFile = { diff --git a/tests/default.nix b/tests/default.nix index d186ee04d25..91942a65af4 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -35,6 +35,7 @@ import nmt { // import ./modules/systemd ) // import ./modules/home-environment + // import ./modules/misc/fontconfig // import ./modules/programs/bash // import ./modules/programs/ssh // import ./modules/programs/tmux diff --git a/tests/modules/misc/fontconfig/default.nix b/tests/modules/misc/fontconfig/default.nix new file mode 100644 index 00000000000..b669e1c343c --- /dev/null +++ b/tests/modules/misc/fontconfig/default.nix @@ -0,0 +1,5 @@ +{ + fontconfig-no-font-package = ./no-font-package.nix; + fontconfig-single-font-package = ./single-font-package.nix; + fontconfig-multiple-font-packages = ./multiple-font-packages.nix; +} diff --git a/tests/modules/misc/fontconfig/multiple-font-packages.nix b/tests/modules/misc/fontconfig/multiple-font-packages.nix new file mode 100644 index 00000000000..3845b4ba4b1 --- /dev/null +++ b/tests/modules/misc/fontconfig/multiple-font-packages.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.packages = [ pkgs.comic-relief pkgs.unifont ]; + + fonts.fontconfig.enable = true; + + nmt.script = '' + assertDirectoryNotEmpty home-path/lib/fontconfig/cache + ''; + }; +} diff --git a/tests/modules/misc/fontconfig/no-font-package.nix b/tests/modules/misc/fontconfig/no-font-package.nix new file mode 100644 index 00000000000..c4c687a1320 --- /dev/null +++ b/tests/modules/misc/fontconfig/no-font-package.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.packages = [ + # Look, no font! + ]; + + fonts.fontconfig.enable = true; + + nmt.script = '' + assertPathNotExists home-path/lib/fontconfig/cache + ''; + }; +} diff --git a/tests/modules/misc/fontconfig/single-font-package.nix b/tests/modules/misc/fontconfig/single-font-package.nix new file mode 100644 index 00000000000..b70bdf8a9a7 --- /dev/null +++ b/tests/modules/misc/fontconfig/single-font-package.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.packages = [ pkgs.comic-relief ]; + + fonts.fontconfig.enable = true; + + nmt.script = '' + assertDirectoryNotEmpty home-path/lib/fontconfig/cache + ''; + }; +} -- cgit v1.2.3 From 8b15f1899356762187ce119980ca41c0aba782bb Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 29 Apr 2019 19:25:53 -0600 Subject: mpv: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/mpv.nix | 139 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 modules/programs/mpv.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 698c37ca39c..aaf6c1c3650 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1084,6 +1084,13 @@ in A new module is available: 'services.rsibreak'. ''; } + + { + time = "2019-05-07T20:49:29+00:00"; + message = '' + A new module is available: 'programs.mpv'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d7bbd8dd65c..452511676d2 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -66,6 +66,7 @@ let (loadModule ./programs/matplotlib.nix { }) (loadModule ./programs/mbsync.nix { }) (loadModule ./programs/mercurial.nix { }) + (loadModule ./programs/mpv.nix { }) (loadModule ./programs/msmtp.nix { }) (loadModule ./programs/neovim.nix { }) (loadModule ./programs/newsboat.nix { }) diff --git a/modules/programs/mpv.nix b/modules/programs/mpv.nix new file mode 100644 index 00000000000..9303e53fa8b --- /dev/null +++ b/modules/programs/mpv.nix @@ -0,0 +1,139 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + inherit (builtins) typeOf stringLength; + + cfg = config.programs.mpv; + + mpvOption = with types; either str (either int (either bool float)); + mpvOptions = with types; attrsOf mpvOption; + mpvProfiles = with types; attrsOf mpvOptions; + mpvBindings = with types; attrsOf str; + + renderOption = option: + rec { + int = toString option; + float = int; + + bool = if option then "yes" else "no"; + + string = option; + }.${typeOf option}; + + renderOptions = options: + concatStringsSep "\n" + (mapAttrsToList + (name: value: + let + rendered = renderOption value; + length = toString (stringLength rendered); + in + "${name}=%${length}%${rendered}") + options); + + renderProfiles = profiles: + concatStringsSep "\n" + (mapAttrsToList + (name: value: '' + [${name}] + ${renderOptions value} + '') + profiles); + + renderBindings = bindings: + concatStringsSep "\n" + (mapAttrsToList + (name: value: + "${name} ${value}") + bindings); + +in { + options = { + programs.mpv = { + enable = mkEnableOption "mpv"; + + config = mkOption { + description = '' + Configuration written to + ~/.config/mpv/mpv.conf. See + + mpv + 1 + + for the full list of options. + ''; + type = mpvOptions; + default = {}; + example = literalExample '' + { + profile = "gpu-hq"; + force-window = "yes"; + ytdl-format = "bestvideo+bestaudio"; + cache-default = 4000000; + } + ''; + }; + + profiles = mkOption { + description = '' + Sub-configuration options for specific profiles written to + ~/.config/mpv/mpv.conf. See + for more information. + ''; + type = mpvProfiles; + default = {}; + example = literalExample '' + { + fast = { + vo = "vdpau"; + }; + "protocol.dvd" = { + profile-desc = "profile for dvd:// streams"; + alang = "en"; + }; + } + ''; + }; + + bindings = mkOption { + description = '' + Input configuration written to + ~/.config/mpv/input.conf. See + + mpv + 1 + + for the full list of options. + ''; + type = mpvBindings; + default = {}; + example = literalExample '' + { + WHEEL_UP = "seek 10"; + WHEEL_DOWN = "seek -10"; + "Alt+0" = "set window-scale 0.5"; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { + home.packages = [ pkgs.mpv ]; + } + (mkIf (cfg.config != {} || cfg.profiles != {}) { + xdg.configFile."mpv/mpv.conf".text = '' + ${optionalString (cfg.config != {}) (renderOptions cfg.config)} + ${optionalString (cfg.profiles != {}) (renderProfiles cfg.profiles)} + ''; + }) + (mkIf (cfg.bindings != {}) { + xdg.configFile."mpv/input.conf".text = renderBindings cfg.bindings; + }) + ]); + + meta.maintainers = with maintainers; [ tadeokondrak ]; +} -- cgit v1.2.3 From d2ed39f103edfaf3c711fee0f323558aaca7bd26 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Sun, 12 May 2019 20:08:23 -0600 Subject: alacritty: don't create file if settings is empty Also add a few test cases for the alacritty module. --- modules/programs/alacritty.nix | 13 +++++---- tests/default.nix | 1 + tests/modules/programs/alacritty/default.nix | 4 +++ .../modules/programs/alacritty/empty-settings.nix | 13 +++++++++ .../alacritty/example-settings-expected.yml | 1 + .../programs/alacritty/example-settings.nix | 32 ++++++++++++++++++++++ 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 tests/modules/programs/alacritty/default.nix create mode 100644 tests/modules/programs/alacritty/empty-settings.nix create mode 100644 tests/modules/programs/alacritty/example-settings-expected.yml create mode 100644 tests/modules/programs/alacritty/example-settings.nix diff --git a/modules/programs/alacritty.nix b/modules/programs/alacritty.nix index a4e5e6056d6..84675cb1c8a 100644 --- a/modules/programs/alacritty.nix +++ b/modules/programs/alacritty.nix @@ -41,10 +41,13 @@ in }; }; - config = mkIf cfg.enable { - home.packages = [ pkgs.alacritty ]; + config = mkMerge [ + (mkIf cfg.enable { + home.packages = [ pkgs.alacritty ]; - xdg.configFile."alacritty/alacritty.yml".text = - replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings); - }; + xdg.configFile."alacritty/alacritty.yml" = mkIf (cfg.settings != {}) { + text = replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings); + }; + }) + ]; } diff --git a/tests/default.nix b/tests/default.nix index 91942a65af4..1fd12d34bf9 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -36,6 +36,7 @@ import nmt { ) // import ./modules/home-environment // import ./modules/misc/fontconfig + // import ./modules/programs/alacritty // import ./modules/programs/bash // import ./modules/programs/ssh // import ./modules/programs/tmux diff --git a/tests/modules/programs/alacritty/default.nix b/tests/modules/programs/alacritty/default.nix new file mode 100644 index 00000000000..f63e033d846 --- /dev/null +++ b/tests/modules/programs/alacritty/default.nix @@ -0,0 +1,4 @@ +{ + alacritty-example-settings = ./example-settings.nix; + alacritty-empty-settings = ./empty-settings.nix; +} diff --git a/tests/modules/programs/alacritty/empty-settings.nix b/tests/modules/programs/alacritty/empty-settings.nix new file mode 100644 index 00000000000..f3f8486ad3d --- /dev/null +++ b/tests/modules/programs/alacritty/empty-settings.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.alacritty.enable = true; + + nmt.script = '' + assertPathNotExists home-files/.config/alacritty + ''; + }; +} diff --git a/tests/modules/programs/alacritty/example-settings-expected.yml b/tests/modules/programs/alacritty/example-settings-expected.yml new file mode 100644 index 00000000000..061624192c3 --- /dev/null +++ b/tests/modules/programs/alacritty/example-settings-expected.yml @@ -0,0 +1 @@ +{"key_bindings":[{"chars":"\x0c","key":"K","mods":"Control"}],"window":{"dimensions":{"columns":200,"lines":3}}} \ No newline at end of file diff --git a/tests/modules/programs/alacritty/example-settings.nix b/tests/modules/programs/alacritty/example-settings.nix new file mode 100644 index 00000000000..2c84710d100 --- /dev/null +++ b/tests/modules/programs/alacritty/example-settings.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.alacritty = { + enable = true; + + settings = { + window.dimensions = { + lines = 3; + columns = 200; + }; + + key_bindings = [ + { + key = "K"; + mods = "Control"; + chars = "\\x0c"; + } + ]; + }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/alacritty/alacritty.yml \ + ${./example-settings-expected.yml} + ''; + }; +} -- cgit v1.2.3 From 02a07f19a14920597732647932bf5963ed2f1de8 Mon Sep 17 00:00:00 2001 From: kalium Date: Sat, 11 May 2019 04:38:36 +0900 Subject: zsh: add autocd option --- modules/programs/zsh.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 3e0e4062d1d..ac42b885e1a 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -149,6 +149,14 @@ in programs.zsh = { enable = mkEnableOption "Z shell (Zsh)"; + autocd = mkOption { + default = null; + description = '' + Automatically enter into a directory if typed directly into shell. + ''; + type = types.nullOr types.bool; + }; + dotDir = mkOption { default = null; example = ".config/zsh"; @@ -378,6 +386,7 @@ in ${if cfg.history.expireDuplicatesFirst then "setopt" else "unsetopt"} HIST_EXPIRE_DUPS_FIRST ${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY ${if cfg.history.extended then "setopt" else "unsetopt"} EXTENDED_HISTORY + ${if cfg.autocd != null then "${if cfg.autocd then "setopt" else "unsetopt"} autocd" else ""} ${cfg.initExtra} -- cgit v1.2.3 From 1480a6ca1429468016d61165c33d49866743981b Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Fri, 3 May 2019 16:11:13 +0200 Subject: nix-darwin: actually install packages Also apply assertions when using the nix-darwin module. Closes #702 --- nix-darwin/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 8e318029938..284d2d60c03 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -39,6 +39,22 @@ in }; config = mkIf (cfg.users != {}) { + assertions = + flatten (flip mapAttrsToList cfg.users (user: config: + flip map config.assertions (assertion: + { + inherit (assertion) assertion; + message = "${user} profile: ${assertion.message}"; + } + ) + )); + + users.users = mkIf cfg.useUserPackages ( + mapAttrs (username: usercfg: { + packages = usercfg.home.packages; + }) cfg.users + ); + system.activationScripts.postActivation.text = concatStringsSep "\n" (mapAttrsToList (username: usercfg: '' echo Activating home-manager configuration for ${username} -- cgit v1.2.3 From d726afd9e45246fe68cfff0af80600ea26bd79fe Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 1 May 2019 17:02:01 +0200 Subject: imapnotify: specify notmuch configuration path --- modules/services/imapnotify.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix index 9c77cbd27b3..fbb0713e978 100644 --- a/modules/services/imapnotify.nix +++ b/modules/services/imapnotify.nix @@ -25,6 +25,8 @@ let Service = { ExecStart = "${pkgs.imapnotify}/bin/imapnotify -c ${genAccountConfig account}"; + } // optionalAttrs account.notmuch.enable { + Environment = "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"; }; Install = { -- cgit v1.2.3 From 2e13c3cdfdb86e0d7dc0dd7a690db417714e4334 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Fri, 24 May 2019 09:17:25 +0200 Subject: nixos: use usercfg.home.username for username Use `usercfg.home.username` for username instead of attribute name, as this way we can change username regardless of the name of the attribute. --- nixos/default.nix | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/nixos/default.nix b/nixos/default.nix index 5328e578124..4628d1f2d9f 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -60,28 +60,31 @@ in }) cfg.users ); - systemd.services = mapAttrs' (username: usercfg: - nameValuePair ("home-manager-${utils.escapeSystemdPath username}") { - description = "Home Manager environment for ${username}"; - wantedBy = [ "multi-user.target" ]; - wants = [ "nix-daemon.socket" ]; - after = [ "nix-daemon.socket" ]; + systemd.services = mapAttrs' (_: usercfg: + let + username = usercfg.home.username; + in + nameValuePair ("home-manager-${utils.escapeSystemdPath username}") { + description = "Home Manager environment for ${username}"; + wantedBy = [ "multi-user.target" ]; + wants = [ "nix-daemon.socket" ]; + after = [ "nix-daemon.socket" ]; - serviceConfig = { - User = usercfg.home.username; - Type = "oneshot"; - RemainAfterExit = "yes"; - SyslogIdentifier = "hm-activate-${username}"; + serviceConfig = { + User = usercfg.home.username; + Type = "oneshot"; + RemainAfterExit = "yes"; + SyslogIdentifier = "hm-activate-${username}"; - # The activation script is run by a login shell to make sure - # that the user is given a sane Nix environment. - ExecStart = pkgs.writeScript "activate-${username}" '' - #! ${pkgs.stdenv.shell} -el - echo Activating home-manager configuration for ${username} - exec ${usercfg.home.activationPackage}/activate - ''; - }; - } + # The activation script is run by a login shell to make sure + # that the user is given a sane Nix environment. + ExecStart = pkgs.writeScript "activate-${username}" '' + #! ${pkgs.stdenv.shell} -el + echo Activating home-manager configuration for ${username} + exec ${usercfg.home.activationPackage}/activate + ''; + }; + } ) cfg.users; }; } -- cgit v1.2.3 From d7eaeaf63622864778c98fcadb4e4d580c06bd45 Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Wed, 29 May 2019 20:01:04 +0200 Subject: random-background: add option `display` This option parameterizes the `--bg-*` argument for feh. --- modules/services/random-background.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index 2af7af0b126..742642fb7a3 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -25,6 +25,12 @@ in ''; }; + display = mkOption { + type = types.enum [ "center" "fill" "max" "scale" "tile" ]; + default = "fill"; + description = "Display background images according to this option."; + }; + interval = mkOption { default = null; type = types.nullOr types.str; @@ -50,7 +56,7 @@ in Service = { Type = "oneshot"; - ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-fill ${cfg.imageDirectory}"; + ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-${cfg.display} ${cfg.imageDirectory}"; IOSchedulingClass = "idle"; }; -- cgit v1.2.3 From fcacba268d9c555bf18b3c387b5c028a4dfdc389 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Fri, 24 May 2019 09:13:55 +0200 Subject: xsuspender: add module --- modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/services/xsuspender.nix | 194 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 modules/services/xsuspender.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index aaf6c1c3650..5e066e7bec2 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1091,6 +1091,13 @@ in A new module is available: 'programs.mpv'. ''; } + + { + time = "2019-05-30T17:49:29+00:00"; + message = '' + A new module is available: 'services.xsuspender'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 452511676d2..ed01defe7ee 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -128,6 +128,7 @@ let (loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xscreensaver.nix { }) + (loadModule ./services/xsuspender.nix { }) (loadModule ./systemd.nix { }) (loadModule ./xcursor.nix { }) (loadModule ./xresources.nix { }) diff --git a/modules/services/xsuspender.nix b/modules/services/xsuspender.nix new file mode 100644 index 00000000000..d565fde85e0 --- /dev/null +++ b/modules/services/xsuspender.nix @@ -0,0 +1,194 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.xsuspender; + + xsuspenderOptions = types.submodule { + options = { + matchWmClassContains = mkOption { + description = "Match windows that wm class contains string."; + type = types.nullOr types.str; + default = null; + }; + + matchWmClassGroupContains = mkOption { + description = "Match windows where wm class group contains string."; + type = types.nullOr types.str; + default = null; + }; + + matchWmNameContains = mkOption { + description = "Match windows where wm name contains string."; + type = types.nullOr types.str; + default = null; + }; + + suspendDelay = mkOption { + description = "Initial suspend delay in seconds."; + type = types.int; + default = 5; + }; + + resumeEvery = mkOption { + description = "Resume interval in seconds."; + type = types.int; + default = 50; + }; + + resumeFor = mkOption { + description = "Resume duration in seconds."; + type = types.int; + default = 5; + }; + + execSuspend = mkOption { + description = '' + Before suspending, execute this shell script. If it fails, + abort suspension. + ''; + type = types.nullOr types.str; + default = null; + example = ''echo "suspending window $XID of process $PID"''; + }; + + execResume = mkOption { + description = '' + Before resuming, execute this shell script. Resume the + process regardless script failure. + ''; + type = types.nullOr types.str; + default = null; + example = ''echo resuming ...''; + }; + + sendSignals = mkOption { + description = '' + Whether to send SIGSTOP / SIGCONT signals or not. + If false just the exec scripts are run. + ''; + type = types.bool; + default = true; + }; + + suspendSubtreePattern = mkOption { + description = "Also suspend descendant processes that match this regex."; + type = types.nullOr types.str; + default = null; + }; + + onlyOnBattery = mkOption { + description = "Whether to enable process suspend only on battery."; + type = types.bool; + default = false; + }; + + autoSuspendOnBattery = mkOption { + description = '' + Whether to auto-apply rules when switching to battery + power even if the window(s) didn't just lose focus. + ''; + type = types.bool; + default = true; + }; + + downclockOnBattery = mkOption { + description = '' + Limit CPU consumption for this factor when on battery power. + Value 1 means 50% decrease, 2 means 66%, 3 means 75% etc. + ''; + type = types.int; + default = 0; + }; + }; + }; + +in + +{ + meta.maintainers = [ maintainers.offline ]; + + options = { + services.xsuspender = { + enable = mkEnableOption "XSuspender"; + + defaults = mkOption { + description = "XSuspender defaults."; + type = xsuspenderOptions; + default = {}; + }; + + rules = mkOption { + description = "Attribute set of XSuspender rules."; + type = types.attrsOf xsuspenderOptions; + default = {}; + example = { + Chromium = { + suspendDelay = 10; + matchWmClassContains = "chromium-browser"; + suspendSubtreePattern = "chromium"; + }; + }; + }; + + debug = mkOption { + description = "Whether to enable debug output."; + type = types.bool; + default = false; + }; + + iniContent = mkOption { + type = types.attrsOf types.attrs; + internal = true; + }; + }; + }; + + config = mkIf cfg.enable { + services.xsuspender.iniContent = + let + mkSection = values: filterAttrs (_: v: v != null) { + suspend_delay = values.suspendDelay; + resume_every = values.resumeEvery; + resume_for = values.resumeFor; + exec_suspend = values.execSuspend; + exec_resume = values.execResume; + send_signals = values.sendSignals; + only_on_battery = values.onlyOnBattery; + auto_suspend_on_battery = values.autoSuspendOnBattery; + downclock_on_battery = values.downclockOnBattery; + }; + in + { + default = mkSection cfg.defaults; + } + // mapAttrs (_: mkSection) cfg.rules; + + # To make the xsuspender tool available. + home.packages = [ pkgs.xsuspender ]; + + xdg.configFile."xsuspender.conf".text = generators.toINI {} cfg.iniContent; + + systemd.user.services.xsuspender = { + Unit = { + Description = "XSuspender"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + X-Restart-Triggers = [ + "${config.xdg.configFile."xsuspender.conf".source}" + ]; + }; + + Service = { + ExecStart = "${pkgs.xsuspender}/bin/xsuspender"; + Environment = mkIf cfg.debug [ "G_MESSAGE_DEBUG=all" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 5b95fd0521d335e180fa2bad5433f046fbf63499 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Fri, 24 May 2019 09:08:56 +0200 Subject: firefox: add profile options --- modules/programs/firefox.nix | 175 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 165 insertions(+), 10 deletions(-) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index e1594a9464e..c43781a7acb 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -8,6 +8,32 @@ let extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; + profiles = + flip mapAttrs' cfg.profiles (_: profile: + nameValuePair "Profile${toString profile.id}" { + Name = profile.name; + Path = profile.path; + IsRelative = 1; + Default = if profile.isDefault then 1 else 0; + } + ) // { + General = { + StartWithLastProfile = 1; + }; + }; + + profilesIni = generators.toINI {} profiles; + + mkUserJs = prefs: extraPrefs: '' + // Generated by Home Manager. + + ${concatStrings (mapAttrsToList (name: value: '' + user_pref("${name}", ${builtins.toJSON value}); + '') prefs)} + + ${extraPrefs} + ''; + in { @@ -40,6 +66,84 @@ in ''; }; + profiles = mkOption { + type = types.attrsOf (types.submodule ({config, name, ...}: { + options = { + name = mkOption { + type = types.str; + default = name; + description = "Profile name."; + }; + + id = mkOption { + type = types.ints.unsigned; + default = 0; + description = '' + Profile ID. This should be set to a unique number per profile. + ''; + }; + + settings = mkOption { + type = with types; attrsOf (either bool (either int str)); + default = {}; + example = literalExample '' + { + "browser.startup.homepage" = "https://nixos.org"; + "browser.search.region" = "GB"; + "browser.search.isUS" = false; + "distribution.searchplugins.defaultLocale" = "en-GB"; + "general.useragent.locale" = "en-GB"; + "browser.bookmarks.showMobileBookmarks" = true; + } + ''; + description = "Attribute set of Firefox preferences."; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra preferences to add to user.js. + ''; + }; + + userChrome = mkOption { + type = types.lines; + default = ""; + description = "Custom Firefox CSS."; + example = '' + /* Hide tab bar in FF Quantum */ + @-moz-document url("chrome://browser/content/browser.xul") { + #TabsToolbar { + visibility: collapse !important; + margin-bottom: 21px !important; + } + + #sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"] #sidebar-header { + visibility: collapse !important; + } + } + ''; + }; + + path = mkOption { + type = types.str; + default = name; + description = "Profile path."; + }; + + isDefault = mkOption { + type = types.bool; + default = config.id == 0; + defaultText = "true if profile ID is 0"; + description = "Whether this is a default profile."; + }; + }; + })); + default = {}; + description = "Attribute set of Firefox profiles."; + }; + enableAdobeFlash = mkOption { type = types.bool; default = false; @@ -81,6 +185,39 @@ in }; config = mkIf cfg.enable { + assertions = [ + ( + let + defaults = + catAttrs "name" (filter (a: a.isDefault) (attrValues cfg.profiles)); + in { + assertion = cfg.profiles == {} || length defaults == 1; + message = + "Must have exactly one default Firefox profile but found " + + toString (length defaults) + + optionalString (length defaults > 1) + (", namely " + concatStringsSep ", " defaults); + } + ) + + ( + let + duplicates = + filterAttrs (_: v: length v != 1) + (zipAttrs + (mapAttrsToList (n: v: { "${toString v.id}" = n; }) + (cfg.profiles))); + + mkMsg = n: v: " - ID ${n} is used by ${concatStringsSep ", " v}"; + in { + assertion = duplicates == {}; + message = + "Must not have Firefox profiles with duplicate IDs but\n" + + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates); + } + ) + ]; + home.packages = let # A bit of hackery to force a config into the wrapper. @@ -99,17 +236,35 @@ in in [ (wrapper cfg.package { }) ]; - home.file.".mozilla/${extensionPath}" = mkIf (cfg.extensions != []) ( - let - extensionsEnv = pkgs.buildEnv { - name = "hm-firefox-extensions"; - paths = cfg.extensions; + home.file = mkMerge ( + [{ + ".mozilla/${extensionPath}" = mkIf (cfg.extensions != []) ( + let + extensionsEnv = pkgs.buildEnv { + name = "hm-firefox-extensions"; + paths = cfg.extensions; + }; + in { + source = "${extensionsEnv}/share/mozilla/${extensionPath}"; + recursive = true; + } + ); + + ".mozilla/firefox/profiles.ini" = mkIf (cfg.profiles != {}) { + text = profilesIni; }; - in - { - source = "${extensionsEnv}/share/mozilla/${extensionPath}"; - recursive = true; - } + }] + ++ flip mapAttrsToList cfg.profiles (_: profile: { + ".mozilla/firefox/${profile.path}/chrome/userChrome.css" = + mkIf (profile.userChrome != "") { + text = profile.userChrome; + }; + + ".mozilla/firefox/${profile.path}/user.js" = + mkIf (profile.settings != {} || profile.extraConfig != "") { + text = mkUserJs profile.settings profile.extraConfig; + }; + }) ); }; } -- cgit v1.2.3 From d5bf68d77dacd523793df097f960584ddd9d0462 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 30 May 2019 23:25:30 +0200 Subject: xsuspender: limit module to Linux --- modules/misc/news.nix | 1 + modules/modules.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 5e066e7bec2..4820ef8eb22 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1094,6 +1094,7 @@ in { time = "2019-05-30T17:49:29+00:00"; + condition = hostPlatform.isLinux; message = '' A new module is available: 'services.xsuspender'. ''; diff --git a/modules/modules.nix b/modules/modules.nix index ed01defe7ee..524202122fb 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -128,7 +128,7 @@ let (loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/xscreensaver.nix { }) - (loadModule ./services/xsuspender.nix { }) + (loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; }) (loadModule ./systemd.nix { }) (loadModule ./xcursor.nix { }) (loadModule ./xresources.nix { }) -- cgit v1.2.3 From e1535d2bd82939457e38ebc3ce23fcdceec19c91 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 31 May 2019 21:37:28 +0200 Subject: vscode: add example for `extensions` option --- modules/programs/vscode.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix index cda18979262..0ebbb8eb13c 100644 --- a/modules/programs/vscode.nix +++ b/modules/programs/vscode.nix @@ -31,6 +31,7 @@ in extensions = mkOption { type = types.listOf types.package; default = []; + example = literalExample "[ pkgs.vscode-extensions.bbenoist.Nix ]"; description = '' The extensions Visual Studio Code should be started with. These will override but not delete manually installed ones. -- cgit v1.2.3 From e25113bcf03f858c3a708211b8e520ece7f7b360 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Fri, 31 May 2019 11:12:46 -0700 Subject: browserpass: fix host/policy link sources --- modules/programs/browserpass.nix | 14 +++++++------- tests/default.nix | 1 + tests/modules/programs/browserpass.nix | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 tests/modules/programs/browserpass.nix diff --git a/modules/programs/browserpass.nix b/modules/programs/browserpass.nix index de549513a61..7af5e8f8756 100644 --- a/modules/programs/browserpass.nix +++ b/modules/programs/browserpass.nix @@ -32,11 +32,11 @@ in { in [ { target = "${dir}/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-host.json"; + source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; } { target = "${dir}/../policies/managed/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-policy.json"; + source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else if x == "chromium" then @@ -46,11 +46,11 @@ in { in [ { target = "${dir}/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-host.json"; + source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; } { target = "${dir}/../policies/managed/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-policy.json"; + source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else if x == "firefox" then @@ -59,7 +59,7 @@ in { then "Library/Application Support/Mozilla/NativeMessagingHosts" else ".mozilla/native-messaging-hosts") + "/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/lib/mozilla/native-messaging-hosts/com.github.browserpass.native.json"; + source = "${pkgs.browserpass}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json"; } ] else if x == "vivaldi" then let dir = if isDarwin @@ -68,11 +68,11 @@ in { in [ { target = "${dir}/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-host.json"; + source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; } { target = "${dir}/../policies/managed/com.github.browserpass.native.json"; - source = "${pkgs.browserpass}/etc/chrome-policy.json"; + source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else throw "unknown browser ${x}") config.programs.browserpass.browsers); diff --git a/tests/default.nix b/tests/default.nix index 1fd12d34bf9..2457e5e4e2a 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -16,6 +16,7 @@ import nmt { modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; }; testedAttrPath = [ "home" "activationPackage" ]; tests = { + browserpass = ./modules/programs/browserpass.nix; files-executable = ./modules/files/executable.nix; files-hidden-source = ./modules/files/hidden-source.nix; files-source-with-spaces = ./modules/files/source-with-spaces.nix; diff --git a/tests/modules/programs/browserpass.nix b/tests/modules/programs/browserpass.nix new file mode 100644 index 00000000000..229392e171b --- /dev/null +++ b/tests/modules/programs/browserpass.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.browserpass = { + enable = true; + browsers = [ + "chrome" + "chromium" + "firefox" + "vivaldi" + ]; + }; + + nmt.script = + if pkgs.stdenv.hostPlatform.isDarwin then '' + for dir in "Google/Chrome" "Chromium" "Mozilla" "Vivaldi"; do + assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.github.browserpass.native.json" + done + + for dir in "Google/Chrome" "Chromium" "Vivaldi"; do + assertFileExists "home-files/Library/Application Support/$dir/policies/managed/com.github.browserpass.native.json" + done + '' else '' + for dir in "google-chrome" "chromium" "vivaldi"; do + assertFileExists "home-files/.config/$dir/NativeMessagingHosts/com.github.browserpass.native.json" + assertFileExists "home-files/.config/$dir/policies/managed/com.github.browserpass.native.json" + done + + assertFileExists "home-files/.mozilla/native-messaging-hosts/com.github.browserpass.native.json" + ''; + }; +} -- cgit v1.2.3 From 2211770d8b6fc22677695726499d6a09b991cfc2 Mon Sep 17 00:00:00 2001 From: Sam Boosalis Date: Fri, 3 May 2019 06:39:49 -0700 Subject: home-manager: add Bash completion --- home-manager/completion.bash | 343 +++++++++++++++++++++++++++++++++++++++++++ home-manager/default.nix | 3 + 2 files changed, 346 insertions(+) create mode 100644 home-manager/completion.bash diff --git a/home-manager/completion.bash b/home-manager/completion.bash new file mode 100644 index 00000000000..cb7c0009693 --- /dev/null +++ b/home-manager/completion.bash @@ -0,0 +1,343 @@ +#!/bin/env bash + +################################################## + +# « home-manager » command-line completion +# +# © 2019 "Sam Boosalis" +# +# MIT License +# + +################################################## +# Contributing: + +# Compatibility — Bash 3. +# +# OSX won't update Bash 3 (last updated circa 2009) to Bash 4, +# and we'd like this completion script to work on both Linux and Mac. +# +# For example, OSX Yosemite (released circa 2014) ships with Bash 3: +# +# $ echo $BASH_VERSION +# 3.2 +# +# While Ubuntu LTS 14.04 (a.k.a. Trusty, also released circa 2016) +# ships with the latest version, Bash 4 (updated circa 2016): +# +# $ echo $BASH_VERSION +# 4.3 +# + +# Testing +# +# (1) Invoke « shellcheck » +# +# * source: « https://github.com/koalaman/shellcheck » +# * run: « shellcheck ./share/bash-completion/completions/home-manager » +# +# (2) Interpret via Bash 3 +# +# * run: « bash --noprofile --norc ./share/bash-completion/completions/home-manager » +# + +################################################## +# Examples: + +# $ home-manager +# +# -A +# -I +# -f +# -h +# -n +# -v +# build +# edit +# expire-generations +# generations +# help +# news +# packages +# remove-generations +# switch + +# $ home-manager e +# +# edit +# expire-generations + +# $ home-manager remove-generations 20 +# +# 200 +# 201 +# 202 +# 203 + +################################################## +# Notes: + +# « home-manager » Subcommands: +# +# help +# edit +# build +# switch +# generations +# remove-generations +# expire-generations +# packages +# news + +# « home-manager » Options: +# +# -f FILE +# -A ATTRIBUTE +# -I PATH +# -v +# -n +# -h + +# $ home-manager +# +# Usage: /home/sboo/.nix-profile/bin/home-manager [OPTION] COMMAND +# +# Options +# +# -f FILE The home configuration file. +# Default is '~/.config/nixpkgs/home.nix'. +# -A ATTRIBUTE Optional attribute that selects a configuration +# expression in the configuration file. +# -I PATH Add a path to the Nix expression search path. +# -v Verbose output +# -n Do a dry run, only prints what actions would be taken +# -h Print this help +# +# Commands +# +# help Print this help +# +# edit Open the home configuration in $EDITOR +# +# build Build configuration into result directory +# +# switch Build and activate configuration +# +# generations List all home environment generations +# +# remove-generations ID... +# Remove indicated generations. Use 'generations' command to +# find suitable generation numbers. +# +# expire-generations TIMESTAMP +# Remove generations older than TIMESTAMP where TIMESTAMP is +# interpreted as in the -d argument of the date tool. For +# example "-30 days" or "2018-01-01". +# +# packages List all packages installed in home-manager-path +# +# news Show news entries in a pager +# + +################################################## +# Dependencies: + +command -v home-manager >/dev/null +command -v grep >/dev/null +command -v sed >/dev/null + +################################################## +# Code: + +_home-manager_list-generation-identifiers () + +{ + + home-manager generations | sed -n -e 's/^................ : id \([[:alnum:]]\+\) -> .*/\1/p' + +} + +# NOTES +# +# (1) the « sed -n -e 's/.../.../p' » invocation: +# +# * the « -e '...' » option takes a Sed Script. +# * the « -n » option only prints when « .../p » would print. +# * the « s/xxx/yyy/ » Sed Script substitutes « yyy » whenever « xxx » is matched. +# +# (2) the « '^................ : id \([[:alnum:]]\+\) -> .*' » regular expression: +# +# * matches « 199 », for example, in the line « 2019-03-13 15:26 : id 199 -> /nix/store/mv619y9pzgsx3kndq0q7fjfvbqqdy5k8-home-manager-generation » +# +# + +#------------------------------------------------# + +# shellcheck disable=SC2120 +_home-manager_list-nix-attributes () + +{ + local HomeFile + local HomeAttrsString + # local HomeAttrsArray + # local HomeAttr + + if [ -z "$1" ] + then + HomeFile=$(readlink -f "$(_home-manager_get-default-home-file)") + else + HomeFile="$1" + fi + + HomeAttrsString=$(nix-instantiate --eval -E "let home = import ${HomeFile}; in (builtins.trace (builtins.toString (builtins.attrNames home)) null)" |& grep '^trace: ') + HomeAttrsString="${HomeAttrsString#trace: }" + + echo "${HomeAttrsString}" + + # IFS=" " read -ar HomeAttrsArray <<< "${HomeAttrsString}" + # + # local HomeAttr + # for HomeAttr in "${HomeAttrsArray[@]}" + # do + # echo "${HomeAttr}" + # done + +} + +# e.g.: +# +# $ nix-instantiate --eval -E 'let home = import /home/sboo/configuration/configs/nixpkgs/home-attrs.nix; in (builtins.trace (builtins.toString (builtins.attrNames home)) null)' 1>/dev/null +# trace: darwin linux +# +# $ _home-manager_list-nix-attributes +# linux darwin +# + +#------------------------------------------------# + +_home-manager_get-default-home-file () + +{ + local HomeFileDefault + + HomeFileDefault="$(_home-manager_xdg-get-config-home)/nixpkgs/home.nix" + + echo "${HomeFileDefault}" +} + +# e.g.: +# +# $ _home-manager_get-default-home-file +# ~/.config/nixpkgs/home.nix +# + +################################################## +# XDG-BaseDirs: + +_home-manager_xdg-get-config-home () { + + echo "${XDG_CONFIG_HOME:-$HOME/.config}" + +} + +#------------------------------------------------# + +_home-manager_xdg-get-data-home () { + + echo "${XDG_DATA_HOME:-$HOME/.local/share}" + +} + + +#------------------------------------------------# +_home-manager_xdg-get-cache-home () { + + echo "${XDG_CACHE_HOME:-$HOME/.cache}" + +} + +################################################## + +# shellcheck disable=SC2207 +_home-manager_completions () +{ + + #--------------------------# + + local Subcommands + Subcommands=( "help" "edit" "build" "switch" "generations" "remove-generations" "expire-generations" "packages" "news" ) + + # ^ « home-manager »'s subcommands. + + #--------------------------# + + local Options + Options=( "-f" "-A" "-I" "-h" "-n" "-v" ) + + # ^ « home-manager »'s options. + + #--------------------------# + + local CurrentWord + CurrentWord="${COMP_WORDS[$COMP_CWORD]}" + + # ^ the word currently being completed + + local PreviousWord + if [ "$COMP_CWORD" -ge 1 ] + then + PreviousWord="${COMP_WORDS[COMP_CWORD-1]}" + else + PreviousWord="" + fi + + # ^ the word to the left of the current word. + # + # e.g. in « home-manager -v -f ./ »: + # + # PreviousWord="-f" + # CurrentWord="./" + + #--------------------------# + + COMPREPLY=() + + case "$PreviousWord" in + + "-f") + + COMPREPLY+=( $( compgen -A file -- "$CurrentWord") ) + ;; + + "-I") + + COMPREPLY+=( $( compgen -A directory -- "$CurrentWord") ) + ;; + + "-A") + + # shellcheck disable=SC2119 + COMPREPLY+=( $( compgen -W "$(_home-manager_list-nix-attributes)" -- "$CurrentWord") ) + ;; + + "remove-generations") + + COMPREPLY+=( $( compgen -W "$(_home-manager_list-generation-identifiers)" -- "$CurrentWord" ) ) + ;; + + *) + + COMPREPLY+=( $( compgen -W "${Subcommands[*]}" -- "$CurrentWord" ) ) + COMPREPLY+=( $( compgen -W "${Options[*]}" -- "$CurrentWord" ) ) + ;; + + esac + + #--------------------------# +} + +################################################## + +complete -F _home-manager_completions -o default home-manager + +#complete -W "help edit build switch generations remove-generations expire-generations packages news" home-manager diff --git a/home-manager/default.nix b/home-manager/default.nix index 82acb2fab63..8b5ae75e0fd 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -34,4 +34,7 @@ runCommand --subst-var-by gnused "${gnused}" \ --subst-var-by less "${less}" \ --subst-var-by HOME_MANAGER_PATH '${pathStr}' + + install -D -m755 ${./completion.bash} \ + $out/share/bash-completion/completions/home-manager '' -- cgit v1.2.3 From 8991fe2e90a9b35a98a8b98f02c9de5425b11785 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 2 Jun 2019 23:12:01 +0200 Subject: screen-locker: fix systemd unit In particular, don't add trailing backslashes introduced by `xautolockExtraOptions`. Systemd's unit file parser seems to have gotten a bit stricter and with systemd 242, the trailing backslash caused the next non-empty line to be ignored. In that case, this was `[Section]`, so all subsequent settings were mistakenly added to `[Service]`, causing them to be ignored entirely. Simplify and fix this by using `concatStringsSep` to build a single `ExecStart` line. --- modules/services/screen-locker.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/services/screen-locker.nix b/modules/services/screen-locker.nix index 844075eee44..e3da14069bc 100644 --- a/modules/services/screen-locker.nix +++ b/modules/services/screen-locker.nix @@ -58,13 +58,12 @@ in { }; Service = { - ExecStart = '' - ${pkgs.xautolock}/bin/xautolock \ - -detectsleep \ - -time ${toString cfg.inactiveInterval} \ - -locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID' \ - ${concatStringsSep " " cfg.xautolockExtraOptions} - ''; + ExecStart = concatStringsSep " " ([ + "${pkgs.xautolock}/bin/xautolock" + "-detectsleep" + "-time ${toString cfg.inactiveInterval}" + "-locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID'" + ] ++ cfg.xautolockExtraOptions); }; }; -- cgit v1.2.3 From 0db26fc3abdfe362d2af16ffb607d0bebebe8a7d Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Fri, 24 May 2019 09:01:10 +0200 Subject: gpg: add module --- modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/gpg.nix | 62 ++++++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/gpg/default.nix | 3 ++ .../programs/gpg/override-defaults-expected.conf | 19 +++++++ tests/modules/programs/gpg/override-defaults.nix | 21 ++++++++ 7 files changed, 114 insertions(+) create mode 100644 modules/programs/gpg.nix create mode 100644 tests/modules/programs/gpg/default.nix create mode 100644 tests/modules/programs/gpg/override-defaults-expected.conf create mode 100644 tests/modules/programs/gpg/override-defaults.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 4820ef8eb22..d6c52687326 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1099,6 +1099,13 @@ in A new module is available: 'services.xsuspender'. ''; } + + { + time = "2019-06-03T21:47:10+00:00"; + message = '' + A new module is available: 'programs.gpg'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 524202122fb..af0cbc1ca1c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -54,6 +54,7 @@ let (loadModule ./programs/git.nix { }) (loadModule ./programs/gnome-terminal.nix { }) (loadModule ./programs/go.nix { }) + (loadModule ./programs/gpg.nix { }) (loadModule ./programs/home-manager.nix { }) (loadModule ./programs/htop.nix { }) (loadModule ./programs/info.nix { }) diff --git a/modules/programs/gpg.nix b/modules/programs/gpg.nix new file mode 100644 index 00000000000..e06ec3a9375 --- /dev/null +++ b/modules/programs/gpg.nix @@ -0,0 +1,62 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.gpg; + + cfgText = + concatStringsSep "\n" + (attrValues + (mapAttrs (key: value: + if isString value + then "${key} ${value}" + else optionalString value key) + cfg.settings)); + +in { + options.programs.gpg = { + enable = mkEnableOption "GnuPG"; + + settings = mkOption { + type = types.attrsOf (types.either types.str types.bool); + example = { + no-comments = false; + s2k-cipher-algo = "AES128"; + }; + description = '' + GnuPG configuration options. Available options are described + in the gpg manpage: + . + ''; + }; + }; + + config = mkIf cfg.enable { + programs.gpg.settings = { + personal-cipher-preferences = mkDefault "AES256 AES192 AES"; + personal-digest-preferences = mkDefault "SHA512 SHA384 SHA256"; + personal-compress-preferences = mkDefault "ZLIB BZIP2 ZIP Uncompressed"; + default-preference-list = mkDefault "SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed"; + cert-digest-algo = mkDefault "SHA512"; + s2k-digest-algo = mkDefault "SHA512"; + s2k-cipher-algo = mkDefault "AES256"; + charset = mkDefault "utf-8"; + fixed-list-mode = mkDefault true; + no-comments = mkDefault true; + no-emit-version = mkDefault true; + keyid-format = mkDefault "0xlong"; + list-options = mkDefault "show-uid-validity"; + verify-options = mkDefault "show-uid-validity"; + with-fingerprint = mkDefault true; + require-cross-certification = mkDefault true; + no-symkey-cache = mkDefault true; + throw-keyids = mkDefault true; + use-agent = mkDefault true; + }; + + home.packages = [ pkgs.gnupg ]; + + home.file.".gnupg/gpg.conf".text = cfgText; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 2457e5e4e2a..3ef1fa43e42 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -39,6 +39,7 @@ import nmt { // import ./modules/misc/fontconfig // import ./modules/programs/alacritty // import ./modules/programs/bash + // import ./modules/programs/gpg // import ./modules/programs/ssh // import ./modules/programs/tmux // import ./modules/programs/zsh; diff --git a/tests/modules/programs/gpg/default.nix b/tests/modules/programs/gpg/default.nix new file mode 100644 index 00000000000..5cb24817cb0 --- /dev/null +++ b/tests/modules/programs/gpg/default.nix @@ -0,0 +1,3 @@ +{ + gpg-override-defaults = ./override-defaults.nix; +} diff --git a/tests/modules/programs/gpg/override-defaults-expected.conf b/tests/modules/programs/gpg/override-defaults-expected.conf new file mode 100644 index 00000000000..3198183f723 --- /dev/null +++ b/tests/modules/programs/gpg/override-defaults-expected.conf @@ -0,0 +1,19 @@ +cert-digest-algo SHA512 +charset utf-8 +default-preference-list SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed +fixed-list-mode +keyid-format 0xlong +list-options show-uid-validity + +no-emit-version +no-symkey-cache +personal-cipher-preferences AES256 AES192 AES +personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed +personal-digest-preferences SHA512 SHA384 SHA256 +require-cross-certification +s2k-cipher-algo AES128 +s2k-digest-algo SHA512 +throw-keyids +use-agent +verify-options show-uid-validity +with-fingerprint \ No newline at end of file diff --git a/tests/modules/programs/gpg/override-defaults.nix b/tests/modules/programs/gpg/override-defaults.nix new file mode 100644 index 00000000000..7cf68b31b13 --- /dev/null +++ b/tests/modules/programs/gpg/override-defaults.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.gpg = { + enable = true; + + settings = { + no-comments = false; + s2k-cipher-algo = "AES128"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.gnupg/gpg.conf + assertFileContent home-files/.gnupg/gpg.conf ${./override-defaults-expected.conf} + ''; + }; +} -- cgit v1.2.3 From 29824a8cf6eabb32343a4af63d27ad6775c238ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Estrella?= Date: Tue, 4 Jun 2019 06:21:20 -0500 Subject: tmux: Disable confirmation prompt --- modules/programs/tmux.nix | 13 +++++++++ tests/modules/programs/tmux/default.nix | 1 + .../programs/tmux/disable-confirmation-prompt.conf | 31 ++++++++++++++++++++++ .../programs/tmux/disable-confirmation-prompt.nix | 28 +++++++++++++++++++ .../modules/programs/tmux/emacs-with-plugins.conf | 2 ++ tests/modules/programs/tmux/vi-all-true.conf | 2 ++ 6 files changed, 77 insertions(+) create mode 100644 tests/modules/programs/tmux/disable-confirmation-prompt.conf create mode 100644 tests/modules/programs/tmux/disable-confirmation-prompt.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index b65da1b14e7..a4892c9b632 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -65,6 +65,11 @@ let bind C-${cfg.shortcut} last-window ''} + ${optionalString cfg.disableConfirmationPrompt '' + bind-key & kill-window + bind-key x kill-pane + ''} + setw -g aggressive-resize ${boolToStr cfg.aggressiveResize} setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"} set -s escape-time ${toString cfg.escapeTime} @@ -109,6 +114,14 @@ in ''; }; + disableConfirmationPrompt = mkOption { + default = false; + type = types.bool; + description = '' + Disable confirmation prompt before killing a pane or window + ''; + }; + enable = mkEnableOption "tmux"; escapeTime = mkOption { diff --git a/tests/modules/programs/tmux/default.nix b/tests/modules/programs/tmux/default.nix index 16d6d63e438..d4501c60981 100644 --- a/tests/modules/programs/tmux/default.nix +++ b/tests/modules/programs/tmux/default.nix @@ -3,4 +3,5 @@ tmux-not-enabled = ./not-enabled.nix; tmux-vi-all-true = ./vi-all-true.nix; tmux-secure-socket-enabled = ./secure-socket-enabled.nix; + tmux-disable-confirmation-prompt = ./disable-confirmation-prompt.nix; } diff --git a/tests/modules/programs/tmux/disable-confirmation-prompt.conf b/tests/modules/programs/tmux/disable-confirmation-prompt.conf new file mode 100644 index 00000000000..b599e603e4a --- /dev/null +++ b/tests/modules/programs/tmux/disable-confirmation-prompt.conf @@ -0,0 +1,31 @@ +# ============================================= # +# Start with defaults from the Sensible plugin # +# --------------------------------------------- # +run-shell @sensible_rtp@ +# ============================================= # + +set -g default-terminal "screen" +set -g base-index 0 +setw -g pane-base-index 0 + + + + + +set -g status-keys emacs +set -g mode-keys emacs + + + + + +bind-key & kill-window +bind-key x kill-pane + + +setw -g aggressive-resize off +setw -g clock-mode-style 12 +set -s escape-time 500 +set -g history-limit 2000 + + diff --git a/tests/modules/programs/tmux/disable-confirmation-prompt.nix b/tests/modules/programs/tmux/disable-confirmation-prompt.nix new file mode 100644 index 00000000000..82c53438b00 --- /dev/null +++ b/tests/modules/programs/tmux/disable-confirmation-prompt.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + substituteExpected = path: pkgs.substituteAll { + src = path; + + sensible_rtp = pkgs.tmuxPlugins.sensible.rtp; + }; + +in + +{ + config = { + programs.tmux = { + enable = true; + disableConfirmationPrompt = true; + }; + + nmt.script = '' + assertFileExists home-files/.tmux.conf + assertFileContent home-files/.tmux.conf \ + ${substituteExpected ./disable-confirmation-prompt.conf} + ''; + }; +} diff --git a/tests/modules/programs/tmux/emacs-with-plugins.conf b/tests/modules/programs/tmux/emacs-with-plugins.conf index 039ae740fc0..b047c97a766 100644 --- a/tests/modules/programs/tmux/emacs-with-plugins.conf +++ b/tests/modules/programs/tmux/emacs-with-plugins.conf @@ -21,6 +21,8 @@ set -g mode-keys emacs + + setw -g aggressive-resize on setw -g clock-mode-style 24 set -s escape-time 500 diff --git a/tests/modules/programs/tmux/vi-all-true.conf b/tests/modules/programs/tmux/vi-all-true.conf index 15bbc9107f6..08e37e19b97 100644 --- a/tests/modules/programs/tmux/vi-all-true.conf +++ b/tests/modules/programs/tmux/vi-all-true.conf @@ -21,6 +21,8 @@ set -g mode-keys vi + + setw -g aggressive-resize on setw -g clock-mode-style 24 set -s escape-time 500 -- cgit v1.2.3 From 5b50eb18fcf6100de1546a86e5e8f98ef17ec141 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 9 Jun 2019 12:13:11 +0200 Subject: network-manager-applet: fix indentation --- modules/services/network-manager-applet.nix | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index e91b8543ee6..72a4711e39a 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -19,24 +19,24 @@ in config = mkIf cfg.enable { systemd.user.services.network-manager-applet = { - Unit = { - Description = "Network Manager applet"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = toString ( - [ - "${pkgs.networkmanagerapplet}/bin/nm-applet" - "--sm-disable" - ] ++ optional config.xsession.preferStatusNotifierItems "--indicator" - ); - }; + Unit = { + Description = "Network Manager applet"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = toString ( + [ + "${pkgs.networkmanagerapplet}/bin/nm-applet" + "--sm-disable" + ] ++ optional config.xsession.preferStatusNotifierItems "--indicator" + ); + }; }; }; } -- cgit v1.2.3 From f82246171b253801021c6f98cc50fa461cd972e5 Mon Sep 17 00:00:00 2001 From: Judson Date: Wed, 17 Apr 2019 12:15:38 -0700 Subject: files: backup file collisions When a configuration file would be written to an existing file, rather than failing switch (and having the user have to move or delete those files), move the files automatically to a new path. Closes #585 --- home-manager/home-manager | 6 +++++- modules/files.nix | 20 +++++++++++++++++--- modules/misc/news.nix | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 85feaae400d..b6ea92edb9e 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -416,6 +416,7 @@ function doHelp() { echo " -A ATTRIBUTE Optional attribute that selects a configuration" echo " expression in the configuration file." echo " -I PATH Add a path to the Nix expression search path." + echo " -b EXT Move existing files to new path rather than fail." echo " -v Verbose output" echo " -n Do a dry run, only prints what actions would be taken" echo " -h Print this help" @@ -460,7 +461,7 @@ for arg in "$@"; do fi done -while getopts 2f:I:A:vnh opt; do +while getopts 2f:I:A:b:vnh opt; do case $opt in 2) USE_NIX2_COMMAND=1 @@ -474,6 +475,9 @@ while getopts 2f:I:A:vnh opt; do A) HOME_MANAGER_CONFIG_ATTRIBUTE="$OPTARG" ;; + b) + export HOME_MANAGER_BACKUP_EXT="$OPTARG" + ;; v) export VERBOSE=1 ;; diff --git a/modules/files.nix b/modules/files.nix index 0e8297f795d..ac946976faf 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -59,13 +59,23 @@ in targetPath="$HOME/$relativePath" if [[ -e "$targetPath" \ && ! "$(readlink "$targetPath")" == ${homeFilePattern} ]] ; then - errorEcho "Existing file '$targetPath' is in the way" - collision=1 + if [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then + backup="$targetPath.$HOME_MANAGER_BACKUP_EXT" + if [[ -e "$backup" ]]; then + errorEcho "Existing file '$backup' would be clobbered by backing up '$targetPath'" + collision=1 + else + warnEcho "Existing file '$targetPath' is in the way, will be moved to '$backup'" + fi + else + errorEcho "Existing file '$targetPath' is in the way" + collision=1 + fi fi done if [[ -v collision ]] ; then - errorEcho "Please move the above files and try again" + errorEcho "Please move the above files and try again or use -b to move automatically." exit 1 fi ''; @@ -111,6 +121,10 @@ in for sourcePath in "$@" ; do relativePath="''${sourcePath#$newGenFiles/}" targetPath="$HOME/$relativePath" + if [[ -e "$targetPath" && ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then + backup="$targetPath.$HOME_MANAGER_BACKUP_EXT" + $DRY_RUN_CMD mv $VERBOSE_ARG "$targetPath" "$backup" || errorEcho "Moving '$targetPath' failed!" + fi $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" done diff --git a/modules/misc/news.nix b/modules/misc/news.nix index d6c52687326..1953354d665 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1106,6 +1106,22 @@ in A new module is available: 'programs.gpg'. ''; } + + { + time = "2019-06-09T12:19:18+00:00"; + message = '' + Collisions between unmanaged and managed files can now be + automatically resolved by moving the target file to a new + path instead of failing the switch operation. To enable + this, use the new '-b' command line argument. For example, + + home-manager -b bck switch + + where 'bck' is the suffix to give the moved file. In this + case a colliding file 'foo.conf' will be moved to + 'foo.conf.bck'. + ''; + } ]; }; } -- cgit v1.2.3 From 42732990cd93e396f7702b2bde460a4aa2fb83a1 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 9 Jun 2019 01:47:43 +0200 Subject: home-manager: rewrite argument parsing This rewrite allows "long options" but unfortunately does not allow merged options such as `-vn`. Also improve the home-manager manual page, with this it should include all sub-commands and arguments. Finally, include the home-manager manual page in the generated HTML documentation. --- doc/default.nix | 1 + doc/man-home-manager.xml | 367 ++++++++++++++++++++++++++++++++++++++++--- doc/manual.xml | 4 + home-manager/completion.bash | 21 ++- home-manager/home-manager | 92 ++++++----- 5 files changed, 423 insertions(+), 62 deletions(-) diff --git a/doc/default.nix b/doc/default.nix index e65e904df8e..c94d52c9e7e 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -119,6 +119,7 @@ let + diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index deb2a3baf88..d83566a3c22 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -2,46 +2,121 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> - home-manager - 1 + home-manager + 1 Home Manager - - home-manager - reconfigure a user environment + home-manager + reconfigure a user environment home-manager - + build - + edit - + expire-generations timestamp - + generations - + help - + news - + packages + + + + remove-generations ID … + + + + switch + + + + uninstall + + + -A attrPath + + + + -I path + + + + -b ext + + + + + + -f + + + + --file + + path + + + + + + -h + + + + --help + + + + + + + + -n + + + + --dry-run + + + + + + --show-trace + + + + + + -v + + + + --verbose + + + @@ -50,6 +125,261 @@ This command updates the user environment so that it corresponds to the configuration specified in ~/.config/nixpkgs/home.nix. + + All operations using this tool expects a sub-command that indicates the + operation to perform. It must be one of + + + + + + + + Build configuration into a result directory. + + + + + + + + + + Open the home configuration using the editor indicated by + EDITOR. + + + + + + + + + + Remove generations older than timestamp where + timestamp is interpreted as in the + argument of the + date + 1 tool. For example -30 + days or 2018-01-01. + + + + + + + + + + List all home environment generations. + + + + + + + + + + Print tool help. + + + + + + + + + + Show news entries in a pager. + + + + + + + + + + List all packages installed in home-manager-path. + + + + + + + + + + Remove indicated generations. Use the + sub-command to find suitable generation numbers. + + + + + + + + + + Build and activate the configuration. + + + + + + + + + + Remove Home Manager from the user environment. This will + + + + remove all managed files from the home directory, + + + + + remove packages installed through Home Manager from the user profile, + and + + + + + optionally remove all Home Manager generations and make them + available for immediate garbage collection. + + + + + + + + + + + Options + + The tool accepts the options + + + + + + + + + Optional attribute that selects a configuration expression in the + configuration file. That is, if home.nix contains + +{ + joe-at-work = {pkgs, ...}: { home.packages = [ pkgs.fortune ]; }; + joe-at-home = {pkgs, ...}: { home.packages = [ pkgs.cowsay ]; }; +} + + then the command home-manager switch -A joe-at-work + will activate the profile containing the fortune program. + + + + + + + + + + Add a path to the Nix expression search path. For example, to build a + Home Manager profile using a specific Nixpkgs run home-manager + -I nixpkgs=/absolute/path/to/nixpkgs build. By default + <nixpkgs> is used. + + + + + + + + + + Enabled automatic resolution of collisions between unmanaged and managed + files. The name of the original file will be suffixed by the given + extension. For example, + +$ home-manager -b bck switch + + will cause a colliding file ~/.config/foo.conf to be + moved to ~/.config/foo.conf.bck. + + + + + + + + + + + + + Indicates the path to the Home Manager configuration file. If not given, + ~/.config/nixpkgs/home.nix is used. + + + + + + + + + + + + + Prints usage information for the home-manager tool. + + + + + + + + + + + + + Perform a dry-run of the given operation, only prints what actions would + be taken. + + + + + + + + + + Passed on to + nix-build + 1 . + + + + + + + + + + + + + Activates verbose output. + + + + Files @@ -77,12 +407,11 @@
- See also - - - home-configuration.nix - 5 - - + See also + + + home-configuration.nix + 5 + diff --git a/doc/manual.xml b/doc/manual.xml index c4493254b7c..014a4a7a865 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -30,5 +30,9 @@ Configuration Options + + Tools + + diff --git a/home-manager/completion.bash b/home-manager/completion.bash index cb7c0009693..501b87279fa 100644 --- a/home-manager/completion.bash +++ b/home-manager/completion.bash @@ -49,9 +49,13 @@ # -A # -I # -f +# --file # -h +# --help # -n +# --dry-run # -v +# --verbose # build # edit # expire-generations @@ -61,6 +65,7 @@ # packages # remove-generations # switch +# uninstall # $ home-manager e # @@ -88,15 +93,21 @@ # expire-generations # packages # news +# uninstall # « home-manager » Options: # +# -b EXT # -f FILE +# --file FILE # -A ATTRIBUTE # -I PATH # -v +# --verbose # -n +# --dry-run # -h +# --help # $ home-manager # @@ -109,6 +120,7 @@ # -A ATTRIBUTE Optional attribute that selects a configuration # expression in the configuration file. # -I PATH Add a path to the Nix expression search path. +# -b EXT Move existing files to new path rather than fail. # -v Verbose output # -n Do a dry run, only prints what actions would be taken # -h Print this help @@ -138,7 +150,8 @@ # # news Show news entries in a pager # - +# uninstall Remove Home Manager +# ################################################## # Dependencies: @@ -265,14 +278,14 @@ _home-manager_completions () #--------------------------# local Subcommands - Subcommands=( "help" "edit" "build" "switch" "generations" "remove-generations" "expire-generations" "packages" "news" ) + Subcommands=( "help" "edit" "build" "switch" "generations" "remove-generations" "expire-generations" "packages" "news" "uninstall" ) # ^ « home-manager »'s subcommands. #--------------------------# local Options - Options=( "-f" "-A" "-I" "-h" "-n" "-v" ) + Options=( "-f" "--file" "-b" "-A" "-I" "-h" "--help" "-n" "--dry-run" "-v" "--verbose" "--show-trace" ) # ^ « home-manager »'s options. @@ -304,7 +317,7 @@ _home-manager_completions () case "$PreviousWord" in - "-f") + "-f"|"--file") COMPREPLY+=( $( compgen -A file -- "$CurrentWord") ) ;; diff --git a/home-manager/home-manager b/home-manager/home-manager index b6ea92edb9e..bd81fc92357 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -93,12 +93,14 @@ function doBuildAttr() { nix build \ -f "" \ $extraArgs \ + ${PASSTHROUGH_OPTS[*]} \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" else nix-build \ "" \ $extraArgs \ + ${PASSTHROUGH_OPTS[*]} \ --argstr confPath "$HOME_MANAGER_CONFIG" \ --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE" fi @@ -451,62 +453,69 @@ function doHelp() { EXTRA_NIX_PATH=() HOME_MANAGER_CONFIG_ATTRIBUTE="" +PASSTHROUGH_OPTS=() +COMMAND="" +COMMAND_ARGS=() -# As a special case, if the user has given --help anywhere on the -# command line then print help and exit. -for arg in "$@"; do - if [[ $arg == "--help" ]]; then - doHelp - exit 0 - fi -done - -while getopts 2f:I:A:b:vnh opt; do +while [[ $# -gt 0 ]]; do + opt="$1" + shift case $opt in - 2) + build|edit|expire-generations|generations|help|news|packages|remove-generations|switch|uninstall) + COMMAND="$opt" + ;; + -2) USE_NIX2_COMMAND=1 ;; - f) - HOME_MANAGER_CONFIG="$OPTARG" + -A) + HOME_MANAGER_CONFIG_ATTRIBUTE="$1" + shift ;; - I) - EXTRA_NIX_PATH+=("$OPTARG") + -I) + EXTRA_NIX_PATH+=("$1") + shift ;; - A) - HOME_MANAGER_CONFIG_ATTRIBUTE="$OPTARG" + -b) + export HOME_MANAGER_BACKUP_EXT="$1" + shift ;; - b) - export HOME_MANAGER_BACKUP_EXT="$OPTARG" + -f|--file) + HOME_MANAGER_CONFIG="$1" + shift ;; - v) - export VERBOSE=1 + -h|--help) + doHelp ;; - n) + -n|--dry-run) export DRY_RUN=1 ;; - h) - doHelp - exit 0 + --show-trace) + PASSTHROUGH_OPTS+=("$opt") + ;; + -v|--verbose) + export VERBOSE=1 ;; *) - doHelp >&2 - exit 1 + case $COMMAND in + expire-generations|remove-generations) + COMMAND_ARGS+=("$opt") + ;; + *) + errorEcho "$0: unknown option '$opt'" + errorEcho "Run '$0 --help' for usage help" + exit 1 + ;; + esac ;; esac done -# Get rid of the options. -shift "$((OPTIND-1))" - -if [[ $# -eq 0 ]]; then +if [[ -z $COMMAND ]]; then doHelp >&2 exit 1 fi -cmd="$1" -shift 1 - -case "$cmd" in +case $COMMAND in edit) doEdit ;; @@ -520,10 +529,15 @@ case "$cmd" in doListGens ;; remove-generations) - doRmGenerations "$@" + doRmGenerations "${COMMAND_ARGS[@]}" ;; expire-generations) - doExpireGenerations "$@" + if [[ ${#COMMAND_ARGS[@]} != 1 ]]; then + errorEcho "expire-generations expects one argument, got ${#COMMAND_ARGS[@]}." + exit 1 + else + doExpireGenerations "${COMMAND_ARGS[@]}" + fi ;; packages) doListPackages @@ -534,11 +548,11 @@ case "$cmd" in uninstall) doUninstall ;; - help|--help) + help) doHelp ;; *) - errorEcho "Unknown command: $cmd" + errorEcho "Unknown command: $COMMAND" doHelp >&2 exit 1 ;; -- cgit v1.2.3 From cf0aad391c10473fa7613dcc41b1f6a366d03148 Mon Sep 17 00:00:00 2001 From: Jonas Holst Damtoft Date: Sat, 29 Dec 2018 21:21:11 +0100 Subject: emacs: fix merging of `extraPackages` and `overrides` Because `extraPackages` and `overrides` expect functions as values it has not been possible to perform merges. This adds suitable types for these options that allow reasonable merging. --- modules/lib/types.nix | 28 ++++++++++++++++++++++++++++ modules/programs/emacs.nix | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 modules/lib/types.nix diff --git a/modules/lib/types.nix b/modules/lib/types.nix new file mode 100644 index 00000000000..1b514d20a82 --- /dev/null +++ b/modules/lib/types.nix @@ -0,0 +1,28 @@ +{ lib }: + +with lib; + +{ + + selectorFunction = mkOptionType { + name = "selectorFunction"; + description = + "Function that takes an attribute set and returns a list" + + " containing a selection of the values of the input set"; + check = isFunction; + merge = _loc: defs: + as: concatMap (select: select as) (getValues defs); + }; + + overlayFunction = mkOptionType { + name = "overlayFunction"; + description = + "An overlay function, takes self and super and returns" + + " an attribute set overriding the desired attributes."; + check = isFunction; + merge = _loc: defs: + self: super: + foldl' (res: def: mergeAttrs res (def.value self super)) {} defs; + }; + +} diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index a7f8b94cd81..fc796af56e8 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -4,6 +4,8 @@ with lib; let + hmTypes = import ../lib/types.nix { inherit lib; }; + cfg = config.programs.emacs; # Copied from all-packages.nix, with modifications to support @@ -34,6 +36,7 @@ in extraPackages = mkOption { default = self: []; + type = hmTypes.selectorFunction; defaultText = "epkgs: []"; example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; description = "Extra packages available to Emacs."; @@ -41,6 +44,7 @@ in overrides = mkOption { default = self: super: {}; + type = hmTypes.overlayFunction; defaultText = "self: super: {}"; example = literalExample '' self: super: rec { -- cgit v1.2.3 From f83c49baa3cf4de627bcfd3c70730478aaa3998a Mon Sep 17 00:00:00 2001 From: Kai Wohlfahrt Date: Tue, 18 Jun 2019 12:59:40 +0100 Subject: gpg-agent: add sshcontrol configuration This lets gpg-agent serve specific keys with authentication capability as SSH keys --- modules/services/gpg-agent.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index c4c045e5021..5dc942fef63 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -70,6 +70,14 @@ in ''; }; + sshKeys = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + Which GPG keys (by keygrip) to expose as SSH keys. + ''; + }; + enableExtraSocket = mkOption { type = types.bool; default = false; @@ -157,6 +165,11 @@ in programs.zsh.initExtra = gpgInitStr; } + (mkIf (cfg.sshKeys != null) { + # Trailing newlines are important + home.file.".gnupg/sshcontrol".text = concatMapStrings (s: "${s}\n") cfg.sshKeys; + }) + # The systemd units below are direct translations of the # descriptions in the # -- cgit v1.2.3 From 95d55b8da152f1efffb7713c82ead83a3fcf476d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 23 Jun 2019 14:06:29 +0200 Subject: xsession: add option `importedVariables` This option lists the environment variables to be imported into the systemd user session. Also add a basic test of the xsession module. --- modules/misc/qt.nix | 3 +- modules/services/taffybar.nix | 2 ++ modules/xsession.nix | 32 +++++++++++++++++----- tests/default.nix | 1 + .../misc/xsession/basic-xprofile-expected.txt | 16 +++++++++++ .../misc/xsession/basic-xsession-expected.txt | 18 ++++++++++++ tests/modules/misc/xsession/basic.nix | 30 ++++++++++++++++++++ tests/modules/misc/xsession/default.nix | 3 ++ 8 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 tests/modules/misc/xsession/basic-xprofile-expected.txt create mode 100644 tests/modules/misc/xsession/basic-xsession-expected.txt create mode 100644 tests/modules/misc/xsession/basic.nix create mode 100644 tests/modules/misc/xsession/default.nix diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index bb59044dd90..60de8774231 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -65,8 +65,7 @@ in then [ pkgs.qgnomeplatform ] else [ pkgs.libsForQt5.qtstyleplugins ]; - xsession.profileExtra = - "systemctl --user import-environment QT_QPA_PLATFORMTHEME"; + xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ]; # Enable GTK+ style for Qt4 in either case. # It doesn’t support the platform theme packages. diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index 23af231ef7a..eb71dd0546c 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -42,5 +42,7 @@ in WantedBy = [ "graphical-session.target" ]; }; }; + + xsession.importedVariables = [ "GDK_PIXBUF_MODULE_FILE" ]; }; } diff --git a/modules/xsession.nix b/modules/xsession.nix index 42fe45bb18a..8202e02599c 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -62,10 +62,31 @@ in default = ""; description = "Extra shell commands to run during initialization."; }; + + importedVariables = mkOption { + type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*"); + example = [ "GDK_PIXBUF_ICON_LOADER" ]; + visible = false; + description = '' + Environment variables to import into the user systemd + session. The will be available for use by graphical + services. + ''; + }; }; }; config = mkIf cfg.enable { + xsession.importedVariables = [ + "DBUS_SESSION_BUS_ADDRESS" + "DISPLAY" + "SSH_AUTH_SOCK" + "XAUTHORITY" + "XDG_DATA_DIRS" + "XDG_RUNTIME_DIR" + "XDG_SESSION_ID" + ]; + systemd.user = { services = mkIf (config.home.keyboard != null) { setxkbmap = { @@ -118,13 +139,10 @@ in # script starts up graphical-session.target. systemctl --user stop graphical-session.target graphical-session-pre.target - systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS - systemctl --user import-environment DISPLAY - systemctl --user import-environment SSH_AUTH_SOCK - systemctl --user import-environment XAUTHORITY - systemctl --user import-environment XDG_DATA_DIRS - systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user import-environment XDG_SESSION_ID + ${optionalString (cfg.importedVariables != []) ( + "systemctl --user import-environment " + + toString (unique cfg.importedVariables) + )} ${cfg.profileExtra} diff --git a/tests/default.nix b/tests/default.nix index 3ef1fa43e42..8009b90c9be 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -33,6 +33,7 @@ import nmt { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; } // import ./modules/misc/pam + // import ./modules/misc/xsession // import ./modules/systemd ) // import ./modules/home-environment diff --git a/tests/modules/misc/xsession/basic-xprofile-expected.txt b/tests/modules/misc/xsession/basic-xprofile-expected.txt new file mode 100644 index 00000000000..4fa93f97e6b --- /dev/null +++ b/tests/modules/misc/xsession/basic-xprofile-expected.txt @@ -0,0 +1,16 @@ +. "/test-home/.nix-profile/etc/profile.d/hm-session-vars.sh" + +if [[ -e "$HOME/.profile" ]]; then + . "$HOME/.profile" +fi + +# If there are any running services from a previous session. +# Need to run this in xprofile because the NixOS xsession +# script starts up graphical-session.target. +systemctl --user stop graphical-session.target graphical-session-pre.target + +systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_AUTH_SOCK XAUTHORITY XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID EXTRA_IMPORTED_VARIABLE + +profile extra commands + +export HM_XPROFILE_SOURCED=1 diff --git a/tests/modules/misc/xsession/basic-xsession-expected.txt b/tests/modules/misc/xsession/basic-xsession-expected.txt new file mode 100644 index 00000000000..20d7c4998c3 --- /dev/null +++ b/tests/modules/misc/xsession/basic-xsession-expected.txt @@ -0,0 +1,18 @@ +if [[ ! -v HM_XPROFILE_SOURCED ]]; then + . ~/.xprofile +fi +unset HM_XPROFILE_SOURCED + +systemctl --user start hm-graphical-session.target + +init extra commands + +window manager command + +systemctl --user stop graphical-session.target +systemctl --user stop graphical-session-pre.target + +# Wait until the units actually stop. +while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do + sleep 0.5 +done diff --git a/tests/modules/misc/xsession/basic.nix b/tests/modules/misc/xsession/basic.nix new file mode 100644 index 00000000000..81329afced5 --- /dev/null +++ b/tests/modules/misc/xsession/basic.nix @@ -0,0 +1,30 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + home.homeDirectory = "/test-home"; + + xsession = { + enable = true; + windowManager.command = "window manager command"; + importedVariables = [ "EXTRA_IMPORTED_VARIABLE" ]; + initExtra = "init extra commands"; + profileExtra = "profile extra commands"; + }; + + nmt.script = '' + assertFileExists home-files/.xprofile + assertFileContent \ + home-files/.xprofile \ + ${./basic-xprofile-expected.txt} + + assertFileExists home-files/.xsession + assertFileContent \ + home-files/.xsession \ + ${./basic-xsession-expected.txt} + + ''; + }; +} diff --git a/tests/modules/misc/xsession/default.nix b/tests/modules/misc/xsession/default.nix new file mode 100644 index 00000000000..fdacd3bbc39 --- /dev/null +++ b/tests/modules/misc/xsession/default.nix @@ -0,0 +1,3 @@ +{ + xsession-basic = ./basic.nix; +} -- cgit v1.2.3 From 8243cc0a5da38226dc223451b6ffbad8a74b6fd7 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Tue, 12 Jun 2018 22:40:05 +0300 Subject: getmail: add module --- modules/misc/news.nix | 8 ++ modules/modules.nix | 1 + modules/services/getmail.nix | 205 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 modules/services/getmail.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1953354d665..2dafe1fdcda 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1122,6 +1122,14 @@ in 'foo.conf.bck'. ''; } + + { + time = "2019-06-19T17:49:29+00:00"; + message = '' + A new module is available: `services.getmail`. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index af0cbc1ca1c..6900ed67d3e 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -99,6 +99,7 @@ let (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) + (loadModule ./services/getmail.nix { }) (loadModule ./services/kbfs.nix { }) (loadModule ./services/kdeconnect.nix { }) (loadModule ./services/keepassx.nix { }) diff --git a/modules/services/getmail.nix b/modules/services/getmail.nix new file mode 100644 index 00000000000..74c9cf6b6c7 --- /dev/null +++ b/modules/services/getmail.nix @@ -0,0 +1,205 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.getmail; + + retrieverModule = types.submodule ({config,...}: { + options = { + type = mkOption { + type = types.enum [ + "SimplePOP3Retriever" + "SimplePOP3SSLRetriever" + "SimpleIMAPRetriever" + "SimpleIMAPSSLRetriever" + ]; + default = "SimpleIMAPSSLRetriever"; + description = "Type of the retriever."; + }; + + server = mkOption { + type = types.string; + default = ""; + description = "The remote server."; + }; + + username = mkOption { + type = types.string; + default = ""; + description = "The server username."; + }; + + password = mkOption { + type = types.nullOr types.string; + default = null; + description = '' + The server password. Note that the passwords are stored clear in the + nix store, so it is recommended to not use this field, but instead + either leave empty or use passwordCommand instead. + ''; + }; + + passwordCommand = mkOption { + type = types.nullOr (types.listOf types.string); + default = null; + example = ["${pkgs.gnupg}/bin/gpg" "--decrypt" "file.gpg"]; + description = '' + The server password. With this the password is retrieved with the + given command. The list value is given escaped to the implementation. + ''; + }; + + mailboxes = mkOption { + type = types.listOf types.string; + default = []; + description = "A list of mailboxes"; + }; + }; + }); + + destinationModule = types.submodule ({config,...}: { + options = { + type = mkOption { + type = types.enum [ + "MDA_external" + "Maildir" + ]; + default = "Maildir"; + description = "Destination type."; + }; + + path = mkOption { + type = types.string; + default = "$HOME/Mail"; + example = "${pkgs.procmail}/bin/procmail"; + description = '' + The destination path. For Maildir it's the file + path and for MDA_external it's the destination + application. + ''; + }; + }; + }); + + optionsModule = types.submodule ({config,...}: { + options = { + delete = mkOption { + type = types.bool; + default = false; + description = '' + Enable if you want to delete read messages from the server. Most + users should either enable delete or disable + readAll. + ''; + }; + + readAll = mkOption { + type = types.bool; + default = true; + description = '' + Enable if you want to fetch all, even the read messages from the + server. Most users should either enable delete or + disable readAll. + ''; + }; + }; + }); + +in + +{ + options = { + programs.getmail = { + enable = mkEnableOption "Enable getmail"; + + retriever = mkOption { + type = retrieverModule; + default = {}; + description = "The server section."; + }; + + destination = mkOption { + type = destinationModule; + default = {}; + description = "The destination section."; + }; + + options = mkOption { + type = optionsModule; + default = {}; + description = "The options section."; + }; + + frequency = mkOption { + type = types.string; + default = "*:0/15"; + example = "hourly"; + description = '' + The refresh frequency. Check man systemd.time for + more information on the syntax. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.file.".getmail/getmailrc".text = + let + quoted = x: "\"${escape ["\""] x}\""; + + passwordCommand = concatStringsSep ", " (map quoted cfg.retriever.passwordCommand); + + password = if cfg.retriever.passwordCommand != null + then "password_command = (${passwordCommand})" + else optionalString (cfg.retriever.password != null) "password = \"${quoted cfg.retriever.password}\""; + mailboxInner = concatStringsSep ", " ( + map quoted cfg.retriever.mailboxes); + + mailboxes = "(${mailboxInner})"; + + in + + '' + [retriever] + type = ${cfg.retriever.type} + server = ${cfg.retriever.server} + username = ${cfg.retriever.username} + ${password} + mailboxes = ${mailboxes} + + [destination] + type = ${cfg.destination.type} + path = ${cfg.destination.path} + + [options] + delete = ${toString cfg.options.delete} + read_all = ${toString cfg.options.readAll} + ''; + + systemd.user.services.getmail = { + Unit = { + Description = "getmail email fetcher"; + PartOf = ["network-online.target"]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.getmail}/bin/getmail"; + }; + }; + + systemd.user.timers.getmail = { + Unit = { + Description = "getmail email fetcher"; + }; + Timer = { + OnCalendar = "${cfg.frequency}"; + Unit = "getmail.service"; + }; + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 68fe8623ad0a38c82776b2d0514e33943068236b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3man=20Joost?= Date: Wed, 1 May 2019 21:32:37 +1000 Subject: Address code review comments for getmail service This patch started by addresssing the code review comments to close https://github.com/rycee/home-manager/pull/290. However initiating a new pull request it became clear, that home-manager changed significantly since then. This changes the initial pull request to be consistent with the email account management in home-manager now. It also adds a simple test and support for multiple accounts. --- modules/accounts/email.nix | 1 + modules/modules.nix | 3 +- modules/programs/getmail-accounts.nix | 49 ++++++++ modules/programs/getmail.nix | 59 +++++++++ modules/services/getmail.nix | 178 +++------------------------ tests/default.nix | 1 + tests/modules/programs/getmail-expected.conf | 15 +++ tests/modules/programs/getmail.nix | 26 ++++ 8 files changed, 170 insertions(+), 162 deletions(-) create mode 100644 modules/programs/getmail-accounts.nix create mode 100644 modules/programs/getmail.nix create mode 100644 tests/modules/programs/getmail-expected.conf create mode 100644 tests/modules/programs/getmail.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 6bde6da0be9..71ecd3020e6 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -388,6 +388,7 @@ in mailAccountOpts (import ../programs/alot-accounts.nix pkgs) (import ../programs/astroid-accounts.nix) + (import ../programs/getmail-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) (import ../programs/notmuch-accounts.nix) diff --git a/modules/modules.nix b/modules/modules.nix index 6900ed67d3e..1fffb5947d7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -51,6 +51,7 @@ let (loadModule ./programs/firefox.nix { }) (loadModule ./programs/fish.nix { }) (loadModule ./programs/fzf.nix { }) + (loadModule ./programs/getmail.nix { }) (loadModule ./programs/git.nix { }) (loadModule ./programs/gnome-terminal.nix { }) (loadModule ./programs/go.nix { }) @@ -99,7 +100,7 @@ let (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/getmail.nix { }) + (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/kbfs.nix { }) (loadModule ./services/kdeconnect.nix { }) (loadModule ./services/keepassx.nix { }) diff --git a/modules/programs/getmail-accounts.nix b/modules/programs/getmail-accounts.nix new file mode 100644 index 00000000000..32e1312dc8f --- /dev/null +++ b/modules/programs/getmail-accounts.nix @@ -0,0 +1,49 @@ +{ config, lib, ... }: + +with lib; + +{ + options.getmail = { + enable = mkEnableOption "the getmail mail retriever for this account"; + + destinationCommand = mkOption { + type = types.nullOr types.str; + default = null; + example = "\${pkgs.maildrop}/bin/maildrop"; + description = '' + Specify a command delivering the incoming mail to your maildir. + ''; + }; + + mailboxes = mkOption { + type = types.nonEmptyListOf types.str; + default = []; + example = ["INBOX" "INBOX.spam"]; + description = '' + A non-empty list of mailboxes. To download all mail you can + use the ALL mailbox. + ''; + }; + + delete = mkOption { + type = types.bool; + default = false; + description = '' + Enable if you want to delete read messages from the server. Most + users should either enable delete or disable + readAll. + ''; + }; + + readAll = mkOption { + type = types.bool; + default = true; + description = '' + Enable if you want to fetch all, even the read messages from the + server. Most users should either enable delete or + disable readAll. + ''; + }; + + }; +} diff --git a/modules/programs/getmail.nix b/modules/programs/getmail.nix new file mode 100644 index 00000000000..8c1ac5e021e --- /dev/null +++ b/modules/programs/getmail.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + accounts = filter (a: a.getmail.enable) + (attrValues config.accounts.email.accounts); + + renderAccountConfig = account: with account; + let + passCmd = concatMapStringsSep ", " (x: "'${x}'") passwordCommand; + renderedMailboxes = concatMapStringsSep ", " (x: "'${x}'") getmail.mailboxes; + retrieverType = if imap.tls.enable + then "SimpleIMAPSSLRetriever" + else "SimpleIMAPRetriever"; + destination = if getmail.destinationCommand != null + then + { + destinationType = "MDA_external"; + destinationPath = getmail.destinationCommand; + } + else + { + destinationType = "Maildir"; + destinationPath = "${maildir.absPath}/"; + }; + renderGetmailBoolean = v: if v then "true" else "false"; + in '' + # Generated by Home-Manager. + [retriever] + type = ${retrieverType} + server = ${imap.host} + username = ${userName} + password_command = (${passCmd}) + mailboxes = ( ${renderedMailboxes} ) + + [destination] + type = ${destination.destinationType} + path = ${destination.destinationPath} + + [options] + delete = ${renderGetmailBoolean getmail.delete} + read_all = ${renderGetmailBoolean getmail.readAll} + ''; + getmailEnabled = length (filter (a: a.getmail.enable) accounts) > 0; + # Watch out! This is used by the getmail.service too! + renderConfigFilepath = a: ".getmail/getmail${if a.primary then "rc" else a.name}"; +in + + { + config = mkIf getmailEnabled { + home.file = map (a: + { target = renderConfigFilepath a; + text = renderAccountConfig a; + }) accounts; + + }; + } diff --git a/modules/services/getmail.nix b/modules/services/getmail.nix index 74c9cf6b6c7..46d4c1752d4 100644 --- a/modules/services/getmail.nix +++ b/modules/services/getmail.nix @@ -4,188 +4,43 @@ with lib; let - cfg = config.programs.getmail; + cfg = config.services.getmail; - retrieverModule = types.submodule ({config,...}: { - options = { - type = mkOption { - type = types.enum [ - "SimplePOP3Retriever" - "SimplePOP3SSLRetriever" - "SimpleIMAPRetriever" - "SimpleIMAPSSLRetriever" - ]; - default = "SimpleIMAPSSLRetriever"; - description = "Type of the retriever."; - }; - - server = mkOption { - type = types.string; - default = ""; - description = "The remote server."; - }; - - username = mkOption { - type = types.string; - default = ""; - description = "The server username."; - }; - - password = mkOption { - type = types.nullOr types.string; - default = null; - description = '' - The server password. Note that the passwords are stored clear in the - nix store, so it is recommended to not use this field, but instead - either leave empty or use passwordCommand instead. - ''; - }; - - passwordCommand = mkOption { - type = types.nullOr (types.listOf types.string); - default = null; - example = ["${pkgs.gnupg}/bin/gpg" "--decrypt" "file.gpg"]; - description = '' - The server password. With this the password is retrieved with the - given command. The list value is given escaped to the implementation. - ''; - }; - - mailboxes = mkOption { - type = types.listOf types.string; - default = []; - description = "A list of mailboxes"; - }; - }; - }); - - destinationModule = types.submodule ({config,...}: { - options = { - type = mkOption { - type = types.enum [ - "MDA_external" - "Maildir" - ]; - default = "Maildir"; - description = "Destination type."; - }; - - path = mkOption { - type = types.string; - default = "$HOME/Mail"; - example = "${pkgs.procmail}/bin/procmail"; - description = '' - The destination path. For Maildir it's the file - path and for MDA_external it's the destination - application. - ''; - }; - }; - }); - - optionsModule = types.submodule ({config,...}: { - options = { - delete = mkOption { - type = types.bool; - default = false; - description = '' - Enable if you want to delete read messages from the server. Most - users should either enable delete or disable - readAll. - ''; - }; - - readAll = mkOption { - type = types.bool; - default = true; - description = '' - Enable if you want to fetch all, even the read messages from the - server. Most users should either enable delete or - disable readAll. - ''; - }; - }; - }); + accounts = filter (a: a.getmail.enable) + (attrValues config.accounts.email.accounts); + # Note: The getmail service does not expect a path, but just the filename! + renderConfigFilepath = a: if a.primary then "getmailrc" else "getmail${a.name}"; + configFiles = concatMapStringsSep " " (a: " --rcfile ${renderConfigFilepath a}") accounts; in - { options = { - programs.getmail = { - enable = mkEnableOption "Enable getmail"; - - retriever = mkOption { - type = retrieverModule; - default = {}; - description = "The server section."; - }; - - destination = mkOption { - type = destinationModule; - default = {}; - description = "The destination section."; - }; - - options = mkOption { - type = optionsModule; - default = {}; - description = "The options section."; - }; + services.getmail = { + enable = mkEnableOption "the getmail systemd service to automatically retrieve mail"; frequency = mkOption { - type = types.string; - default = "*:0/15"; + type = types.str; + default = "*:0/5"; example = "hourly"; description = '' The refresh frequency. Check man systemd.time for - more information on the syntax. + more information on the syntax. If you use a gpg-agent in + combination with the passwordCommand, keep the poll + frequency below the cache-ttl value (as set by the + default) to avoid pinentry asking + permanently for a password. ''; }; }; }; config = mkIf cfg.enable { - home.file.".getmail/getmailrc".text = - let - quoted = x: "\"${escape ["\""] x}\""; - - passwordCommand = concatStringsSep ", " (map quoted cfg.retriever.passwordCommand); - - password = if cfg.retriever.passwordCommand != null - then "password_command = (${passwordCommand})" - else optionalString (cfg.retriever.password != null) "password = \"${quoted cfg.retriever.password}\""; - mailboxInner = concatStringsSep ", " ( - map quoted cfg.retriever.mailboxes); - - mailboxes = "(${mailboxInner})"; - - in - - '' - [retriever] - type = ${cfg.retriever.type} - server = ${cfg.retriever.server} - username = ${cfg.retriever.username} - ${password} - mailboxes = ${mailboxes} - - [destination] - type = ${cfg.destination.type} - path = ${cfg.destination.path} - - [options] - delete = ${toString cfg.options.delete} - read_all = ${toString cfg.options.readAll} - ''; - systemd.user.services.getmail = { Unit = { Description = "getmail email fetcher"; - PartOf = ["network-online.target"]; }; Service = { - Type = "simple"; - ExecStart = "${pkgs.getmail}/bin/getmail"; + ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; }; }; @@ -201,5 +56,6 @@ in WantedBy = [ "timers.target" ]; }; }; + }; } diff --git a/tests/default.nix b/tests/default.nix index 8009b90c9be..9fcd1d9f8db 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -25,6 +25,7 @@ import nmt { git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; mbsync = ./modules/programs/mbsync.nix; + getmail = ./modules/programs/getmail.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } diff --git a/tests/modules/programs/getmail-expected.conf b/tests/modules/programs/getmail-expected.conf new file mode 100644 index 00000000000..da54e709236 --- /dev/null +++ b/tests/modules/programs/getmail-expected.conf @@ -0,0 +1,15 @@ +# Generated by Home-Manager. +[retriever] +type = SimpleIMAPSSLRetriever +server = imap.example.com +username = home.manager +password_command = ('password-command') +mailboxes = ( 'INBOX', 'Sent', 'Work' ) + +[destination] +type = MDA_external +path = /bin/maildrop + +[options] +delete = false +read_all = true diff --git a/tests/modules/programs/getmail.nix b/tests/modules/programs/getmail.nix new file mode 100644 index 00000000000..12806c25679 --- /dev/null +++ b/tests/modules/programs/getmail.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../accounts/email-test-accounts.nix ]; + + config = { + home.username = "hm-user"; + home.homeDirectory = "/home/hm-user"; + + accounts.email.accounts = { + "hm@example.com".getmail = { + enable = true; + mailboxes = ["INBOX" "Sent" "Work"]; + destinationCommand = "/bin/maildrop"; + delete = false; + }; + }; + + nmt.script = '' + assertFileExists home-files/.getmail/getmailhm@example.com + assertFileContent home-files/.getmail/getmailhm@example.com ${./getmail-expected.conf} + ''; + }; +} -- cgit v1.2.3 From 8f7cd532040d14e3db907c6ffaa4a149e443d5e4 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 27 Jun 2019 20:04:18 +0200 Subject: getmail: restrict platform to Linux Need to limit this module to Linux since it uses systemd. --- modules/misc/news.nix | 1 + modules/modules.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 2dafe1fdcda..93e649c434e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1125,6 +1125,7 @@ in { time = "2019-06-19T17:49:29+00:00"; + condition = hostPlatform.isLinux; message = '' A new module is available: `services.getmail`. ''; diff --git a/modules/modules.nix b/modules/modules.nix index 1fffb5947d7..55a420f55f5 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -51,7 +51,7 @@ let (loadModule ./programs/firefox.nix { }) (loadModule ./programs/fish.nix { }) (loadModule ./programs/fzf.nix { }) - (loadModule ./programs/getmail.nix { }) + (loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; }) (loadModule ./programs/git.nix { }) (loadModule ./programs/gnome-terminal.nix { }) (loadModule ./programs/go.nix { }) -- cgit v1.2.3 From 8467e7e10a6f4a8968710b1a8e1826cae29834b7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 28 Jun 2019 05:56:42 +0200 Subject: getmail: restrict tests to Linux --- tests/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/default.nix b/tests/default.nix index 9fcd1d9f8db..29b02eeb4af 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -25,12 +25,12 @@ import nmt { git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; mbsync = ./modules/programs/mbsync.nix; - getmail = ./modules/programs/getmail.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux ( { + getmail = ./modules/programs/getmail.nix; i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; } // import ./modules/misc/pam -- cgit v1.2.3 From 28f2dd612ec7c3bd07ec951aa6862d0702ab6624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20H=C3=A9aum=C3=A9?= Date: Wed, 27 Mar 2019 12:36:37 +0100 Subject: broot: add module --- modules/misc/news.nix | 6 ++ modules/modules.nix | 1 + modules/programs/broot.nix | 261 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 modules/programs/broot.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 93e649c434e..0af6963a3bb 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1131,6 +1131,12 @@ in ''; } + { + time = "2019-07-02T09:27:56+00:00"; + message = '' + A new module is available: 'programs.broot'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 55a420f55f5..2a3549d17de 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -41,6 +41,7 @@ let (loadModule ./programs/bash.nix { }) (loadModule ./programs/bat.nix { }) (loadModule ./programs/beets.nix { }) + (loadModule ./programs/broot.nix { }) (loadModule ./programs/browserpass.nix { }) (loadModule ./programs/chromium.nix { condition = hostPlatform.isLinux; }) (loadModule ./programs/command-not-found/command-not-found.nix { }) diff --git a/modules/programs/broot.nix b/modules/programs/broot.nix new file mode 100644 index 00000000000..f6d3cd7f920 --- /dev/null +++ b/modules/programs/broot.nix @@ -0,0 +1,261 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.broot; + + configFile = config: + pkgs.runCommand "conf.toml" + { + buildInputs = [ pkgs.remarshal ]; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + remarshal -if json -of toml \ + < ${pkgs.writeText "verbs.json" (builtins.toJSON config)} \ + > $out + ''; + + brootConf = { + verbs = + mapAttrsToList + (name: value: value // { invocation = name; }) + cfg.verbs; + skin = cfg.skin; + }; + +in + +{ + meta.maintainers = [ maintainers.aheaume ]; + + options.programs.broot = { + enable = mkEnableOption "Broot, a better way to navigate directories"; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + + enableFishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Fish integration. + ''; + }; + + verbs = mkOption { + type = with types; attrsOf (attrsOf (either bool str)); + default = { + "p" = { execution = ":parent"; }; + "edit" = { shortcut = "e"; execution = "$EDITOR {file}" ; }; + "create {subpath}" = { execution = "$EDITOR {directory}/{subpath}"; }; + "view" = { execution = "less {file}"; }; + }; + example = literalExample '' + { + "p" = { execution = ":parent"; }; + "edit" = { shortcut = "e"; execution = "$EDITOR {file}" ; }; + "create {subpath}" = { execution = "$EDITOR {directory}/{subpath}"; }; + "view" = { execution = "less {file}"; }; + "blop {name}\\.{type}" = { + execution = "/bin/mkdir {parent}/{type} && /usr/bin/nvim {parent}/{type}/{name}.{type}"; + from_shell = true; + }; + } + ''; + description = '' + Define new verbs. The attribute name indicates how the verb is + called by the user, with placeholders for arguments. + + The possible attributes are: + + + + + + execution (mandatory) + how the verb is executed + + + shortcut (optional) + an alternate way to call the verb (without + the arguments part) + + + leave_broot (optional) + whether to quit broot on execution + (default: true) + + + from_shell (optional) + whether the verb must be executed from the + parent shell (default: + false) + + + ''; + }; + + skin = mkOption { + type = types.attrsOf types.str; + default = {}; + example = literalExample '' + { + status_normal_fg = "grayscale(18)"; + status_normal_bg = "grayscale(3)"; + status_error_fg = "red"; + status_error_bg = "yellow"; + tree_fg = "red"; + selected_line_bg = "grayscale(7)"; + permissions_fg = "grayscale(12)"; + size_bar_full_bg = "red"; + size_bar_void_bg = "black"; + directory_fg = "lightyellow"; + input_fg = "cyan"; + flag_value_fg = "lightyellow"; + table_border_fg = "red"; + code_fg = "lightyellow"; + } + ''; + description = '' + Color configuration. + + Complete list of keys (expected to change before the v1 of broot): + + + char_match + code + directory + exe + file + file_error + flag_label + flag_value + input + link + permissions + selected_line + size_bar_full + size_bar_void + size_text + spinner + status_error + status_normal + table_border + tree + unlisted + + + + Add _fg for a foreground color and + _bg for a background colors. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.broot ]; + + xdg.configFile."broot/conf.toml".source = configFile brootConf; + + # Dummy file to prevent broot from trying to reinstall itself + xdg.configFile."broot/launcher/installed".text = ""; + + programs.bash.initExtra = + mkIf cfg.enableBashIntegration ( + # Using mkAfter to make it more likely to appear after other + # manipulations of the prompt. + mkAfter '' + # This script was automatically generated by the broot function + # More information can be found in https://github.com/Canop/broot + # This function starts broot and executes the command + # it produces, if any. + # It's needed because some shell commands, like `cd`, + # have no useful effect if executed in a subshell. + function br { + f=$(mktemp) + ( + set +e + broot --outcmd "$f" "$@" + code=$? + if [ "$code" != 0 ]; then + rm -f "$f" + exit "$code" + fi + ) + code=$? + if [ "$code" != 0 ]; then + return "$code" + fi + d=$(cat "$f") + rm -f "$f" + eval "$d" + } + '' + ); + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + # This script was automatically generated by the broot function + # More information can be found in https://github.com/Canop/broot + # This function starts broot and executes the command + # it produces, if any. + # It's needed because some shell commands, like `cd`, + # have no useful effect if executed in a subshell. + function br { + f=$(mktemp) + ( + set +e + broot --outcmd "$f" "$@" + code=$? + if [ "$code" != 0 ]; then + rm -f "$f" + exit "$code" + fi + ) + code=$? + if [ "$code" != 0 ]; then + return "$code" + fi + d=$(cat "$f") + rm -f "$f" + eval "$d" + } + ''; + + programs.fish.shellInit = mkIf cfg.enableFishIntegration '' + # This script was automatically generated by the broot function + # More information can be found in https://github.com/Canop/broot + # This function starts broot and executes the command + # it produces, if any. + # It's needed because some shell commands, like `cd`, + # have no useful effect if executed in a subshell. + function br + set f (mktemp) + broot --outcmd $f $argv + if test $status -ne 0 + rm -f "$f" + return "$code" + end + set d (cat "$f") + rm -f "$f" + eval "$d" + end + ''; + }; +} -- cgit v1.2.3 From 472d7731d64d8db89ea8bbbe5fbf6194fd6a1af8 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 12 Mar 2019 01:35:55 -0700 Subject: git: support multiple values Closes #614 --- modules/programs/git.nix | 19 +++++++++++++++---- tests/modules/programs/git-expected.conf | 2 ++ tests/modules/programs/git.nix | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index a71169cec40..2ab84b5a172 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -6,11 +6,22 @@ let cfg = config.programs.git; + # generation for multiple ini values + mkKeyValue = k: v: + let + mkKeyValue = generators.mkKeyValueDefault {} "=" k; + in + concatStringsSep "\n" (map mkKeyValue (toList v)); + + gitToIni = generators.toINI { inherit mkKeyValue; }; + gitIniType = with types; let - primitiveType = either bool (either int str); + primitiveType = either str (either bool int); + multipleType = either primitiveType (listOf primitiveType); + sectionType = attrsOf multipleType; in - attrsOf (attrsOf primitiveType); + attrsOf sectionType; signModule = types.submodule { options = { @@ -64,7 +75,7 @@ let }; config.path = mkIf (config.contents != {}) ( - mkDefault (pkgs.writeText "contents" (generators.toINI {} config.contents)) + mkDefault (pkgs.writeText "contents" (gitToIni config.contents)) ); }); @@ -175,7 +186,7 @@ in }; xdg.configFile = { - "git/config".text = generators.toINI {} cfg.iniContent; + "git/config".text = gitToIni cfg.iniContent; "git/ignore" = mkIf (cfg.ignores != []) { text = concatStringsSep "\n" cfg.ignores + "\n"; diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf index e6d23d11692..ba4a362e46e 100644 --- a/tests/modules/programs/git-expected.conf +++ b/tests/modules/programs/git-expected.conf @@ -8,6 +8,8 @@ gpgSign=true [extra] boolean=true integer=38 +multiple=1 +multiple=2 name=value [filter "lfs"] diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix index 71573c38428..771c909a5d1 100644 --- a/tests/modules/programs/git.nix +++ b/tests/modules/programs/git.nix @@ -31,6 +31,7 @@ in extraConfig = { extra = { name = "value"; + multiple = [1]; }; }; ignores = [ "*~" "*.swp" ]; @@ -59,6 +60,7 @@ in aliases.a2 = mkForce "baz"; extraConfig.extra.boolean = true; extraConfig.extra.integer = 38; + extraConfig.extra.multiple = [2]; } ]; -- cgit v1.2.3 From 95382060ebaa19ec49a861921216b1db8460b314 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 12 Mar 2019 16:06:36 -0700 Subject: git: support nested section options Closes #614 --- modules/programs/git.nix | 58 ++++++++++++++++++++++++++------ tests/modules/programs/git-expected.conf | 12 +++++-- tests/modules/programs/git.nix | 2 ++ 3 files changed, 58 insertions(+), 14 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 2ab84b5a172..16db07d9adf 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -6,6 +6,19 @@ let cfg = config.programs.git; + # create [section "subsection"] keys from "section.subsection" attrset names + mkSectionName = name: + let + containsQuote = strings.hasInfix ''"'' name; + sections = splitString "." name; + section = head sections; + subsections = tail sections; + subsection = concatStringsSep "." subsections; + in + if containsQuote || subsections == [] + then name + else "${section} \"${subsection}\""; + # generation for multiple ini values mkKeyValue = k: v: let @@ -13,15 +26,33 @@ let in concatStringsSep "\n" (map mkKeyValue (toList v)); - gitToIni = generators.toINI { inherit mkKeyValue; }; + # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI + gitFlattenAttrs = + let + recurse = path: value: + if isAttrs value then + mapAttrsToList (name: value: recurse ([name] ++ path) value) value + else if length path > 1 then + { ${concatStringsSep "." (reverseList (tail path))}.${head path} = value; } + else + { ${head path} = value; }; + in + attrs: foldl recursiveUpdate {} (flatten (recurse [] attrs)); + + gitToIni = attrs: + let + toIni = generators.toINI { inherit mkKeyValue mkSectionName; }; + in + toIni (gitFlattenAttrs attrs); gitIniType = with types; let primitiveType = either str (either bool int); multipleType = either primitiveType (listOf primitiveType); sectionType = attrsOf multipleType; + supersectionType = attrsOf (either multipleType sectionType); in - attrsOf sectionType; + attrsOf supersectionType; signModule = types.submodule { options = { @@ -128,6 +159,7 @@ in default = {}; example = { core = { whitespace = "trailing-space,space-before-tab"; }; + url."ssh://git@host".insteadOf = "otherhost"; }; description = "Additional configuration to add."; }; @@ -200,7 +232,7 @@ in hasSmtp = name: account: account.smtp != null; genIdentity = name: account: with account; - nameValuePair "sendemail \"${name}\"" ({ + nameValuePair "sendemail.${name}" ({ smtpEncryption = if smtp.tls.enable then "tls" else ""; smtpServer = smtp.host; smtpUser = userName; @@ -235,19 +267,23 @@ in }) (mkIf (cfg.includes != []) { - xdg.configFile."git/config".text = mkAfter - (concatMapStringsSep "\n" - (i: with i; '' - [${if (condition == null) then "include" else "includeIf \"${condition}\""}] - path = ${path} - '') - cfg.includes); + xdg.configFile."git/config".text = + let + include = i: with i; + if condition != null + then { includeIf.${condition}.path = "${path}"; } + else { include.path = "${path}"; }; + in + mkAfter + (concatStringsSep "\n" + (map gitToIni + (map include cfg.includes))); }) (mkIf cfg.lfs.enable { home.packages = [ pkgs.git-lfs ]; - programs.git.iniContent."filter \"lfs\"" = + programs.git.iniContent.filter.lfs = let skipArg = optional cfg.lfs.skipSmudge "--skip"; in diff --git a/tests/modules/programs/git-expected.conf b/tests/modules/programs/git-expected.conf index ba4a362e46e..d02ebf31649 100644 --- a/tests/modules/programs/git-expected.conf +++ b/tests/modules/programs/git-expected.conf @@ -12,6 +12,12 @@ multiple=1 multiple=2 name=value +[extra "backcompat.with.dots"] +previously=worked + +[extra "subsection"] +value=test + [filter "lfs"] clean=git-lfs clean -- %f process=git-lfs filter-process @@ -27,10 +33,10 @@ name=John Doe signingKey=00112233445566778899AABBCCDDEEFF [include] -path = ~/path/to/config.inc +path=~/path/to/config.inc [includeIf "gitdir:~/src/dir"] -path = ~/path/to/conditional.inc +path=~/path/to/conditional.inc [includeIf "gitdir:~/src/dir"] -path = @git_include_path@ +path=@git_include_path@ diff --git a/tests/modules/programs/git.nix b/tests/modules/programs/git.nix index 771c909a5d1..c5203e417dc 100644 --- a/tests/modules/programs/git.nix +++ b/tests/modules/programs/git.nix @@ -58,9 +58,11 @@ in { aliases.a2 = mkForce "baz"; + extraConfig."extra \"backcompat.with.dots\"".previously = "worked"; extraConfig.extra.boolean = true; extraConfig.extra.integer = 38; extraConfig.extra.multiple = [2]; + extraConfig.extra.subsection.value = "test"; } ]; -- cgit v1.2.3 From 7c76f4a71f61e8d6d085f86c73ad5b99b2217a27 Mon Sep 17 00:00:00 2001 From: Andreas Fehn Date: Thu, 4 Jul 2019 13:44:43 +0200 Subject: xsuspender: correctly name default section --- modules/services/xsuspender.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/xsuspender.nix b/modules/services/xsuspender.nix index d565fde85e0..17aaa244be2 100644 --- a/modules/services/xsuspender.nix +++ b/modules/services/xsuspender.nix @@ -162,7 +162,7 @@ in }; in { - default = mkSection cfg.defaults; + Default = mkSection cfg.defaults; } // mapAttrs (_: mkSection) cfg.rules; -- cgit v1.2.3 From 2029e104d45e291cdcc2609893b026362497f4ce Mon Sep 17 00:00:00 2001 From: Andreas Fehn Date: Thu, 4 Jul 2019 13:44:59 +0200 Subject: xsuspender: write all options to config --- modules/services/xsuspender.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/services/xsuspender.nix b/modules/services/xsuspender.nix index 17aaa244be2..22a5ca536a5 100644 --- a/modules/services/xsuspender.nix +++ b/modules/services/xsuspender.nix @@ -150,12 +150,16 @@ in services.xsuspender.iniContent = let mkSection = values: filterAttrs (_: v: v != null) { + match_wm_class_contains = values.matchWmClassContains; + match_wm_class_group_contains = values.matchWmClassGroupContains; + match_wm_name_contains = values.matchWmNameContains; suspend_delay = values.suspendDelay; resume_every = values.resumeEvery; resume_for = values.resumeFor; exec_suspend = values.execSuspend; exec_resume = values.execResume; send_signals = values.sendSignals; + suspend_subtree_pattern = values.suspendSubtreePattern; only_on_battery = values.onlyOnBattery; auto_suspend_on_battery = values.autoSuspendOnBattery; downclock_on_battery = values.downclockOnBattery; -- cgit v1.2.3 From c3520bfa52b30f984e73e9616abe4d11ab56de36 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 5 Jul 2019 22:16:15 +0200 Subject: mbsync: put extra config at the beginning If it is at the end it will just end up applying to the last defined section. Fixes #748 --- modules/programs/mbsync.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 209db0dc04f..7e9cdb7f84f 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -173,9 +173,9 @@ in in concatStringsSep "\n" ( [ "# Generated by Home Manager.\n" ] + ++ optional (cfg.extraConfig != "") cfg.extraConfig ++ accountsConfig ++ groupsConfig - ++ optional (cfg.extraConfig != "") cfg.extraConfig ) + "\n"; home.activation.createMaildir = -- cgit v1.2.3 From ca4f22be85bcc1fdc086e72c3104f1c747910f27 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 17 Jul 2019 10:02:35 +0200 Subject: mbsync: use full path to mu in example --- modules/services/mbsync.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/mbsync.nix b/modules/services/mbsync.nix index 5c994cc6bc3..a7897536802 100644 --- a/modules/services/mbsync.nix +++ b/modules/services/mbsync.nix @@ -71,7 +71,7 @@ in postExec = mkOption { type = types.nullOr types.str; default = null; - example = "mu index"; + example = "\${pkgs.mu}/bin/mu index"; description = '' An optional command to run after mbsync executes successfully. This is useful for running mailbox indexing tools. -- cgit v1.2.3 From cc0cd538e62ce5e220ae296e65342ba258d186f8 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 14 Jul 2019 18:08:33 +0200 Subject: taskwarrior-sync: add service module --- modules/misc/news.nix | 8 +++++ modules/modules.nix | 1 + modules/services/taskwarrior-sync.nix | 59 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 modules/services/taskwarrior-sync.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0af6963a3bb..59f1726d3b0 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1137,6 +1137,14 @@ in A new module is available: 'programs.broot'. ''; } + + { + time = "2019-07-17T19:30:29+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.taskwarrior-sync'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 2a3549d17de..d5efe2d1e93 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -124,6 +124,7 @@ let (loadModule ./services/syncthing.nix { }) (loadModule ./services/taffybar.nix { }) (loadModule ./services/tahoe-lafs.nix { }) + (loadModule ./services/taskwarrior-sync.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/udiskie.nix { }) (loadModule ./services/unclutter.nix { }) (loadModule ./services/window-managers/awesome.nix { }) diff --git a/modules/services/taskwarrior-sync.nix b/modules/services/taskwarrior-sync.nix new file mode 100644 index 00000000000..f92f532bdcb --- /dev/null +++ b/modules/services/taskwarrior-sync.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.taskwarrior-sync; + +in + +{ + meta.maintainers = with maintainers; [ minijackson pacien ]; + + options.services.taskwarrior-sync = { + enable = mkEnableOption "Taskwarrior periodic sync"; + + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to run taskwarrior sync. This + value is passed to the systemd timer configuration as the + OnCalendar option. See + + systemd.time + 7 + + for more information about the format. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.taskwarrior-sync = { + Unit = { + Description = "Taskwarrior sync"; + PartOf = [ "network-online.target" ]; + }; + Service = { + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + ExecStart = "${pkgs.taskwarrior}/bin/task synchronize"; + }; + }; + + systemd.user.timers.taskwarrior-sync = { + Unit = { + Description = "Taskwarrior periodic sync"; + }; + Timer = { + Unit = "taskwarrior-sync.service"; + OnCalendar = cfg.frequency; + }; + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }; +} -- cgit v1.2.3 From 734128930f3721bc45fc085ab132b225a8bc5981 Mon Sep 17 00:00:00 2001 From: Shanon McQuay Date: Wed, 17 Jul 2019 23:36:57 +1000 Subject: skim: correctly name default options skim uses SKIM_DEFAULT_OPTIONS rather than SKIM_DEFAULT_OPTS. --- modules/programs/skim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/skim.nix b/modules/programs/skim.nix index 4b8f8ee37e0..de1bff30fce 100644 --- a/modules/programs/skim.nix +++ b/modules/programs/skim.nix @@ -107,7 +107,7 @@ in SKIM_CTRL_T_COMMAND = cfg.fileWidgetCommand; SKIM_CTRL_T_OPTS = cfg.fileWidgetOptions; SKIM_DEFAULT_COMMAND = cfg.defaultCommand; - SKIM_DEFAULT_OPTS = cfg.defaultOptions; + SKIM_DEFAULT_OPTIONS = cfg.defaultOptions; } ); -- cgit v1.2.3 From 7d68c46feb845c572ef335f824062f90fdebf655 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Thu, 21 Mar 2019 19:38:55 +0100 Subject: kakoune: add module --- modules/misc/news.nix | 7 + modules/modules.nix | 1 + modules/programs/kakoune.nix | 574 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 582 insertions(+) create mode 100644 modules/programs/kakoune.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 59f1726d3b0..fce1eb689db 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1145,6 +1145,13 @@ in A new module is available: 'services.taskwarrior-sync'. ''; } + + { + time = "2019-07-17T20:05:29+00:00"; + message = '' + A new module is available: 'programs.kakoune'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d5efe2d1e93..03e048e2bbb 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -62,6 +62,7 @@ let (loadModule ./programs/info.nix { }) (loadModule ./programs/irssi.nix { }) (loadModule ./programs/jq.nix { }) + (loadModule ./programs/kakoune.nix { }) (loadModule ./programs/keychain.nix { }) (loadModule ./programs/lesspipe.nix { }) (loadModule ./programs/lsd.nix { }) diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix new file mode 100644 index 00000000000..5ac4a7b69c2 --- /dev/null +++ b/modules/programs/kakoune.nix @@ -0,0 +1,574 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.kakoune; + + hook = types.submodule { + options = { + name = mkOption { + type = types.enum [ + "NormalBegin" "NormalIdle" "NormalEnd" "NormalKey" + "InsertBegin" "InsertIdle" "InsertEnd" "InsertKey" + "InsertChar" "InsertDelete" "InsertMove" "WinCreate" + "WinClose" "WinResize" "WinDisplay" "WinSetOption" + "BufSetOption" "BufNewFile" "BufOpenFile" "BufCreate" + "BufWritePre" "BufWritePost" "BufReload" "BufClose" + "BufOpenFifo" "BufReadFifo" "BufCloseFifo" "RuntimeError" + "ModeChange" "PromptIdle" "GlobalSetOption" "KakBegin" + "KakEnd" "FocusIn" "FocusOut" "RawKey" + "InsertCompletionShow" "InsertCompletionHide" + "InsertCompletionSelect" + ]; + example = "SetOption"; + description = '' + The name of the hook. For a description, see + . + ''; + }; + + once = mkOption { + type = types.bool; + default = false; + description = '' + Remove the hook after running it once. + ''; + }; + + group = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Add the hook to the named group. + ''; + }; + + option = mkOption { + type = types.nullOr types.str; + default = null; + example = "filetype=latex"; + description = '' + Additional option to pass to the hook. + ''; + }; + + commands = mkOption { + type = types.lines; + default = ""; + example = "set-option window indentwidth 2"; + description = '' + Commands to run when the hook is activated. + ''; + }; + }; + }; + + keyMapping = types.submodule { + options = { + mode = mkOption { + type = types.enum [ + "insert" + "normal" + "prompt" + "menu" + "user" + "goto" + "view" + "object" + ]; + example = "user"; + description = '' + The mode in which the mapping takes effect. + ''; + }; + + docstring = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Optional documentation text to display in info boxes. + ''; + }; + + key = mkOption { + type = types.str; + example = ""; + description = '' + The key to be mapped. See + + for possible values. + ''; + }; + + effect = mkOption { + type = types.str; + example = ":wq"; + description = '' + The sequence of keys to be mapped. + ''; + }; + }; + }; + + configModule = types.submodule { + options = { + colorScheme = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Set the color scheme. To see available schemes, enter + colorscheme at the kakoune prompt. + ''; + }; + + tabStop = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + description = '' + The width of a tab in spaces. The kakoune default is + 6. + ''; + }; + + indentWidth = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + description = '' + The width of an indentation in spaces. + The kakoune default is 4. + If 0, a tab will be used instead. + ''; + }; + + incrementalSearch = mkOption { + type = types.bool; + default = true; + description = '' + Execute a search as it is being typed. + ''; + }; + + alignWithTabs = mkOption { + type = types.bool; + default = false; + description = '' + Use tabs for the align command. + ''; + }; + + autoInfo = mkOption { + type = types.nullOr (types.listOf (types.enum [ "command" "onkey" "normal" ])); + default = null; + example = [ "command" "normal" ]; + description = '' + Contexts in which to display automatic information box. + The kakoune default is [ "command" "onkey" ]. + ''; + }; + + autoComplete = mkOption { + type = types.nullOr(types.listOf (types.enum [ "insert" "prompt" ])); + default = null; + description = '' + Modes in which to display possible completions. + The kakoune default is [ "insert" "prompt" ]. + ''; + }; + + autoReload = mkOption { + type = types.nullOr (types.enum [ "yes" "no" "ask" ]); + default = null; + description = '' + Reload buffers when an external modification is detected. + The kakoune default is "ask". + ''; + }; + + scrollOff = mkOption { + type = types.nullOr (types.submodule { + options = { + lines = mkOption { + type = types.ints.unsigned; + default = 0; + description = '' + The number of lines to keep visible around the cursor. + ''; + }; + + columns = mkOption { + type = types.ints.unsigned; + default = 0; + description = '' + The number of columns to keep visible around the cursor. + ''; + }; + }; + }); + default = null; + description = '' + How many lines and columns to keep visible around the cursor. + ''; + }; + + ui = mkOption { + type = types.nullOr (types.submodule { + options = { + setTitle = mkOption { + type = types.bool; + default = false; + description = '' + Change the title of the terminal emulator. + ''; + }; + + statusLine = mkOption { + type = types.enum [ "top" "bottom" ]; + default = "bottom"; + description = '' + Where to display the status line. + ''; + }; + + assistant = mkOption { + type = types.enum [ "clippy" "cat" "dilbert" "none" ]; + default = "clippy"; + description = '' + The assistant displayed in info boxes. + ''; + }; + + enableMouse = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable mouse support. + ''; + }; + + changeColors = mkOption { + type = types.bool; + default = true; + description = '' + Change color palette. + ''; + }; + + wheelDownButton = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Button to send for wheel down events. + ''; + }; + + wheelUpButton = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Button to send for wheel up events. + ''; + }; + + shiftFunctionKeys = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + description = '' + Amount by which shifted function keys are offset. That + is, if the terminal sends F13 for Shift-F1, this + should be 12. + ''; + }; + + useBuiltinKeyParser = mkOption { + type = types.bool; + default = false; + description = '' + Bypass ncurses key parser and use an internal one. + ''; + }; + }; + }); + default = null; + description = '' + Settings for the ncurses interface. + ''; + }; + + showMatching = mkOption { + type = types.bool; + default = false; + description = '' + Highlight the matching char of the character under the + selections' cursor using the MatchingChar + face. + ''; + }; + + wrapLines = mkOption { + type = types.nullOr (types.submodule { + options = { + enable = mkEnableOption "the wrap lines highlighter"; + + word = mkOption { + type = types.bool; + default = false; + description = '' + Wrap at word boundaries instead of codepoint boundaries. + ''; + }; + + indent = mkOption { + type = types.bool; + default = false; + description = '' + Preserve line indentation when wrapping. + ''; + }; + + maxWidth = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + description = '' + Wrap text at maxWidth, even if the window is wider. + ''; + }; + + marker = mkOption { + type = types.nullOr types.str; + default = null; + example = "⏎"; + description = '' + Prefix wrapped lines with marker text. + If not null, + the marker text will be displayed in the indentation if possible. + ''; + }; + }; + }); + default = null; + description = '' + Settings for the wrap lines highlighter. + ''; + }; + + numberLines = mkOption { + type = types.nullOr (types.submodule { + options = { + enable = mkEnableOption "the number lines highlighter"; + + relative = mkOption { + type = types.bool; + default = false; + description = '' + Show line numbers relative to the main cursor line. + ''; + }; + + highlightCursor = mkOption { + type = types.bool; + default = false; + description = '' + Highlight the cursor line with a separate face. + ''; + }; + + separator = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + String that separates the line number column from the + buffer contents. The kakoune default is + "|". + ''; + }; + }; + }); + default = null; + description = '' + Settings for the number lines highlighter. + ''; + }; + + showWhitespace = mkOption { + type = types.nullOr (types.submodule { + options = { + enable = mkEnableOption "the show whitespace highlighter"; + + lineFeed = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The character to display for line feeds. + The kakoune default is "¬". + ''; + }; + + space = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The character to display for spaces. + The kakoune default is "·". + ''; + }; + + nonBreakingSpace = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The character to display for non-breaking spaces. + The kakoune default is "⍽". + ''; + }; + + tab = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The character to display for tabs. + The kakoune default is "→". + ''; + }; + + tabStop = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + The character to append to tabs to reach the width of a tabstop. + The kakoune default is " ". + ''; + }; + }; + }); + default = null; + description = '' + Settings for the show whitespaces highlighter. + ''; + }; + + keyMappings = mkOption { + type = types.listOf keyMapping; + default = []; + description = '' + User-defined key mappings. For documentation, see + + ''; + }; + + hooks = mkOption { + type = types.listOf hook; + default = []; + description = '' + Global hooks. For documentation, see + . + ''; + }; + }; + }; + + configFile = + let + wrapOptions = with cfg.config.wrapLines; concatStrings [ + "${optionalString word " -word"}" + "${optionalString indent " -indent"}" + "${optionalString (marker != null) " -marker ${marker}"}" + "${optionalString (maxWidth != null) " -width ${toString maxWidth}"}" + ]; + + numberLinesOptions = with cfg.config.numberLines; concatStrings [ + "${optionalString relative " -relative "}" + "${optionalString highlightCursor " -hlcursor"}" + "${optionalString (separator != null) " -separator ${separator}"}" + ]; + + uiOptions = with cfg.config.ui; concatStringsSep " " [ + "ncurses_set_title=${if setTitle then "true" else "false"}" + "ncurses_status_on_top=${if (statusLine == "top") then "true" else "false"}" + "ncurses_assistant=${assistant}" + "ncurses_enable_mouse=${if enableMouse then "true" else "false"}" + "ncurses_change_colors=${if changeColors then "true" else "false"}" + "${optionalString (wheelDownButton != null) + "ncurses_wheel_down_button=${wheelDownButton}"}" + "${optionalString (wheelUpButton != null) + "ncurses_wheel_up_button=${wheelUpButton}"}" + "${optionalString (shiftFunctionKeys != null) + "ncurses_shift_function_key=${toString shiftFunctionKeys}"}" + "ncurses_builtin_key_parser=${if useBuiltinKeyParser then "true" else "false"}" + ]; + + keyMappingString = km: concatStringsSep " " [ + "map global" + "${km.mode} ${km.key} '${km.effect}'" + "${optionalString (km.docstring != null) "-docstring '${km.docstring}'"}" + ]; + + hookString = h: concatStringsSep " " [ + "hook" "${optionalString (h.group != null) "-group ${group}"}" + "${optionalString (h.once) "-once"}" "global" + "${h.name}" "${optionalString (h.option != null) h.option}" + "%{ ${h.commands} }" + ]; + + cfgStr = with cfg.config; concatStringsSep "\n" ( + [ "# Generated by home-manager" ] + ++ optional (colorScheme != null) "colorscheme ${colorScheme}" + ++ optional (tabStop != null) "set-option global tabstop ${toString tabStop}" + ++ optional (indentWidth != null) "set-option global indentwidth ${toString indentWidth}" + ++ optional (!incrementalSearch) "set-option global incsearch false" + ++ optional (alignWithTabs) "set-option global aligntab true" + ++ optional (autoInfo != null) "set-option global autoinfo ${concatStringsSep "|" autoInfo}" + ++ optional (autoComplete != null) "set-option global autocomplete ${concatStringsSep "|" autoComplete}" + ++ optional (autoReload != null) "set-option global/ autoreload ${autoReload}" + ++ optional (wrapLines != null && wrapLines.enable) "add-highlighter global/ wrap${wrapOptions}" + ++ optional (numberLines != null && numberLines.enable) + "add-highlighter global/ number-lines${numberLinesOptions}" + ++ optional showMatching "add-highlighter global/ show-matching" + ++ optional (scrollOff != null) + "set-option global scrolloff ${toString scrollOff.lines},${toString scrollOff.columns}" + + ++ [ "# UI options" ] + ++ optional (ui != null) "set-option global ui_options ${uiOptions}" + + ++ [ "# Key mappings" ] + ++ map keyMappingString keyMappings + + ++ [ "# Hooks" ] + ++ map hookString hooks + ); + in + pkgs.writeText "kakrc" ( + optionalString (cfg.config != null) cfgStr + + cfg.extraConfig + ); + +in + +{ + options = { + programs.kakoune = { + enable = mkEnableOption "the kakoune text editor"; + + config = mkOption { + type = types.nullOr configModule; + default = {}; + description = "kakoune configuration options."; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Extra configuration lines to add to + ~/.config/kak/kakrc. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.kakoune ]; + xdg.configFile."kak/kakrc".source = configFile; + }; +} -- cgit v1.2.3 From 056443ccbdbedeed36f403d5cc1017413358c61a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Jul 2019 19:15:47 +0200 Subject: vscode: fix configuration path for Darwin Fixes #737 --- modules/programs/vscode.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix index 0ebbb8eb13c..3a82816f588 100644 --- a/modules/programs/vscode.nix +++ b/modules/programs/vscode.nix @@ -6,6 +6,12 @@ let cfg = config.programs.vscode; + configFilePath = + if pkgs.stdenv.hostPlatform.isDarwin then + "Library/Application Support/Code/User/settings.json" + else + "${config.xdg.configHome}/Code/User/settings.json"; + in { @@ -23,8 +29,8 @@ in } ''; description = '' - Configuration written to - ~/.config/Code/User/settings.json. + Configuration written to Visual Studio Code's + settings.json. ''; }; @@ -47,7 +53,6 @@ in }) ]; - xdg.configFile."Code/User/settings.json".text = - builtins.toJSON cfg.userSettings; + home.file."${configFilePath}".text = builtins.toJSON cfg.userSettings; }; } -- cgit v1.2.3 From 54de0e1d79a1370e57a8f23bef89f99f9b92ab67 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 26 Jul 2019 23:23:51 +0200 Subject: xdg: create cache directory using keep file We can avoid the activation block by instead creating a hidden file in the directory. --- modules/misc/xdg.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index c3e7981b725..84ab4ada59a 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -92,10 +92,13 @@ in }) { - home.file = mkMerge [ cfg.configFile cfg.dataFile ]; - home.activation.xdgCreateCache = dag.entryAfter [ "writeBoundary" ] '' - $DRY_RUN_CMD mkdir $VERBOSE_ARG -m0700 -p "${config.xdg.cacheHome}" - ''; + home.file = mkMerge [ + cfg.configFile + cfg.dataFile + { + "${config.xdg.cacheHome}/.keep".text = ""; + } + ]; } ]; } -- cgit v1.2.3 From 6239ce20afdc699fe8057d8fe1389d6895ad8730 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Tue, 23 Jul 2019 14:05:38 -0500 Subject: nix-darwin: add docs --- doc/installation.xml | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/doc/installation.xml b/doc/installation.xml index 77f6e167e74..0e4c904e570 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -230,7 +230,81 @@ home-manager.useUserPackages = true; nix-darwin module - To be done. + Home Manager provides a module that allows you to prepare user + environments directly from the nix-darwin configuration file, which often is + more convenient than using the home-manager tool. + + + To make the NixOS module available for use you must + it into your system configuration. This is most conveniently done by adding + a Home Manager channel, for example + + + +# nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager +# nix-channel --update + + + + if you are following Nixpkgs master or an unstable channel and + + + +# nix-channel --add https://github.com/rycee/home-manager/archive/release-19.03.tar.gz home-manager +# nix-channel --update + + + + if you follow a Nixpkgs version 19.03 channel. + + + + It is then possible to add + + + +imports = [ <home-manager/nix-darwin> ]; + + + + to your nix-darwin configuration.nix file, which will + introduce a new NixOS option called whose type + is an attribute set that maps user names to Home Manager configurations. + + + + For example, a nix-darwin configuration may include the lines + + + +home-manager.users.eve = { pkgs, ... }: { + home.packages = [ pkgs.atool pkgs.httpie ]; + programs.bash.enable = true; +}; + + + + and after a darwin-rebuild --switch the user eve's + environment should include a basic Bash configuration and the packages atool + and httpie. + + + + + By default user packages will not be ignored in favor of + , but they will be intalled to + if + + + +home-manager.useUserPackages = true; + + + + is added to the nix-darwin configuration. This option may become the default + value in the future. + + -- cgit v1.2.3 From caf3349f01a18a737356c0b488aa5f611b07782c Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Sun, 28 Jul 2019 13:01:29 +0300 Subject: dconf: assume empty list value is a list of strings Fixes #769. --- modules/misc/dconf.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/misc/dconf.nix b/modules/misc/dconf.nix index 7d3a9731d0e..ef87f8972ff 100644 --- a/modules/misc/dconf.nix +++ b/modules/misc/dconf.nix @@ -13,9 +13,15 @@ let let tweakVal = v: if isString v then "'${v}'" - else if isList v then "[" + concatMapStringsSep "," tweakVal v + "]" + else if isList v then tweakList v else if isBool v then (if v then "true" else "false") else toString v; + + # Assume empty list is a list of strings, see #769 + tweakList = v: + if v == [] then "@as []" + else "[" + concatMapStringsSep "," tweakVal v + "]"; + in "${key}=${tweakVal value}"; -- cgit v1.2.3 From d625186ce599a663b0115b83b70ea0be0ba8afbf Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 28 Jul 2019 14:16:16 +0200 Subject: Remove use of `network-online.target` This target is only available at the system level and has no effect on user services. --- modules/services/mbsync.nix | 1 - modules/services/taskwarrior-sync.nix | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/services/mbsync.nix b/modules/services/mbsync.nix index a7897536802..1fe755938ab 100644 --- a/modules/services/mbsync.nix +++ b/modules/services/mbsync.nix @@ -83,7 +83,6 @@ in systemd.user.services.mbsync = { Unit = { Description = "mbsync mailbox synchronization"; - PartOf = [ "network-online.target" ]; }; Service = { diff --git a/modules/services/taskwarrior-sync.nix b/modules/services/taskwarrior-sync.nix index f92f532bdcb..4179ac8aa85 100644 --- a/modules/services/taskwarrior-sync.nix +++ b/modules/services/taskwarrior-sync.nix @@ -34,7 +34,6 @@ in systemd.user.services.taskwarrior-sync = { Unit = { Description = "Taskwarrior sync"; - PartOf = [ "network-online.target" ]; }; Service = { CPUSchedulingPolicy = "idle"; -- cgit v1.2.3 From 4c9b40ca0ed640f752128617ea2788007859fbd6 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Wed, 7 Aug 2019 23:12:30 +0200 Subject: systemd-activate.rb: add start/stop/restart sockets --- modules/systemd-activate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb index c0cf87457f5..8382c840e93 100644 --- a/modules/systemd-activate.rb +++ b/modules/systemd-activate.rb @@ -76,7 +76,7 @@ def get_services(dir) end def get_service_files(dir) - Dir.chdir(dir) { Dir['*.service'] } + Dir.chdir(dir) { Dir['*.{service,socket}'] } end def get_changed_services(dir_a, dir_b, services) -- cgit v1.2.3 From 3743e8995aa7d7075ede22c772dd206e3d681e75 Mon Sep 17 00:00:00 2001 From: paumr Date: Tue, 6 Aug 2019 00:10:58 +0200 Subject: mbsync: fix use of `certificatesFile` The `tls.certificatesFile` option may be set to a path but the `CertificateFile` attribute should be a string. --- modules/programs/mbsync.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 7e9cdb7f84f..cda468dd3e4 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -20,7 +20,7 @@ let } // optionalAttrs (tls.enable && tls.certificatesFile != null) { - CertificateFile = tls.certificatesFile; + CertificateFile = toString tls.certificatesFile; }; masterSlaveMapping = { -- cgit v1.2.3 From e59b8b0c37f08f6b6a9399b24e9b67d90c9b8436 Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Sun, 28 Jul 2019 21:41:02 -0400 Subject: numlock: add module This adds an option `xsession.numlock` that enable the Num Lock key when starting a graphical session. Fixes #651 --- modules/misc/numlock.nix | 34 ++++++++++++++++++++++++++++++++++ modules/modules.nix | 1 + 2 files changed, 35 insertions(+) create mode 100644 modules/misc/numlock.nix diff --git a/modules/misc/numlock.nix b/modules/misc/numlock.nix new file mode 100644 index 00000000000..df11f22a780 --- /dev/null +++ b/modules/misc/numlock.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession.numlock; + +in + +{ + options = { + xsession.numlock.enable = mkEnableOption "Num Lock"; + }; + + config = mkIf cfg.enable { + systemd.user.services.numlockx = { + Unit = { + Description = "NumLockX"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.numlockx}/bin/numlockx"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 03e048e2bbb..1ec06144d58 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -28,6 +28,7 @@ let (loadModule ./misc/lib.nix { }) (loadModule ./misc/news.nix { }) (loadModule ./misc/nixpkgs.nix { }) + (loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; }) (loadModule ./misc/pam.nix { }) (loadModule ./misc/qt.nix { }) (loadModule ./misc/submodule-support.nix { }) -- cgit v1.2.3 From a9ecef1fa938db8c6c3d2ed705646927e3db55b9 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 2 Aug 2019 09:45:28 +0100 Subject: hound: add module --- modules/misc/news.nix | 8 +++++ modules/modules.nix | 1 + modules/services/hound.nix | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 modules/services/hound.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index fce1eb689db..b4c672f36ea 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1152,6 +1152,14 @@ in A new module is available: 'programs.kakoune'. ''; } + + { + time = "2019-08-08T11:49:35+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.hound'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1ec06144d58..ba1fdb3920c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -102,6 +102,7 @@ let (loadModule ./services/flameshot.nix { }) (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) + (loadModule ./services/hound.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/kbfs.nix { }) diff --git a/modules/services/hound.nix b/modules/services/hound.nix new file mode 100644 index 00000000000..a252a68d271 --- /dev/null +++ b/modules/services/hound.nix @@ -0,0 +1,84 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.hound; + + configFile = pkgs.writeText "hound-config.json" ( + builtins.toJSON { + max-concurrent-indexers = cfg.maxConcurrentIndexers; + dbpath = cfg.databasePath; + repos = cfg.repositories; + health-check-url = "/healthz"; + } + ); + + houndOptions = [ + "--addr ${cfg.listenAddress}" + "--conf ${configFile}" + ]; + +in + +{ + meta.maintainers = [ maintainers.adisbladis ]; + + options.services.hound = { + enable = mkEnableOption "hound"; + + maxConcurrentIndexers = mkOption { + type = types.ints.positive; + default = 2; + description = "Limit the amount of concurrent indexers."; + }; + + databasePath = mkOption { + type = types.path; + default = "${config.xdg.dataHome}/hound"; + defaultText = "\$XDG_DATA_HOME/hound"; + description = "The Hound database path."; + }; + + listenAddress = mkOption { + type = types.str; + default = "localhost:6080"; + description = "Listen address of the Hound daemon."; + }; + + repositories = mkOption { + type = types.attrsOf (types.uniq types.attrs); + default = {}; + example = literalExample '' + { + SomeGitRepo = { + url = "https://www.github.com/YourOrganization/RepoOne.git"; + ms-between-poll = 10000; + exclude-dot-files = true; + }; + } + ''; + description = "The repository configuration."; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.hound ]; + + systemd.user.services.hound = { + Unit = { + Description = "Hound source code search engine"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + + Service = { + Environment = "PATH=${makeBinPath [ pkgs.mercurial pkgs.git ]}"; + ExecStart = "${pkgs.hound}/bin/houndd ${concatStringsSep " " houndOptions}"; + }; + }; + }; +} -- cgit v1.2.3 From 9302523d3481156f0fd42bd66329f9c8fbf50834 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 8 Aug 2019 13:53:22 +0200 Subject: modules: fix module order --- modules/modules.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/modules.nix b/modules/modules.nix index ba1fdb3920c..ef11de5481c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -100,11 +100,11 @@ let (loadModule ./services/dunst.nix { }) (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/flameshot.nix { }) + (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gpg-agent.nix { }) (loadModule ./services/hound.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/kbfs.nix { }) (loadModule ./services/kdeconnect.nix { }) (loadModule ./services/keepassx.nix { }) -- cgit v1.2.3 From bce63e4dff4f770879359d7e61791ba03c6bd89f Mon Sep 17 00:00:00 2001 From: paumr Date: Wed, 7 Aug 2019 00:32:54 +0200 Subject: msmtp: add account option `tls.fingerprint` --- modules/programs/msmtp-accounts.nix | 11 +++++++++++ modules/programs/msmtp.nix | 3 +++ 2 files changed, 14 insertions(+) diff --git a/modules/programs/msmtp-accounts.nix b/modules/programs/msmtp-accounts.nix index fedddb69b03..277710f4cba 100644 --- a/modules/programs/msmtp-accounts.nix +++ b/modules/programs/msmtp-accounts.nix @@ -22,6 +22,17 @@ with lib; ''; }; + tls.fingerprint = mkOption { + type = types.nullOr (types.strMatching "([[:alnum:]]{2}\:)+[[:alnum:]]{2}"); + default = null; + example = "my:SH:a2:56:ha:sh"; + description = '' + Fingerprint of a trusted TLS certificate. + The fingerprint can be obtained by executing + msmtp --serverinfo --tls --tls-certcheck=off. + ''; + }; + extraConfig = mkOption { type = types.attrsOf types.str; default = { }; diff --git a/modules/programs/msmtp.nix b/modules/programs/msmtp.nix index eff2019cf2b..1ff3139ef36 100644 --- a/modules/programs/msmtp.nix +++ b/modules/programs/msmtp.nix @@ -24,6 +24,9 @@ let tls_starttls = onOff smtp.tls.useStartTls; tls_trust_file = smtp.tls.certificatesFile; } + // optionalAttrs (msmtp.tls.fingerprint != null) { + tls_fingerprint = msmtp.tls.fingerprint; + } // optionalAttrs (smtp.port != null) { port = toString smtp.port; } -- cgit v1.2.3 From 42ad0effdd14c0cec63e24ae093dff34e5a1e320 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 8 Aug 2019 15:24:23 +0200 Subject: zsh: create oh-my-zsh cache directory Fixes #761. --- modules/programs/zsh.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index ac42b885e1a..4abb9cebf82 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -302,7 +302,7 @@ in (mkIf cfg.oh-my-zsh.enable { home.file."${relToDotDir ".zshenv"}".text = '' ZSH="${pkgs.oh-my-zsh}/share/oh-my-zsh"; - ZSH_CACHE_DIR="''${XDG_CACHE_HOME:-''$HOME/.cache}/oh-my-zsh"; + ZSH_CACHE_DIR="${config.xdg.cacheHome}/oh-my-zsh"; ''; }) @@ -400,6 +400,10 @@ in # calling it twice causes sight start up slowdown # as all $fpath entries will be traversed again. programs.zsh.enableCompletion = mkForce false; + + # Make sure we create a cache directory since some plugins expect it to exist + # See: https://github.com/rycee/home-manager/issues/761 + home.file."${config.xdg.cacheHome}/oh-my-zsh/.keep".text = ""; }) (mkIf (cfg.plugins != []) { -- cgit v1.2.3 From 7310cfc557b38b6b27beeda1455fd81d15ed7ce7 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 8 Aug 2019 14:57:53 +0200 Subject: zsh: fix completion when oh-my-zsh is enabled enableCompletion option not only calls compinit but also adds nix-zsh-completions package to home.packages which should still happen even if oh-my-zsh is enabled. The double compinit call will still be eliminated by moving guarding condition down to the compinit call itself. Fixes #771. --- modules/programs/zsh.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 4abb9cebf82..0359796f062 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -346,7 +346,13 @@ in fpath+="$HOME/${pluginsDir}/${plugin.name}" '') cfg.plugins)} - ${optionalString cfg.enableCompletion "autoload -U compinit && compinit"} + # Oh-My-Zsh calls compinit during initialization, + # calling it twice causes sight start up slowdown + # as all $fpath entries will be traversed again. + ${optionalString (cfg.enableCompletion && !cfg.oh-my-zsh.enable) + "autoload -U compinit && compinit" + } + ${optionalString cfg.enableAutosuggestions "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } @@ -396,11 +402,6 @@ in } (mkIf cfg.oh-my-zsh.enable { - # Oh-My-Zsh calls compinit during initialization, - # calling it twice causes sight start up slowdown - # as all $fpath entries will be traversed again. - programs.zsh.enableCompletion = mkForce false; - # Make sure we create a cache directory since some plugins expect it to exist # See: https://github.com/rycee/home-manager/issues/761 home.file."${config.xdg.cacheHome}/oh-my-zsh/.keep".text = ""; -- cgit v1.2.3 From eb7f39f0aaf3b3e65e783ba317d35ccb6c7e6f4c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 14 Aug 2019 00:45:26 +0200 Subject: gitlab-ci: add test stage --- .gitlab-ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18f19731e53..2fe0352bbc5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,18 @@ image: nixos/nix:latest -pages: +stages: + - test + - deploy + +Run tests: + stage: test + script: + - nix-shell tests -A run.all + only: + - master + +Deploy manual: + stage: deploy script: - mkdir -p ~/.config/nixpkgs - echo '{ manual.html.enable = true; }' > ~/.config/nixpkgs/home.nix -- cgit v1.2.3 From 55c962fda2b9e4576ed62980230e3141021c17ed Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 14 Aug 2019 01:13:16 +0200 Subject: gitlab-ci: trigger NUR update This will trigger a CI job at https://gitlab.com/rycee/nur-expressions that will update Home Manager in NUR. --- .gitlab-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2fe0352bbc5..2073da3869c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,3 +24,14 @@ Deploy manual: - public only: - master + +Deploy NUR: + stage: deploy + variables: + HM_BRANCH: $CI_COMMIT_REF_NAME + HM_COMMIT_SHA: $CI_COMMIT_SHA + trigger: + project: rycee/nur-expressions + branch: master + only: + - master -- cgit v1.2.3 From 2eae9daae77776e7ee3ed249ba83f881360e5fcf Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Wed, 14 Aug 2019 20:40:40 +0200 Subject: xsession: set RemainAfterExit for setxkbmap.service --- modules/xsession.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/xsession.nix b/modules/xsession.nix index 8202e02599c..b05581516b5 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -102,6 +102,7 @@ in Service = { Type = "oneshot"; + RemainAfterExit = true; ExecStart = let args = concatStringsSep " " ( -- cgit v1.2.3 From 5c94538c7dc800e57eb9af8ca9f251e376b4e018 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Wed, 14 Aug 2019 20:41:19 +0200 Subject: numlock: set RemainAfterExit for numlockx.service --- modules/misc/numlock.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/misc/numlock.nix b/modules/misc/numlock.nix index df11f22a780..77149d123ec 100644 --- a/modules/misc/numlock.nix +++ b/modules/misc/numlock.nix @@ -23,6 +23,7 @@ in Service = { Type = "oneshot"; + RemainAfterExit = true; ExecStart = "${pkgs.numlockx}/bin/numlockx"; }; -- cgit v1.2.3 From fcdab6a62df47e0b23ef9bd0e4ff2a9452277f71 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 15 Aug 2019 23:23:43 +0200 Subject: install: restrict to nix-shell This commit adds a "build" command to the install derivation that tells the user that `nix-shell` should be used. A derivation attribute `shellHookOnly = true` is also added with the intent to indicate that the shell hook is the entire point of the derivation. --- home-manager/install.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home-manager/install.nix b/home-manager/install.nix index 8abf6af9e15..c58c0ba7478 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -6,6 +6,7 @@ runCommand propagatedBuildInputs = [ home-manager ]; preferLocalBuild = true; allowSubstitutes = false; + shellHookOnly = true; shellHook = '' confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" @@ -53,4 +54,7 @@ runCommand fi ''; } - "" + '' + echo This derivation is not buildable, instead run it using nix-shell. + exit 1 + '' -- cgit v1.2.3 From 1499b85ac6c722793d6f7215f4f1fc4f83106439 Mon Sep 17 00:00:00 2001 From: paumr Date: Thu, 8 Aug 2019 14:45:55 +0200 Subject: alot: added send/draf_box to configuration file --- modules/programs/alot.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix index 341bb04a98e..32796b1cf1b 100644 --- a/modules/programs/alot.nix +++ b/modules/programs/alot.nix @@ -21,6 +21,8 @@ let realname = realName; sendmail_command = optionalString (alot.sendMailCommand != null) alot.sendMailCommand; + sent_box = "maildir" + "://" + maildir.absPath + "/" + folders.sent; + draft_box = "maildir" + "://"+ maildir.absPath + "/" + folders.drafts; } // optionalAttrs (aliases != []) { aliases = concatStringsSep "," aliases; -- cgit v1.2.3 From 8b759c24e6551b274b96e7c54047d874fe8373d2 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Tue, 23 Jul 2019 23:55:41 +0200 Subject: bash: add logoutExtra option --- modules/programs/bash.nix | 17 +++++++++++++++++ tests/modules/programs/bash/default.nix | 1 + tests/modules/programs/bash/logout-expected.txt | 4 ++++ tests/modules/programs/bash/logout.nix | 22 ++++++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 tests/modules/programs/bash/logout-expected.txt create mode 100644 tests/modules/programs/bash/logout.nix diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 98f14906631..82a9fbe8f8b 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -123,6 +123,15 @@ in interactive shell. ''; }; + + logoutExtra = mkOption { + default = ""; + type = types.lines; + description = '' + Extra commands that should be run when logging out of an + interactive shell. + ''; + }; }; }; @@ -195,6 +204,14 @@ in ${cfg.bashrcExtra} ''; + home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") { + text = '' + # -*- mode: sh -*- + + ${cfg.logoutExtra} + ''; + }; + home.packages = optional (cfg.enableAutojump) pkgs.autojump; } diff --git a/tests/modules/programs/bash/default.nix b/tests/modules/programs/bash/default.nix index 0d361adf7b0..e9f431cd2b9 100644 --- a/tests/modules/programs/bash/default.nix +++ b/tests/modules/programs/bash/default.nix @@ -1,3 +1,4 @@ { + bash-logout = ./logout.nix; bash-session-variables = ./session-variables.nix; } diff --git a/tests/modules/programs/bash/logout-expected.txt b/tests/modules/programs/bash/logout-expected.txt new file mode 100644 index 00000000000..9462f58f732 --- /dev/null +++ b/tests/modules/programs/bash/logout-expected.txt @@ -0,0 +1,4 @@ +# -*- mode: sh -*- + +clear-console + diff --git a/tests/modules/programs/bash/logout.nix b/tests/modules/programs/bash/logout.nix new file mode 100644 index 00000000000..8f96dc7e1ae --- /dev/null +++ b/tests/modules/programs/bash/logout.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bash = { + enable = true; + + logoutExtra = '' + clear-console + ''; + }; + + nmt.script = '' + assertFileExists home-files/.bash_logout + assertFileContent \ + home-files/.bash_logout \ + ${./logout-expected.txt} + ''; + }; +} -- cgit v1.2.3 From ed0e40dee87a2ced45e5094a1769151292e08ee0 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Tue, 23 Jul 2019 21:40:41 +0200 Subject: zsh: add initExtraBeforeCompInit config option The new initExtraBeforeCompInit option enables the user to inject commands in zshrc before compinit is executed. --- modules/programs/zsh.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 0359796f062..24c00f67479 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -215,6 +215,12 @@ in description = "Environment variables that will be set for zsh session."; }; + initExtraBeforeCompInit = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zshrc before compinit."; + }; + initExtra = mkOption { default = ""; type = types.lines; @@ -341,6 +347,8 @@ in ${localVarsStr} + ${cfg.initExtraBeforeCompInit} + ${concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}" -- cgit v1.2.3 From 5203340b64328d14a7d6eee68d846d13fe97fb0d Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Tue, 23 Jul 2019 21:58:06 +0200 Subject: zsh: add envExtra option --- modules/programs/zsh.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 24c00f67479..ffe5f4960b6 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -227,6 +227,12 @@ in description = "Extra commands that should be added to .zshrc."; }; + envExtra = mkOption { + default = ""; + type = types.lines; + description = "Extra commands that should be added to .zshenv."; + }; + profileExtra = mkOption { default = ""; type = types.lines; @@ -293,6 +299,10 @@ in }; config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.envExtra != "") { + home.file."${relToDotDir ".zshenv"}".text = cfg.envExtra; + }) + (mkIf (cfg.profileExtra != "") { home.file."${relToDotDir ".zprofile"}".text = cfg.profileExtra; }) -- cgit v1.2.3 From a124dae35a088ab18747effa9442467b90937e9a Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 23 Jul 2019 00:15:45 +0200 Subject: muchsync: add module --- modules/modules.nix | 1 + modules/services/muchsync.nix | 211 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 modules/services/muchsync.nix diff --git a/modules/modules.nix b/modules/modules.nix index ef11de5481c..05f3bb50bf1 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -112,6 +112,7 @@ let (loadModule ./services/mbsync.nix { }) (loadModule ./services/mpd.nix { }) (loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; }) + (loadModule ./services/muchsync.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/network-manager-applet.nix { }) (loadModule ./services/nextcloud-client.nix { }) (loadModule ./services/owncloud-client.nix { }) diff --git a/modules/services/muchsync.nix b/modules/services/muchsync.nix new file mode 100644 index 00000000000..72bf737c27d --- /dev/null +++ b/modules/services/muchsync.nix @@ -0,0 +1,211 @@ +{ config, lib, pkgs, ... }: + +with lib; + +# Documentation was partially copied from the muchsync manual. +# See http://www.muchsync.org/muchsync.html + +let + cfg = config.services.muchsync; + syncOptions = { + options = { + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to run muchsync. This + value is passed to the systemd timer configuration as the + OnCalendar option. See + + systemd.time + 7 + + for more information about the format. + ''; + }; + + sshCommand = mkOption { + type = types.str; + default = "${pkgs.openssh}/bin/ssh -CTaxq"; + defaultText = "ssh -CTaxq"; + description = '' + Specifies a command line to pass to /bin/sh + to execute a command on another machine. + + Note that because this string is passed to the shell, + special characters including spaces may need to be escaped. + ''; + }; + + upload = mkOption { + type = types.bool; + default = true; + description = '' + Whether to propagate local changes to the remote. + ''; + }; + + local = { + checkForModifiedFiles = mkOption { + type = types.bool; + default = false; + description = '' + Check for locally modified files. + Without this option, muchsync assumes that files in a maildir are + never edited. + + disables certain + optimizations so as to make muchsync at least check the timestamp on + every file, which will detect modified files at the cost of a longer + startup time. + + This option is useful if your software regularly modifies the + contents of mail files (e.g., because you are running offlineimap + with "synclabels = yes"). + ''; + }; + + importNew = mkOption { + type = types.bool; + default = true; + description = '' + Whether to begin the synchronisation by running + notmuch new locally. + ''; + }; + }; + + remote = { + host = mkOption { + type = types.str; + description = '' + Remote SSH host to synchronize with. + ''; + }; + + muchsyncPath = mkOption { + type = types.str; + default = ""; + defaultText = "$PATH/muchsync"; + description = '' + Specifies the path to muchsync on the server. + Ordinarily, muchsync should be in the default PATH on the server + so this option is not required. + However, this option is useful if you have to install muchsync in + a non-standard place or wish to test development versions of the + code. + ''; + }; + + checkForModifiedFiles = mkOption { + type = types.bool; + default = false; + description = '' + Check for modified files on the remote side. + Without this option, muchsync assumes that files in a maildir are + never edited. + + disables certain + optimizations so as to make muchsync at least check the timestamp on + every file, which will detect modified files at the cost of a longer + startup time. + + This option is useful if your software regularly modifies the + contents of mail files (e.g., because you are running offlineimap + with "synclabels = yes"). + ''; + }; + + importNew = mkOption { + type = types.bool; + default = true; + description = '' + Whether to begin the synchronisation by running + notmuch new on the remote side. + ''; + }; + }; + }; + }; + +in { + meta.maintainers = with maintainers; [ pacien ]; + + options.services.muchsync = { + remotes = mkOption { + type = with types; attrsOf (submodule syncOptions); + default = { }; + example = literalExample '' + { + server = { + frequency = "*:0/10"; + remote.host = "server.tld"; + }; + } + ''; + description = '' + Muchsync remotes to synchronise with. + ''; + }; + }; + + config = let + mapRemotes = gen: with attrsets; mapAttrs' + (name: remoteCfg: nameValuePair "muchsync-${name}" (gen name remoteCfg)) + cfg.remotes; + in mkIf (cfg.remotes != { }) { + assertions = [ + { + assertion = config.programs.notmuch.enable; + message = '' + The muchsync module requires 'programs.notmuch.enable = true'. + ''; + } + ]; + + systemd.user.services = mapRemotes (name: remoteCfg: { + Unit = { + Description = "muchsync sync service (${name})"; + }; + Service = { + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + Environment = [ + ''"PATH=${pkgs.notmuch}/bin"'' + ''"NOTMUCH_CONFIG=${config.home.sessionVariables.NOTMUCH_CONFIG}"'' + ''"NMBGIT=${config.home.sessionVariables.NMBGIT}"'' + ]; + ExecStart = concatStringsSep " " ( + [ "${pkgs.muchsync}/bin/muchsync" ] + ++ [ "-s ${escapeShellArg remoteCfg.sshCommand}" ] + ++ optional (!remoteCfg.upload) "--noup" + + # local configuration + ++ optional remoteCfg.local.checkForModifiedFiles "-F" + ++ optional (!remoteCfg.local.importNew) "--nonew" + + # remote configuration + ++ [ (escapeShellArg remoteCfg.remote.host) ] + ++ optional (remoteCfg.remote.muchsyncPath != "") + "-r ${escapeShellArg remoteCfg.remote.muchsyncPath}" + ++ optional remoteCfg.remote.checkForModifiedFiles "-F" + ++ optional (!remoteCfg.remote.importNew) "--nonew" + ); + }; + }); + + systemd.user.timers = mapRemotes (name: remoteCfg: { + Unit = { + Description = "muchsync periodic sync (${name})"; + }; + Timer = { + Unit = "muchsync-${name}.service"; + OnCalendar = remoteCfg.frequency; + Persistent = true; + }; + Install = { + WantedBy = [ "timers.target" ]; + }; + }); + }; +} -- cgit v1.2.3 From 6932e6330e9cbe73629e9f15300bdd0d3b9cc418 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 17 Aug 2019 14:25:15 +0200 Subject: muchsync: add news entry --- modules/misc/news.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b4c672f36ea..6d3e174ac39 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1160,6 +1160,14 @@ in A new module is available: 'services.hound'. ''; } + + { + time = "2019-08-17T12:24:58+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.muchsync'. + ''; + } ]; }; } -- cgit v1.2.3 From 31ae1bc2fff9660a1870161e064e86d3b4d6b396 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 18 Aug 2019 06:32:31 +0200 Subject: alot: fix account extraConfig section --- modules/programs/alot.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix index 32796b1cf1b..2b28f34caa3 100644 --- a/modules/programs/alot.nix +++ b/modules/programs/alot.nix @@ -38,11 +38,10 @@ let boolStr (signature.showSignature == "attach"); } ) + ++ [ alot.extraConfig ] ++ [ "[[[abook]]]" ] ++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion - ) - + "\n" - + alot.extraConfig; + ); configFile = let -- cgit v1.2.3 From 5eed33ef087f9267c956e902861168616a47ca74 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 13:33:34 +0200 Subject: emacs: document how to list available extra packages --- modules/programs/emacs.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index fc796af56e8..0b1514f291a 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -39,7 +39,11 @@ in type = hmTypes.selectorFunction; defaultText = "epkgs: []"; example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; - description = "Extra packages available to Emacs."; + description = '' + Extra packages available to Emacs. To get a list of + available packages run: + nix-env -f '<nixpkgs>' -qaP -A emacsPackagesNg. + ''; }; overrides = mkOption { -- cgit v1.2.3 From db0dfb4b089d0f5ba86ab39b40a228ae47c5d440 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sat, 10 Aug 2019 16:57:19 +0200 Subject: dwm-status: add module --- modules/misc/news.nix | 8 +++++ modules/modules.nix | 1 + modules/services/dwm-status.nix | 70 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 modules/services/dwm-status.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 6d3e174ac39..6c0f88cbdfe 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1168,6 +1168,14 @@ in A new module is available: 'services.muchsync'. ''; } + + { + time = "2019-08-18T14:22:41+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.dwm-status'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 05f3bb50bf1..cc38e9e7143 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -98,6 +98,7 @@ let (loadModule ./services/blueman-applet.nix { }) (loadModule ./services/compton.nix { }) (loadModule ./services/dunst.nix { }) + (loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/flameshot.nix { }) (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/services/dwm-status.nix b/modules/services/dwm-status.nix new file mode 100644 index 00000000000..6b6a8cbdaa6 --- /dev/null +++ b/modules/services/dwm-status.nix @@ -0,0 +1,70 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.dwm-status; + + features = [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]; + + configText = builtins.toJSON ({ inherit (cfg) order; } // cfg.extraConfig); + + configFile = pkgs.writeText "dwm-status.json" configText; +in + +{ + options = { + services.dwm-status = { + enable = mkEnableOption "dwm-status user service"; + + package = mkOption { + type = types.package; + default = pkgs.dwm-status; + defaultText = "pkgs.dwm-status"; + example = "pkgs.dwm-status.override { enableAlsaUtils = false; }"; + description = "Which dwm-status package to use."; + }; + + order = mkOption { + type = types.listOf (types.enum features); + description = "List of enabled features in order."; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + separator = "#"; + + battery = { + notifier_levels = [ 2 5 10 15 20 ]; + }; + + time = { + format = "%H:%M"; + }; + } + ''; + description = "Extra config of dwm-status."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.dwm-status = { + Unit = { + Description = "DWM status service"; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/dwm-status ${configFile}"; + }; + }; + }; +} -- cgit v1.2.3 From 9cc30b18f710eba6aa1f72155a747a640fc17b2a Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Thu, 8 Aug 2019 18:24:08 +0200 Subject: nixos: add backup file extension and verbosity options --- nixos/default.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index 4628d1f2d9f..51f4640c0fd 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -23,6 +23,14 @@ let }; }); + serviceEnvironment = + optionalAttrs (cfg.backupFileExtension != null) { + HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension; + } + // optionalAttrs cfg.verbose { + VERBOSE = "1"; + }; + in { @@ -33,6 +41,18 @@ in option. ''; + backupFileExtension = mkOption { + type = types.nullOr types.str; + default = null; + example = "backup"; + description = '' + On activation move existing files by appending the given + file extension rather than exiting with an error. + ''; + }; + + verbose = mkEnableOption "verbose output on activation"; + users = mkOption { type = types.attrsOf hmModule; default = {}; @@ -70,6 +90,8 @@ in wants = [ "nix-daemon.socket" ]; after = [ "nix-daemon.socket" ]; + environment = serviceEnvironment; + serviceConfig = { User = usercfg.home.username; Type = "oneshot"; -- cgit v1.2.3 From fa82ced4148c6dc04cc7cbd48ad5f443e2d565e7 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 17:35:20 +0200 Subject: nixos: use non-deprecated fontconfig option --- nixos/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/default.nix b/nixos/default.nix index 51f4640c0fd..f723fb5e3a0 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -15,7 +15,7 @@ let # The per-user directory inside /etc/profiles is not known by # fontconfig by default. - fonts.fontconfig.enableProfileFonts = + fonts.fontconfig.enable = cfg.useUserPackages && config.fonts.fontconfig.enable; home.username = config.users.users.${name}.name; -- cgit v1.2.3 From 7834ffbbf1f543a6784ca7785c4e5bb6dfc7b584 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 17:33:25 +0200 Subject: nixos: pass on warnings to the system configuration Fixes #804 --- nixos/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index f723fb5e3a0..29803ddcc69 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -64,6 +64,13 @@ in }; config = mkIf (cfg.users != {}) { + warnings = + flatten (flip mapAttrsToList cfg.users (user: config: + flip map config.warnings (warning: + "${user} profile: ${warning}" + ) + )); + assertions = flatten (flip mapAttrsToList cfg.users (user: config: flip map config.assertions (assertion: -- cgit v1.2.3 From c2429ca0cfc5aabb128773c262915321009b4ea9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 17:37:26 +0200 Subject: nix-darwin: pass on warnings to the system configuration --- nix-darwin/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 284d2d60c03..4ce64a7752a 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -39,6 +39,13 @@ in }; config = mkIf (cfg.users != {}) { + warnings = + flatten (flip mapAttrsToList cfg.users (user: config: + flip map config.warnings (warning: + "${user} profile: ${warning}" + ) + )); + assertions = flatten (flip mapAttrsToList cfg.users (user: config: flip map config.assertions (assertion: -- cgit v1.2.3 From 73641e492c2d761676110d52eb15607b308b5e70 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 10:57:30 +0200 Subject: firefox: use wrapped package This makes the programs.firefox.package option take a pre-wrapped Firefox package as value if state version is set to "19.09" or later. This should make the Firefox module work with a wider range of Firefox packages. --- doc/release-notes/rl-1909.xml | 23 ++++++++++++++ modules/programs/firefox.nix | 36 ++++++++++++++-------- tests/default.nix | 1 + tests/modules/programs/firefox/default.nix | 4 +++ .../firefox/profile-settings-expected-user.js | 6 ++++ .../modules/programs/firefox/profile-settings.nix | 24 +++++++++++++++ .../programs/firefox/state-version-19_09.nix | 17 ++++++++++ 7 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 tests/modules/programs/firefox/default.nix create mode 100644 tests/modules/programs/firefox/profile-settings-expected-user.js create mode 100644 tests/modules/programs/firefox/profile-settings.nix create mode 100644 tests/modules/programs/firefox/state-version-19_09.nix diff --git a/doc/release-notes/rl-1909.xml b/doc/release-notes/rl-1909.xml index 6addc0c5b48..3094debc1f2 100644 --- a/doc/release-notes/rl-1909.xml +++ b/doc/release-notes/rl-1909.xml @@ -9,4 +9,27 @@ This is the current unstable branch and the information in this section is therefore not final. + +
+ State Version Changes + + + The state version in this release includes the changes below. These changes + are only active if the option is set to + "19.09" or later. + + + + + + The option now expects a wrapped + Firefox package and defaults to pkgs.firefox. + + + +
diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index c43781a7acb..e47bec3e171 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -45,9 +45,16 @@ in package = mkOption { type = types.package; - default = pkgs.firefox-unwrapped; - defaultText = "pkgs.firefox-unwrapped"; - description = "The unwrapped Firefox package to use."; + default = + if versionAtLeast config.home.stateVersion "19.09" + then pkgs.firefox + else pkgs.firefox-unwrapped; + defaultText = "pkgs.firefox"; + description = '' + The Firefox package to use. If state version ≥ 19.09 then + this should be a wrapped Firefox package. For earlier state + versions it should be an unwrapped Firefox package. + ''; }; extensions = mkOption { @@ -220,21 +227,26 @@ in home.packages = let - # A bit of hackery to force a config into the wrapper. - browserName = cfg.package.browserName - or (builtins.parseDrvName cfg.package.name).name; - - fcfg = setAttrByPath [browserName] { + # The configuration expected by the Firefox wrapper. + fcfg = { enableAdobeFlash = cfg.enableAdobeFlash; enableGoogleTalkPlugin = cfg.enableGoogleTalk; icedtea = cfg.enableIcedTea; }; - wrapper = pkgs.wrapFirefox.override { - config = fcfg; - }; + # A bit of hackery to force a config into the wrapper. + browserName = cfg.package.browserName + or (builtins.parseDrvName cfg.package.name).name; + + # The configuration expected by the Firefox wrapper builder. + bcfg = setAttrByPath [browserName] fcfg; + + package = + if versionAtLeast config.home.stateVersion "19.09" + then cfg.package.override { cfg = fcfg; } + else (pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { }; in - [ (wrapper cfg.package { }) ]; + [ package ]; home.file = mkMerge ( [{ diff --git a/tests/default.nix b/tests/default.nix index 29b02eeb4af..3d0d23b99b6 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -35,6 +35,7 @@ import nmt { } // import ./modules/misc/pam // import ./modules/misc/xsession + // import ./modules/programs/firefox // import ./modules/systemd ) // import ./modules/home-environment diff --git a/tests/modules/programs/firefox/default.nix b/tests/modules/programs/firefox/default.nix new file mode 100644 index 00000000000..6612a9ac978 --- /dev/null +++ b/tests/modules/programs/firefox/default.nix @@ -0,0 +1,4 @@ +{ + firefox-profile-settings = ./profile-settings.nix; + firefox-state-version-19_09 = ./state-version-19_09.nix; +} diff --git a/tests/modules/programs/firefox/profile-settings-expected-user.js b/tests/modules/programs/firefox/profile-settings-expected-user.js new file mode 100644 index 00000000000..0edd47b9101 --- /dev/null +++ b/tests/modules/programs/firefox/profile-settings-expected-user.js @@ -0,0 +1,6 @@ +// Generated by Home Manager. + +user_pref("general.smoothScroll", false); + + + diff --git a/tests/modules/programs/firefox/profile-settings.nix b/tests/modules/programs/firefox/profile-settings.nix new file mode 100644 index 00000000000..45465b1d0bf --- /dev/null +++ b/tests/modules/programs/firefox/profile-settings.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.firefox = { + enable = true; + profiles.test.settings = { + "general.smoothScroll" = false; + }; + }; + + nmt.script = '' + assertFileRegex \ + home-path/bin/firefox \ + MOZ_APP_LAUNCHER + + assertFileContent \ + home-files/.mozilla/firefox/test/user.js \ + ${./profile-settings-expected-user.js} + ''; + }; +} diff --git a/tests/modules/programs/firefox/state-version-19_09.nix b/tests/modules/programs/firefox/state-version-19_09.nix new file mode 100644 index 00000000000..0c93096190e --- /dev/null +++ b/tests/modules/programs/firefox/state-version-19_09.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.stateVersion = "19.09"; + + programs.firefox.enable = true; + + nmt.script = '' + assertFileRegex \ + home-path/bin/firefox \ + MOZ_APP_LAUNCHER + ''; + }; +} -- cgit v1.2.3 From 8830b8d0828752c8a8f54f13b917c33e4a5a753b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 18 Aug 2019 21:32:52 +0200 Subject: gitlab-ci: only run a single test Unfortunately the full test suite seems to run out of memory on the GitLab CI runner. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2073da3869c..e94c3cd58b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: Run tests: stage: test script: - - nix-shell tests -A run.all + - nix-shell tests -A run.files-text only: - master -- cgit v1.2.3 From 3d645c0ce1a02954aa1ebd458e7e45774be1f2a1 Mon Sep 17 00:00:00 2001 From: leotaku Date: Sun, 18 Aug 2019 22:02:17 +0200 Subject: kdeconnect: fix incorrect path to kdeconnectd --- modules/services/kdeconnect.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/kdeconnect.nix b/modules/services/kdeconnect.nix index a953c4ab8d3..bd698fcf836 100644 --- a/modules/services/kdeconnect.nix +++ b/modules/services/kdeconnect.nix @@ -42,7 +42,7 @@ in Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; - ExecStart = "${package}/lib/libexec/kdeconnectd"; + ExecStart = "${package}/libexec/kdeconnectd"; Restart = "on-abort"; }; }; -- cgit v1.2.3 From ed4f66185f93cf5e33fb1e53fb669da74364a9b6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 19 Aug 2019 20:37:48 +0200 Subject: Use `types.port` where applicable This changes the type of all options that specify ports to `types.port`. This type restricts values to between 0 and 65535. --- modules/accounts/email.nix | 4 ++-- modules/programs/irssi.nix | 2 +- modules/programs/ssh.nix | 2 +- modules/services/mpd.nix | 2 +- modules/services/mpdris2.nix | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 71ecd3020e6..cc9d0dc2813 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -95,7 +95,7 @@ let }; port = mkOption { - type = types.nullOr types.ints.positive; + type = types.nullOr types.port; default = null; example = 993; description = '' @@ -125,7 +125,7 @@ let }; port = mkOption { - type = types.nullOr types.ints.positive; + type = types.nullOr types.port; default = null; example = 465; description = '' diff --git a/modules/programs/irssi.nix b/modules/programs/irssi.nix index ad9a642ebee..fc8fa8e6132 100644 --- a/modules/programs/irssi.nix +++ b/modules/programs/irssi.nix @@ -101,7 +101,7 @@ let }; port = mkOption { - type = types.int; + type = types.port; default = 6667; description = "Port of the chat server."; }; diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index bf6677cd9c6..c6e09bda958 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -21,7 +21,7 @@ let }; port = mkOption { - type = types.nullOr types.int; + type = types.nullOr types.port; default = null; description = "Specifies port number to connect on remote host."; }; diff --git a/modules/services/mpd.nix b/modules/services/mpd.nix index 822d2fe3936..fbcf9e94230 100644 --- a/modules/services/mpd.nix +++ b/modules/services/mpd.nix @@ -98,7 +98,7 @@ in { }; port = mkOption { - type = types.ints.positive; + type = types.port; default = 6600; description = '' The TCP port on which the the daemon will listen. diff --git a/modules/services/mpdris2.nix b/modules/services/mpdris2.nix index 14c8902308b..51ce7e892c8 100644 --- a/modules/services/mpdris2.nix +++ b/modules/services/mpdris2.nix @@ -56,7 +56,7 @@ in }; port = mkOption { - type = types.ints.positive; + type = types.port; default = config.services.mpd.network.port; defaultText = "config.services.mpd.network.port"; description = '' -- cgit v1.2.3 From 0e871b490eb7661191ca43c02cf820cc5225cee1 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Fri, 2 Aug 2019 19:37:45 +0200 Subject: ssh: add localForwards option for matchBlocks --- modules/programs/ssh.nix | 62 ++++++++++++++++++++++ .../programs/ssh/match-blocks-attrs-expected.conf | 1 + tests/modules/programs/ssh/match-blocks-attrs.nix | 7 +++ 3 files changed, 70 insertions(+) diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index c6e09bda958..fdf02a2c14e 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -10,6 +10,39 @@ let unwords = builtins.concatStringsSep " "; + localForwardModule = types.submodule ({ ... }: { + options = { + bind = { + address = mkOption { + type = types.str; + default = "localhost"; + example = "example.org"; + description = "The address where to bind the port."; + }; + + port = mkOption { + type = types.port; + example = 8080; + description = "Specifies port number to bind on bind address."; + }; + }; + + host = { + address = mkOption { + type = types.str; + example = "example.org"; + description = "The address where to forward the traffic to."; + }; + + port = mkOption { + type = types.port; + example = 80; + description = "Specifies port number to forward the traffic to."; + }; + }; + }; + }); + matchBlockModule = types.submodule ({ name, ... }: { options = { host = mkOption { @@ -152,6 +185,27 @@ let ''; }; + localForwards = mkOption { + type = types.listOf localForwardModule; + default = []; + example = literalExample '' + [ + { + bind.port = 8080; + host.address = "10.0.0.13"; + host.port = 80; + } + ]; + ''; + description = '' + Specify local port forwardings. See + + ssh_config + 5 + for LocalForward. + ''; + }; + extraOptions = mkOption { type = types.attrsOf types.str; default = {}; @@ -181,6 +235,14 @@ let ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ optional (cf.proxyJump != null) " ProxyJump ${cf.proxyJump}" ++ map (file: " IdentityFile ${file}") cf.identityFile + ++ map (f: + let + addressPort = entry: " [${entry.address}]:${toString entry.port}"; + in + " LocalForward" + + addressPort f.bind + + addressPort f.host + ) cf.localForwards ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); diff --git a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf index 76bbe2e32f1..1bff480fdce 100644 --- a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf +++ b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf @@ -11,6 +11,7 @@ Host abc Host xyz ServerAliveInterval 60 IdentityFile file + LocalForward [localhost]:8080 [10.0.0.1]:80 Host * ForwardAgent no diff --git a/tests/modules/programs/ssh/match-blocks-attrs.nix b/tests/modules/programs/ssh/match-blocks-attrs.nix index cb554db24bf..3e09cd2d5f2 100644 --- a/tests/modules/programs/ssh/match-blocks-attrs.nix +++ b/tests/modules/programs/ssh/match-blocks-attrs.nix @@ -15,6 +15,13 @@ with lib; xyz = { identityFile = "file"; serverAliveInterval = 60; + localForwards = [ + { + bind.port = 8080; + host.address = "10.0.0.1"; + host.port = 80; + } + ]; }; "* !github.com" = { -- cgit v1.2.3 From 57925c50bf069acec091e7e396e7a2629bd2ad4d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 21 Aug 2019 20:19:33 +0200 Subject: nixpkgs: improve description formatting slightly --- modules/misc/nixpkgs.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index b59e0d1ddaa..e7c0d8f25ea 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -82,8 +82,7 @@ in nixpkgs.config = import ./nixpkgs-config.nix; - xdg.configFile."nixpkgs/config.nix".source = - ./nixpkgs-config.nix; + xdg.configFile."nixpkgs/config.nix".source = ./nixpkgs-config.nix; in your Home Manager configuration. -- cgit v1.2.3 From 35752e07faf19e8587905805b28f764d029b05d0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 21 Aug 2019 20:22:39 +0200 Subject: kakoune: add missing period at end of description --- modules/programs/kakoune.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix index 5ac4a7b69c2..e48f0e295a8 100644 --- a/modules/programs/kakoune.nix +++ b/modules/programs/kakoune.nix @@ -453,7 +453,7 @@ let default = []; description = '' User-defined key mappings. For documentation, see - + . ''; }; -- cgit v1.2.3 From eb0ccf7286a7167f52ed2183753aaf81f334c270 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 18 Dec 2018 18:09:56 +0100 Subject: docs: use nmd for generating documentation The nmd library is an external library for generating Nix-centric documentation. --- doc/default.nix | 349 +++++---------------------------------------- doc/man-configuration.xml | 2 +- doc/manual.xml | 2 +- doc/options-to-docbook.xsl | 239 ------------------------------- doc/overrides.css | 9 -- doc/style.css | 271 ----------------------------------- modules/manual.nix | 63 +------- 7 files changed, 45 insertions(+), 890 deletions(-) delete mode 100644 doc/options-to-docbook.xsl delete mode 100644 doc/overrides.css delete mode 100644 doc/style.css diff --git a/doc/default.nix b/doc/default.nix index c94d52c9e7e..7abe278a096 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -1,122 +1,33 @@ -{ pkgs, options, config, version, revision, extraSources ? [] }: - -with pkgs; +{ pkgs }: let - lib = pkgs.lib; - - # Remove invisible and internal options. - optionsListVisible = lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList options); - - # Replace functions by the string - substFunction = x: - if builtins.isAttrs x then lib.mapAttrs (name: substFunction) x - else if builtins.isList x then map substFunction x - else if lib.isFunction x then "" - else x; - - # Generate DocBook documentation for a list of packages. This is - # what `relatedPackages` option of `mkOption` from - # ../../../lib/options.nix influences. - # - # Each element of `relatedPackages` can be either - # - a string: that will be interpreted as an attribute name from `pkgs`, - # - a list: that will be interpreted as an attribute path from `pkgs`, - # - an attrset: that can specify `name`, `path`, `package`, `comment` - # (either of `name`, `path` is required, the rest are optional). - genRelatedPackages = packages: - let - unpack = p: if lib.isString p then { name = p; } - else if lib.isList p then { path = p; } - else p; - describe = args: - let - name = args.name or (lib.concatStringsSep "." args.path); - path = args.path or [ args.name ]; - package = args.package or (lib.attrByPath path (throw "Invalid package attribute path `${toString path}'") pkgs); - in "" - + "pkgs.${name} (${package.meta.name})" - + lib.optionalString (!package.meta.available) " [UNAVAILABLE]" - + ": ${package.meta.description or "???"}." - + lib.optionalString (args ? comment) "\n${args.comment}" - # Lots of `longDescription's break DocBook, so we just wrap them into - + lib.optionalString (package.meta ? longDescription) "\n${package.meta.longDescription}" - + ""; - in "${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}"; - - optionsListDesc = lib.flip map optionsListVisible (opt: opt // { - # Clean up declaration sites to not refer to the NixOS source tree. - declarations = map stripAnyPrefixes opt.declarations; - } - // lib.optionalAttrs (opt ? example) { example = substFunction opt.example; } - // lib.optionalAttrs (opt ? default) { default = substFunction opt.default; } - // lib.optionalAttrs (opt ? type) { type = substFunction opt.type; } - // lib.optionalAttrs (opt ? relatedPackages) { relatedPackages = genRelatedPackages opt.relatedPackages; }); - - # We need to strip references to /nix/store/* from options, - # including any `extraSources` if some modules came from elsewhere, - # or else the build will fail. - # - # E.g. if some `options` came from modules in ${pkgs.customModules}/nix, - # you'd need to include `extraSources = [ pkgs.customModules ]` - prefixesToStrip = map (p: "${toString p}/") ([ ./.. ] ++ extraSources); - stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip; - - # Custom "less" that pushes up all the things ending in ".enable*" - # and ".package*" - optionLess = a: b: - let - ise = lib.hasPrefix "enable"; - isp = lib.hasPrefix "package"; - cmp = lib.splitByAndCompare ise lib.compare - (lib.splitByAndCompare isp lib.compare lib.compare); - in lib.compareLists cmp a.loc b.loc < 0; - - # Customly sort option list for the man page. - optionsList = lib.sort optionLess optionsListDesc; - - # Convert the list of options into an XML file. - optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList); - - optionsDocBook = runCommand "options-db.xml" - { - nativeBuildInputs = [ buildPackages.libxslt.bin ]; - } - '' - optionsXML=${optionsXML} - xsltproc \ - --stringparam program 'home-manager' \ - --stringparam revision '${revision}' \ - -o $out ${./options-to-docbook.xsl} $optionsXML - ''; - - sources = lib.sourceFilesBySuffices ./. [".xml"]; - - modulesDoc = builtins.toFile "modules.xml" '' -
- ${(lib.concatMapStrings (path: '' - - '') (lib.catAttrs "value" config.meta.doc))} -
- ''; - generatedSources = runCommand "generated-docbook" {} '' - mkdir $out - ln -s ${modulesDoc} $out/modules.xml - ln -s ${optionsDocBook} $out/options-db.xml - printf "%s" "${version}" > $out/version - ''; - - copySources = - '' - cp -prd $sources/* . # */ - ln -s ${generatedSources} ./generated - chmod -R u+w . - ''; + lib = pkgs.lib; - toc = builtins.toFile "toc.xml" - '' - + nmdSrc = pkgs.fetchFromGitLab { + owner = "rycee"; + repo = "nmd"; + rev = "b57fc6657b6645086a286e62a05a1795f258daa6"; + sha256 = "1b6bdgn6d4awxi8al5hbw8vycxp4laf63l29rjrvxi2j2g69rgvc"; + }; + + nmd = import nmdSrc { inherit pkgs; }; + + hmModulesDocs = nmd.buildModulesDocs { + modules = import ../modules/modules.nix { inherit lib pkgs; }; + moduleRootPaths = [ ./.. ]; + mkModuleUrl = path: + "https://github.com/rycee/home-manager/blob/master/${path}#blob-path"; + channelName = "home-manager"; + docBook.id = "home-manager-options"; + }; + + docs = nmd.buildDocBookDocs { + pathName = "home-manager"; + modulesDocs = [ hmModulesDocs ]; + documentsDirectory = ./.; + chunkToc = '' + @@ -124,206 +35,22 @@ let ''; + }; - manualXsltprocOptions = toString [ - "--param section.autolabel 1" - "--param section.label.includes.component.label 1" - "--stringparam html.stylesheet 'style.css overrides.css highlightjs/mono-blue.css'" - "--stringparam html.script './highlightjs/highlight.pack.js ./highlightjs/loader.js'" - "--param xref.with.number.and.title 1" - "--param toc.section.depth 3" - "--stringparam admon.style ''" - "--stringparam callout.graphics.extension .svg" - "--stringparam current.docid manual" - "--param chunk.section.depth 0" - "--param chunk.first.sections 1" - "--param use.id.as.filename 1" - "--stringparam generate.toc 'book toc appendix toc'" - "--stringparam chunk.toc ${toc}" - ]; +in - manual-combined = runCommand "home-manager-manual-combined" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; - meta.description = "The Home Manager manual as plain docbook XML"; - } - '' - ${copySources} +{ - xmllint --xinclude --output ./manual-combined.xml ./manual.xml - xmllint --xinclude --noxincludenode \ - --output ./man-pages-combined.xml ./man-pages.xml + options = { + json = hmModulesDocs.json.override { + path = "share/doc/home-manager/options.json"; + }; + }; - # outputs the context of an xmllint error output - # LEN lines around the failing line are printed - function context { - # length of context - local LEN=6 - # lines to print before error line - local BEFORE=4 - - # xmllint output lines are: - # file.xml:1234: there was an error on line 1234 - while IFS=':' read -r file line rest; do - echo - if [[ -n "$rest" ]]; then - echo "$file:$line:$rest" - local FROM=$(($line>$BEFORE ? $line - $BEFORE : 1)) - # number lines & filter context - nl --body-numbering=a "$file" | sed -n "$FROM,+$LEN p" - else - if [[ -n "$line" ]]; then - echo "$file:$line" - else - echo "$file" - fi - fi - done - } - - function lintrng { - xmllint --debug --noout --nonet \ - --relaxng ${docbook5}/xml/rng/docbook/docbook.rng \ - "$1" \ - 2>&1 | context 1>&2 - # ^ redirect assumes xmllint doesn’t print to stdout - } - - lintrng manual-combined.xml - lintrng man-pages-combined.xml - - mkdir $out - cp manual-combined.xml $out/ - cp man-pages-combined.xml $out/ - ''; + manPages = docs.manPages; - olinkDB = runCommand "manual-olinkdb" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; - } - '' - xsltproc \ - ${manualXsltprocOptions} \ - --stringparam collect.xref.targets only \ - --stringparam targets.filename "$out/manual.db" \ - --nonet \ - ${docbook5_xsl}/xml/xsl/docbook/xhtml/chunktoc.xsl \ - ${manual-combined}/manual-combined.xml - - cat > "$out/olinkdb.xml" < - - ]> - - - Allows for cross-referencing olinks between the manpages - and manual. - - - &manualtargets; - - EOF - ''; - -in rec { - inherit generatedSources; - - # The Home Manager options in JSON format. - optionsJSON = runCommand "options-json" - { meta.description = "List of Home Manager options in JSON format"; - } - '' - # Export list of options in different format. - dst=$out/share/doc/home-manager - mkdir -p $dst - - cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON - (builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList)))) - } $dst/options.json - - mkdir -p $out/nix-support - echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products - ''; # */ - - # Generate the Home Manager manual. - manual = runCommand "home-manager-manual" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; - meta.description = "The Home Manager manual in HTML format"; - allowedReferences = ["out"]; - } - '' - # Generate the HTML manual. - dst=$out/share/doc/home-manager - mkdir -p $dst - xsltproc \ - ${manualXsltprocOptions} \ - --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ - --nonet --output $dst/ \ - ${docbook5_xsl}/xml/xsl/docbook/xhtml/chunktoc.xsl \ - ${manual-combined}/manual-combined.xml - - mkdir -p $dst/images/callouts - cp ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.svg $dst/images/callouts/ - - cp ${./style.css} $dst/style.css - cp ${./overrides.css} $dst/overrides.css - cp -r ${pkgs.documentation-highlighter} $dst/highlightjs - - mkdir -p $out/nix-support - echo "nix-build out $out" >> $out/nix-support/hydra-build-products - echo "doc manual $dst" >> $out/nix-support/hydra-build-products - ''; # */ - - - manualEpub = runCommand "home-manager-manual-epub" - { inherit sources; - buildInputs = [ libxml2.bin libxslt.bin zip ]; - } - '' - # Generate the epub manual. - dst=$out/share/doc/home-manager - - xsltproc \ - ${manualXsltprocOptions} \ - --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ - --nonet --xinclude --output $dst/epub/ \ - ${docbook5_xsl}/xml/xsl/docbook/epub/docbook.xsl \ - ${manual-combined}/manual-combined.xml - - mkdir -p $dst/epub/OEBPS/images/callouts - cp -r ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.svg $dst/epub/OEBPS/images/callouts # */ - echo "application/epub+zip" > mimetype - manual="$dst/home-manager-manual.epub" - zip -0Xq "$manual" mimetype - cd $dst/epub && zip -Xr9D "$manual" * - - rm -rf $dst/epub - - mkdir -p $out/nix-support - echo "doc-epub manual $manual" >> $out/nix-support/hydra-build-products - ''; - - - # Generate the Home Manager manpages. - manpages = runCommand "home-manager-manpages" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; - allowedReferences = ["out"]; - } - '' - # Generate manpages. - mkdir -p $out/share/man - xsltproc --nonet \ - --param man.output.in.separate.dir 1 \ - --param man.output.base.dir "'$out/share/man/'" \ - --param man.endnotes.are.numbered 0 \ - --param man.break.after.slash 1 \ - --stringparam target.database.document "${olinkDB}/olinkdb.xml" \ - ${docbook5_xsl}/xml/xsl/docbook/manpages/docbook.xsl \ - ${manual-combined}/man-pages-combined.xml - ''; + manual = { + inherit (docs) html htmlOpenTool; + }; } diff --git a/doc/man-configuration.xml b/doc/man-configuration.xml index 1ddd31317ee..42962a75f3c 100644 --- a/doc/man-configuration.xml +++ b/doc/man-configuration.xml @@ -26,7 +26,7 @@ You can use the following options in home-configuration.nix: - + See also diff --git a/doc/manual.xml b/doc/manual.xml index 014a4a7a865..8ff81308b2c 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -28,7 +28,7 @@ Configuration Options - + Tools diff --git a/doc/options-to-docbook.xsl b/doc/options-to-docbook.xsl deleted file mode 100644 index 0fef4e1df65..00000000000 --- a/doc/options-to-docbook.xsl +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - Configuration Options - - - - - - - - - - - - - - - - - - Type: - - - - - (read only) - - - - - - - Default: - - - - - - - - Example: - - - - - - - - - - - - - - - Related packages: - - - - - - - - Declared by: - - - - - - - Defined by: - - - - - - - - - - - - - - - - - - - -'' -'' - - - - - - - - - - null - - - - - - - '''' - - - "" - - - - - - - - - - - - true - - - - - false - - - - - [ - - - - - ] - - - - - - - - - - { - - - = - ; - - } - - - - - (build of ) - - - - - - - - - - - - https://github.com/rycee/home-manager/blob//#blob-path - - - https://github.com/NixOS/nixpkgs/blob/master/ - - - https://github.com/NixOS/nixpkgs/blob// - - - - - https://github.com/NixOS/nixops/blob//nix/ - - - file:// - - - - - - <home-manager/> - - - <nixpkgs/> - - - <nixops/> - - - - - - - - - - - - - λ - - - - diff --git a/doc/overrides.css b/doc/overrides.css deleted file mode 100644 index 4c7d4a31be2..00000000000 --- a/doc/overrides.css +++ /dev/null @@ -1,9 +0,0 @@ -.docbook .xref img[src^=images\/callouts\/], -.screen img, -.programlisting img { - width: 1em; -} - -.calloutlist img { - width: 1.5em; -} diff --git a/doc/style.css b/doc/style.css deleted file mode 100644 index 0db907815b6..00000000000 --- a/doc/style.css +++ /dev/null @@ -1,271 +0,0 @@ -/* Copied from http://bakefile.sourceforge.net/, which appears - licensed under the GNU GPL. */ - - -/*************************************************************************** - Basic headers and text: - ***************************************************************************/ - -body -{ - font-family: "Nimbus Sans L", sans-serif; - background: white; - margin: 2em 1em 2em 1em; -} - -h1, h2, h3, h4 -{ - color: #005aa0; -} - -h1 /* title */ -{ - font-size: 200%; -} - -h2 /* chapters, appendices, subtitle */ -{ - font-size: 180%; -} - -/* Extra space between chapters, appendices. */ -div.chapter > div.titlepage h2, div.appendix > div.titlepage h2 -{ - margin-top: 1.5em; -} - -div.section > div.titlepage h2 /* sections */ -{ - font-size: 150%; - margin-top: 1.5em; -} - -h3 /* subsections */ -{ - font-size: 125%; -} - -div.simplesect h2 -{ - font-size: 110%; -} - -div.appendix h3 -{ - font-size: 150%; - margin-top: 1.5em; -} - -div.refnamediv h2, div.refsynopsisdiv h2, div.refsection h2 /* refentry parts */ -{ - margin-top: 1.4em; - font-size: 125%; -} - -div.refsection h3 -{ - font-size: 110%; -} - - -/*************************************************************************** - Examples: - ***************************************************************************/ - -div.example -{ - border: 1px solid #b0b0b0; - padding: 6px 6px; - margin-left: 1.5em; - margin-right: 1.5em; - background: #f4f4f8; - border-radius: 0.4em; - box-shadow: 0.4em 0.4em 0.5em #e0e0e0; -} - -div.example p.title -{ - margin-top: 0em; -} - -div.example pre -{ - box-shadow: none; -} - - -/*************************************************************************** - Screen dumps: - ***************************************************************************/ - -pre.screen, pre.programlisting -{ - border: 1px solid #b0b0b0; - padding: 3px 3px; - margin-left: 1.5em; - margin-right: 1.5em; - - background: #f4f4f8; - font-family: monospace; - border-radius: 0.4em; - box-shadow: 0.4em 0.4em 0.5em #e0e0e0; -} - -div.example pre.programlisting -{ - border: 0px; - padding: 0 0; - margin: 0 0 0 0; -} - -/*************************************************************************** - Notes, warnings etc: - ***************************************************************************/ - -.note, .warning -{ - border: 1px solid #b0b0b0; - padding: 3px 3px; - margin-left: 1.5em; - margin-right: 1.5em; - margin-bottom: 1em; - padding: 0.3em 0.3em 0.3em 0.3em; - background: #fffff5; - border-radius: 0.4em; - box-shadow: 0.4em 0.4em 0.5em #e0e0e0; -} - -div.note, div.warning -{ - font-style: italic; -} - -div.note h3, div.warning h3 -{ - color: red; - font-size: 100%; - padding-right: 0.5em; - display: inline; -} - -div.note p, div.warning p -{ - margin-bottom: 0em; -} - -div.note h3 + p, div.warning h3 + p -{ - display: inline; -} - -div.note h3 -{ - color: blue; - font-size: 100%; -} - -div.navfooter * -{ - font-size: 90%; -} - - -/*************************************************************************** - Links colors and highlighting: - ***************************************************************************/ - -a { text-decoration: none; } -a:hover { text-decoration: underline; } -a:link { color: #0048b3; } -a:visited { color: #002a6a; } - - -/*************************************************************************** - Table of contents: - ***************************************************************************/ - -div.toc -{ - font-size: 90%; -} - -div.toc dl -{ - margin-top: 0em; - margin-bottom: 0em; -} - - -/*************************************************************************** - Special elements: - ***************************************************************************/ - -tt, code -{ - color: #400000; -} - -.term -{ - font-weight: bold; - -} - -div.variablelist dd p, div.glosslist dd p -{ - margin-top: 0em; -} - -div.variablelist dd, div.glosslist dd -{ - margin-left: 1.5em; -} - -div.glosslist dt -{ - font-style: italic; -} - -.varname -{ - color: #400000; -} - -span.command strong -{ - font-weight: normal; - color: #400000; -} - -div.calloutlist table -{ - box-shadow: none; -} - -table -{ - border-collapse: collapse; - box-shadow: 0.4em 0.4em 0.5em #e0e0e0; -} - -table.simplelist -{ - text-align: left; - color: #005aa0; - border: 0; - padding: 5px; - background: #fffff5; - font-weight: normal; - font-style: italic; - box-shadow: none; - margin-bottom: 1em; -} - -div.navheader table, div.navfooter table { - box-shadow: none; -} - -div.affiliation -{ - font-style: italic; -} diff --git a/modules/manual.nix b/modules/manual.nix index 0c2681b3acf..1ee48b20b83 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, baseModules, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -6,55 +6,7 @@ let cfg = config.manual; - /* For the purpose of generating docs, evaluate options with each derivation - in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}". - It isn't perfect, but it seems to cover a vast majority of use cases. - Caveat: even if the package is reached by a different means, - the path above will be shown and not e.g. `${config.services.foo.package}`. */ - homeManagerManual = import ../doc { - inherit pkgs config; - version = "0.1"; - revision = "master"; - options = - let - scrubbedEval = evalModules { - modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ baseModules; - args = (config._module.args) // { modules = [ ]; }; - specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; }; - }; - scrubDerivations = namePrefix: pkgSet: mapAttrs - (name: value: - let wholeName = "${namePrefix}.${name}"; in - if isAttrs value then - scrubDerivations wholeName value - // (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; }) - else value - ) - pkgSet; - in scrubbedEval.options; - }; - - manualHtmlRoot = "${homeManagerManual.manual}/share/doc/home-manager/index.html"; - - helpScript = pkgs.writeShellScriptBin "home-manager-help" '' - #!${pkgs.bash}/bin/bash -e - - if [ -z "$BROWSER" ]; then - for candidate in xdg-open open w3m; do - BROWSER="$(type -P $candidate || true)" - if [ -x "$BROWSER" ]; then - break; - fi - done - fi - - if [ -z "$BROWSER" ]; then - echo "$0: unable to start a web browser; please set \$BROWSER" - exit 1 - fi - - exec "$BROWSER" ${manualHtmlRoot} - ''; + docs = import ../doc { inherit pkgs; }; in @@ -100,15 +52,10 @@ in config = { home.packages = mkMerge [ - (mkIf cfg.html.enable [ helpScript homeManagerManual.manual ]) - (mkIf cfg.manpages.enable [ homeManagerManual.manpages ]) - (mkIf cfg.json.enable [ homeManagerManual.optionsJSON ]) + (mkIf cfg.html.enable [ docs.manual.html docs.manual.htmlOpenTool ]) + (mkIf cfg.manpages.enable [ docs.manPages ]) + (mkIf cfg.json.enable [ docs.options.json ]) ]; }; - # To fix error during manpage build. - meta = { - maintainers = [ maintainers.rycee ]; - doc = builtins.toFile "nothingness" ""; - }; } -- cgit v1.2.3 From 7159c293af3362370159da45fdb1ac0b0b7c373c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 21 Aug 2019 22:57:46 +0200 Subject: gitlab-ci: fix deployment of manual --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e94c3cd58b9..73c00f30510 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ Run tests: only: - master -Deploy manual: +pages: stage: deploy script: - mkdir -p ~/.config/nixpkgs -- cgit v1.2.3 From eb1b86a5ec7baf1a1ce2c277d568a8751c24a7ee Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 22 Aug 2019 08:35:06 +0200 Subject: Replace use of `stdenv.shell` by `runtimeShell` --- modules/home-environment.nix | 2 +- modules/programs/notmuch.nix | 2 +- modules/services/emacs.nix | 2 +- nixos/default.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 7f51cd8a3df..4b14d2d40d7 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -370,7 +370,7 @@ in + optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH"; activationScript = pkgs.writeScript "activation-script" '' - #!${pkgs.stdenv.shell} + #!${pkgs.runtimeShell} set -eu set -o pipefail diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index e39747c8bab..cd0b1384ad9 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -188,7 +188,7 @@ in { target = "${notmuchIni.database.path}/.notmuch/hooks/${name}"; source = pkgs.writeScript name '' - #!${pkgs.stdenv.shell} + #!${pkgs.runtimeShell} export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH" export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/notmuchrc" diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index 216645475a9..33d6871c61b 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -35,7 +35,7 @@ in }; Service = { - ExecStart = "${pkgs.stdenv.shell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'"; + ExecStart = "${pkgs.runtimeShell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'"; ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs)'"; Restart = "on-failure"; }; diff --git a/nixos/default.nix b/nixos/default.nix index 29803ddcc69..8e616d9e262 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -108,7 +108,7 @@ in # The activation script is run by a login shell to make sure # that the user is given a sane Nix environment. ExecStart = pkgs.writeScript "activate-${username}" '' - #! ${pkgs.stdenv.shell} -el + #! ${pkgs.runtimeShell} -el echo Activating home-manager configuration for ${username} exec ${usercfg.home.activationPackage}/activate ''; -- cgit v1.2.3 From b2a787ca6937cdfba182fd013d727076157f30b1 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Mon, 26 Aug 2019 14:11:42 +0200 Subject: random-background: add option `enableXinerama` --- modules/services/random-background.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index 742642fb7a3..789c9164e3c 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -6,6 +6,11 @@ let cfg = config.services.random-background; + flags = lib.concatStringsSep " " ( + [ "--randomize" "--bg-${cfg.display}" ] + ++ lib.optional (!cfg.enableXinerama) "--no-xinerama" + ); + in { @@ -41,6 +46,16 @@ in as a duration understood by systemd. ''; }; + + enableXinerama = mkOption { + default = true; + type = types.bool; + description = '' + Will place a separate image per screen when enabled, + otherwise a single image will be stretched across all + screens. + ''; + }; }; }; @@ -56,7 +71,7 @@ in Service = { Type = "oneshot"; - ExecStart = "${pkgs.feh}/bin/feh --randomize --bg-${cfg.display} ${cfg.imageDirectory}"; + ExecStart = "${pkgs.feh}/bin/feh ${flags} ${cfg.imageDirectory}"; IOSchedulingClass = "idle"; }; -- cgit v1.2.3 From bfc28cacbed9124d0162db60a1cb0a453da273bd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Aug 2019 20:07:07 +0200 Subject: random-background: disable creation of `~/.fehbg` file --- modules/services/random-background.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index 789c9164e3c..cbec97ae7cb 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -7,7 +7,11 @@ let cfg = config.services.random-background; flags = lib.concatStringsSep " " ( - [ "--randomize" "--bg-${cfg.display}" ] + [ + "--bg-${cfg.display}" + "--no-fehbg" + "--randomize" + ] ++ lib.optional (!cfg.enableXinerama) "--no-xinerama" ); -- cgit v1.2.3 From 6bec9547c67d603e266d0f039b5cf6e1e6f23813 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Aug 2019 23:06:20 +0200 Subject: home-manager: exit directly after printing help --- home-manager/home-manager | 1 + 1 file changed, 1 insertion(+) diff --git a/home-manager/home-manager b/home-manager/home-manager index bd81fc92357..86adde1e5d0 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -485,6 +485,7 @@ while [[ $# -gt 0 ]]; do ;; -h|--help) doHelp + exit 0 ;; -n|--dry-run) export DRY_RUN=1 -- cgit v1.2.3 From 8fe4e0879c15102f5d30f9803d53ba4e8493a120 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Aug 2019 22:45:31 +0200 Subject: home-manager: support a few extra pass-through options These options will be passed through to the `nix-build` tool. --- doc/man-home-manager.xml | 64 +++++++++++++++++++++++++++++++++++++++++++++++ home-manager/home-manager | 14 ++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index d83566a3c22..6f7a0551922 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -102,6 +102,22 @@ + + --cores number + + + + --max-jobs number + + + + --keep-failed + + + + --keep-going + + --show-trace @@ -354,6 +370,54 @@ + + + + + + + Passed on to + nix-build + 1 . + + + + + + + + + + Passed on to + nix-build + 1 . + + + + + + + + + + Passed on to + nix-build + 1 . + + + + + + + + + + Passed on to + nix-build + 1 . + + + diff --git a/home-manager/home-manager b/home-manager/home-manager index 86adde1e5d0..2e7f8c72ebd 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -423,6 +423,14 @@ function doHelp() { echo " -n Do a dry run, only prints what actions would be taken" echo " -h Print this help" echo + echo "Options passed on to nix-build(1)" + echo + echo " --cores NUM" + echo " --keep-failed" + echo " --keep-going" + echo " --max-jobs NUM" + echo " --show-trace" + echo echo "Commands" echo echo " help Print this help" @@ -490,7 +498,11 @@ while [[ $# -gt 0 ]]; do -n|--dry-run) export DRY_RUN=1 ;; - --show-trace) + --max-jobs|--cores) + PASSTHROUGH_OPTS+=("$opt" "$1") + shift + ;; + --keep-failed|--keep-going|--show-trace) PASSTHROUGH_OPTS+=("$opt") ;; -v|--verbose) -- cgit v1.2.3 From 13fa61744c0c8242446a349cc1e9d6279446db35 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Aug 2019 23:14:51 +0200 Subject: doc: minor grammar fix --- doc/man-home-manager.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index 6f7a0551922..3b89939443d 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -318,7 +318,7 @@ - Enabled automatic resolution of collisions between unmanaged and managed + Enable automatic resolution of collisions between unmanaged and managed files. The name of the original file will be suffixed by the given extension. For example, -- cgit v1.2.3 From db86bd6c013d3434159885d0987e5b48d8b7b141 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 27 Aug 2019 23:40:52 +0200 Subject: doc: update nmd Also perform scrubbing of `pkgs` since nmd no longer does this automatically. --- doc/default.nix | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/default.nix b/doc/default.nix index 7abe278a096..4482475c135 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -7,14 +7,29 @@ let nmdSrc = pkgs.fetchFromGitLab { owner = "rycee"; repo = "nmd"; - rev = "b57fc6657b6645086a286e62a05a1795f258daa6"; - sha256 = "1b6bdgn6d4awxi8al5hbw8vycxp4laf63l29rjrvxi2j2g69rgvc"; + rev = "9751ca5ef6eb2ef27470010208d4c0a20e89443d"; + sha256 = "0rbx10n8kk0bvp1nl5c8q79lz1w0p1b8103asbvwps3gmqd070hi"; }; nmd = import nmdSrc { inherit pkgs; }; + # Make sure the used package is scrubbed to avoid actually + # instantiating derivations. + scrubbedPkgsModule = { + imports = [ + { + _module.args = { + pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs); + pkgs_i686 = lib.mkForce { }; + }; + } + ]; + }; + hmModulesDocs = nmd.buildModulesDocs { - modules = import ../modules/modules.nix { inherit lib pkgs; }; + modules = + import ../modules/modules.nix { inherit lib pkgs; } + ++ [ scrubbedPkgsModule ]; moduleRootPaths = [ ./.. ]; mkModuleUrl = path: "https://github.com/rycee/home-manager/blob/master/${path}#blob-path"; -- cgit v1.2.3 From 55b71223d404040ed2416a9e80d7f522fbd7048d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 28 Aug 2019 00:12:28 +0200 Subject: Fix option `defaultText` when referencing packages By using `literalExample` the documentation will show the option default without surrounding quotes. --- modules/programs/chromium.nix | 2 +- modules/programs/emacs.nix | 2 +- modules/programs/firefox.nix | 2 +- modules/programs/fish.nix | 2 +- modules/programs/git.nix | 2 +- modules/programs/go.nix | 2 +- modules/programs/keychain.nix | 2 +- modules/programs/mbsync.nix | 2 +- modules/programs/mercurial.nix | 2 +- modules/programs/neovim.nix | 2 +- modules/programs/opam.nix | 2 +- modules/programs/pidgin.nix | 2 +- modules/programs/tmux.nix | 2 +- modules/programs/urxvt.nix | 2 +- modules/services/compton.nix | 2 +- modules/services/dwm-status.nix | 2 +- modules/services/mbsync.nix | 2 +- modules/services/mpdris2.nix | 2 +- modules/services/polybar.nix | 2 +- modules/services/redshift.nix | 2 +- modules/services/stalonetray.nix | 2 +- modules/services/status-notifier-watcher.nix | 2 +- modules/services/taffybar.nix | 2 +- modules/services/unclutter.nix | 2 +- modules/services/window-managers/awesome.nix | 2 +- modules/services/window-managers/i3.nix | 4 ++-- modules/services/window-managers/xmonad.nix | 2 +- modules/services/xembed-sni-proxy.nix | 2 +- 28 files changed, 29 insertions(+), 29 deletions(-) diff --git a/modules/programs/chromium.nix b/modules/programs/chromium.nix index ba39c50b5dc..83a827a0ed0 100644 --- a/modules/programs/chromium.nix +++ b/modules/programs/chromium.nix @@ -21,7 +21,7 @@ let inherit visible; type = types.package; default = defaultPkg; - defaultText = "pkgs.${browser}"; + defaultText = literalExample "pkgs.${browser}"; description = "The ${name} package to use."; }; diff --git a/modules/programs/emacs.nix b/modules/programs/emacs.nix index 0b1514f291a..78c136c9868 100644 --- a/modules/programs/emacs.nix +++ b/modules/programs/emacs.nix @@ -29,7 +29,7 @@ in package = mkOption { type = types.package; default = pkgs.emacs; - defaultText = "pkgs.emacs"; + defaultText = literalExample "pkgs.emacs"; example = literalExample "pkgs.emacs25-nox"; description = "The Emacs package to use."; }; diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index e47bec3e171..708b05417d6 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -49,7 +49,7 @@ in if versionAtLeast config.home.stateVersion "19.09" then pkgs.firefox else pkgs.firefox-unwrapped; - defaultText = "pkgs.firefox"; + defaultText = literalExample "pkgs.firefox"; description = '' The Firefox package to use. If state version ≥ 19.09 then this should be a wrapped Firefox package. For earlier state diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 2328f9b94a6..87a17b85507 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -23,7 +23,7 @@ in package = mkOption { default = pkgs.fish; - defaultText = "pkgs.fish"; + defaultText = literalExample "pkgs.fish"; description = '' The fish package to install. May be used to change the version. ''; diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 16db07d9adf..a3c241bf01a 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -122,7 +122,7 @@ in package = mkOption { type = types.package; default = pkgs.git; - defaultText = "pkgs.git"; + defaultText = literalExample "pkgs.git"; description = '' Git package to install. Use pkgs.gitAndTools.gitFull to gain access to git send-email for instance. diff --git a/modules/programs/go.nix b/modules/programs/go.nix index bccf7c9a2e5..06c25c9b82a 100644 --- a/modules/programs/go.nix +++ b/modules/programs/go.nix @@ -18,7 +18,7 @@ in package = mkOption { type = types.package; default = pkgs.go; - defaultText = "pkgs.go"; + defaultText = literalExample "pkgs.go"; description = "The Go package to use."; }; diff --git a/modules/programs/keychain.nix b/modules/programs/keychain.nix index c39c852011a..6dbf83a872e 100644 --- a/modules/programs/keychain.nix +++ b/modules/programs/keychain.nix @@ -25,7 +25,7 @@ in package = mkOption { type = types.package; default = pkgs.keychain; - defaultText = "pkgs.keychain"; + defaultText = literalExample "pkgs.keychain"; description = '' Keychain package to install. ''; diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index cda468dd3e4..908a1add715 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -112,7 +112,7 @@ in package = mkOption { type = types.package; default = pkgs.isync; - defaultText = "pkgs.isync"; + defaultText = literalExample "pkgs.isync"; example = literalExample "pkgs.isync"; description = "The package to use for the mbsync binary."; }; diff --git a/modules/programs/mercurial.nix b/modules/programs/mercurial.nix index 5daee39f153..fa6e7b3e5ba 100644 --- a/modules/programs/mercurial.nix +++ b/modules/programs/mercurial.nix @@ -17,7 +17,7 @@ in package = mkOption { type = types.package; default = pkgs.mercurial; - defaultText = "pkgs.mercurial"; + defaultText = literalExample "pkgs.mercurial"; description = "Mercurial package to install."; }; diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 7f2a9aaa115..d32f8f4aa19 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -107,7 +107,7 @@ in package = mkOption { type = types.package; default = pkgs.neovim-unwrapped; - defaultText = "pkgs.neovim-unwrapped"; + defaultText = literalExample "pkgs.neovim-unwrapped"; description = "The package to use for the neovim binary."; }; diff --git a/modules/programs/opam.nix b/modules/programs/opam.nix index d62b50dd377..4de2e82da55 100644 --- a/modules/programs/opam.nix +++ b/modules/programs/opam.nix @@ -17,7 +17,7 @@ in package = mkOption { type = types.package; default = pkgs.opam; - defaultText = "pkgs.opam"; + defaultText = literalExample "pkgs.opam"; description = "Opam package to install."; }; diff --git a/modules/programs/pidgin.nix b/modules/programs/pidgin.nix index 534ee5f0cb2..8dcb2122172 100644 --- a/modules/programs/pidgin.nix +++ b/modules/programs/pidgin.nix @@ -18,7 +18,7 @@ in package = mkOption { type = types.package; default = pkgs.pidgin; - defaultText = "pkgs.pidgin"; + defaultText = literalExample "pkgs.pidgin"; description = "The Pidgin package to use."; }; diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index a4892c9b632..766bc6238ba 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -169,7 +169,7 @@ in package = mkOption { type = types.package; default = pkgs.tmux; - defaultText = "pkgs.tmux"; + defaultText = literalExample "pkgs.tmux"; example = literalExample "pkgs.tmux"; description = "The tmux package to install"; }; diff --git a/modules/programs/urxvt.nix b/modules/programs/urxvt.nix index 5ac4f4bd652..6f4eb3ff7ba 100644 --- a/modules/programs/urxvt.nix +++ b/modules/programs/urxvt.nix @@ -15,7 +15,7 @@ in package = mkOption { type = types.package; default = pkgs.rxvt_unicode; - defaultText = "pkgs.rxvt_unicode"; + defaultText = literalExample "pkgs.rxvt_unicode"; description = "rxvt-unicode package to install."; }; diff --git a/modules/services/compton.nix b/modules/services/compton.nix index 88b15b43bbc..c227f0a8c07 100644 --- a/modules/services/compton.nix +++ b/modules/services/compton.nix @@ -263,7 +263,7 @@ in { package = mkOption { type = types.package; default = pkgs.compton; - defaultText = "pkgs.compton"; + defaultText = literalExample "pkgs.compton"; example = literalExample "pkgs.compton"; description = '' Compton derivation to use. diff --git a/modules/services/dwm-status.nix b/modules/services/dwm-status.nix index 6b6a8cbdaa6..2b010cec1e1 100644 --- a/modules/services/dwm-status.nix +++ b/modules/services/dwm-status.nix @@ -20,7 +20,7 @@ in package = mkOption { type = types.package; default = pkgs.dwm-status; - defaultText = "pkgs.dwm-status"; + defaultText = literalExample "pkgs.dwm-status"; example = "pkgs.dwm-status.override { enableAlsaUtils = false; }"; description = "Which dwm-status package to use."; }; diff --git a/modules/services/mbsync.nix b/modules/services/mbsync.nix index 1fe755938ab..73c3b326695 100644 --- a/modules/services/mbsync.nix +++ b/modules/services/mbsync.nix @@ -22,7 +22,7 @@ in package = mkOption { type = types.package; default = pkgs.isync; - defaultText = "pkgs.isync"; + defaultText = literalExample "pkgs.isync"; example = literalExample "pkgs.isync"; description = "The package to use for the mbsync binary."; }; diff --git a/modules/services/mpdris2.nix b/modules/services/mpdris2.nix index 51ce7e892c8..450f84c5912 100644 --- a/modules/services/mpdris2.nix +++ b/modules/services/mpdris2.nix @@ -42,7 +42,7 @@ in package = mkOption { type = types.package; default = pkgs.mpdris2; - defaultText = "pkgs.mpdris2"; + defaultText = literalExample "pkgs.mpdris2"; description = "The mpDris2 package to use."; }; diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index 8bc4539d769..ae4b426ed13 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -37,7 +37,7 @@ in package = mkOption { type = types.package; default = pkgs.polybar; - defaultText = "pkgs.polybar"; + defaultText = literalExample "pkgs.polybar"; description = "Polybar package to install."; example = literalExample '' pkgs.polybar.override { diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index b1351dfb872..fd782996b43 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -96,7 +96,7 @@ in package = mkOption { type = types.package; default = pkgs.redshift; - defaultText = "pkgs.redshift"; + defaultText = literalExample "pkgs.redshift"; description = '' redshift derivation to use. ''; diff --git a/modules/services/stalonetray.nix b/modules/services/stalonetray.nix index 7b16f7544f7..934e78c99a1 100644 --- a/modules/services/stalonetray.nix +++ b/modules/services/stalonetray.nix @@ -15,7 +15,7 @@ in package = mkOption { default = pkgs.stalonetray; - defaultText = "pkgs.stalonetray"; + defaultText = literalExample "pkgs.stalonetray"; type = types.package; example = literalExample "pkgs.stalonetray"; description = "The package to use for the Stalonetray binary."; diff --git a/modules/services/status-notifier-watcher.nix b/modules/services/status-notifier-watcher.nix index 08c668bf050..8a2ded8720a 100644 --- a/modules/services/status-notifier-watcher.nix +++ b/modules/services/status-notifier-watcher.nix @@ -17,7 +17,7 @@ in package = mkOption { default = pkgs.haskellPackages.status-notifier-item; - defaultText = "pkgs.haskellPackages.status-notifier-item"; + defaultText = literalExample "pkgs.haskellPackages.status-notifier-item"; type = types.package; example = literalExample "pkgs.haskellPackages.status-notifier-item"; description = "The package to use for the status notifier watcher binary."; diff --git a/modules/services/taffybar.nix b/modules/services/taffybar.nix index eb71dd0546c..69531a19dc9 100644 --- a/modules/services/taffybar.nix +++ b/modules/services/taffybar.nix @@ -17,7 +17,7 @@ in package = mkOption { default = pkgs.taffybar; - defaultText = "pkgs.taffybar"; + defaultText = literalExample "pkgs.taffybar"; type = types.package; example = literalExample "pkgs.taffybar"; description = "The package to use for the Taffybar binary."; diff --git a/modules/services/unclutter.nix b/modules/services/unclutter.nix index 26dca37ab44..6b5ac866ec5 100644 --- a/modules/services/unclutter.nix +++ b/modules/services/unclutter.nix @@ -13,7 +13,7 @@ in { description = "unclutter derivation to use."; type = types.package; default = pkgs.unclutter-xfixes; - defaultText = "pkgs.unclutter-xfixes"; + defaultText = literalExample "pkgs.unclutter-xfixes"; }; timeout = mkOption { diff --git a/modules/services/window-managers/awesome.nix b/modules/services/window-managers/awesome.nix index a01ee70dce1..fe914864e2a 100644 --- a/modules/services/window-managers/awesome.nix +++ b/modules/services/window-managers/awesome.nix @@ -22,7 +22,7 @@ in package = mkOption { type = types.package; default = pkgs.awesome; - defaultText = "pkgs.awesome"; + defaultText = literalExample "pkgs.awesome"; description = "Package to use for running the Awesome WM."; }; diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 059c7a8a932..6c52ff6c335 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -781,8 +781,8 @@ in package = mkOption { type = types.package; default = pkgs.i3; - defaultText = "pkgs.i3"; - example = "pkgs.i3-gaps"; + defaultText = literalExample "pkgs.i3"; + example = literalExample "pkgs.i3-gaps"; description = '' i3 package to use. If 'i3.config.gaps' settings are specified, 'pkgs.i3-gaps' will be set as a default package. diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 5b64963b6ef..6b3426b963b 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -24,7 +24,7 @@ in haskellPackages = mkOption { default = pkgs.haskellPackages; - defaultText = "pkgs.haskellPackages"; + defaultText = literalExample "pkgs.haskellPackages"; example = literalExample "pkgs.haskell.packages.ghc784"; description = '' The haskellPackages used to build xmonad diff --git a/modules/services/xembed-sni-proxy.nix b/modules/services/xembed-sni-proxy.nix index 0854365da13..d9e5ae783f9 100644 --- a/modules/services/xembed-sni-proxy.nix +++ b/modules/services/xembed-sni-proxy.nix @@ -18,7 +18,7 @@ in package = mkOption { type = types.package; default = pkgs.plasma-workspace; - defaultText = "pkgs.plasma-workspace"; + defaultText = literalExample "pkgs.plasma-workspace"; description = '' Package containing the xembedsniproxy program. -- cgit v1.2.3 From f1146a1fef60b5455cff473a5e92acab378da236 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sun, 18 Aug 2019 16:36:46 +0200 Subject: vim: allow packages to be passed as plugins This change allows to pass custom packages into the `vim.plugins` option. Additionally this adds a deprecation warning and an error message if a vim plugin is not present. This is an improvement because the user gets instant feedback, when a plugin is not found. --- modules/misc/news.nix | 9 +++++++ modules/programs/vim.nix | 64 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 6c0f88cbdfe..c3f7c548829 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1176,6 +1176,15 @@ in A new module is available: 'services.dwm-status'. ''; } + + { + time = "2019-08-28T10:18:07+00:00"; + condition = config.programs.vim.enable; + message = '' + The 'programs.vim.plugins' option now accepts packages. + Specifying them as strings is deprecated. + ''; + } ]; }; } diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index 86c6910ec18..d9abdc2775b 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.programs.vim; - defaultPlugins = [ "sensible" ]; + defaultPlugins = [ pkgs.vimPlugins.sensible ]; knownSettings = { background = types.enum [ "dark" "light" ]; @@ -55,6 +55,16 @@ let in optionalString (value != null) ("set " + v); + plugins = + let + vpkgs = pkgs.vimPlugins; + getPkg = p: + if isDerivation p + then [ p ] + else optional (isString p && hasAttr p vpkgs) vpkgs.${p}; + in + concatMap getPkg cfg.plugins; + in { @@ -63,12 +73,16 @@ in enable = mkEnableOption "Vim"; plugins = mkOption { - type = types.listOf types.str; + type = with types; listOf (either str package); default = defaultPlugins; - example = [ "YankRing" ]; + example = literalExample ''[ pkgs.vimPlugins.YankRing ]''; description = '' List of vim plugins to install. To get a list of supported plugins run: nix-env -f '<nixpkgs>' -qaP -A vimPlugins. + + + + Note: String values are deprecated, please use actual packages. ''; }; @@ -135,16 +149,40 @@ in vim = pkgs.vim_configurable.customize { name = "vim"; - vimrcConfig.customRC = customRC; - vimrcConfig.vam.knownPlugins = pkgs.vimPlugins; - vimrcConfig.vam.pluginDictionaries = [ - { names = defaultPlugins ++ cfg.plugins; } - ]; - }; + vimrcConfig = { + inherit customRC; - in mkIf cfg.enable { - programs.vim.package = vim; - home.packages = [ cfg.package ]; - } + packages.home-manager.start = plugins; + }; + }; + in + mkIf cfg.enable { + assertions = + let + packagesNotFound = filter (p: isString p && (!hasAttr p pkgs.vimPlugins)) cfg.plugins; + in + [ + { + assertion = packagesNotFound == []; + message = "Following VIM plugin not found in pkgs.vimPlugins: ${ + concatMapStringsSep ", " (p: ''"${p}"'') packagesNotFound + }"; + } + ]; + + warnings = + let + stringPlugins = filter isString cfg.plugins; + in + optional (stringPlugins != []) '' + Specifying VIM plugins using strings is deprecated, found ${ + concatMapStringsSep ", " (p: ''"${p}"'') stringPlugins + } as strings. + ''; + + home.packages = [ cfg.package ]; + + programs.vim.package = vim; + } ); } -- cgit v1.2.3 From 5d7eabb93fd70264f7e64f02fa3d4334ed01ad09 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sat, 10 Aug 2019 13:55:05 +0200 Subject: neovim: add finalPackage option as readOnly --- modules/programs/neovim.nix | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index d32f8f4aa19..6aaa3980ac8 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -111,6 +111,13 @@ in description = "The package to use for the neovim binary."; }; + finalPackage = mkOption { + type = types.package; + visible = false; + readOnly = true; + description = "Resulting customized neovim package."; + }; + configure = mkOption { type = types.attrs; default = {}; @@ -136,13 +143,13 @@ in }; config = mkIf cfg.enable { - home.packages = [ - (pkgs.wrapNeovim cfg.package { - inherit (cfg) - extraPython3Packages withPython3 - extraPythonPackages withPython - withNodeJs withRuby viAlias vimAlias configure; - }) - ]; + home.packages = [ cfg.finalPackage ]; + + programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package { + inherit (cfg) + extraPython3Packages withPython3 + extraPythonPackages withPython + withNodeJs withRuby viAlias vimAlias configure; + }; }; } -- cgit v1.2.3 From c142e5264dc0b3e1e68d7af73e76e3d83446da11 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sun, 18 Aug 2019 15:20:17 +0200 Subject: neovim: add extraConfig and plugins options --- modules/programs/neovim.nix | 59 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 6aaa3980ac8..dadda2c7118 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -24,6 +24,14 @@ let merge = mergeOneOption; }; + moduleConfigure = + optionalAttrs (cfg.extraConfig != "") { + customRC = cfg.extraConfig; + } + // optionalAttrs (cfg.plugins != []) { + packages.home-manager.start = cfg.plugins; + }; + in { @@ -137,19 +145,68 @@ in description = '' Generate your init file from your list of plugins and custom commands, and loads it from the store via nvim -u /nix/store/hash-vimrc + + + + This option is deprecated. Please use the options extraConfig + and plugins which are mutually exclusive with this option. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + set nocompatible + set nobackup + ''; + description = '' + Custom vimrc lines. + + + + This option is mutually exclusive with configure. + ''; + }; + + plugins = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExample "[ pkgs.vimPlugins.yankring ]"; + description = '' + List of vim plugins to install. + + + + This option is mutually exclusive with configure. ''; }; }; }; config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.configure == { } || moduleConfigure == { }; + message = "The programs.neovim option configure is mutually exclusive" + + " with extraConfig and plugins."; + } + ]; + + warnings = optional (cfg.configure != {}) '' + The programs.neovim.configure option is deprecated. Please use + extraConfig and package option. + ''; + home.packages = [ cfg.finalPackage ]; programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package { inherit (cfg) extraPython3Packages withPython3 extraPythonPackages withPython - withNodeJs withRuby viAlias vimAlias configure; + withNodeJs withRuby viAlias vimAlias; + + configure = cfg.configure // moduleConfigure; }; }; } -- cgit v1.2.3 From 7c76ae1814838154a6c99fe481af3191f7258a1a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 28 Aug 2019 20:36:11 +0200 Subject: manual: add nmd as a generation dependency This is to allow network-less rebuilding of a generation after a garbage collection. Fixes #819 --- doc/default.nix | 3 ++- modules/manual.nix | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/default.nix b/doc/default.nix index 4482475c135..acfa1f1e49c 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -5,6 +5,7 @@ let lib = pkgs.lib; nmdSrc = pkgs.fetchFromGitLab { + name = "nmd"; owner = "rycee"; repo = "nmd"; rev = "9751ca5ef6eb2ef27470010208d4c0a20e89443d"; @@ -55,6 +56,7 @@ let in { + inherit nmdSrc; options = { json = hmModulesDocs.json.override { @@ -67,5 +69,4 @@ in manual = { inherit (docs) html htmlOpenTool; }; - } diff --git a/modules/manual.nix b/modules/manual.nix index 1ee48b20b83..e4c127c0d47 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -56,6 +56,13 @@ in (mkIf cfg.manpages.enable [ docs.manPages ]) (mkIf cfg.json.enable [ docs.options.json ]) ]; + + # Whether a dependency on nmd should be introduced. + home.extraBuilderCommands = + mkIf (cfg.html.enable || cfg.manpages.enable || cfg.json.enable) '' + mkdir $out/lib + ln -s ${docs.nmdSrc} $out/lib/nmd + ''; }; } -- cgit v1.2.3 From 875eea1330d8847a78dfead2ee26143adc542138 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 29 Aug 2019 19:12:39 +0200 Subject: systemd: fix unit examples Closes #823 --- modules/systemd.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 2a67bb31848..cdc4486f542 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -81,15 +81,17 @@ let unitExample = type: literalExample '' { - Unit = { - Description = "Example description"; - Documentation = [ "man:example(1)" "man:example(5)" ]; - }; + ${toLower type}-name = { + Unit = { + Description = "Example description"; + Documentation = [ "man:example(1)" "man:example(5)" ]; + }; - ${type} = { - … - }; - } + ${type} = { + … + }; + } + }; ''; sessionVariables = mkIf (cfg.sessionVariables != {}) { -- cgit v1.2.3 From b6289f70221ca9ef986512a01cca95337981cda2 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Thu, 29 Aug 2019 23:18:11 +0200 Subject: vim: always add sensible plugin --- modules/programs/vim.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index d9abdc2775b..a14a9562ac1 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -182,7 +182,10 @@ in home.packages = [ cfg.package ]; - programs.vim.package = vim; + programs.vim = { + package = vim; + plugins = defaultPlugins; + }; } ); } -- cgit v1.2.3 From 8ab1d22a82b0cda5acc06c3d6404b4c6c9c8e267 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 30 Aug 2019 00:52:09 +0200 Subject: home-manager: support `--option` argument Fixes #784 --- doc/man-home-manager.xml | 16 ++++++++++++++++ home-manager/home-manager | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/doc/man-home-manager.xml b/doc/man-home-manager.xml index 3b89939443d..a0f55d1106a 100644 --- a/doc/man-home-manager.xml +++ b/doc/man-home-manager.xml @@ -102,6 +102,10 @@ + + --option name value + + --cores number @@ -370,6 +374,18 @@ + + + + + + + Passed on to + nix-build + 1 . + + + diff --git a/home-manager/home-manager b/home-manager/home-manager index 2e7f8c72ebd..6fe4f13c7f0 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -429,6 +429,7 @@ function doHelp() { echo " --keep-failed" echo " --keep-going" echo " --max-jobs NUM" + echo " --option NAME VALUE" echo " --show-trace" echo echo "Commands" @@ -498,6 +499,10 @@ while [[ $# -gt 0 ]]; do -n|--dry-run) export DRY_RUN=1 ;; + --option) + PASSTHROUGH_OPTS+=("$opt" "$1" "$2") + shift 2 + ;; --max-jobs|--cores) PASSTHROUGH_OPTS+=("$opt" "$1") shift -- cgit v1.2.3 From a28614e65d2ff0e78fe54ca6ec31cc042f563669 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 30 Aug 2019 14:50:10 +0200 Subject: git: deprecate `extraConfig` as string --- modules/programs/git.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index a3c241bf01a..370fcbb3f77 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -161,7 +161,10 @@ in core = { whitespace = "trailing-space,space-before-tab"; }; url."ssh://git@host".insteadOf = "otherhost"; }; - description = "Additional configuration to add."; + description = '' + Additional configuration to add. The use of string values is + deprecated and will be removed in the future. + ''; }; iniContent = mkOption { @@ -263,6 +266,14 @@ in }) (mkIf (lib.isString cfg.extraConfig) { + warnings = [ + '' + Using programs.git.extraConfig as a string option is + deprecated and will be removed in the future. Please + change to using it as an attribute set instead. + '' + ]; + xdg.configFile."git/config".text = cfg.extraConfig; }) -- cgit v1.2.3 From a144c723a11cafbb01f01b5d581be453d2947aa8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 1 Sep 2019 21:28:40 +0200 Subject: doc: surround `name?` with fancier characters --- doc/release-notes/rl-1903.xml | 4 ++-- modules/misc/submodule-support.nix | 2 +- nix-darwin/default.nix | 2 +- nixos/default.nix | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/release-notes/rl-1903.xml b/doc/release-notes/rl-1903.xml index b3c45370f6b..2c666da7dcf 100644 --- a/doc/release-notes/rl-1903.xml +++ b/doc/release-notes/rl-1903.xml @@ -23,8 +23,8 @@ - The now allows source - files to be hidden, that is, having a name starting with the + The now allows source files + to be hidden, that is, having a name starting with the . character. It also allows the source file name to contain characters not typically allowed for Nix store paths. For example, your configuration can now contain things such as diff --git a/modules/misc/submodule-support.nix b/modules/misc/submodule-support.nix index d6138c7ccd8..ff80291cadf 100644 --- a/modules/misc/submodule-support.nix +++ b/modules/misc/submodule-support.nix @@ -25,7 +25,7 @@ with lib; installed separately from the Home Manager activation script. In NixOS, for example, this may be accomplished by installing the packages through - . + . ''; }; }; diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 4ce64a7752a..1482c7bb245 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -25,7 +25,7 @@ in home-manager = { useUserPackages = mkEnableOption '' installation of user packages through the - option. + option. ''; users = mkOption { diff --git a/nixos/default.nix b/nixos/default.nix index 8e616d9e262..f53b4d4d6b7 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -38,7 +38,7 @@ in home-manager = { useUserPackages = mkEnableOption '' installation of user packages through the - option. + option. ''; backupFileExtension = mkOption { -- cgit v1.2.3 From d5e73c39fc413e65dd8930054777303e8a372979 Mon Sep 17 00:00:00 2001 From: dawidsowa Date: Mon, 2 Sep 2019 17:52:02 +0200 Subject: mpv: add `scripts` option --- modules/programs/mpv.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/programs/mpv.nix b/modules/programs/mpv.nix index 9303e53fa8b..1051f71ccd6 100644 --- a/modules/programs/mpv.nix +++ b/modules/programs/mpv.nix @@ -54,6 +54,15 @@ in { programs.mpv = { enable = mkEnableOption "mpv"; + scripts = mkOption { + type = types.listOf types.package; + default = []; + example = literalExample "[ pkgs.mpvScripts.mpris ]"; + description = '' + List of scripts to use with mpv. + ''; + }; + config = mkOption { description = '' Configuration written to @@ -122,7 +131,11 @@ in { config = mkIf cfg.enable (mkMerge [ { - home.packages = [ pkgs.mpv ]; + home.packages = [( + if cfg.scripts == [] + then pkgs.mpv + else pkgs.mpv-with-scripts.override { scripts = cfg.scripts; } + )]; } (mkIf (cfg.config != {} || cfg.profiles != {}) { xdg.configFile."mpv/mpv.conf".text = '' -- cgit v1.2.3 From ec0459e1394ace2ecb8750d91f20c38646486946 Mon Sep 17 00:00:00 2001 From: Alex Rice Date: Tue, 3 Sep 2019 01:25:24 +0100 Subject: rofi: string -> str --- modules/programs/rofi.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 7fd69dc7247..e64e5d4782e 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -270,7 +270,7 @@ in theme = mkOption { default = null; - type = with types; nullOr (either string path); + type = with types; nullOr (either str path); example = "Arc"; description = '' Name of theme or path to theme file in rasi format. Available -- cgit v1.2.3 From 698d0f0a442f12ac0cd70cbc46a69026cc86f7c8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 3 Sep 2019 23:51:23 +0200 Subject: polybar: restart service on failure --- modules/services/polybar.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/polybar.nix b/modules/services/polybar.nix index ae4b426ed13..4225ed9b38c 100644 --- a/modules/services/polybar.nix +++ b/modules/services/polybar.nix @@ -131,6 +131,7 @@ in scriptPkg = pkgs.writeShellScriptBin "polybar-start" cfg.script; in "${scriptPkg}/bin/polybar-start"; + Restart = "on-failure"; }; Install = { -- cgit v1.2.3 From 1923ac3358cbd2d75352c2db2178314eb4623818 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 4 Sep 2019 12:46:04 +0200 Subject: rofi: add test to verify assertion --- tests/default.nix | 1 + .../assert-on-both-theme-and-colors-expected.json | 1 + .../rofi/assert-on-both-theme-and-colors.nix | 33 ++++++++++++++++++++++ tests/modules/programs/rofi/default.nix | 3 ++ 4 files changed, 38 insertions(+) create mode 100644 tests/modules/programs/rofi/assert-on-both-theme-and-colors-expected.json create mode 100644 tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix create mode 100644 tests/modules/programs/rofi/default.nix diff --git a/tests/default.nix b/tests/default.nix index 3d0d23b99b6..ef63c7bf854 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -36,6 +36,7 @@ import nmt { // import ./modules/misc/pam // import ./modules/misc/xsession // import ./modules/programs/firefox + // import ./modules/programs/rofi // import ./modules/systemd ) // import ./modules/home-environment diff --git a/tests/modules/programs/rofi/assert-on-both-theme-and-colors-expected.json b/tests/modules/programs/rofi/assert-on-both-theme-and-colors-expected.json new file mode 100644 index 00000000000..808288f4193 --- /dev/null +++ b/tests/modules/programs/rofi/assert-on-both-theme-and-colors-expected.json @@ -0,0 +1 @@ +["Cannot use the rofi options 'theme' and 'colors' simultaneously.\n"] \ No newline at end of file diff --git a/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix b/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix new file mode 100644 index 00000000000..2558a25832f --- /dev/null +++ b/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix @@ -0,0 +1,33 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.rofi = { + enable = true; + theme = "foo"; + colors = { + window = { + background = "background"; + border = "border"; + separator = "separator"; + }; + rows = { + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent \ + home-files/result \ + ${./assert-on-both-theme-and-colors-expected.json} + ''; + }; +} diff --git a/tests/modules/programs/rofi/default.nix b/tests/modules/programs/rofi/default.nix new file mode 100644 index 00000000000..b42b43e949a --- /dev/null +++ b/tests/modules/programs/rofi/default.nix @@ -0,0 +1,3 @@ +{ + rofi-assert-on-both-theme-and-colors = import ./assert-on-both-theme-and-colors.nix; +} -- cgit v1.2.3 From 0083087e01af2b336be1f5009c3bbdebd040458a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 5 Sep 2019 01:31:44 +0200 Subject: xsession: verify setxkbmap service in test --- tests/modules/misc/xsession/basic-setxkbmap-expected.service | 12 ++++++++++++ tests/modules/misc/xsession/basic.nix | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/modules/misc/xsession/basic-setxkbmap-expected.service diff --git a/tests/modules/misc/xsession/basic-setxkbmap-expected.service b/tests/modules/misc/xsession/basic-setxkbmap-expected.service new file mode 100644 index 00000000000..39f876dd60e --- /dev/null +++ b/tests/modules/misc/xsession/basic-setxkbmap-expected.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=graphical-session.target + +[Service] +ExecStart=@setxkbmap@/bin/setxkbmap -layout 'us' -variant '' +RemainAfterExit=true +Type=oneshot + +[Unit] +After=graphical-session-pre.target +Description=Set up keyboard in X +PartOf=graphical-session.target diff --git a/tests/modules/misc/xsession/basic.nix b/tests/modules/misc/xsession/basic.nix index 81329afced5..60623d1bf6b 100644 --- a/tests/modules/misc/xsession/basic.nix +++ b/tests/modules/misc/xsession/basic.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -25,6 +25,13 @@ with lib; home-files/.xsession \ ${./basic-xsession-expected.txt} + assertFileExists home-files/.config/systemd/user/setxkbmap.service + assertFileContent \ + home-files/.config/systemd/user/setxkbmap.service \ + ${pkgs.substituteAll { + src = ./basic-setxkbmap-expected.service; + inherit (pkgs.xorg) setxkbmap; + }} ''; }; } -- cgit v1.2.3 From 824d31a21c7199a20f55dcb5f6311178e706dd72 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 5 Sep 2019 01:37:45 +0200 Subject: keyboard: make `layout` and `variant` optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also default these options to `null` for state version ≥ 19.09. Fixes #811 Suggested-by: Sean Marshallsay --- doc/release-notes/rl-1909.xml | 8 ++++++ modules/home-environment.nix | 28 ++++++++++++++---- modules/xsession.nix | 14 ++++----- tests/modules/misc/xsession/default.nix | 1 + .../keyboard-without-layout-expected.service | 12 ++++++++ .../misc/xsession/keyboard-without-layout.nix | 33 ++++++++++++++++++++++ 6 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 tests/modules/misc/xsession/keyboard-without-layout-expected.service create mode 100644 tests/modules/misc/xsession/keyboard-without-layout.nix diff --git a/doc/release-notes/rl-1909.xml b/doc/release-notes/rl-1909.xml index 3094debc1f2..99a2f27c580 100644 --- a/doc/release-notes/rl-1909.xml +++ b/doc/release-notes/rl-1909.xml @@ -30,6 +30,14 @@ Firefox package and defaults to pkgs.firefox. + + + The options and + now default to + null, which indicates that the system value should be + used. + + diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 4b14d2d40d7..6321bcb7869 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -55,10 +55,18 @@ let keyboardSubModule = types.submodule { options = { layout = mkOption { - type = types.str; - default = "us"; + type = with types; nullOr str; + default = + if versionAtLeast config.home.stateVersion "19.09" + then null + else "us"; + defaultText = literalExample "null"; description = '' - Keyboard layout. + Keyboard layout. If null, then the system + configuration will be used. + + This defaults to null for state + version ≥ 19.09 and "us" otherwise. ''; }; @@ -81,11 +89,19 @@ let }; variant = mkOption { - type = types.str; - default = ""; + type = with types; nullOr str; + default = + if versionAtLeast config.home.stateVersion "19.09" + then null + else ""; + defaultText = literalExample "null"; example = "colemak"; description = '' - X keyboard variant. + X keyboard variant. If null, then the + system configuration will be used. + + This defaults to null for state + version ≥ 19.09 and "" otherwise. ''; }; }; diff --git a/modules/xsession.nix b/modules/xsession.nix index b05581516b5..164fe503e16 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -104,16 +104,14 @@ in Type = "oneshot"; RemainAfterExit = true; ExecStart = + with config.home.keyboard; let - args = concatStringsSep " " ( - [ - "-layout '${config.home.keyboard.layout}'" - "-variant '${config.home.keyboard.variant}'" - ] ++ - (map (v: "-option '${v}'") config.home.keyboard.options) - ); + args = + optional (layout != null) "-layout '${layout}'" + ++ optional (variant != null) "-variant '${variant}'" + ++ map (v: "-option '${v}'") options; in - "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${toString args}"; }; }; }; diff --git a/tests/modules/misc/xsession/default.nix b/tests/modules/misc/xsession/default.nix index fdacd3bbc39..2ddbf47efac 100644 --- a/tests/modules/misc/xsession/default.nix +++ b/tests/modules/misc/xsession/default.nix @@ -1,3 +1,4 @@ { xsession-basic = ./basic.nix; + xsession-keyboard-without-layout = ./keyboard-without-layout.nix; } diff --git a/tests/modules/misc/xsession/keyboard-without-layout-expected.service b/tests/modules/misc/xsession/keyboard-without-layout-expected.service new file mode 100644 index 00000000000..a04af53dad7 --- /dev/null +++ b/tests/modules/misc/xsession/keyboard-without-layout-expected.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=graphical-session.target + +[Service] +ExecStart=@setxkbmap@/bin/setxkbmap -option 'ctrl:nocaps' -option 'altwin:no_win' +RemainAfterExit=true +Type=oneshot + +[Unit] +After=graphical-session-pre.target +Description=Set up keyboard in X +PartOf=graphical-session.target diff --git a/tests/modules/misc/xsession/keyboard-without-layout.nix b/tests/modules/misc/xsession/keyboard-without-layout.nix new file mode 100644 index 00000000000..b7eb3decebb --- /dev/null +++ b/tests/modules/misc/xsession/keyboard-without-layout.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + home.stateVersion = "19.09"; + + home.homeDirectory = "/test-home"; + + home.keyboard = { + options = [ "ctrl:nocaps" "altwin:no_win" ]; + }; + + xsession = { + enable = true; + windowManager.command = "window manager command"; + importedVariables = [ "EXTRA_IMPORTED_VARIABLE" ]; + initExtra = "init extra commands"; + profileExtra = "profile extra commands"; + }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/setxkbmap.service + assertFileContent \ + home-files/.config/systemd/user/setxkbmap.service \ + ${pkgs.substituteAll { + src = ./keyboard-without-layout-expected.service; + inherit (pkgs.xorg) setxkbmap; + }} + ''; + }; +} -- cgit v1.2.3 From d6b36f12ff74b41b34e162bbe757f01f9636399c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 5 Sep 2019 01:56:14 +0200 Subject: keyboard: make the `model` option optional Also, actually use it in the call to setxkbmap. --- modules/home-environment.nix | 4 ++-- modules/xsession.nix | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 6321bcb7869..f12e86d4104 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -71,8 +71,8 @@ let }; model = mkOption { - type = types.str; - default = "pc104"; + type = with types; nullOr str; + default = null; example = "presario"; description = '' Keyboard model. diff --git a/modules/xsession.nix b/modules/xsession.nix index 164fe503e16..7a1642cc995 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -109,6 +109,7 @@ in args = optional (layout != null) "-layout '${layout}'" ++ optional (variant != null) "-variant '${variant}'" + ++ optional (model != null) "-model '${model}'" ++ map (v: "-option '${v}'") options; in "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${toString args}"; -- cgit v1.2.3 From 05d91c5f50ba37f7ee31ce533d533ee84aafe676 Mon Sep 17 00:00:00 2001 From: Hugo Geoffroy Date: Thu, 5 Sep 2019 06:57:12 +0200 Subject: mpd: use systemd journal instead of syslog MPD is using syslog for its logging output, while it could directly log to systemd's journal, as this daemon is primarily used as a systemd user service. This change makes MPD log to standard output, which is captured by systemd. See https://github.com/NixOS/nixpkgs/pull/57608, which does the same thing to NixOS's MPD service. --- modules/services/mpd.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/services/mpd.nix b/modules/services/mpd.nix index fbcf9e94230..5dc80a4a345 100644 --- a/modules/services/mpd.nix +++ b/modules/services/mpd.nix @@ -16,7 +16,6 @@ let ''} state_file "${cfg.dataDir}/state" sticker_file "${cfg.dataDir}/sticker.sql" - log_file "syslog" ${optionalString (cfg.network.listenAddress != "any") ''bind_to_address "${cfg.network.listenAddress}"''} -- cgit v1.2.3 From 45ec65e1cceb6d3434222cd4d94da9dad3d2a234 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Aug 2019 16:37:57 +0200 Subject: doc: convert some DocBook files to AsciiDoc --- doc/release-notes/rl-1809.adoc | 4 ++ doc/release-notes/rl-1809.xml | 11 ------ doc/release-notes/rl-1903.adoc | 59 ++++++++++++++++++++++++++++ doc/release-notes/rl-1903.xml | 88 ------------------------------------------ doc/release-notes/rl-1909.adoc | 19 +++++++++ doc/release-notes/rl-1909.xml | 43 --------------------- 6 files changed, 82 insertions(+), 142 deletions(-) create mode 100644 doc/release-notes/rl-1809.adoc delete mode 100644 doc/release-notes/rl-1809.xml create mode 100644 doc/release-notes/rl-1903.adoc delete mode 100644 doc/release-notes/rl-1903.xml create mode 100644 doc/release-notes/rl-1909.adoc delete mode 100644 doc/release-notes/rl-1909.xml diff --git a/doc/release-notes/rl-1809.adoc b/doc/release-notes/rl-1809.adoc new file mode 100644 index 00000000000..b363704e241 --- /dev/null +++ b/doc/release-notes/rl-1809.adoc @@ -0,0 +1,4 @@ +[[sec-release-18.09]] +== Release 18.09 + +The 18.09 release branch became the stable branch in September, 2018. diff --git a/doc/release-notes/rl-1809.xml b/doc/release-notes/rl-1809.xml deleted file mode 100644 index e19a4776a46..00000000000 --- a/doc/release-notes/rl-1809.xml +++ /dev/null @@ -1,11 +0,0 @@ -
- Release 18.09 - - - The 18.09 release branch became the stable branch in September, 2018. - -
diff --git a/doc/release-notes/rl-1903.adoc b/doc/release-notes/rl-1903.adoc new file mode 100644 index 00000000000..6dfdc67f5bf --- /dev/null +++ b/doc/release-notes/rl-1903.adoc @@ -0,0 +1,59 @@ +[[sec-release-19.03]] +== Release 19.03 + +The 19.03 release branch became the stable branch in April, 2019. + +[[sec-release-19.03-highlights]] +=== Highlights +:opt-home-file-source: opt-home.file._name__.source + +This release has the following notable changes: + +* The <<{opt-home-file-source}>> option now allows source files to be +hidden, that is, having a name starting with the `.` character. It +also allows the source file name to contain characters not typically +allowed for Nix store paths. For example, your configuration can now +contain things such as ++ +[source,nix] +---- +home.file."my file".source = ./. + "/file with spaces!"; +---- + +* The type used for the systemd unit options under +<>, <>, etc. has +been changed to offer more robust merging of configurations. If you +don't override values within systemd units then you are not affected +by this change. Unfortunately, if you do override unit values you may +encounter errors. ++ +In particular, if you get an error saying that a ``unique option'' is +``defined multiple times'' then you need to use the +https://nixos.org/nixos/manual/#sec-option-definitions-setting-priorities[`mkForce`] +function. For example, ++ +[source,nix] +---- +systemd.user.services.foo.Service.ExecStart = "/foo/bar"; +---- ++ +becomes ++ +[source,nix] +---- +systemd.user.services.foo.Service.ExecStart = lib.mkForce "/foo/bar"; +---- ++ +We had to make this change because the old merging was causing too +many confusing situations for people. + +[[sec-release-19.03-state-version-changes]] +=== State Version Changes + +The state version in this release includes the changes below. These +changes are only active if the <> option is set +to ``19.03'' or later. + +* There is now an option <> that defaults +to `false`. Before the module would be active if the +<> option was non-empty. diff --git a/doc/release-notes/rl-1903.xml b/doc/release-notes/rl-1903.xml deleted file mode 100644 index 2c666da7dcf..00000000000 --- a/doc/release-notes/rl-1903.xml +++ /dev/null @@ -1,88 +0,0 @@ -
- Release 19.03 - - - The 19.03 release branch became the stable branch in April, 2019. - - -
- Highlights - - - This release has the following notable changes: - - - - - - The now allows source files - to be hidden, that is, having a name starting with the - . character. It also allows the source file name to - contain characters not typically allowed for Nix store paths. For example, - your configuration can now contain things such as - -home.file."my file".source = ./. + "/file with spaces!"; - - - - - - The type used for the systemd unit options under - , - , etc. has been changed to offer more - robust merging of configurations. If you don't override values within - systemd units then you are not affected by this change. Unfortunately, if - you do override unit values you may encounter errors. - - - In particular, if you get an error saying that a unique - option is defined multiple times then you need to - use the - mkForce - function. For example, - -systemd.user.services.foo.Service.ExecStart = "/foo/bar"; - - becomes - -systemd.user.services.foo.Service.ExecStart = lib.mkForce "/foo/bar"; - - We had to make this change because the old merging was causing too many - confusing situations for people. - - - -
- -
- State Version Changes - - - The state version in this release includes the changes below. These changes - are only active if the option is set to - "19.03" or later. - - - - - - There is now an option that - defaults to false. Before the module would be active if - the option was non-empty. - - - -
-
diff --git a/doc/release-notes/rl-1909.adoc b/doc/release-notes/rl-1909.adoc new file mode 100644 index 00000000000..a33d629767e --- /dev/null +++ b/doc/release-notes/rl-1909.adoc @@ -0,0 +1,19 @@ +[[sec-release-19.09]] +== Release 19.09 (unreleased) + +This is the current unstable branch and the information in this +section is therefore not final. + +[[sec-release-19.09-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 +"19.09" or later. + +* The <> option now expects a wrapped + Firefox package and defaults to `pkgs.firefox`. + +* The options <> and + <> now default to `null`, which indicates + that the system value should be used. diff --git a/doc/release-notes/rl-1909.xml b/doc/release-notes/rl-1909.xml deleted file mode 100644 index 99a2f27c580..00000000000 --- a/doc/release-notes/rl-1909.xml +++ /dev/null @@ -1,43 +0,0 @@ -
- Release 19.09 (unreleased) - - - This is the current unstable branch and the information in this section is - therefore not final. - - -
- State Version Changes - - - The state version in this release includes the changes below. These changes - are only active if the option is set to - "19.09" or later. - - - - - - The option now expects a wrapped - Firefox package and defaults to pkgs.firefox. - - - - - The options and - now default to - null, which indicates that the system value should be - used. - - - -
-
-- cgit v1.2.3 From d3e316eec5de4b81be5975815c17de7c0dddec83 Mon Sep 17 00:00:00 2001 From: Bruno Bigras Date: Tue, 10 Sep 2019 15:01:47 -0400 Subject: imapnotify: pkgs.mbsync -> pkgs.isync --- modules/services/imapnotify-accounts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/imapnotify-accounts.nix b/modules/services/imapnotify-accounts.nix index 75b3ecd1ea5..1c780bf28c3 100644 --- a/modules/services/imapnotify-accounts.nix +++ b/modules/services/imapnotify-accounts.nix @@ -9,7 +9,7 @@ with lib; onNotify = mkOption { type = with types; either str (attrsOf str); default = ""; - example = "\${pkgs.mbsync}/bin/mbsync test-%s"; + example = "\${pkgs.isync}/bin/mbsync test-%s"; description = "Shell commands to run on any event."; }; -- cgit v1.2.3 From 41f918499bea1d6e95fc9314f18e8cf5e94aff79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarki=20=C3=81g=C3=BAst=20Gu=C3=B0mundsson?= Date: Sun, 8 Sep 2019 17:06:14 +0000 Subject: gpg: sane default for throw-keyids option The [throw-keyids](https://www.gnupg.org/gph/en/manual/r2110.html) option "hides the receiver of the encrypted data as a countermeasure against traffic analysis." However, it also slows down decryption, and even breaks some applications; see e.g. https://github.com/open-keychain/open-keychain/issues/626 I think the sane default would be to leave it off, just as it is off by default in gpg. The typical user will probably not need this level of security, and will probably prefer a better user experience (faster decryption and compatibility with a wider range of applications). Closes #838 --- modules/programs/gpg.nix | 1 - tests/modules/programs/gpg/override-defaults.nix | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/gpg.nix b/modules/programs/gpg.nix index e06ec3a9375..4588c59c882 100644 --- a/modules/programs/gpg.nix +++ b/modules/programs/gpg.nix @@ -51,7 +51,6 @@ in { with-fingerprint = mkDefault true; require-cross-certification = mkDefault true; no-symkey-cache = mkDefault true; - throw-keyids = mkDefault true; use-agent = mkDefault true; }; diff --git a/tests/modules/programs/gpg/override-defaults.nix b/tests/modules/programs/gpg/override-defaults.nix index 7cf68b31b13..850334dc589 100644 --- a/tests/modules/programs/gpg/override-defaults.nix +++ b/tests/modules/programs/gpg/override-defaults.nix @@ -10,6 +10,7 @@ with lib; settings = { no-comments = false; s2k-cipher-algo = "AES128"; + throw-keyids = true; }; }; -- cgit v1.2.3 From aa5ba177cc55b89aab8622e7dd011f1092cc3bdc Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 5 Sep 2019 11:18:43 +0200 Subject: xdg-user-dirs: add module --- modules/misc/xdg-user-dirs.nix | 100 +++++++++++++++++++++++++++++++++++++++++ modules/modules.nix | 1 + 2 files changed, 101 insertions(+) create mode 100644 modules/misc/xdg-user-dirs.nix diff --git a/modules/misc/xdg-user-dirs.nix b/modules/misc/xdg-user-dirs.nix new file mode 100644 index 00000000000..4d034d7fe43 --- /dev/null +++ b/modules/misc/xdg-user-dirs.nix @@ -0,0 +1,100 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xdg.userDirs; + +in + +{ + meta.maintainers = with maintainers; [ pacien ]; + + options.xdg.userDirs = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to manage $XDG_CONFIG_HOME/user-dirs.dirs. +
+ + The generated file is read-only. + ''; + }; + + # Well-known directory list from + # https://gitlab.freedesktop.org/xdg/xdg-user-dirs/blob/master/man/user-dirs.dirs.xml + + desktop = mkOption { + type = types.str; + default = "$HOME/Desktop"; + description = "The Desktop directory."; + }; + + documents = mkOption { + type = types.str; + default = "$HOME/Documents"; + description = "The Documents directory."; + }; + + download = mkOption { + type = types.str; + default = "$HOME/Downloads"; + description = "The Downloads directory."; + }; + + music = mkOption { + type = types.str; + default = "$HOME/Music"; + description = "The Music directory."; + }; + + pictures = mkOption { + type = types.str; + default = "$HOME/Pictures"; + description = "The Pictures directory."; + }; + + publishShare = mkOption { + type = types.str; + default = "$HOME/Public"; + description = "The Public share directory."; + }; + + templates = mkOption { + type = types.str; + default = "$HOME/Templates"; + description = "The Templates directory."; + }; + + videos = mkOption { + type = types.str; + default = "$HOME/Videos"; + description = "The Videos directory."; + }; + + extraConfig = mkOption { + type = with types; attrsOf str; + default = { }; + example = { XDG_MISC_DIR = "$HOME/Misc"; }; + description = "Other user directories."; + }; + }; + + config = mkIf cfg.enable { + xdg.configFile."user-dirs.dirs".text = generators.toKeyValue {} ( + { + XDG_DESKTOP_DIR = cfg.desktop; + XDG_DOCUMENTS_DIR = cfg.documents; + XDG_DOWNLOAD_DIR = cfg.download; + XDG_MUSIC_DIR = cfg.music; + XDG_PICTURES_DIR = cfg.pictures; + XDG_PUBLICSHARE_DIR = cfg.publishShare; + XDG_TEMPLATES_DIR = cfg.templates; + XDG_VIDEOS_DIR = cfg.videos; + } + // cfg.extraConfig + ); + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index cc38e9e7143..0e187959052 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -34,6 +34,7 @@ let (loadModule ./misc/submodule-support.nix { }) (loadModule ./misc/version.nix { }) (loadModule ./misc/xdg.nix { }) + (loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; }) (loadModule ./programs/afew.nix { }) (loadModule ./programs/alacritty.nix { }) (loadModule ./programs/alot.nix { }) -- cgit v1.2.3 From 0dfa1eef25a8c1090ff1e38f7a73123626605da0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 11 Sep 2019 20:11:16 +0200 Subject: xsession: remove bashisms in start scripts Fixes #836 --- modules/xsession.nix | 6 +++--- tests/modules/misc/xsession/basic-xprofile-expected.txt | 2 +- tests/modules/misc/xsession/basic-xsession-expected.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index 7a1642cc995..e1cf9942e7c 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -130,7 +130,7 @@ in home.file.".xprofile".text = '' . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" - if [[ -e "$HOME/.profile" ]]; then + if [ -e "$HOME/.profile" ]; then . "$HOME/.profile" fi @@ -152,7 +152,7 @@ in home.file.${cfg.scriptPath} = { executable = true; text = '' - if [[ ! -v HM_XPROFILE_SOURCED ]]; then + if [ -z "$HM_XPROFILE_SOURCED" ]; then . ~/.xprofile fi unset HM_XPROFILE_SOURCED @@ -167,7 +167,7 @@ in systemctl --user stop graphical-session-pre.target # Wait until the units actually stop. - while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do + while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do sleep 0.5 done ''; diff --git a/tests/modules/misc/xsession/basic-xprofile-expected.txt b/tests/modules/misc/xsession/basic-xprofile-expected.txt index 4fa93f97e6b..05733a974ff 100644 --- a/tests/modules/misc/xsession/basic-xprofile-expected.txt +++ b/tests/modules/misc/xsession/basic-xprofile-expected.txt @@ -1,6 +1,6 @@ . "/test-home/.nix-profile/etc/profile.d/hm-session-vars.sh" -if [[ -e "$HOME/.profile" ]]; then +if [ -e "$HOME/.profile" ]; then . "$HOME/.profile" fi diff --git a/tests/modules/misc/xsession/basic-xsession-expected.txt b/tests/modules/misc/xsession/basic-xsession-expected.txt index 20d7c4998c3..c11b7c33048 100644 --- a/tests/modules/misc/xsession/basic-xsession-expected.txt +++ b/tests/modules/misc/xsession/basic-xsession-expected.txt @@ -1,4 +1,4 @@ -if [[ ! -v HM_XPROFILE_SOURCED ]]; then +if [ -z "$HM_XPROFILE_SOURCED" ]; then . ~/.xprofile fi unset HM_XPROFILE_SOURCED @@ -13,6 +13,6 @@ systemctl --user stop graphical-session.target systemctl --user stop graphical-session-pre.target # Wait until the units actually stop. -while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do +while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do sleep 0.5 done -- cgit v1.2.3 From e347e932afb1fe3b3c545c4ac7a4d90cd2072fde Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 5 Sep 2019 11:25:31 +0200 Subject: xdg-mime-apps: add module --- modules/misc/xdg-mime-apps.nix | 88 ++++++++++++++++++++++ modules/modules.nix | 3 +- tests/default.nix | 1 + tests/modules/misc/xdg/default.nix | 3 + .../modules/misc/xdg/mime-apps-basics-expected.ini | 9 +++ tests/modules/misc/xdg/mime-apps-basics.nix | 30 ++++++++ 6 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 modules/misc/xdg-mime-apps.nix create mode 100644 tests/modules/misc/xdg/default.nix create mode 100644 tests/modules/misc/xdg/mime-apps-basics-expected.ini create mode 100644 tests/modules/misc/xdg/mime-apps-basics.nix diff --git a/modules/misc/xdg-mime-apps.nix b/modules/misc/xdg-mime-apps.nix new file mode 100644 index 00000000000..ac675d2dfe2 --- /dev/null +++ b/modules/misc/xdg-mime-apps.nix @@ -0,0 +1,88 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xdg.mimeApps; + + strListOrSingleton = with types; + coercedTo (either (listOf str) str) toList (listOf str); + +in + +{ + meta.maintainers = with maintainers; [ pacien ]; + + options.xdg.mimeApps = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to manage $XDG_CONFIG_HOME/mimeapps.list. + + + The generated file is read-only. + ''; + }; + + # descriptions from + # https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.1.html + + associations.added = mkOption { + type = types.attrsOf strListOrSingleton; + default = { }; + example = literalExample '' + { + "mimetype1" = [ "foo1.desktop" "foo2.desktop" "foo3.desktop" ]; + "mimetype2" = "foo4.desktop"; + } + ''; + description = '' + Defines additional associations of applications with + mimetypes, as if the .desktop file was listing this mimetype + in the first place. + ''; + }; + + associations.removed = mkOption { + type = types.attrsOf strListOrSingleton; + default = { }; + example = { "mimetype1" = "foo5.desktop"; }; + description = '' + Removes associations of applications with mimetypes, as if the + .desktop file was not listing this + mimetype in the first place. + ''; + }; + + defaultApplications = mkOption { + type = types.attrsOf strListOrSingleton; + default = { }; + example = literalExample '' + { + "mimetype1" = [ "default1.desktop" "default2.desktop" ]; + } + ''; + description = '' + The default application to be used for a given mimetype. This + is, for instance, the one that will be started when + double-clicking on a file in a file manager. If the + application is no longer installed, the next application in + the list is attempted, and so on. + ''; + }; + }; + + config = mkIf cfg.enable { + xdg.configFile."mimeapps.list".text = + let + joinValues = mapAttrs (n: concatStringsSep ";"); + in + generators.toINI {} { + "Added Associations" = joinValues cfg.associations.added; + "Removed Associations" = joinValues cfg.associations.removed; + "Default Applications" = joinValues cfg.defaultApplications; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 0e187959052..c4261182fc0 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -33,8 +33,9 @@ let (loadModule ./misc/qt.nix { }) (loadModule ./misc/submodule-support.nix { }) (loadModule ./misc/version.nix { }) - (loadModule ./misc/xdg.nix { }) + (loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; }) (loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; }) + (loadModule ./misc/xdg.nix { }) (loadModule ./programs/afew.nix { }) (loadModule ./programs/alacritty.nix { }) (loadModule ./programs/alot.nix { }) diff --git a/tests/default.nix b/tests/default.nix index ef63c7bf854..355427acb2f 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -34,6 +34,7 @@ import nmt { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; } // import ./modules/misc/pam + // import ./modules/misc/xdg // import ./modules/misc/xsession // import ./modules/programs/firefox // import ./modules/programs/rofi diff --git a/tests/modules/misc/xdg/default.nix b/tests/modules/misc/xdg/default.nix new file mode 100644 index 00000000000..5772becd712 --- /dev/null +++ b/tests/modules/misc/xdg/default.nix @@ -0,0 +1,3 @@ +{ + xdg-mime-apps-basics = ./mime-apps-basics.nix; +} diff --git a/tests/modules/misc/xdg/mime-apps-basics-expected.ini b/tests/modules/misc/xdg/mime-apps-basics-expected.ini new file mode 100644 index 00000000000..c27181eb58f --- /dev/null +++ b/tests/modules/misc/xdg/mime-apps-basics-expected.ini @@ -0,0 +1,9 @@ +[Added Associations] +mimetype1=foo1.desktop;foo2.desktop;foo3.desktop +mimetype2=foo4.desktop + +[Default Applications] +mimetype1=default1.desktop;default2.desktop + +[Removed Associations] +mimetype1=foo5.desktop diff --git a/tests/modules/misc/xdg/mime-apps-basics.nix b/tests/modules/misc/xdg/mime-apps-basics.nix new file mode 100644 index 00000000000..2c32071064c --- /dev/null +++ b/tests/modules/misc/xdg/mime-apps-basics.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + xdg.mimeApps = { + enable = true; + associations = { + added = { + "mimetype1" = [ "foo1.desktop" "foo2.desktop" "foo3.desktop" ]; + "mimetype2" = "foo4.desktop"; + }; + removed = { + mimetype1 = "foo5.desktop"; + }; + }; + defaultApplications = { + "mimetype1" = [ "default1.desktop" "default2.desktop" ]; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/mimeapps.list + assertFileContent \ + home-files/.config/mimeapps.list \ + ${./mime-apps-basics-expected.ini} + ''; + }; +} -- cgit v1.2.3 From b0544c8cded820fc1439c26b4fc7485846430516 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 16 Sep 2019 21:43:53 +0200 Subject: mpd: allow path literal values in options This allows specifying, for example, the music directory using path literals without causing the directory to be copied to the Nix store. Suggested-by: Silvan Mosberger --- modules/services/mpd.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/services/mpd.nix b/modules/services/mpd.nix index 5dc80a4a345..2aa1cd3a9fe 100644 --- a/modules/services/mpd.nix +++ b/modules/services/mpd.nix @@ -45,6 +45,7 @@ in { type = types.path; default = "${config.home.homeDirectory}/music"; defaultText = "$HOME/music"; + apply = toString; # Prevent copies to Nix store. description = '' The directory where mpd reads music from. ''; @@ -54,6 +55,7 @@ in { type = types.path; default = "${cfg.dataDir}/playlists"; defaultText = ''''${dataDir}/playlists''; + apply = toString; # Prevent copies to Nix store. description = '' The directory where mpd stores playlists. ''; @@ -78,6 +80,7 @@ in { type = types.path; default = "${config.xdg.dataHome}/${name}"; defaultText = "$XDG_DATA_HOME/mpd"; + apply = toString; # Prevent copies to Nix store. description = '' The directory where MPD stores its state, tag cache, playlists etc. -- cgit v1.2.3 From 51581b7e43b24be6cf75497cee6bcfb5f37f2a61 Mon Sep 17 00:00:00 2001 From: Nazarii Bardiuk Date: Sun, 15 Sep 2019 22:12:08 +0100 Subject: sxhkd: add service --- modules/misc/news.nix | 8 +++ modules/modules.nix | 1 + modules/services/sxhkd.nix | 86 ++++++++++++++++++++++++++ tests/default.nix | 1 + tests/modules/services/sxhkd/configuration.nix | 31 ++++++++++ tests/modules/services/sxhkd/default.nix | 4 ++ tests/modules/services/sxhkd/service.nix | 20 ++++++ tests/modules/services/sxhkd/sxhkdrc | 13 ++++ 8 files changed, 164 insertions(+) create mode 100644 modules/services/sxhkd.nix create mode 100644 tests/modules/services/sxhkd/configuration.nix create mode 100644 tests/modules/services/sxhkd/default.nix create mode 100644 tests/modules/services/sxhkd/service.nix create mode 100644 tests/modules/services/sxhkd/sxhkdrc diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c3f7c548829..580efcd632c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1185,6 +1185,14 @@ in Specifying them as strings is deprecated. ''; } + + { + time = "2019-09-17T19:33:49+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.sxhkd'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index c4261182fc0..42f425d4b61 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -128,6 +128,7 @@ let (loadModule ./services/screen-locker.nix { }) (loadModule ./services/stalonetray.nix { }) (loadModule ./services/status-notifier-watcher.nix { }) + (loadModule ./services/sxhkd.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/syncthing.nix { }) (loadModule ./services/taffybar.nix { }) (loadModule ./services/tahoe-lafs.nix { }) diff --git a/modules/services/sxhkd.nix b/modules/services/sxhkd.nix new file mode 100644 index 00000000000..d9f0a968515 --- /dev/null +++ b/modules/services/sxhkd.nix @@ -0,0 +1,86 @@ +{config, lib, pkgs, ...}: + +with lib; + +let + + cfg = config.services.sxhkd; + + keybindingsStr = concatStringsSep "\n" ( + mapAttrsToList (hotkey: command: + optionalString (command != null) '' + ${hotkey} + ${command} + '' + ) + cfg.keybindings + ); + +in + +{ + options.services.sxhkd = { + enable = mkEnableOption "simple X hotkey daemon"; + + keybindings = mkOption { + type = types.attrsOf (types.nullOr types.str); + default = {}; + description = "An attribute set that assigns hotkeys to commands."; + example = literalExample '' + { + "super + shift + {r,c}" = "i3-msg {restart,reload}"; + "super + {s,w}" = "i3-msg {stacking,tabbed}"; + } + ''; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = "Additional configuration to add."; + example = literalExample '' + super + {_,shift +} {1-9,0} + i3-msg {workspace,move container to workspace} {1-10} + ''; + }; + + extraPath = mkOption { + default = ""; + type = types.envVar; + description = '' + Additional PATH entries to search for commands. + ''; + example = "/home/some-user/bin:/extra/path/bin"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.sxhkd ]; + + xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [ + keybindingsStr + cfg.extraConfig + ]; + + systemd.user.services.sxhkd = { + Unit = { + Description = "simple X hotkey daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Environment = + "PATH=" + + "${config.home.profileDirectory}/bin" + + optionalString (cfg.extraPath != "") ":" + + cfg.extraPath; + ExecStart = "${pkgs.sxhkd}/bin/sxhkd"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 355427acb2f..4bda0474f88 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -38,6 +38,7 @@ import nmt { // import ./modules/misc/xsession // import ./modules/programs/firefox // import ./modules/programs/rofi + // import ./modules/services/sxhkd // import ./modules/systemd ) // import ./modules/home-environment diff --git a/tests/modules/services/sxhkd/configuration.nix b/tests/modules/services/sxhkd/configuration.nix new file mode 100644 index 00000000000..ac04a7ecf30 --- /dev/null +++ b/tests/modules/services/sxhkd/configuration.nix @@ -0,0 +1,31 @@ +{ config, ... }: +{ + config = { + services.sxhkd = { + enable = true; + + keybindings = { + "super + a" = "run command a"; + "super + b" = null; + "super + Shift + b" = "run command b"; + }; + + extraConfig = '' + super + c + call command c + + # comment + super + d + call command d + ''; + }; + + nmt.script = '' + local sxhkdrc=home-files/.config/sxhkd/sxhkdrc + + assertFileExists $sxhkdrc + + assertFileContent $sxhkdrc ${./sxhkdrc} + ''; + }; +} diff --git a/tests/modules/services/sxhkd/default.nix b/tests/modules/services/sxhkd/default.nix new file mode 100644 index 00000000000..ec25252cee0 --- /dev/null +++ b/tests/modules/services/sxhkd/default.nix @@ -0,0 +1,4 @@ +{ + sxhkd-configuration = ./configuration.nix; + sxhkd-service = ./service.nix; +} diff --git a/tests/modules/services/sxhkd/service.nix b/tests/modules/services/sxhkd/service.nix new file mode 100644 index 00000000000..46ce259a718 --- /dev/null +++ b/tests/modules/services/sxhkd/service.nix @@ -0,0 +1,20 @@ +{ config, ... }: +{ + config = { + services.sxhkd = { + enable = true; + extraPath = "/home/the-user/bin:/extra/path/bin"; + }; + + nmt.script = '' + local serviceFile=home-files/.config/systemd/user/sxhkd.service + + assertFileExists $serviceFile + + assertFileRegex $serviceFile 'ExecStart=.*/bin/sxhkd' + + assertFileRegex $serviceFile \ + 'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin' + ''; + }; +} diff --git a/tests/modules/services/sxhkd/sxhkdrc b/tests/modules/services/sxhkd/sxhkdrc new file mode 100644 index 00000000000..c8883464b29 --- /dev/null +++ b/tests/modules/services/sxhkd/sxhkdrc @@ -0,0 +1,13 @@ +super + Shift + b + run command b + +super + a + run command a + + +super + c + call command c + +# comment +super + d + call command d -- cgit v1.2.3 From 3f4563018010e2ad180d99d9cd876187e2905cee Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Fri, 20 Sep 2019 20:00:25 +0200 Subject: xdg-mime-apps: add legacy `mimeapps.list` path Although `.local/share/applications/mimeapps.list` is deprecated, this file is still being read by some applications. To ensure compatibility duplicate the file as recommended in https://wiki.archlinux.org/index.php/XDG_MIME_Applications#mimeapps.list --- modules/misc/xdg-mime-apps.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/misc/xdg-mime-apps.nix b/modules/misc/xdg-mime-apps.nix index ac675d2dfe2..979c7ea48be 100644 --- a/modules/misc/xdg-mime-apps.nix +++ b/modules/misc/xdg-mime-apps.nix @@ -75,6 +75,10 @@ in }; config = mkIf cfg.enable { + # Deprecated but still used by some applications. + home.file.".local/share/applications/mimeapps.list".source = + config.xdg.configFile."mimeapps.list".source; + xdg.configFile."mimeapps.list".text = let joinValues = mapAttrs (n: concatStringsSep ";"); -- cgit v1.2.3 From bb5c29107e355ce0db61197df03c8b2c67cb1c8f Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Tue, 24 Sep 2019 04:20:00 -0500 Subject: git: add attributes support --- modules/programs/git.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 370fcbb3f77..913f86f71ce 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -179,6 +179,13 @@ in description = "List of paths that should be globally ignored."; }; + attributes = mkOption { + type = types.listOf types.str; + default = []; + example = [ "*.pdf diff=pdf" ]; + description = "List of defining attributes set globally."; + }; + includes = mkOption { type = types.listOf includeModule; default = []; @@ -226,6 +233,10 @@ in "git/ignore" = mkIf (cfg.ignores != []) { text = concatStringsSep "\n" cfg.ignores + "\n"; }; + + "git/attributes" = mkIf (cfg.attributes != []) { + text = concatStringsSep "\n" cfg.attributes + "\n"; + }; }; } -- cgit v1.2.3 From 7205d3b2d2192b6f0d3fe54a4cf38525ec4e27f5 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 8 Sep 2019 04:20:00 -0500 Subject: starship: add module --- modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/programs/starship.nix | 91 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 modules/programs/starship.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 580efcd632c..a16bd64dd42 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1193,6 +1193,13 @@ in A new module is available: 'services.sxhkd'. ''; } + + { + time = "2019-09-26T21:05:24+00:00"; + message = '' + A new module is available: 'programs.starship'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 42f425d4b61..f2f54f4e1e8 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -85,6 +85,7 @@ let (loadModule ./programs/pidgin.nix { }) (loadModule ./programs/rofi.nix { }) (loadModule ./programs/skim.nix { }) + (loadModule ./programs/starship.nix { }) (loadModule ./programs/ssh.nix { }) (loadModule ./programs/taskwarrior.nix { }) (loadModule ./programs/termite.nix { }) diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix new file mode 100644 index 00000000000..f61c044ad8e --- /dev/null +++ b/modules/programs/starship.nix @@ -0,0 +1,91 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.starship; + + configFile = config: + pkgs.runCommand "config.toml" + { + buildInputs = [ pkgs.remarshal ]; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + remarshal -if json -of toml \ + < ${pkgs.writeText "config.json" (builtins.toJSON config)} \ + > $out + ''; +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.starship = { + enable = mkEnableOption "starship"; + + settings = mkOption { + type = types.attrs; + default = {}; + description = '' + Configuration written to + ~/.config/starship.toml. + + See for the full list + of options. + ''; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + + enableFishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Fish integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.starship ]; + + xdg.configFile."starship.toml" = mkIf (cfg.settings != {}) { + source = configFile cfg.settings; + }; + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + if [ -z "$INSIDE_EMACS" ]; then + eval "$(${pkgs.starship}/bin/starship init bash)" + fi + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + if [ -z "$INSIDE_EMACS" ]; then + eval "$(${pkgs.starship}/bin/starship init zsh)" + fi + ''; + + programs.fish.shellInit = mkIf cfg.enableFishIntegration '' + if [ -z "$INSIDE_EMACS" ]; then + eval (${pkgs.starship}/bin/starship init fish) + fi + ''; + }; +} -- cgit v1.2.3 From bdb4cf6c59b262c39b77a1d296116817b7631b42 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 13 May 2019 01:00:00 -0500 Subject: rtorrent: add module --- modules/modules.nix | 1 + modules/programs/rtorrent.nix | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 modules/programs/rtorrent.nix diff --git a/modules/modules.nix b/modules/modules.nix index f2f54f4e1e8..2dc89ebc012 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -84,6 +84,7 @@ let (loadModule ./programs/opam.nix { }) (loadModule ./programs/pidgin.nix { }) (loadModule ./programs/rofi.nix { }) + (loadModule ./programs/rtorrent.nix { }) (loadModule ./programs/skim.nix { }) (loadModule ./programs/starship.nix { }) (loadModule ./programs/ssh.nix { }) diff --git a/modules/programs/rtorrent.nix b/modules/programs/rtorrent.nix new file mode 100644 index 00000000000..6300969a519 --- /dev/null +++ b/modules/programs/rtorrent.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.rtorrent; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.rtorrent = { + enable = mkEnableOption "rTorrent"; + + settings = mkOption { + type = types.lines; + default = ""; + description = '' + Configuration written to + ~/.config/rtorrent/rtorrent.rc. See + + for explanation about possible values. + ''; + }; + + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.rtorrent ]; + + xdg.configFile."rtorrent/rtorrent.rc" = mkIf (cfg.settings != "") { + text = cfg.settings; + }; + }; +} -- cgit v1.2.3 From 761b3d0c124856433ae69c77b9c44e9b5e40e6ac Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 26 Sep 2019 23:47:41 +0200 Subject: rtorrent: add news entry --- modules/misc/news.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a16bd64dd42..4949b757fff 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1200,6 +1200,13 @@ in A new module is available: 'programs.starship'. ''; } + + { + time = "2019-09-26T21:47:13+00:00"; + message = '' + A new module is available: 'programs.rtorrent'. + ''; + } ]; }; } -- cgit v1.2.3 From a5999a62cd3b50278b303e7c0beda2c51608c35c Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 1 Oct 2019 21:21:36 +0200 Subject: starship: fix fish syntax Fixes #858 --- modules/programs/starship.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index f61c044ad8e..83cdc29ece5 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -83,9 +83,9 @@ in ''; programs.fish.shellInit = mkIf cfg.enableFishIntegration '' - if [ -z "$INSIDE_EMACS" ]; then + if test -z "$INSIDE_EMACS" eval (${pkgs.starship}/bin/starship init fish) - fi + end ''; }; } -- cgit v1.2.3 From 3d546e0d01996268e717b13e727bd53f6b14fb1a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 1 Oct 2019 21:56:56 +0200 Subject: starship: use `[[` in bash init --- modules/programs/starship.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index 83cdc29ece5..81793c7a6f6 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -71,7 +71,7 @@ in }; programs.bash.initExtra = mkIf cfg.enableBashIntegration '' - if [ -z "$INSIDE_EMACS" ]; then + if [[ -z $INSIDE_EMACS ]]; then eval "$(${pkgs.starship}/bin/starship init bash)" fi ''; -- cgit v1.2.3 From e8dbc3561373b68d12decb3c0d7c1ba245f138f7 Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 20 Aug 2019 12:20:39 +0100 Subject: ssh: sockets forwards; remote and dynamic forwards This commit adds support for forwarding paths rather than just addresses/ports. It also adds options for specifying remote and dynamic forwards. --- modules/programs/ssh.nix | 115 ++++++++++++++++----- tests/modules/programs/ssh/default-config.nix | 7 ++ tests/modules/programs/ssh/default.nix | 13 +++ ...orwards-dynamic-bind-path-with-port-asserts.nix | 32 ++++++ ...rds-dynamic-valid-bind-no-asserts-expected.conf | 19 ++++ .../ssh/forwards-dynamic-valid-bind-no-asserts.nix | 45 ++++++++ .../forwards-local-bind-path-with-port-asserts.nix | 36 +++++++ .../forwards-local-host-path-with-port-asserts.nix | 36 +++++++ .../ssh/forwards-paths-with-ports-error.json | 1 + ...forwards-remote-bind-path-with-port-asserts.nix | 36 +++++++ ...forwards-remote-host-path-with-port-asserts.nix | 36 +++++++ .../programs/ssh/match-blocks-attrs-expected.conf | 3 + tests/modules/programs/ssh/match-blocks-attrs.nix | 23 +++++ tests/modules/programs/ssh/no-assertions.json | 1 + 14 files changed, 377 insertions(+), 26 deletions(-) create mode 100644 tests/modules/programs/ssh/forwards-dynamic-bind-path-with-port-asserts.nix create mode 100644 tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf create mode 100644 tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts.nix create mode 100644 tests/modules/programs/ssh/forwards-local-bind-path-with-port-asserts.nix create mode 100644 tests/modules/programs/ssh/forwards-local-host-path-with-port-asserts.nix create mode 100644 tests/modules/programs/ssh/forwards-paths-with-ports-error.json create mode 100644 tests/modules/programs/ssh/forwards-remote-bind-path-with-port-asserts.nix create mode 100644 tests/modules/programs/ssh/forwards-remote-host-path-with-port-asserts.nix create mode 100644 tests/modules/programs/ssh/no-assertions.json diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index fdf02a2c14e..ab61c0dcbc4 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -6,26 +6,39 @@ let cfg = config.programs.ssh; + isPath = x: builtins.substring 0 1 (toString x) == "/"; + + addressPort = entry: + if isPath entry.address + then " ${entry.address}" + else " [${entry.address}]:${toString entry.port}"; + yn = flag: if flag then "yes" else "no"; unwords = builtins.concatStringsSep " "; - localForwardModule = types.submodule ({ ... }: { - options = { - bind = { - address = mkOption { - type = types.str; - default = "localhost"; - example = "example.org"; - description = "The address where to bind the port."; - }; + bindOptions = { + address = mkOption { + type = types.str; + default = "localhost"; + example = "example.org"; + description = "The address where to bind the port."; + }; - port = mkOption { - type = types.port; - example = 8080; - description = "Specifies port number to bind on bind address."; - }; - }; + port = mkOption { + type = types.port; + example = 8080; + description = "Specifies port number to bind on bind address."; + }; + }; + + dynamicForwardModule = types.submodule { + options = bindOptions; + }; + + forwardModule = types.submodule { + options = { + bind = bindOptions; host = { address = mkOption { @@ -41,7 +54,7 @@ let }; }; }; - }); + }; matchBlockModule = types.submodule ({ name, ... }: { options = { @@ -186,7 +199,7 @@ let }; localForwards = mkOption { - type = types.listOf localForwardModule; + type = types.listOf forwardModule; default = []; example = literalExample '' [ @@ -202,7 +215,43 @@ let ssh_config 5 - for LocalForward. + for LocalForward. + ''; + }; + + remoteForwards = mkOption { + type = types.listOf forwardModule; + default = []; + example = literalExample '' + [ + { + bind.port = 8080; + host.address = "10.0.0.13"; + host.port = 80; + } + ]; + ''; + description = '' + Specify remote port forwardings. See + + ssh_config + 5 + for RemoteForward. + ''; + }; + + dynamicForwards = mkOption { + type = types.listOf dynamicForwardModule; + default = []; + example = literalExample '' + [ { port = 8080; } ]; + ''; + description = '' + Specify dynamic port forwardings. See + + ssh_config + 5 + for DynamicForward. ''; }; @@ -235,14 +284,9 @@ let ++ optional (cf.proxyCommand != null) " ProxyCommand ${cf.proxyCommand}" ++ optional (cf.proxyJump != null) " ProxyJump ${cf.proxyJump}" ++ map (file: " IdentityFile ${file}") cf.identityFile - ++ map (f: - let - addressPort = entry: " [${entry.address}]:${toString entry.port}"; - in - " LocalForward" - + addressPort f.bind - + addressPort f.host - ) cf.localForwards + ++ map (f: " LocalForward" + addressPort f.bind + addressPort f.host) cf.localForwards + ++ map (f: " RemoteForward" + addressPort f.bind + addressPort f.host) cf.remoteForwards + ++ map (f: " DynamicForward" + addressPort f) cf.dynamicForwards ++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions ); @@ -370,6 +414,25 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = + let + # `builtins.any`/`lib.lists.any` does not return `true` if there are no elements. + any' = pred: items: if items == [] then true else any pred items; + # Check that if `entry.address` is defined, and is a path, that `entry.port` has not + # been defined. + noPathWithPort = entry: entry ? address && isPath entry.address -> !(entry ? port); + checkDynamic = block: any' noPathWithPort block.dynamicForwards; + checkBindAndHost = fwd: noPathWithPort fwd.bind && noPathWithPort fwd.host; + checkLocal = block: any' checkBindAndHost block.localForwards; + checkRemote = block: any' checkBindAndHost block.remoteForwards; + checkMatchBlock = block: all (fn: fn block) [ checkLocal checkRemote checkDynamic ]; + in any' checkMatchBlock (builtins.attrValues cfg.matchBlocks); + message = "Forwarded paths cannot have ports."; + } + ]; + home.file.".ssh/config".text = '' ${concatStringsSep "\n" ( mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)} diff --git a/tests/modules/programs/ssh/default-config.nix b/tests/modules/programs/ssh/default-config.nix index e43ee3dc769..266bc9d1f5d 100644 --- a/tests/modules/programs/ssh/default-config.nix +++ b/tests/modules/programs/ssh/default-config.nix @@ -8,9 +8,16 @@ with lib; enable = true; }; + home.file.assertions.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + nmt.script = '' assertFileExists home-files/.ssh/config assertFileContent home-files/.ssh/config ${./default-config-expected.conf} + assertFileContent home-files/assertions ${./no-assertions.json} ''; }; } diff --git a/tests/modules/programs/ssh/default.nix b/tests/modules/programs/ssh/default.nix index d385e4ee921..507eef0bdb8 100644 --- a/tests/modules/programs/ssh/default.nix +++ b/tests/modules/programs/ssh/default.nix @@ -1,4 +1,17 @@ { ssh-defaults = ./default-config.nix; ssh-match-blocks = ./match-blocks-attrs.nix; + + ssh-forwards-dynamic-valid-bind-no-asserts = + ./forwards-dynamic-valid-bind-no-asserts.nix; + ssh-forwards-dynamic-bind-path-with-port-asserts = + ./forwards-dynamic-bind-path-with-port-asserts.nix; + ssh-forwards-local-bind-path-with-port-asserts = + ./forwards-local-bind-path-with-port-asserts.nix; + ssh-forwards-local-host-path-with-port-asserts = + ./forwards-local-host-path-with-port-asserts.nix; + ssh-forwards-remote-bind-path-with-port-asserts = + ./forwards-remote-bind-path-with-port-asserts.nix; + ssh-forwards-remote-host-path-with-port-asserts = + ./forwards-remote-host-path-with-port-asserts.nix; } diff --git a/tests/modules/programs/ssh/forwards-dynamic-bind-path-with-port-asserts.nix b/tests/modules/programs/ssh/forwards-dynamic-bind-path-with-port-asserts.nix new file mode 100644 index 00000000000..2e9082de378 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-dynamic-bind-path-with-port-asserts.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + dynamicBindPathWithPort = { + dynamicForwards = [ + { + # Error: + address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent home-files/result ${./forwards-paths-with-ports-error.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf b/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf new file mode 100644 index 00000000000..5213d282c28 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts-expected.conf @@ -0,0 +1,19 @@ + + +Host dynamicBindAddressWithPort + DynamicForward [127.0.0.1]:3000 + +Host dynamicBindPathNoPort + DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra + +Host * + ForwardAgent no + Compression no + ServerAliveInterval 0 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + diff --git a/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts.nix b/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts.nix new file mode 100644 index 00000000000..15ab59e82ca --- /dev/null +++ b/tests/modules/programs/ssh/forwards-dynamic-valid-bind-no-asserts.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + dynamicBindPathNoPort = { + dynamicForwards = [ + { + # OK: + address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + } + ]; + }; + + dynamicBindAddressWithPort = { + dynamicForwards = [ + { + # OK: + address = "127.0.0.1"; + port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContent \ + home-files/.ssh/config \ + ${./forwards-dynamic-valid-bind-no-asserts-expected.conf} + assertFileContent home-files/result ${./no-assertions.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/forwards-local-bind-path-with-port-asserts.nix b/tests/modules/programs/ssh/forwards-local-bind-path-with-port-asserts.nix new file mode 100644 index 00000000000..c05cba82791 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-local-bind-path-with-port-asserts.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + localBindPathWithPort = { + localForwards = [ + { + # OK: + host.address = "127.0.0.1"; + host.port = 3000; + + # Error: + bind.address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + bind.port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent home-files/result ${./forwards-paths-with-ports-error.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/forwards-local-host-path-with-port-asserts.nix b/tests/modules/programs/ssh/forwards-local-host-path-with-port-asserts.nix new file mode 100644 index 00000000000..8cecc5e5121 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-local-host-path-with-port-asserts.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + localHostPathWithPort = { + localForwards = [ + { + # OK: + bind.address = "127.0.0.1"; + bind.port = 3000; + + # Error: + host.address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + host.port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent home-files/result ${./forwards-paths-with-ports-error.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/forwards-paths-with-ports-error.json b/tests/modules/programs/ssh/forwards-paths-with-ports-error.json new file mode 100644 index 00000000000..e7e3a374ecc --- /dev/null +++ b/tests/modules/programs/ssh/forwards-paths-with-ports-error.json @@ -0,0 +1 @@ +["Forwarded paths cannot have ports."] \ No newline at end of file diff --git a/tests/modules/programs/ssh/forwards-remote-bind-path-with-port-asserts.nix b/tests/modules/programs/ssh/forwards-remote-bind-path-with-port-asserts.nix new file mode 100644 index 00000000000..a0473147bd3 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-remote-bind-path-with-port-asserts.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + remoteBindPathWithPort = { + remoteForwards = [ + { + # OK: + host.address = "127.0.0.1"; + host.port = 3000; + + # Error: + bind.address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + bind.port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent home-files/result ${./forwards-paths-with-ports-error.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/forwards-remote-host-path-with-port-asserts.nix b/tests/modules/programs/ssh/forwards-remote-host-path-with-port-asserts.nix new file mode 100644 index 00000000000..770b8ab2870 --- /dev/null +++ b/tests/modules/programs/ssh/forwards-remote-host-path-with-port-asserts.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + remoteHostPathWithPort = { + remoteForwards = [ + { + # OK: + bind.address = "127.0.0.1"; + bind.port = 3000; + + # Error: + host.address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + host.port = 3000; + } + ]; + }; + }; + }; + + home.file.result.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + + nmt.script = '' + assertFileContent home-files/result ${./forwards-paths-with-ports-error.json} + ''; + }; +} diff --git a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf index 1bff480fdce..f0d768375f0 100644 --- a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf +++ b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf @@ -12,6 +12,9 @@ Host xyz ServerAliveInterval 60 IdentityFile file LocalForward [localhost]:8080 [10.0.0.1]:80 + RemoteForward [localhost]:8081 [10.0.0.2]:80 + RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent + DynamicForward [localhost]:2839 Host * ForwardAgent no diff --git a/tests/modules/programs/ssh/match-blocks-attrs.nix b/tests/modules/programs/ssh/match-blocks-attrs.nix index 3e09cd2d5f2..94263ef9d27 100644 --- a/tests/modules/programs/ssh/match-blocks-attrs.nix +++ b/tests/modules/programs/ssh/match-blocks-attrs.nix @@ -22,6 +22,22 @@ with lib; host.port = 80; } ]; + remoteForwards = [ + { + bind.port = 8081; + host.address = "10.0.0.2"; + host.port = 80; + } + { + bind.address = "/run/user/1000/gnupg/S.gpg-agent.extra"; + host.address = "/run/user/1000/gnupg/S.gpg-agent"; + } + ]; + dynamicForwards = [ + { + port = 2839; + } + ]; }; "* !github.com" = { @@ -31,11 +47,18 @@ with lib; }; }; + home.file.assertions.text = + builtins.toJSON + (map (a: a.message) + (filter (a: !a.assertion) + config.assertions)); + nmt.script = '' assertFileExists home-files/.ssh/config assertFileContent \ home-files/.ssh/config \ ${./match-blocks-attrs-expected.conf} + assertFileContent home-files/assertions ${./no-assertions.json} ''; }; } diff --git a/tests/modules/programs/ssh/no-assertions.json b/tests/modules/programs/ssh/no-assertions.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/tests/modules/programs/ssh/no-assertions.json @@ -0,0 +1 @@ +[] \ No newline at end of file -- cgit v1.2.3 From 8bddc1adab0f7a51476f819fa2197353e8e1d136 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 2 Oct 2019 22:00:58 +0200 Subject: redshift: add assertion on latitude and longitude These two options must be set if the provider is set to "manual". Closes #841 --- modules/services/redshift.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/services/redshift.nix b/modules/services/redshift.nix index fd782996b43..1452fcc95ed 100644 --- a/modules/services/redshift.nix +++ b/modules/services/redshift.nix @@ -123,6 +123,18 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = + cfg.provider == "manual" + -> cfg.latitude != null && cfg.longitude != null; + message = + "Must provide services.redshift.latitude and" + + " services.redshift.latitude when" + + " services.redshift.provider is set to \"manual\"."; + } + ]; + systemd.user.services.redshift = { Unit = { Description = "Redshift colour temperature adjuster"; -- cgit v1.2.3