Compare commits

...

22 commits

Author SHA1 Message Date
Symphorien Gibol e6f96b6aa3
unison: fix escaping of arguments
The `ExecStart=` option of systemd must take arguments fully quoted.
That is,

    "-sshargs=-i somekey"

and not

    -ssargs="-i somekey"

Additionally, inside arguments passed to unison, `=` characters must
be quoted. After unquotation by systemd, one must have

    -sshargs=-o Foo\=4

instead of

    -sshargs=-o Foo=4

(cherry picked from commit 92c682cd10)

Fixes #1500
2020-09-18 00:51:16 +02:00
jD91mZM2 4a8d628054
xdg-user-dirs: fix erroneous dirs file
Before this change,

```rust
fn main() {
    println!("{:?}", glib::get_user_special_dir(glib::UserDirectory::Documents));
}
```

would return `None` even though `~/Documents` is available and
`xdg.userDirs.enable = true`. Checking the differences between
`xdg-user-dirs-update` shows that the latter has quotes around each
thing.

PR #1440

(cherry picked from commit fceef469c2)
2020-08-23 23:13:45 +02:00
Damien Cassou 318bc0754e
direnv: add support for nix-direnv
PR #1297

(cherry picked from commit b33802ca7f)
2020-07-05 21:08:04 +02:00
Damien Cassou 3a8e036f4a
direnv: add initial test for bash integration
(cherry picked from commit 575cd4b8ba)
2020-07-05 21:08:03 +02:00
Justin Lovinger d8fdbbdf03
dircolors: fix usage together with zsh.oh-my-zsh
PR #1280

(cherry picked from commit 3a80ece9fa)
2020-06-17 00:00:52 +02:00
Justin Lovinger 12620f7fd4
dircolors: add module
PR #1219

(cherry picked from commit e9945ee6ee)
2020-06-17 00:00:28 +02:00
Damien Cassou 1710db409d
firefox: show how to get pre-packaged add-ons
PR #1296

(cherry picked from commit ca6fcc92a1)
2020-06-16 23:48:25 +02:00
Robert Helgesson ab911f44e6
xdg-mime: fix issue on WSL1
This change stops update-mime-database from running unless the
`share/mime/packages` directory is writable. For some reason it
appears to be read-only on WSL1.

Fixes #1192

(cherry picked from commit 8e8210b441)
2020-06-16 23:47:56 +02:00
Finn Behrens 3797004203
nixos: add mount check for home directory
PR #1271

(cherry picked from commit 5ba71ef91f)
2020-06-16 23:47:01 +02:00
Robert Helgesson 96fcf3b017
sway: fix config.keybindings example
(cherry picked from commit f90b86b577)
2020-05-24 13:05:32 +02:00
Robert Helgesson db21f23943
i3: fix config.keybindings example
(cherry picked from commit 1c71bd1242)
2020-05-24 13:05:31 +02:00
Robert Helgesson b49ababba0
lorri: make system environment attribute a list
It should be a list to allow inclusions of additional variables.

(cherry picked from commit a0d9a58616)
2020-05-24 13:05:30 +02:00
Matthew Bauer 7c0774ba0e
readme: remove firefox "enableIcedTea" option
This option was actually removed in commit
3461ceebc0.

(cherry picked from commit d99f54b51b)
2020-05-24 13:05:29 +02:00
Andrew McDermott cc69c3115f
gnome-terminal: allow for 'system' theme variant
PR #1228

(cherry picked from commit 40b1c5c448)
2020-05-20 23:45:52 +02:00
Robert Helgesson 9fea5ac54f
xdg.mimeApps: use xdg.dataFile instead of home.file
The former honors the data home path set by the user.

(cherry picked from commit b886cbea0b)
2020-05-20 23:44:55 +02:00
Robert Helgesson 22d03f20fb
git: escape string values in configuration
This should handle the special characters that typically occur.

Fixes #1206

(cherry picked from commit 642d9ffe24)
2020-05-20 23:44:29 +02:00
Robert Helgesson c91b2f4556
home-manager: add activation sanity check of Nix
This adds an empty `nix-build` command to verify that the user is
having a good Nix install. It also, as a side effect, will create the
necessary per-user `profiles` and `gcroots` directories.

Fixes #1246

(cherry picked from commit dcbe0f2a31)
2020-05-20 23:43:33 +02:00
Robert Helgesson 25ddbf4824
home-manager: use nix-env to list generations
Using the `nix-env` command is far more robust. It also has the
benefit that if the per-user `profiles` and `gcroots` directories do
not exist then they will be created with the correct permissions.

Because of the second point this commit also removes the `mkdir` step
of the installation instructions.

PR #1239
Closes #474, #948, #1091

(cherry picked from commit 9ec9f004e1)
2020-05-20 23:43:24 +02:00
Robert Helgesson a378bccd60
Revert "vscode: fix extension path symlink error"
This reverts commit fe145b12cd.

