diff --git a/configurations/direnv.nix b/configurations/direnv.nix deleted file mode 100644 index 59fc3928..00000000 --- a/configurations/direnv.nix +++ /dev/null @@ -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; - }; - }; -} diff --git a/configurations/eid.nix b/configurations/eid.nix deleted file mode 100644 index 5d1eb936..00000000 --- a/configurations/eid.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs, ... }: - -{ - services.pcscd = { - enable = true; - plugins = [ pkgs.ccid ]; - }; - - environment.systemPackages = with pkgs; [ eid-mw ]; -} diff --git a/configurations/element-desktop.nix b/configurations/element-desktop.nix deleted file mode 100644 index 18705b66..00000000 --- a/configurations/element-desktop.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: - -{ - home-manager.users.charlotte = { pkgs, ... }: { - home.packages = with pkgs; [ element-desktop ]; - }; - - chvp.zfs.homeLinks = [ - { path = ".config/Element"; type = "data"; } - ]; -} diff --git a/configurations/kernel.nix b/configurations/kernel.nix deleted file mode 100644 index 012fa01e..00000000 --- a/configurations/kernel.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ pkgs, ... }: - -{ - # Use latest kernel - #boot.kernelPackages = pkgs.linuxPackages_latest; -} diff --git a/configurations/nix-index.nix b/configurations/nix-index.nix deleted file mode 100644 index 29f569ea..00000000 --- a/configurations/nix-index.nix +++ /dev/null @@ -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" ]; - }; - }; - }; - }; -} diff --git a/configurations/nix-store.nix b/configurations/nix-store.nix deleted file mode 100644 index a60b7d0a..00000000 --- a/configurations/nix-store.nix +++ /dev/null @@ -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; - }; -} diff --git a/configurations/pass.nix b/configurations/pass.nix index 1348607d..a32d6a18 100644 --- a/configurations/pass.nix +++ b/configurations/pass.nix @@ -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 ]); }) ]; diff --git a/configurations/tmux.nix b/configurations/tmux.nix deleted file mode 100644 index 96fea172..00000000 --- a/configurations/tmux.nix +++ /dev/null @@ -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; - }; - }; -} diff --git a/configurations/users.nix b/configurations/users.nix deleted file mode 100644 index 1c0b9a22..00000000 --- a/configurations/users.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs, ... }: - -{ - users.users.charlotte.extraGroups = [ "input" "video" ]; -} diff --git a/machines/kharbranth/default.nix b/machines/kharbranth/default.nix index d989432b..098268c2 100644 --- a/machines/kharbranth/default.nix +++ b/machines/kharbranth/default.nix @@ -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; diff --git a/machines/kholinar/default.nix b/machines/kholinar/default.nix index 345440c7..645bd2a3 100644 --- a/machines/kholinar/default.nix +++ b/machines/kholinar/default.nix @@ -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; diff --git a/machines/lasting-integrity/default.nix b/machines/lasting-integrity/default.nix index 10f7aed8..5aed485b 100644 --- a/machines/lasting-integrity/default.nix +++ b/machines/lasting-integrity/default.nix @@ -18,6 +18,7 @@ docker.enable = true; nginx.enable = true; ovh.enable = true; + smartd.enable = true; sshd.enable = true; syncthing-server.enable = true; zfs = { diff --git a/machines/urithiru/default.nix b/machines/urithiru/default.nix index 254dc7e7..b30dd7ac 100644 --- a/machines/urithiru/default.nix +++ b/machines/urithiru/default.nix @@ -18,6 +18,7 @@ docker.enable = true; nginx.enable = true; ovh.enable = true; + smartd.enable = true; sshd.enable = true; zfs = { enable = true; diff --git a/modules/bluetooth.nix b/modules/bluetooth.nix new file mode 100644 index 00000000..5ba28124 --- /dev/null +++ b/modules/bluetooth.nix @@ -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; + }); + }; +} diff --git a/modules/default.nix b/modules/default.nix index 1a993fcd..c2d03c6e 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -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" ]; }; }; }; diff --git a/modules/eid.nix b/modules/eid.nix new file mode 100644 index 00000000..10bf4892 --- /dev/null +++ b/modules/eid.nix @@ -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 ]; + }; + }; +} diff --git a/modules/global-mailer.nix b/modules/global-mailer.nix new file mode 100644 index 00000000..06e27db0 --- /dev/null +++ b/modules/global-mailer.nix @@ -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; + }; + }; +} diff --git a/configurations/neovim.nix b/modules/neovim.nix similarity index 88% rename from configurations/neovim.nix rename to modules/neovim.nix index a6175e30..fdd82e5d 100644 --- a/configurations/neovim.nix +++ b/modules/neovim.nix @@ -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"); + }; } diff --git a/modules/nix.nix b/modules/nix.nix new file mode 100644 index 00000000..769594f7 --- /dev/null +++ b/modules/nix.nix @@ -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); + }; +} diff --git a/configurations/nix-store/config.nix b/modules/nix/unfree.nix similarity index 100% rename from configurations/nix-store/config.nix rename to modules/nix/unfree.nix diff --git a/modules/smartd.nix b/modules/smartd.nix new file mode 100644 index 00000000..d8681e22 --- /dev/null +++ b/modules/smartd.nix @@ -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; + }; + }; + }; +} diff --git a/modules/tmux.nix b/modules/tmux.nix new file mode 100644 index 00000000..42c43f98 --- /dev/null +++ b/modules/tmux.nix @@ -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; + }; +} diff --git a/configurations/tmux/accentor.yml b/modules/tmux/accentor.yml similarity index 100% rename from configurations/tmux/accentor.yml rename to modules/tmux/accentor.yml diff --git a/configurations/tmux/dodona.yml b/modules/tmux/dodona.yml similarity index 100% rename from configurations/tmux/dodona.yml rename to modules/tmux/dodona.yml diff --git a/configurations/tmux/mail.yml b/modules/tmux/mail.yml similarity index 100% rename from configurations/tmux/mail.yml rename to modules/tmux/mail.yml diff --git a/modules/zsh.nix b/modules/zsh.nix index abc8f7f1..9d3619bd 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -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 = { diff --git a/profiles/bluetooth.nix b/profiles/bluetooth.nix deleted file mode 100644 index ecd4d72a..00000000 --- a/profiles/bluetooth.nix +++ /dev/null @@ -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; - }; -} diff --git a/profiles/common.nix b/profiles/common.nix deleted file mode 100644 index 3aec94ea..00000000 --- a/profiles/common.nix +++ /dev/null @@ -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 - ]; - }; -} diff --git a/profiles/graphical.nix b/profiles/graphical.nix index 7a1d73dd..6b715531 100644 --- a/profiles/graphical.nix +++ b/profiles/graphical.nix @@ -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