Add lots of new nix config

This commit is contained in:
Oystein Kristoffer Tveit 2021-12-11 15:29:12 +01:00
parent aab1d4ff96
commit 13871c1ff9
29 changed files with 796 additions and 372 deletions

View File

@ -9,6 +9,8 @@ in
_module.args.colorTheme = colorTheme;
imports = [
./misc/mimetypes.nix
./programs/alacritty.nix
./programs/comma.nix
./programs/emacs.nix
@ -17,11 +19,20 @@ in
./programs/ncmpcpp.nix
./programs/neovim.nix
./programs/newsboat.nix
./programs/qutebrowser.nix
./programs/rofi.nix
./programs/tmux.nix
./programs/vscode.nix
./programs/zathura.nix
./programs/zsh.nix
./services/dunst.nix
./services/mpd.nix
./services/picom.nix
./services/stalonetray.nix
./services/sxhkd.nix
./secret/ssh/hosts
];
xsession = {
@ -36,11 +47,8 @@ in
home-manager.enable = true;
bat.enable = true;
# bottom.enable = true;
bottom.enable = true;
exa.enable = true;
feh.enable = true;
fzf = {
@ -52,6 +60,7 @@ in
irssi.enable = true;
lazygit.enable = true;
mpv.enable = true;
ssh.enable = true;
man = {
enable = true;
@ -60,16 +69,6 @@ in
obs-studio.enable = true;
qutebrowser = {
enable = true;
aliases = {};
searchEngines = {};
settings = {};
keyBindings = {};
# quickmarks = {};
extraConfig = '''';
};
skim = {
enable = true;
defaultCommand ="fd --type f";
@ -85,12 +84,6 @@ in
zoxide.enable = true;
};
services.mpd = import ./services/mpd.nix args;
services.picom = import ./services/picom.nix;
services.stalonetray = import ./services/stalonetray.nix (args // { inherit colorTheme; });
services.sxhkd = import ./services/sxhkd.nix args;
home = {
stateVersion = "21.05";
username = "h7x4";
@ -101,11 +94,14 @@ in
asciidoctor
audacity
beets
biber
calibre
castnow
citra
cool-retro-term
copyq
czkawka
darktable
desmume
discord
diskonaut
@ -116,8 +112,10 @@ in
fd
ffmpeg
geogebra
gnome.gnome-font-viewer
google-chrome
# gpgtui
graphviz
# hck
hexyl
imagemagick
@ -132,6 +130,7 @@ in
lastpass-cli
lazydocker
libreoffice-fresh
light
lolcat
maim
mdcat
@ -197,34 +196,12 @@ in
];
};
services.gnome-keyring.enable = true;
services.dropbox.enable = true;
services.dunst = {
enable = true;
iconTheme = {
package = pkgs.gnome.adwaita-icon-theme;
name = "Adwaita";
size = "32x32";
services = {
gnome-keyring.enable = true;
dropbox.enable = true;
network-manager-applet.enable = true;
# redshift.enable = true;
};
settings = {
global = {
geometry = "300x5-30+50";
transparency = 10;
frame_color = "#eceff1";
font = "Droid Sans 9";
};
urgency_normal = {
background = "#37474f";
foreground = "#eceff1";
timeout = 10;
};
};
};
services.network-manager-applet.enable = true;
# services.redshift.enable = true;
}

142
nixpkgs/misc/mimetypes.nix Normal file
View File

@ -0,0 +1,142 @@
{ lib, ... }:
let
# Applications
google-chrome = "google-chrome.desktop";
gimp = "gimp.desktop";
inkscape = "org.inkscape.Inkscape.desktop";
vscode = "code.desktop";
mpv = "mpv.desktop";
zathura = "org.pwmt.zathura.desktop";
sxiv = "sxiv.desktop";
font-viewer = "org.gnome.font-viewer.desktop";
# Formats
"3g2-audio" = "audio/3gpp";
"3g2-video" = "video/3gpp";
"3gp-audio" = "audio/3gpp";
"3gp-video" = "video/3gpp";
aac = "audio/aac";
avi = "video/x-msvideo";
bmp = "image/bmp";
cbr = "application/vnd.comicbook+rar";
cbrx = "application/x-cbr";
cbz = "application/vnd.comicbook+zip";
cbzx = "application/x-cbz";
djvu = "image/vnd.djvu";
epub = "application/epub+zip";
flv = "video/x-flv";
gif = "image/gif";
html = "text/html";
http = "x-scheme-handler/http";
https = "x-scheme-handler/https";
ico = "image/vnd.microsoft.icon";
icox = "image/x-icon";
ini = "application/x-wine-extension-ini";
jpg = "image/jpeg";
m4v = "video/x-m4v";
mkv = "video/x-matroska";
mov = "video/quicktime";
mp3 = "audio/mpeg";
mp4 = "video/mp4";
mpeg = "video/mpeg";
ogg = "audio/ogg";
ogv = "video/ogg";
opus = "audio/opus";
otf = "font/otf";
pdf = "application/pdf";
pic = "image/x-pict";
png = "image/png";
psd = "image/vnd.adobe.photoshop";
svg = "image/svg+xml";
tiff = "image/tiff";
ttf = "font/ttf";
txt = "text/plain";
url = "application/x-mswinurl";
wav = "audio/wav";
wavx = "audio/x-wav";
webm-audio = "audio/webm";
webm-video = "video/webm";
webp = "image/webp";
wmv = "video/x-ms-wmv";
woff = "font/woff";
woff2 = "font/woff2";
xbm = "image/x-xbitmap";
xcf = "image/x-xcf";
xhtml = "application/xhtml+xml";
xml = "text/xml";
xpm = "image/x-xpixmap";
# Generalizations
audio-player = mpv;
gui-text-editor = vscode;
image-viewer = sxiv;
pdf-viewer = zathura;
video-player = mpv;
web-browser = google-chrome;
in {
xdg.mimeApps = {
enable = true;
# associations.added = {};
# associations.removed = {};
defaultApplications = {
${"3g2-audio"} = audio-player;
${"3g2-video"} = video-player;
${"3gp-audio"} = audio-player;
${"3gp-video"} = video-player;
${aac} = audio-player;
${avi} = video-player;
${bmp} = image-viewer;
${cbrx} = zathura;
${cbr} = zathura;
${cbzx} = zathura;
${cbz} = zathura;
${djvu} = pdf-viewer;
${epub} = zathura;
${flv} = video-player;
${gif} = image-viewer;
${html} = web-browser;
${https} = web-browser;
${http} = web-browser;
${icox} = image-viewer;
${ico} = image-viewer;
${jpg} = image-viewer;
${m4v} = video-player;
${mkv} = video-player;
${mov} = video-player;
${mp3} = audio-player;
${mp4} = video-player;
${mpeg} = video-player;
${ogg} = audio-player;
${ogv} = video-player;
${opus} = audio-player;
${otf} = font-viewer;
${pdf} = pdf-viewer;
${pic} = image-viewer;
${png} = image-viewer;
${psd} = gimp;
${svg} = image-viewer;
${tiff} = image-viewer;
${ttf} = font-viewer;
${txt} = gui-text-editor;
${url} = web-browser;
${wav} = audio-player;
${webm-audio} = audio-player;
${webm-video} = video-player;
${webp} = image-viewer;
${wmv} = video-player;
${woff2} = font-viewer;
${woff} = font-viewer;
${xbm} = image-viewer;
${xcf} = gimp;
${xhtml} = web-browser;
${xml} = gui-text-editor;
${xpm} = image-viewer;
};
};
}

View File

@ -1,13 +1,31 @@
{ lib, pkgs, colorTheme, ... }:
{
programs.alacritty = { enable = true; settings = { window.padding = { x = 15; y = 15; }; font = { normal = { family = "Fira Code"; style = "Retina"; }; bold.family = "Fira Code"; italic.family = "Fira Code"; size = 12.0; };
programs.alacritty = {
enable = true;
settings = {
window.padding = { x = 15; y = 15; };
font = {
normal = {
family = "Fira Code";
style = "Retina";
};
bold.family = "Fira Code";
italic.family = "Fira Code";
size = 12.0;
};
colors =
let
pColors = [ "foreground" "background" ];
inherit (lib.attrsets) getAttrs filterAttrs;
inherit (lib.lists) any;
primaryColors = [ "foreground" "background" ];
in
{
primary = lib.attrsets.getAttrs pColors colorTheme.default;
normal = lib.attrsets.filterAttrs (n: v: pColors ? n) colorTheme.default;
primary = getAttrs primaryColors colorTheme.default;
normal = let
removePrimaryColorAttrs = n: v: !(any (pc: n ? pc) primaryColors);
in filterAttrs removePrimaryColorAttrs colorTheme.default;
};
background_opacity = 1.0;
@ -18,6 +36,12 @@
unfocused_hollow = true;
};
bell = {
animation = "EaseOutExpo";
color = "0xffffff";
duration = 20;
};
live_config_reload = true;
shell = {

View File

@ -2,10 +2,12 @@
{
programs.gh = {
enable = true;
settings = {
gitProtocol = "ssh";
aliases = {
co = "pr checkout";
pv = "pr view";
};
};
};
}

View File

@ -1,14 +1,12 @@
{pkgs, ...}:
{ pkgs, home, colorTheme, ... }:
{
programs.neovim = {
enable = true;
# defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfig = ''
set clipboard+=unnamedplus
'';
plugins = with pkgs.vimPlugins; [
vim-commentary
vim-gitgutter
@ -23,12 +21,33 @@
limelight-vim
vim-tmux-navigator
vim-polyglot
lightline-vim
{
plugin = rainbow;
config = ''
let g:rainbow_active = 1
'';
}
{
plugin = vim-monokai;
config = ''
colorscheme monokai
autocmd ColorScheme * highlight Normal ctermbg=0
autocmd ColorScheme * highlight LineNr ctermbg=0
autocmd ColorScheme * highlight CursorLineNR ctermbg=0 ctermfg=208
autocmd ColorScheme * highlight SignColumn ctermbg=0
autocmd ColorScheme * highlight GitGutterAdd ctermbg=0
autocmd ColorScheme * highlight GitGutterChange ctermbg=0
autocmd ColorScheme * highlight GitGutterDelete ctermbg=0
'';
}
];
extraConfig = ''
set clipboard+=unnamedplus
set number relativenumber
'';
};
home.sessionVariables = { EDITOR = "nvim"; };
}

View File

@ -1,4 +1,4 @@
{ ... }:
{ lib, ... }:
let
defaultBrowser = "google-chrome-stable %u";
videoViewer = "mpv %u";
@ -8,7 +8,7 @@ in {
autoReload = true;
maxItems = 50;
browser = defaultBrowser;
extraConfig = builtins.concatStringsSep "\n" [
extraConfig = lib.strings.concatStringsSep "\n" [
''
macro m set browser "${videoViewer}"; open-in-browser ; set browser "${defaultBrowser}"
macro l set browser "${defaultBrowser}"; open-in-browser ; set browser "${defaultBrowser}"

View File

@ -0,0 +1,12 @@
{ ... }:
{
programs.qutebrowser = {
enable = true;
aliases = {};
searchEngines = {};
settings = {};
keyBindings = {};
# quickmarks = {};
extraConfig = '''';
};
}

View File

@ -14,13 +14,13 @@
# ];
font = "Droid Sans 12";
theme = ../../rofi/themes/blank.rasi;
theme = ../../general/.config/rofi/themes/blank.rasi;
extraConfig = {
modi = "window,run,drun,ssh,windowcd,file-browser";
modi = "window,run,drun,ssh,windowcd";
show-icons = true;
drun-display-format = "{name}";
fullscreen = false;
# fullscreen = false;
threads = 0;
matching = "fuzzy";
scroll-method = 0;

View File

@ -5,10 +5,16 @@
baseIndex = 1;
clock24 = true;
escapeTime = 0;
# keyMode = "vi";
keyMode = "vi";
prefix = "C-a";
plugins = with pkgs.tmuxPlugins; [
fingers
fpp
pain-control
prefix-highlight
sidebar
tmux-fzf
urlview
];
extraConfig = ''
# Don't rename windows automatically after rename with ','
@ -82,7 +88,7 @@
### DESIGN CHANGES ###
######################
set-option -g status-left '#[bg=blue]#[fg=black,bold] ###S #[bg=default] #[fg=green]#(~/.scripts/tmux/fcitx) #[fg=red]%H:%M '
set-option -g status-left '#{prefix_highlight} #[bg=blue]#[fg=black,bold] ###S #[bg=default] #[fg=green]#(~/.scripts/tmux/fcitx) #[fg=red]%H:%M '
set-option -g status-right '#[fg=red]#(~/.scripts/tmux/mpd)'
set-window-option -g window-status-current-style fg=magenta
set-option -g status-style 'bg=black fg=default'

View File

@ -307,7 +307,7 @@ in
# ms-vsliveshare.vsliveshare
redhat.java
wholroyd.jinja
bbenoist.Nix
bbenoist.nix
# jock.svg
vscodevim.vim
haskell.haskell

View File

@ -7,6 +7,14 @@
defaultKeymap = "viins";
plugins = [
# {
# name = "nix-zsh-shell-integration";
# src = pkgs.nix-zsh-shell-integration;
# }
{
name = "zsh-fast-syntax-highlighting";
src = pkgs.zsh-fast-syntax-highlighting;
}
{
name = "zsh-completions";
src = pkgs.zsh-completions;
@ -55,7 +63,8 @@
# hs = "${pkgs.home-manager}/bin/home-manager switch";
hms = "home-manager switch";
nos = "sudo ${nixos-rebuild}/bin/nixos-rebuild switch";
nxr = "sudo ${nixos-rebuild}/bin/nixos-rebuild switch";
nxc = "sudoedit /etc/nixos/configuration.nix";
ns = "nix-shell";
# Having 'watch' with a space after as an alias, enables it to expand other aliases
@ -117,6 +126,8 @@
ip = "ip -c";
regex-escapechars = "echo \"[\\^$.|?*+()\"";
connectedIps = shellPipe [
"netstat -tn 2>/dev/null"
"grep :$1"
@ -183,7 +194,7 @@
nthCdsAsNameValuePairs = n: map (cmd: nameValuePair cmd (realCommand n)) (nthCds n);
allCdNameValuePairs = (flatten (map nthCdsAsNameValuePairs (range 1 9)));
in
builtins.listToAttrs allCdNameValuePairs);
lib.attrsets.listToAttrs allCdNameValuePairs);
initExtra = ''
source ${config.home.homeDirectory}/${dotDir}/p10k.zsh

17
nixpkgs/secret/.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
# Ignore everything
*
# Sincde it's not possible to re-include a file if a
# parent directory of that file is excluded, we need to
# reinclude all directories.
!/**/
# Root level exceptions
!/**/default.nix
!.gitignore
!update.sh
!README.md
# Other exceptions
!ssh/hosts/pvv.nix

36
nixpkgs/secret/README.md Normal file
View File

@ -0,0 +1,36 @@
# Secrets
## Structure
<!-- tree-output -->
```
.
├── common
│ ├── browser-bookmarks.nix
│ └── browser-engines.nix
├── programs
│ ├── chromium
│ │ ├── bookmarks.nix
│ │ ├── default.nix
│ │ └── engines.nix
│ ├── newsboat
│ │ ├── default.nix
│ │ └── sources.nix
│ ├── qutebrowser
│ │ ├── bookmarks.nix
│ │ ├── default.nix
│ │ └── engines.nix
│ └── default.nix
├── ssh
│ └── hosts
│ ├── default.nix
│ ├── home.nix
│ ├── ntnu.nix
│ ├── pvv.nix
│ └── users.nix
├── default.nix
├── README.md
└── update.sh
```

View File

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./programs
./ssh/hosts
];
}

View File

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./bookmarks.nix
./engines.nix
];
}

