Rework common profile into module system

This commit is contained in:
Charlotte Van Petegem 2020-12-05 13:39:22 +01:00
parent 9d2e54547c
commit 9fdec35027
No known key found for this signature in database
GPG key ID: 019E764B7184435A
29 changed files with 288 additions and 214 deletions

View file

@ -1,20 +0,0 @@
{ ... }:
{
chvp.zfs.homeLinks = [
{ path = ".local/share/direnv"; type = "cache"; }
];
nix.extraOptions = ''
keep-outputs = true
keep-derivations = true
'';
home-manager.users.charlotte = { ... }: {
programs.direnv = {
enable = true;
enableZshIntegration = true;
enableNixDirenvIntegration = true;
};
};
}

View file

@ -1,10 +0,0 @@
{ pkgs, ... }:
{
services.pcscd = {
enable = true;
plugins = [ pkgs.ccid ];
};
environment.systemPackages = with pkgs; [ eid-mw ];
}

View file

@ -1,11 +0,0 @@
{ ... }:
{
home-manager.users.charlotte = { pkgs, ... }: {
home.packages = with pkgs; [ element-desktop ];
};
chvp.zfs.homeLinks = [
{ path = ".config/Element"; type = "data"; }
];
}

View file

@ -1,6 +0,0 @@
{ pkgs, ... }:
{
# Use latest kernel
#boot.kernelPackages = pkgs.linuxPackages_latest;
}

View file

@ -1,36 +0,0 @@
{ ... }:
{
chvp.zfs.homeLinks = [
{ path = ".cache/nix-index"; type = "cache"; }
];
home-manager.users.charlotte = { pkgs, ... }: {
home.packages = with pkgs; [
nix-index
];
systemd.user = {
services.nix-index = {
Unit = {
Description = "Service to run nix-index";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.nix-index}/bin/nix-index";
};
};
timers.nix-index = {
Unit = {
Description = "Timer that starts nix-index every two hours";
PartOf = [ "nix-index.service" ];
};
Timer = {
OnCalendar = "00/2:30";
};
Install = {
WantedBy = [ "default.target" ];
};
};
};
};
}

View file

@ -1,31 +0,0 @@
{ pkgs, ... }:
{
nix = {
extraOptions = ''
experimental-features = nix-command flakes
'';
gc = {
automatic = true;
dates = "hourly";
options = "--delete-older-than 7d";
};
optimise = {
automatic = true;
dates = [ "hourly" ];
};
trustedUsers = [ "@wheel" ];
};
nixpkgs.overlays = [
(self: super: {
nix = super.nixUnstable;
})
];
nixpkgs.config = import ./nix-store/config.nix;
home-manager.users.charlotte = { ... }: {
xdg.configFile."nixpkgs/config.nix".source = ./nix-store/config.nix;
};
}

View file