Turns out the change does not apply to Nixpkgs 20.03 [1].

[1] https://github.com/rycee/home-manager/pull/1100#issuecomment-621506706
2020-04-30 09:44:00 +02:00
Bruno Bigras 98fa8f63b8
spotifyd: user -> username
PR #1168

(cherry picked from commit 2d88cbe496)
2020-04-23 23:54:18 +02:00
Cole Helbling 9b5133529e
systemd: don't page failed user units
Otherwise, the pager (typically `less`) pauses execution of
`home-manager switch` until the pager is dismissed, if the content is
larger than would fit on the screen.

PR #1175

(cherry picked from commit 8369624512)
2020-04-23 23:43:00 +02:00
Paul 2dd4c20f49
keynav: use correct ExecStart command
When the change requested in

  https://github.com/rycee/home-manager/pull/1082#discussion_r392715440

was applied, the service `ExecStart` attribute was not updated to use
`pkgs.keynav`.

Fixes #1177
PR #1184

(cherry picked from commit ee1c40e5c5)
2020-04-23 23:42:59 +02:00
38 changed files with 617 additions and 117 deletions

2
.github/CODEOWNERS vendored
View file

@ -32,6 +32,8 @@
/modules/programs/broot.nix @aheaume /modules/programs/broot.nix @aheaume
/modules/programs/dircolors.nix @JustinLovinger
/modules/programs/direnv.nix @rycee /modules/programs/direnv.nix @rycee
/modules/programs/eclipse.nix @rycee /modules/programs/eclipse.nix @rycee

View file

@ -4,9 +4,6 @@ os:
- linux - linux
- osx - osx
before_script:
- mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER
script: script:
- ./format -c - ./format -c
- nix-shell . -A install - nix-shell . -A install

View file