View File

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./chromium
./newsboat
./qutebrowser
];
}

View File

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./sources
];
}

View File

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./bookmarks.nix
./engines.nix
];
}

View File

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./pvv.nix
./ntnu.nix
./home.nix
];
}

View File

@ -0,0 +1,100 @@
{ lib, ... }:
let
users = import ./users.nix;
inherit (users.pvv) normalUser adminUser;
# http://www.pvv.ntnu.no/pvv/Maskiner
normalMachines = [
[ "hildring" "pvv-login" "pvv" ]
"demiurgen"
"eirin"
[ "jokum" "pvv-nix" ]
"isvegg"
[ "microbel" "pvv-users" "pvv-mail" ]
];
rootMachines = [
[ "knakelibrak" "pvv-databases" ]
[ "spikkjeposche" "pvv-web" "pvv-wiki" "pvv-webmail" ]
"sleipner"
"fenris"
"balduzius"
"joshua"
"skrotnisse"
"principal"
"tom"
"monty"
{
names = ["dvask"];
proxyJump = "monty";
}
[ "innovation" "pvv-minecraft" ]
];
normalizeValueType = let
inherit (lib.strings) isString concatStringsSep;
inherit (lib.lists) isList;
inherit (lib.attrsets) filterAttrs;
in
machine:
if (isString machine) then (normalizeValueType [machine])
else if (isList machine) then (normalizeValueType { names = machine; })
else ({ name = concatStringsSep " " machine.names; } // (removeAttrs machine ["names"]));
# TODO: Merge the following two functions. They have too much code in common.
convertNormalMachines = let
inherit (lib.trivial) pipe;
inherit (lib.attrsets) listToAttrs;
inherit (lib.lists) head;
inherit (lib.strings) split;
convertNormalMachine = normalizedMachine:
rec {
inherit (normalizedMachine) name;
value = ({
hostname = "${head (split " " name)}.pvv.org";
user = normalUser;
} // removeAttrs normalizedMachine ["name"]);
};
pipeline = [
(ms: map normalizeValueType ms)
(ms: map convertNormalMachine ms)
listToAttrs
];
in machines: pipe machines pipeline;
convertAdminMachines = let
inherit (lib.trivial) pipe;
inherit (lib.attrsets) listToAttrs;
inherit (lib.lists) head;
inherit (lib.strings) split;
convertAdminMachine = normalizedMachine:
rec {
inherit (normalizedMachine) name;
value = ({
hostname = "${head (split " " name)}.pvv.org";
user = adminUser;
proxyJump = "hildring";
} // removeAttrs normalizedMachine ["name"]);
};
pipeline = [
(ms: map normalizeValueType ms)
(ms: map convertAdminMachine ms)
listToAttrs
];
in machines: pipe machines pipeline;
in
{
programs.ssh.matchBlocks = let
concatSets = lib.lists.foldl (s1: s2: s1 // s2) {};
in concatSets [
(convertNormalMachines normalMachines)
(convertAdminMachines rootMachines)
];
}

2
nixpkgs/secret/update.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
perl -0777 -pi -e '$tree=`exa -I XX* --tree --group-directories-first`; s/<!-- tree-output -->\n```\n(?:.|\n)+```/<!-- tree-output -->\n```\n$tree```/' README.md

View File

@ -0,0 +1,24 @@
{ pkgs, ... }:
{
services.dunst = {
enable = true;
iconTheme = {
package = pkgs.gnome.adwaita-icon-theme;
name = "Adwaita";
size = "32x32";
};
settings = {
global = {
geometry = "300x5-30+50";
transparency = 10;
frame_color = "#eceff1";
font = "Droid Sans 9";
};
urgency_normal = {
background = "#37474f";
foreground = "#eceff1";
timeout = 10;
};
};
};
}

View File

@ -1,8 +1,10 @@
{ config, ... }:
rec {
{
services.mpd = rec {
enable = true;
musicDirectory = "${config.services.dropbox.path}/music/music";
# musicDirectory = "${config.home.homeDirectory}/music";
playlistDirectory = "${musicDirectory}/playlists/MPD";
};
}

View File

@ -1,4 +1,6 @@
{ ... }:
{
services.picom = {
enable = true;
blur = true;
@ -31,4 +33,5 @@
vSync = true;
extraOptions = '''';
};
}

View File

@ -1,5 +1,6 @@
{ colorTheme, ... }:
{
services.stalonetray = {
enable = true;
config = {
decorations = "none";
@ -18,4 +19,5 @@
skip_taskbar = true;
slot_size = 40;
};
};
}

View File

@ -1,5 +1,6 @@
{ pkgs, ... }:
{
services.sxhkd = {
enable = true;
keybindings = {
@ -74,4 +75,5 @@
# é
"super + shift + e" = "sleep 0.3; ${pkgs.xdotool}/bin/xdotool key U00E9";
};
};
}