@ -1,7 +1,7 @@
{ ... }: {
nixpkgs.overlays = [
(self: super: {
pass = (super.pass-wayland.override { pass = super.pass-wayland; }).withExtensions (ext: [ ext.pass-otp ]);
pass = (super.pass.override { pass = super.pass-wayland; }).withExtensions (ext: [ ext.pass-otp ]);
})
];

View file

@ -1,25 +0,0 @@
{ ... }:
{
home-manager.users.charlotte = { ... }: {
programs.tmux = {
enable = true;
clock24 = true;
extraConfig = ''
bind q kill-session
bind v run-shell "tmux setw main-pane-width $(($(tmux display -p '#{window_width}') * 70 / 100)); tmux select-layout main-vertical"
bind h run-shell "tmux setw main-pane-height $(($(tmux display -p '#{window_height}') * 70 / 100)); tmux select-layout main-horizontal"
set -g default-terminal "screen-256color"
set -sg escape-time 10
'';
keyMode = "vi";
tmuxinator.enable = true;
};
xdg.configFile = {
"tmuxinator/accentor.yml".source = ./tmux/accentor.yml;
"tmuxinator/dodona.yml".source = ./tmux/dodona.yml;
"tmuxinator/mail.yml".source = ./tmux/mail.yml;
};
};
}

View file

@ -1,5 +0,0 @@
{ pkgs, ... }:
{
users.users.charlotte.extraGroups = [ "input" "video" ];
}

View file

@ -3,9 +3,6 @@
{
imports = [
./hardware.nix
../../configurations/eid.nix
../../profiles/bluetooth.nix
../../profiles/common.nix
../../profiles/graphical.nix
];
@ -20,8 +17,11 @@
chvp = {
stateVersion = "20.09";
graphical = true;
bluetooth.enable = true;
docker.enable = true;
eid.enable = true;
git.email = "charlotte.vanpetegem@ugent.be";
nix.enableUnfree = true;
zfs = {
enable = true;
encrypted = true;

View file

@ -3,9 +3,6 @@
{
imports = [
./hardware.nix
../../configurations/eid.nix
../../profiles/bluetooth.nix
../../profiles/common.nix
../../profiles/graphical.nix
];
@ -20,8 +17,11 @@
chvp = {
stateVersion = "20.09";
graphical = true;
bluetooth.enable = true;
docker.enable = true;
eid.enable = true;
git.email = "charlotte@vanpetegem.me";
nix.enableUnfree = true;
zfs = {
enable = true;
encrypted = true;

View file

@ -18,6 +18,7 @@
docker.enable = true;
nginx.enable = true;
ovh.enable = true;
smartd.enable = true;
sshd.enable = true;
syncthing-server.enable = true;
zfs = {

View file

@ -18,6 +18,7 @@
docker.enable = true;
nginx.enable = true;
ovh.enable = true;
smartd.enable = true;
sshd.enable = true;
zfs = {
enable = true;

21
modules/bluetooth.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
{
options.chvp.bluetooth.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.bluetooth.enable {
chvp.zfs.systemLinks = [{ path = "/var/lib/bluetooth"; type = "cache"; }];
hardware.bluetooth.enable = true;
services.blueman.enable = true;
hardware.pulseaudio.extraModules = [ pkgs.pulseaudio-modules-bt ];
hardware.pulseaudio.package = pkgs.pulseaudioFull;
home-manager.users.charlotte = lib.mkIf config.chvp.bluetooth.enable ({ ... }: {
services.blueman-applet.enable = true;
});
};
}

View file

@ -3,13 +3,20 @@
{
imports = [
./default/secret.nix
./bluetooth.nix
./docker.nix
./eid.nix
./git.nix
./global-mailer.nix
./neovim.nix
./nix.nix
./nginx.nix
./ovh.nix
./smartd.nix
./ssh.nix
./sshd.nix
./syncthing-server.nix
./tmux.nix
./zfs.nix
./zsh.nix
];
@ -54,6 +61,18 @@
ripgrep
];
i18n = {
defaultLocale = "en_IE.UTF-8";
extraLocaleSettings = {
LC_TIME = "en_GB.UTF-8";
};
};
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
users = {
mutableUsers = false;
defaultUserShell = pkgs.zsh;
@ -62,7 +81,7 @@
isNormalUser = true;
home = "/home/charlotte";
description = "Charlotte Van Petegem";
extraGroups = [ "wheel" "systemd-journal" ];
extraGroups = [ "wheel" "systemd-journal" ] ++ lib.optionals config.chvp.graphical [ "input" "video" ];
};
};
};

16
modules/eid.nix Normal file
View file

@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
{
options.chvp.eid.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.eid.enable {
environment.systemPackages = [ pkgs.eid-mw ];
services.pcscd = {
enable = true;
plugins = [ pkgs.ccid ];
};
};
}

21
modules/global-mailer.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
{
options.chvp.globalMailer.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.smartd.enable {
services.ssmtp = {
enable = true;
authUser = "webmaster@vanpetegem.me";
authPassFile = "/data/var/secrets/ssmtp-mail-pass";
domain = "${config.networking.hostName}.vanpetegem.me";
hostName = "mail.vanpetegem.me:465";
root = "webmaster@vanpetegem.me";
setSendmail = true;
useTLS = true;
};
};
}

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ config, lib, pkgs, ... }:
let
customPlugins = {
snow-color-theme = pkgs.vimUtils.buildVimPlugin {
@ -13,14 +13,7 @@ let
};
jdtls = import ../packages/jdtls/default.nix { inherit pkgs; stdenv = pkgs.stdenv; };
kotlinls = import ../packages/kotlin-language-server/default.nix { inherit pkgs; };
in
{
chvp.zfs.homeLinks = [
{ path = ".local/share/nvim"; type = "cache"; }
{ path = ".cache/nvim"; type = "cache"; }
];
home-manager.users.charlotte = { pkgs, ... }: {
base = home: {
home.sessionVariables = { EDITOR = "nvim"; };
programs.neovim = {
enable = true;
@ -36,11 +29,11 @@ in
" Undo over sessions
set undofile
set undodir=~/.cache/nvim/undo
set undodir=${config.chvp.cachePrefix}${home}/.cache/nvim/undo
" Automatically save sessions on exit and load them on start
function! MakeSession()
let b:sessiondir = $HOME . "/.local/share/nvim/sessions" . getcwd()
let b:sessiondir = "${config.chvp.cachePrefix}${home}/.local/share/nvim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
@ -50,7 +43,7 @@ in
endfunction
function! LoadSession()
let b:sessiondir = $HOME . "/.local/share/nvim/sessions" . getcwd()
let b:sessiondir = "${config.chvp.cachePrefix}${home}/.local/share/nvim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
@ -140,16 +133,18 @@ in
{
plugin = ale;
config = ''
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
'' + (lib.optionalString config.chvp.graphical ''
\ 'javascript': ['eslint', 'remove_trailing_lines', 'trim_whitespace'],
\ 'ledger': ['trim_whitespace'],
\ 'nix': ['nixpkgs-fmt', 'remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop', 'remove_trailing_lines', 'trim_whitespace'],
\ 'typescript': ['eslint', 'remove_trailing_lines', 'trim_whitespace'],
\ 'vue': ['prettier', 'remove_trailing_lines', 'trim_whitespace'],
'') + ''
\}
let g:ale_fix_on_save = 1
'';
}
auto-pairs
@ -158,12 +153,16 @@ in
config = ''
let g:deoplete#enable_at_startup = 1
set completeopt+=noselect
'' + lib.optionalString config.chvp.graphical ''
au VimEnter * call deoplete#custom#option('omni_patterns', {
\ 'ledger': ['[a-zA-Z][a-zA-Z: ]*'],
\})
'';
}
editorconfig-vim
snow-color-theme
vim-nix
] ++ lib.optionals config.chvp.graphical [
kotlin-vim
{
plugin = LanguageClient-neovim;
@ -191,9 +190,7 @@ in
autocmd FileType * call LC_maps()
'';
}
snow-color-theme
vim-ledger
vim-nix
vim-ruby
vim-vue
yats-vim
@ -203,4 +200,17 @@ in
];
};
};
in
{
options.chvp.neovim = {
enable = lib.mkOption {
default = true;
example = false;
};
};
config = lib.mkIf config.chvp.neovim.enable {
home-manager.users.charlotte = { ... }: (base "/home/charlotte");
home-manager.users.root = { ... }: (base "/root");
};
}

105
modules/nix.nix Normal file
View file

@ -0,0 +1,105 @@
{ config, lib, pkgs, ... }:
let
baseDirenv = {
programs.direnv = {
enable = true;
enableZshIntegration = true;
enableNixDirenvIntegration = true;
};
};
baseUnfree = {
xdg.configFile."nixpkgs/config.nix".source = ./nix/unfree.nix;
};
baseNixIndex = {
home.packages = with pkgs; [ nix-index ];
programs.zsh.initExtra = ''
source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh
'';
systemd.user = {
services.nix-index = {
Unit = {
Description = "Service to run nix-index";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.nix-index}/bin/nix-index";
};
};
timers.nix-index = {
Unit = {
Description = "Timer that starts nix-index every two hours";
PartOf = [ "nix-index.service" ];
};
Timer = {
OnCalendar = "00/2:30";
};
Install = {
WantedBy = [ "default.target" ];
};
};
};
};
in
{
options.chvp.nix = {
enableDirenv = lib.mkOption {
default = true;
example = false;
};
enableFlakes = lib.mkOption {
default = true;
example = false;
};
enableUnfree = lib.mkOption {
default = false;
example = true;
};
# Note that this is only enabled for charlotte, until https://github.com/bennofs/nix-index/issues/143 is resolved.
enableNixIndex = lib.mkOption {
default = true;
example = false;
};
};
config = {
chvp.zfs.homeLinks =
(lib.optional config.chvp.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }) ++
(lib.optional config.chvp.nix.enableNixIndex { path = ".cache/nix-index"; type = "cache"; });
chvp.zfs.systemLinks =
(lib.optional config.chvp.nix.enableDirenv { path = "/root/.local/share/direnv"; type = "cache"; });
nix = {
gc = {
automatic = true;
dates = "hourly";
options = "--delete-older-than 7d";
};
optimise = {
automatic = true;
dates = [ "hourly" ];
};
trustedUsers = [ "@wheel" ];
extraOptions = (lib.optionalString config.chvp.nix.enableDirenv ''
keep-outputs = true
keep-derivations = true
'') + (lib.optionalString config.chvp.nix.enableFlakes ''
experimental-features = nix-command flakes
'');
};
nixpkgs.config = lib.mkIf config.chvp.nix.enableUnfree (import ./nix/unfree.nix);
nixpkgs.overlays = lib.mkIf config.chvp.nix.enableFlakes [
(self: super: {
nix = super.nixUnstable;
})
];
home-manager.users.charlotte = { ... }:
(lib.optionalAttrs config.chvp.nix.enableDirenv baseDirenv) //
(lib.optionalAttrs config.chvp.nix.enableUnfree baseUnfree) //
(lib.optionalAttrs config.chvp.nix.enableNixIndex baseNixIndex);
home-manager.users.root = { ... }:
(lib.optionalAttrs config.chvp.nix.enableDirenv baseDirenv) //
(lib.optionalAttrs config.chvp.nix.enableUnfree baseUnfree);
};
}

25
modules/smartd.nix Normal file
View file

@ -0,0 +1,25 @@
{ config, lib, pkgs, ... }:
{
options.chvp.smartd.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.smartd.enable {
chvp.globalMailer.enable = true;
environment.systemPackages = [ pkgs.smartmontools ];
services.smartd = {
enable = true;
autodetect = true;
notifications = {
mail = {
enable = true;
sender = "${config.networking.hostName}@vanpetegem.me";
recipient = "webmaster@vanpetegem.me";
};
wall.enable = false;
};
};
};
}

36
modules/tmux.nix Normal file
View file

@ -0,0 +1,36 @@
{ config, lib, ... }:
let
base = {
programs.tmux = {
enable = true;
clock24 = true;
extraConfig = ''
bind q kill-session
bind v run-shell "tmux setw main-pane-width $(($(tmux display -p '#{window_width}') * 70 / 100)); tmux select-layout main-vertical"
bind h run-shell "tmux setw main-pane-height $(($(tmux display -p '#{window_height}') * 70 / 100)); tmux select-layout main-horizontal"
set -g default-terminal "screen-256color"
set -sg escape-time 10
'';
keyMode = "vi";
tmuxinator.enable = lib.mkIf config.chvp.graphical true;
};
};
in
{
options.chvp.tmux.enable = lib.mkOption {
default = true;
example = false;
};
config = lib.mkIf config.chvp.tmux.enable {
home-manager.users.charlotte = { ... }: base // lib.optionalAttrs config.chvp.graphical {
xdg.configFile = {
"tmuxinator/accentor.yml".source = ./tmux/accentor.yml;
"tmuxinator/dodona.yml".source = ./tmux/dodona.yml;
"tmuxinator/mail.yml".source = ./tmux/mail.yml;
};
};
home-manager.users.root = { ... }: base;
};
}

View file

@ -20,7 +20,6 @@
path = "${config.chvp.cachePrefix}${home}/.local/share/zsh/history";
};
initExtra = ''
source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh
${pkgs.any-nix-shell}/bin/any-nix-shell zsh --info-right | source /dev/stdin
'';
oh-my-zsh = {

View file

@ -1,16 +0,0 @@
{ pkgs, ... }:
{
chvp.zfs.systemLinks = [
{ path = "/var/lib/bluetooth"; type = "cache"; }
];
hardware.bluetooth.enable = true;
services.blueman.enable = true;
hardware.pulseaudio.extraModules = [ pkgs.pulseaudio-modules-bt ];
hardware.pulseaudio.package = pkgs.pulseaudioFull;
home-manager.users.charlotte = { ... }: {
services.blueman-applet.enable = true;
};
}

View file

@ -1,28 +0,0 @@
{ pkgs, ... }:
{
imports = [
../modules/zfs.nix
../configurations/direnv.nix
../configurations/gnupg.nix
../configurations/hledger.nix
../configurations/locale.nix
../configurations/mail.nix
../configurations/neovim.nix
../configurations/nix-index.nix
../configurations/nix-store.nix
../configurations/pass.nix
../configurations/tmux.nix
../configurations/users.nix
];
home-manager.users.charlotte = { pkgs, ... }: {
home.packages = with pkgs; [
moreutils
pandoc
texlive.combined.scheme-small
unzip
youtube-dl
];
};
}

View file

@ -10,17 +10,20 @@
../configurations/dwarf-fortress.nix
../configurations/firefox.nix
../configurations/fonts.nix
../configurations/gnupg.nix
../configurations/hledger.nix
../configurations/i3.nix
../configurations/kernel.nix
../configurations/kitty.nix
../configurations/mail.nix
../configurations/mime.nix
../configurations/mounts.nix
../configurations/mumble.nix
../configurations/networkmanager.nix
../configurations/pass.nix
../configurations/sound.nix
../configurations/steam.nix
../configurations/sway.nix
../configurations/syncthing.nix
../configurations/steam.nix
../configurations/teams.nix
../configurations/themes.nix
../configurations/virtualbox.nix
@ -34,15 +37,20 @@
google-chrome
greenfoot
libreoffice
moreutils
mpv
okular
pandoc
pavucontrol
ranger
slurp
sshfs
texlive.combined.scheme-small
ungoogled-chromium
unzip
wf-recorder
wl-clipboard
youtube-dl
];
programs.zsh.loginExtra = ''
if [[ -z "$DISPLAY" ]] && [[ $(tty) = "/dev/tty1" ]]; then