@ -46,21 +46,12 @@ Installation
Currently the easiest way to install Home Manager is as follows: Currently the easiest way to install Home Manager is as follows:
1. Make sure you have a working Nix installation. If you are not 1. Make sure you have a working Nix installation. Specifically, make
using NixOS then you may here have to run sure that your user is able to build and install Nix packages. For
example, you should be able to successfully run a command like
```console `nix-instantiate '<nixpkgs>' -A hello` without having to switch to
$ mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER the root user. For a multi-user install of Nix this means that
``` your user must be covered by the
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`][nixAllowedUsers] Nix option. On NixOS you can [`allowed-users`][nixAllowedUsers] Nix option. On NixOS you can
control this option using the control this option using the
[`nix.allowedUsers`][nixosAllowedUsers] system option. [`nix.allowedUsers`][nixosAllowedUsers] system option.
@ -158,7 +149,13 @@ To satisfy the above setup we should elaborate the
programs.firefox = { programs.firefox = {
enable = true; enable = true;
enableIcedTea = true; profiles = {
myprofile = {
settings = {
"general.smoothScroll" = false;
};
};
};
}; };
services.gpg-agent = { services.gpg-agent = {

View file

@ -44,22 +44,12 @@
<orderedlist> <orderedlist>
<listitem> <listitem>
<para> <para>
Make sure you have a working Nix installation. If you are not using NixOS Make sure you have a working Nix installation. Specifically, make
then it may be necessary to run sure that your user is able to build and install Nix packages.
</para> For example, you should be able to successfully run a command
<screen> like <literal>nix-instantiate '&lt;nixpkgs&gt;' -A hello</literal>
<prompt>$</prompt> <userinput>mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER</userinput> without having to switch to the root user. For a multi-user
</screen> install of Nix this means that your user must be covered by the
<para>
since Home Manager uses these directories to manage your profile
generations. On NixOS these should already be available.
</para>
<para>
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
<literal>nix-instantiate '&lt;nixpkgs&gt;' -A hello</literal> 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
<link xlink:href="https://nixos.org/nix/manual/#conf-allowed-users"><literal>allowed-users</literal></link> <link xlink:href="https://nixos.org/nix/manual/#conf-allowed-users"><literal>allowed-users</literal></link>
Nix option. On NixOS you can control this option using the Nix option. On NixOS you can control this option using the
<link xlink:href="https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers"><literal>nix.allowedUsers</literal></link> <link xlink:href="https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers"><literal>nix.allowedUsers</literal></link>

View file

@ -3,13 +3,16 @@
function setupVars() { function setupVars() {
local profilesPath="/nix/var/nix/profiles/per-user/$USER" local profilesPath="/nix/var/nix/profiles/per-user/$USER"
local gcPath="/nix/var/nix/gcroots/per-user/$USER" local gcPath="/nix/var/nix/gcroots/per-user/$USER"
local greatestGenNum
genProfilePath="$profilesPath/home-manager"
newGenPath="@GENERATION_DIR@";
newGenGcPath="$gcPath/current-home"
local greatestGenNum
greatestGenNum=$( \ greatestGenNum=$( \
find "$profilesPath" -name 'home-manager-*-link' \ nix-env --list-generations --profile "$genProfilePath" \
| sed 's/^.*-\([0-9]*\)-link$/\1/' \ | tail -1 \
| sort -rn \ | sed -E 's/ *([[:digit:]]+) .*/\1/')
| head -1)
if [[ -n $greatestGenNum ]] ; then if [[ -n $greatestGenNum ]] ; then
oldGenNum=$greatestGenNum oldGenNum=$greatestGenNum
@ -18,15 +21,15 @@ function setupVars() {
newGenNum=1 newGenNum=1
fi fi
if [[ -e $gcPath/current-home ]] ; then if [[ -e $profilesPath/home-manager ]] ; then
oldGenPath="$(readlink -e "$gcPath/current-home")" oldGenPath="$(readlink -e "$profilesPath/home-manager")"
fi fi
$VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath" $VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath"
if [[ -v oldGenNum && ! -v oldGenPath if [[ -v oldGenNum && ! -v oldGenPath
|| ! -v oldGenNum && -v oldGenPath ]]; then || ! -v oldGenNum && -v oldGenPath ]]; then
errorEcho "Invalid profile number and GC root values! These must be" errorEcho "Invalid profile number and current profile values! These"
errorEcho "either both empty or both set but are now set to" errorEcho "must be either both empty or both set but are now set to"
errorEcho " '${oldGenNum:-}' and '${oldGenPath:-}'" errorEcho " '${oldGenNum:-}' and '${oldGenPath:-}'"
errorEcho "If you don't mind losing previous profile generations then" errorEcho "If you don't mind losing previous profile generations then"
errorEcho "the easiest solution is probably to run" errorEcho "the easiest solution is probably to run"
@ -35,12 +38,6 @@ function setupVars() {
errorEcho "and trying home-manager switch again. Good luck!" errorEcho "and trying home-manager switch again. Good luck!"
exit 1 exit 1
fi fi
genProfilePath="$profilesPath/home-manager"
newGenPath="@GENERATION_DIR@";
newGenProfilePath="$profilesPath/home-manager-$newGenNum-link"
newGenGcPath="$gcPath/current-home"
} }
if [[ -v VERBOSE ]]; then if [[ -v VERBOSE ]]; then
@ -53,6 +50,11 @@ fi
echo "Starting home manager activation" echo "Starting home manager activation"
# Verify that we can connect to the Nix store and/or daemon. This will
# also create the necessary directories in profiles and gcroots.
$VERBOSE_ECHO "Sanity checking Nix"
nix-build --expr '{}' --no-out-link
setupVars setupVars
if [[ -v DRY_RUN ]] ; then if [[ -v DRY_RUN ]] ; then
@ -78,6 +80,5 @@ else
fi fi
$VERBOSE_ECHO " newGenPath=$newGenPath" $VERBOSE_ECHO " newGenPath=$newGenPath"
$VERBOSE_ECHO " newGenNum=$newGenNum" $VERBOSE_ECHO " newGenNum=$newGenNum"
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath" $VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
$VERBOSE_ECHO " genProfilePath=$genProfilePath" $VERBOSE_ECHO " genProfilePath=$genProfilePath"

View file

@ -1474,6 +1474,13 @@ in
A new module is available: 'services.mako' A new module is available: 'services.mako'
''; '';
} }
{
time = "2020-05-12T20:09:54+00:00";
message = ''
A new module is available: 'programs.dircolors'
'';
}
]; ];
}; };
} }

View file

@ -74,7 +74,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
# Deprecated but still used by some applications. # Deprecated but still used by some applications.
home.file.".local/share/applications/mimeapps.list".source = xdg.dataFile."applications/mimeapps.list".source =
config.xdg.configFile."mimeapps.list".source; config.xdg.configFile."mimeapps.list".source;
xdg.configFile."mimeapps.list".text = xdg.configFile."mimeapps.list".text =

View file

@ -30,7 +30,7 @@ in {
]; ];
home.extraProfileCommands = '' home.extraProfileCommands = ''
if [[ -w $out/share/mime && -d $out/share/mime/packages ]]; then if [[ -w $out/share/mime && -w $out/share/mime/packages && -d $out/share/mime/packages ]]; then
XDG_DATA_DIRS=$out/share \ XDG_DATA_DIRS=$out/share \
PKGSYSTEM_ENABLE_FSYNC=0 \ PKGSYSTEM_ENABLE_FSYNC=0 \
${pkgs.buildPackages.shared-mime-info}/bin/update-mime-database \ ${pkgs.buildPackages.shared-mime-info}/bin/update-mime-database \

View file

@ -89,16 +89,21 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
xdg.configFile."user-dirs.dirs".text = generators.toKeyValue { } ({ xdg.configFile."user-dirs.dirs".text = let
XDG_DESKTOP_DIR = cfg.desktop; options = {
XDG_DOCUMENTS_DIR = cfg.documents; XDG_DESKTOP_DIR = cfg.desktop;
XDG_DOWNLOAD_DIR = cfg.download; XDG_DOCUMENTS_DIR = cfg.documents;
XDG_MUSIC_DIR = cfg.music; XDG_DOWNLOAD_DIR = cfg.download;
XDG_PICTURES_DIR = cfg.pictures; XDG_MUSIC_DIR = cfg.music;
XDG_PUBLICSHARE_DIR = cfg.publicShare; XDG_PICTURES_DIR = cfg.pictures;
XDG_TEMPLATES_DIR = cfg.templates; XDG_PUBLICSHARE_DIR = cfg.publicShare;
XDG_VIDEOS_DIR = cfg.videos; XDG_TEMPLATES_DIR = cfg.templates;
} // cfg.extraConfig); XDG_VIDEOS_DIR = cfg.videos;
} // cfg.extraConfig;
# For some reason, these need to be wrapped with quotes to be valid.
wrapped = mapAttrs (_: value: ''"${value}"'') options;
in generators.toKeyValue { } wrapped;
xdg.configFile."user-dirs.conf".text = "enabled=False"; xdg.configFile."user-dirs.conf".text = "enabled=False";
}; };

View file

@ -54,6 +54,7 @@ let
(loadModule ./programs/browserpass.nix { }) (loadModule ./programs/browserpass.nix { })
(loadModule ./programs/chromium.nix { condition = hostPlatform.isLinux; }) (loadModule ./programs/chromium.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/command-not-found/command-not-found.nix { }) (loadModule ./programs/command-not-found/command-not-found.nix { })
(loadModule ./programs/dircolors.nix { })
(loadModule ./programs/direnv.nix { }) (loadModule ./programs/direnv.nix { })
(loadModule ./programs/eclipse.nix { }) (loadModule ./programs/eclipse.nix { })
(loadModule ./programs/emacs.nix { }) (loadModule ./programs/emacs.nix { })

View file

@ -0,0 +1,223 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.dircolors;
formatLine = n: v: "${n} ${toString v}";
in {
meta.maintainers = [ hm.maintainers.justinlovinger ];
options.programs.dircolors = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to manage <filename>.dir_colors</filename>
and set <code>LS_COLORS</code>.
'';
};
enableBashIntegration = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Bash integration.
'';
};
enableFishIntegration = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Fish integration.
'';
};
enableZshIntegration = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Zsh integration.
'';
};
settings = mkOption {
type = with types; attrsOf str;
default = { };
description = ''
Options to add to <filename>.dir_colors</filename> file.
See <command>dircolors --print-database</command>
for options.
'';
example = literalExample ''
{
OTHER_WRITABLE = "30;46";
".sh" = "01;32";
".csh" = "01;32";
}
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra lines added to <filename>.dir_colors</filename> file.
'';
};
};
config = mkIf cfg.enable {
# Add default settings from `dircolors --print-database`.
programs.dircolors.settings = {
RESET = mkDefault "0";
DIR = mkDefault "01;34";
LINK = mkDefault "01;36";
MULTIHARDLINK = mkDefault "00";
FIFO = mkDefault "40;33";
SOCK = mkDefault "01;35";
DOOR = mkDefault "01;35";
BLK = mkDefault "40;33;01";
CHR = mkDefault "40;33;01";
ORPHAN = mkDefault "40;31;01";
MISSING = mkDefault "00";
SETUID = mkDefault "37;41";
SETGID = mkDefault "30;43";
CAPABILITY = mkDefault "30;41";
STICKY_OTHER_WRITABLE = mkDefault "30;42";
OTHER_WRITABLE = mkDefault "34;42";
STICKY = mkDefault "37;44";
EXEC = mkDefault "01;32";
".tar" = mkDefault "01;31";
".tgz" = mkDefault "01;31";
".arc" = mkDefault "01;31";
".arj" = mkDefault "01;31";
".taz" = mkDefault "01;31";
".lha" = mkDefault "01;31";
".lz4" = mkDefault "01;31";
".lzh" = mkDefault "01;31";
".lzma" = mkDefault "01;31";
".tlz" = mkDefault "01;31";
".txz" = mkDefault "01;31";
".tzo" = mkDefault "01;31";
".t7z" = mkDefault "01;31";
".zip" = mkDefault "01;31";
".z" = mkDefault "01;31";
".dz" = mkDefault "01;31";
".gz" = mkDefault "01;31";
".lrz" = mkDefault "01;31";
".lz" = mkDefault "01;31";
".lzo" = mkDefault "01;31";
".xz" = mkDefault "01;31";
".zst" = mkDefault "01;31";
".tzst" = mkDefault "01;31";
".bz2" = mkDefault "01;31";
".bz" = mkDefault "01;31";
".tbz" = mkDefault "01;31";
".tbz2" = mkDefault "01;31";
".tz" = mkDefault "01;31";
".deb" = mkDefault "01;31";
".rpm" = mkDefault "01;31";
".jar" = mkDefault "01;31";
".war" = mkDefault "01;31";
".ear" = mkDefault "01;31";
".sar" = mkDefault "01;31";
".rar" = mkDefault "01;31";
".alz" = mkDefault "01;31";
".ace" = mkDefault "01;31";
".zoo" = mkDefault "01;31";
".cpio" = mkDefault "01;31";
".7z" = mkDefault "01;31";
".rz" = mkDefault "01;31";
".cab" = mkDefault "01;31";
".wim" = mkDefault "01;31";
".swm" = mkDefault "01;31";
".dwm" = mkDefault "01;31";
".esd" = mkDefault "01;31";
".jpg" = mkDefault "01;35";
".jpeg" = mkDefault "01;35";
".mjpg" = mkDefault "01;35";
".mjpeg" = mkDefault "01;35";
".gif" = mkDefault "01;35";
".bmp" = mkDefault "01;35";
".pbm" = mkDefault "01;35";
".pgm" = mkDefault "01;35";
".ppm" = mkDefault "01;35";
".tga" = mkDefault "01;35";
".xbm" = mkDefault "01;35";
".xpm" = mkDefault "01;35";
".tif" = mkDefault "01;35";
".tiff" = mkDefault "01;35";
".png" = mkDefault "01;35";
".svg" = mkDefault "01;35";
".svgz" = mkDefault "01;35";
".mng" = mkDefault "01;35";
".pcx" = mkDefault "01;35";
".mov" = mkDefault "01;35";
".mpg" = mkDefault "01;35";
".mpeg" = mkDefault "01;35";
".m2v" = mkDefault "01;35";
".mkv" = mkDefault "01;35";
".webm" = mkDefault "01;35";
".ogm" = mkDefault "01;35";
".mp4" = mkDefault "01;35";
".m4v" = mkDefault "01;35";
".mp4v" = mkDefault "01;35";
".vob" = mkDefault "01;35";
".qt" = mkDefault "01;35";
".nuv" = mkDefault "01;35";
".wmv" = mkDefault "01;35";
".asf" = mkDefault "01;35";
".rm" = mkDefault "01;35";
".rmvb" = mkDefault "01;35";
".flc" = mkDefault "01;35";
".avi" = mkDefault "01;35";
".fli" = mkDefault "01;35";
".flv" = mkDefault "01;35";
".gl" = mkDefault "01;35";
".dl" = mkDefault "01;35";
".xcf" = mkDefault "01;35";
".xwd" = mkDefault "01;35";
".yuv" = mkDefault "01;35";
".cgm" = mkDefault "01;35";
".emf" = mkDefault "01;35";
".ogv" = mkDefault "01;35";
".ogx" = mkDefault "01;35";
".aac" = mkDefault "00;36";
".au" = mkDefault "00;36";
".flac" = mkDefault "00;36";
".m4a" = mkDefault "00;36";
".mid" = mkDefault "00;36";
".midi" = mkDefault "00;36";
".mka" = mkDefault "00;36";
".mp3" = mkDefault "00;36";
".mpc" = mkDefault "00;36";
".ogg" = mkDefault "00;36";
".ra" = mkDefault "00;36";
".wav" = mkDefault "00;36";
".oga" = mkDefault "00;36";
".opus" = mkDefault "00;36";
".spx" = mkDefault "00;36";
".xspf" = mkDefault "00;36";
};
home.file.".dir_colors".text = concatStringsSep "\n" ([ ]
++ optional (cfg.extraConfig != "") cfg.extraConfig
++ mapAttrsToList formatLine cfg.settings) + "\n";
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ~/.dir_colors)
'';
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
eval (${pkgs.coreutils}/bin/dircolors -c ~/.dir_colors)
'';
# Set `LS_COLORS` before Oh My Zsh and `initExtra`.
programs.zsh.initExtraBeforeCompInit = mkIf cfg.enableZshIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ~/.dir_colors)
'';
};
}

View file

@ -70,6 +70,11 @@ in {
Whether to enable Fish integration. Whether to enable Fish integration.
''; '';
}; };
enableNixDirenvIntegration = mkEnableOption ''
<link
xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>,
a fast, persistent use_nix implementation for direnv'';
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -78,8 +83,11 @@ in {
xdg.configFile."direnv/config.toml" = xdg.configFile."direnv/config.toml" =
mkIf (cfg.config != { }) { source = configFile cfg.config; }; mkIf (cfg.config != { }) { source = configFile cfg.config; };
xdg.configFile."direnv/direnvrc" = xdg.configFile."direnv/direnvrc" = let
mkIf (cfg.stdlib != "") { text = cfg.stdlib; }; text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib
++ optional cfg.enableNixDirenvIntegration
"source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc");
in mkIf (text != "") { inherit text; };
programs.bash.initExtra = mkIf cfg.enableBashIntegration ( programs.bash.initExtra = mkIf cfg.enableBashIntegration (
# Using mkAfter to make it more likely to appear after other # Using mkAfter to make it more likely to appear after other

View file

@ -101,9 +101,19 @@ in
] ]
''; '';
description = '' description = ''
List of Firefox add-on packages to install. Note, it is List of Firefox add-on packages to install. Some
necessary to manually enable these extensions inside Firefox pre-packaged add-ons are accessible from NUR,
after the first installation. <link xlink:href="https://github.com/nix-community/NUR"/>.
Once you have NUR installed run
<screen language="console">
<prompt>$</prompt> <userinput>nix-env -f '&lt;nixpkgs&gt;' -qaP -A nur.repos.rycee.firefox-addons</userinput>
</screen>
to list the available Firefox add-ons.
</para><para>
Note that it is necessary to manually enable these
extensions inside Firefox after the first installation.
''; '';
}; };

View file

@ -19,9 +19,19 @@ let
else else
''${section} "${subsection}"''; ''${section} "${subsection}"'';
mkValueString = v:
let
escapedV = ''
"${
replaceStrings [ "\n" " " ''"'' "\\" ] [ "\\n" "\\t" ''\"'' "\\\\" ] v
}"'';
in generators.mkValueStringDefault { } (if isString v then escapedV else v);
# generation for multiple ini values # generation for multiple ini values
mkKeyValue = k: v: mkKeyValue = k: v:
let mkKeyValue = generators.mkKeyValueDefault { } " = " k; let
mkKeyValue =
generators.mkKeyValueDefault { inherit mkValueString; } " = " k;
in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v)); in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v));
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI

View file

@ -186,7 +186,7 @@ in {
themeVariant = mkOption { themeVariant = mkOption {
default = "default"; default = "default";
type = types.enum [ "default" "light" "dark" ]; type = types.enum [ "default" "light" "dark" "system" ];
description = "The theme variation to request"; description = "The theme variation to request";
}; };

View file

@ -78,11 +78,14 @@ in
home.file = home.file =
let let
toPaths = path: toPaths = path:
# Links every dir in path to the extension path. let
mapAttrsToList (k: v: p = "${path}/share/vscode/extensions";
{ in
"${extensionPath}/${k}".source = "${path}/${k}"; # Links every dir in p to the extension path.
}) (builtins.readDir path); mapAttrsToList (k: v:
{
"${extensionPath}/${k}".source = "${p}/${k}";
}) (builtins.readDir p);
toSymlink = concatMap toPaths cfg.extensions; toSymlink = concatMap toPaths cfg.extensions;
in in
foldr foldr

View file

@ -18,7 +18,7 @@ in {
}; };
Service = { Service = {
ExecStart = "${cfg.package}/bin/keynav"; ExecStart = "${pkgs.keynav}/bin/keynav";
RestartSec = 3; RestartSec = 3;
Restart = "always"; Restart = "always";
}; };

View file

@ -32,7 +32,7 @@ in {
Environment = let Environment = let
path = with pkgs; path = with pkgs;
makeSearchPath "bin" [ nix gitMinimal gnutar gzip ]; makeSearchPath "bin" [ nix gitMinimal gnutar gzip ];
in "PATH=${path}"; in [ "PATH=${path}" ];
}; };
}; };

View file

@ -21,7 +21,7 @@ in {
example = literalExample '' example = literalExample ''
{ {
global = { global = {
user = "Alex"; username = "Alex";
password = "foo"; password = "foo";
device_name = "nix"; device_name = "nix";
}; };

View file

@ -60,7 +60,7 @@ let
}; };
}; };
serialiseArg = key: val: "-${key}=${escapeShellArg val}"; serialiseArg = key: val: escapeShellArg "-${key}=${escape [ "=" ] val}";
serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args); serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args);

View file

@ -101,10 +101,8 @@ let
''; '';
example = literalExample '' example = literalExample ''
let let
modifier = xsession.windowManager.i3.config.modifier; modifier = config.xsession.windowManager.i3.config.modifier;
in in lib.mkOptionDefault {
lib.mkOptionDefault {
"''${modifier}+Return" = "exec i3-sensible-terminal"; "''${modifier}+Return" = "exec i3-sensible-terminal";
"''${modifier}+Shift+q" = "kill"; "''${modifier}+Shift+q" = "kill";
"''${modifier}+d" = "exec \${pkgs.dmenu}/bin/dmenu_run"; "''${modifier}+d" = "exec \${pkgs.dmenu}/bin/dmenu_run";

View file

@ -130,10 +130,8 @@ let
''; '';
example = literalExample '' example = literalExample ''
let let
modifier = cfg.config.modifier; modifier = config.wayland.windowManager.sway.config.modifier;
in in lib.mkOptionDefault {
lib.mkOptionDefault {
"''${modifier}+Return" = "exec ${cfg.config.terminal}"; "''${modifier}+Return" = "exec ${cfg.config.terminal}";
"''${modifier}+Shift+q" = "kill"; "''${modifier}+Shift+q" = "kill";
"''${modifier}+d" = "exec ${cfg.config.menu}"; "''${modifier}+d" = "exec ${cfg.config.menu}";

View file

@ -249,7 +249,7 @@ in
if [[ $systemdStatus == 'running' || $systemdStatus == 'degraded' ]]; then if [[ $systemdStatus == 'running' || $systemdStatus == 'degraded' ]]; then
if [[ $systemdStatus == 'degraded' ]]; then if [[ $systemdStatus == 'degraded' ]]; then
warnEcho "The user systemd session is degraded:" warnEcho "The user systemd session is degraded:"
${systemctl} --user --state=failed ${systemctl} --user --no-pager --state=failed
warnEcho "Attempting to reload services anyway..." warnEcho "Attempting to reload services anyway..."
fi fi

View file

@ -98,6 +98,8 @@ in {
environment = serviceEnvironment; environment = serviceEnvironment;
unitConfig = { RequiresMountsFor = usercfg.home.homeDirectory; };
serviceConfig = { serviceConfig = {
User = usercfg.home.username; User = usercfg.home.username;
Type = "oneshot"; Type = "oneshot";

View file

@ -29,6 +29,8 @@ import nmt {
./modules/programs/alacritty ./modules/programs/alacritty
./modules/programs/bash ./modules/programs/bash
./modules/programs/browserpass ./modules/programs/browserpass
./modules/programs/dircolors
./modules/programs/direnv
./modules/programs/fish ./modules/programs/fish
./modules/programs/git ./modules/programs/git
./modules/programs/gpg ./modules/programs/gpg

View file

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

View file

@ -0,0 +1,133 @@
# Extra dircolors configuration.
.7z 01;31
.aac 00;36
.ace 01;31
.alz 01;31
.arc 01;31
.arj 01;31
.asf 01;35
.au 00;36
.avi 01;35
.bmp 01;35
.bz 01;31
.bz2 01;31
.cab 01;31
.cgm 01;35
.cpio 01;31
.csh 01;32
.deb 01;31
.dl 01;35
.dwm 01;31
.dz 01;31
.ear 01;31
.emf 01;35
.esd 01;31
.flac 00;36
.flc 01;35
.fli 01;35
.flv 01;35
.gif 01;35
.gl 01;35
.gz 01;31
.jar 01;31
.jpeg 01;35
.jpg 01;35
.lha 01;31
.lrz 01;31
.lz 01;31
.lz4 01;31
.lzh 01;31
.lzma 01;31
.lzo 01;31
.m2v 01;35
.m4a 00;36
.m4v 01;35
.mid 00;36
.midi 00;36
.mjpeg 01;35
.mjpg 01;35
.mka 00;36
.mkv 01;35
.mng 01;35
.mov 01;35
.mp3 00;36
.mp4 01;35
.mp4v 01;35
.mpc 00;36
.mpeg 01;35
.mpg 01;35
.nuv 01;35
.oga 00;36
.ogg 00;36
.ogm 01;35
.ogv 01;35
.ogx 01;35
.opus 00;36
.pbm 01;35
.pcx 01;35
.pgm 01;35
.png 01;35
.ppm 01;35
.qt 01;35
.ra 00;36
.rar 01;31
.rm 01;35
.rmvb 01;35
.rpm 01;31
.rz 01;31
.sar 01;31
.sh 01;32
.spx 00;36
.svg 01;35
.svgz 01;35
.swm 01;31
.t7z 01;31
.tar 01;31
.taz 01;31
.tbz 01;31
.tbz2 01;31
.tga 01;35
.tgz 01;31
.tif 01;35
.tiff 01;35
.tlz 01;31
.txz 01;31
.tz 01;31
.tzo 01;31
.tzst 01;31
.vob 01;35
.war 01;31
.wav 00;36
.webm 01;35
.wim 01;31
.wmv 01;35
.xbm 01;35
.xcf 01;35
.xpm 01;35
.xspf 00;36
.xwd 01;35
.xz 01;31
.yuv 01;35
.z 01;31
.zip 01;31
.zoo 01;31
.zst 01;31
BLK 40;33;01
CAPABILITY 30;41
CHR 40;33;01
DIR 01;34
DOOR 01;35
EXEC 01;32
FIFO 40;33
LINK 01;36
MISSING 00
MULTIHARDLINK 00
ORPHAN 40;31;01
OTHER_WRITABLE 30;46
RESET 0
SETGID 30;43
SETUID 37;41
SOCK 01;35
STICKY 37;44
STICKY_OTHER_WRITABLE 30;42

View file

@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.dircolors = {
enable = true;
settings = {
OTHER_WRITABLE = "30;46";
".sh" = "01;32";
".csh" = "01;32";
};
extraConfig = ''
# Extra dircolors configuration.
'';
};
nmt.script = ''
assertFileContent \
home-files/.dir_colors \
${./settings-expected.conf}
'';
};
}

View file

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.bash.enable = true;
programs.direnv.enable = true;
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileRegex \
home-files/.bashrc \
'eval "\$(/nix/store/.*direnv.*/bin/direnv hook bash)"'
'';
};
}

View file

@ -0,0 +1,6 @@
{
direnv-bash = ./bash.nix;
direnv-nix-direnv = ./nix-direnv.nix;
direnv-stdlib = ./stdlib.nix;
direnv-stdlib-and-nix-direnv = ./stdlib-and-nix-direnv.nix;
}

View file

@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.bash.enable = true;
programs.direnv.enable = true;
programs.direnv.enableNixDirenvIntegration = true;
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileRegex \
home-files/.config/direnv/direnvrc \
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
'';
};
}

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
with lib;
let expectedContent = "something important";
in {
config = {
programs.bash.enable = true;
programs.direnv.enable = true;
programs.direnv.enableNixDirenvIntegration = true;
programs.direnv.stdlib = expectedContent;
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileRegex \
home-files/.config/direnv/direnvrc \
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
assertFileRegex \
home-files/.config/direnv/direnvrc \
'${expectedContent}'
'';
};
}

View file

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
let expectedContent = "something important";
in {
config = {
programs.bash.enable = true;
programs.direnv.enable = true;
programs.direnv.stdlib = expectedContent;
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileRegex \
home-files/.config/direnv/direnvrc \
'${expectedContent}'
'';
};
}

View file

@ -1,3 +1,3 @@
[user] [user]
email = user@example.org email = "user@example.org"
name = John Doe name = "John Doe"

View file

@ -1,6 +1,7 @@
[alias] [alias]
a1 = foo a1 = "foo"
a2 = baz a2 = "baz"
escapes = "\"\\n\t"
[commit] [commit]
gpgSign = true gpgSign = true
@ -10,33 +11,33 @@
integer = 38 integer = 38
multiple = 1 multiple = 1
multiple = 2 multiple = 2
name = value name = "value"
[extra "backcompat.with.dots"] [extra "backcompat.with.dots"]
previously = worked previously = "worked"
[extra "subsection"] [extra "subsection"]
value = test value = "test"
[filter "lfs"] [filter "lfs"]
clean = git-lfs clean -- %f clean = "git-lfs clean -- %f"
process = git-lfs filter-process process = "git-lfs filter-process"
required = true required = true
smudge = git-lfs smudge -- %f smudge = "git-lfs smudge -- %f"
[gpg] [gpg]
program = path-to-gpg program = "path-to-gpg"
[user] [user]
email = user@example.org email = "user@example.org"
name = John Doe name = "John Doe"
signingKey = 00112233445566778899AABBCCDDEEFF signingKey = "00112233445566778899AABBCCDDEEFF"
[include] [include]
path = ~/path/to/config.inc path = "~/path/to/config.inc"
[includeIf "gitdir:~/src/dir"] [includeIf "gitdir:~/src/dir"]
path = ~/path/to/conditional.inc path = "~/path/to/conditional.inc"
[includeIf "gitdir:~/src/dir"] [includeIf "gitdir:~/src/dir"]
path = @git_include_path@ path = "@git_include_path@"

View file

@ -1,15 +1,15 @@
[sendemail "hm-account"] [sendemail "hm-account"]
from = hm@example.org from = "hm@example.org"
smtpEncryption = tls smtpEncryption = "tls"
smtpServer = smtp.example.org smtpServer = "smtp.example.org"
smtpUser = home.manager.jr smtpUser = "home.manager.jr"
[sendemail "hm@example.com"] [sendemail "hm@example.com"]
from = hm@example.com from = "hm@example.com"
smtpEncryption = tls smtpEncryption = "tls"
smtpServer = smtp.example.com smtpServer = "smtp.example.com"
smtpUser = home.manager smtpUser = "home.manager"
[user] [user]
email = hm@example.com email = "hm@example.com"
name = H. M. Test name = "H. M. Test"

View file

@ -1,5 +1,5 @@
This can be anything. This can be anything.
[user] [user]
email = user@example.org email = "user@example.org"
name = John Doe name = "John Doe"

View file

@ -28,6 +28,7 @@ in {
aliases = { aliases = {
a1 = "foo"; a1 = "foo";
a2 = "bar"; a2 = "bar";
escapes = ''"\n '';
}; };
extraConfig = { extraConfig = {
extra = { extra = {