diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index e2f5dd2..9f05b1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -result \ No newline at end of file +.direnv +.vscode +result diff --git a/flake.nix b/flake.nix index d89b9ae..d4d7633 100644 --- a/flake.nix +++ b/flake.nix @@ -55,22 +55,42 @@ outputs = { self, ... }@inputs: with inputs; let + homeConfigurations = import ./home; + sharedModules = [ + self.homeManagerModules + inputs.nix-index-database.hmModules.nix-index + ]; mkHome = user: host: { config, system, ... }: { imports = [ + home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.xin = import ./home/${user}/${host}; - home-manager.extraSpecialArgs = { inherit inputs system; }; + home-manager = { + inherit sharedModules; + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { inherit inputs; }; + }; + home-manager.users.${user} = homeConfigurations.${user}.${host}; } ]; }; + mkHomeConfiguration = user: settings: { + name = user; + value = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { system = "x86_64-linux"; }; + modules = [ + self.homeManagerModules + ] ++ sharedModules; + specialArgs = { + inherit inputs; + }; + }; + }; mkNixos = { system, modules, specialArgs ? {}}: nixpkgs.lib.nixosSystem { inherit system; specialArgs = specialArgs // { inherit inputs system; }; modules = [ self.nixosModules.default - home-manager.nixosModules.home-manager nur.nixosModules.nur ] ++ modules; }; @@ -80,6 +100,8 @@ nixosModules.default = import ./modules/nixos; homeManagerModules = import ./modules/home-manager; + homeConfigurations = listToAttrs [ (mkHomeConfiguration "xin" "calcite") ]; + colmenaHive = colmena.lib.makeHive { meta = { nixpkgs = import nixpkgs { @@ -165,5 +187,14 @@ } ]; }).config.system.build.sdImage; - }; + } // flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; in + { + devShells = { + default = pkgs.mkShell { + packages = with pkgs; [ git colmena ]; + }; + }; + } + ); } diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..0c683f6 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,5 @@ +{ + xin = { + calcite = import ./xin/calcite.nix; + }; +} \ No newline at end of file diff --git a/home/xin/alacritty.nix b/home/xin/alacritty.nix deleted file mode 100644 index f34ff67..0000000 --- a/home/xin/alacritty.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, ... }: { - programs.alacritty = { - enable = true; - settings = { - shell = { - program = config.programs.zellij.package + "/bin/zellij"; - args = [ - "attach" - "-c" - ]; - }; - font.size = 10.0; - window = { - resize_increments = true; - dynamic_padding = true; - }; - }; - }; -} diff --git a/home/xin/calcite/default.nix b/home/xin/calcite.nix similarity index 68% rename from home/xin/calcite/default.nix rename to home/xin/calcite.nix index 94e3d77..31c9811 100644 --- a/home/xin/calcite/default.nix +++ b/home/xin/calcite.nix @@ -1,10 +1,7 @@ -{ inputs, config, pkgs, ... }: +{ config, pkgs, ... }: { imports = [ - ../common - ../vscode.nix - ../alacritty.nix - inputs.nix-index-database.hmModules.nix-index + ./common ]; programs.nix-index-database.comma.enable = true; @@ -34,4 +31,14 @@ thunderbird remmina ]; + + custom-hm = { + alacritty = { enable = true; }; + direnv = { enable = true; }; + fish = { enable = true; }; + git = { enable = true; }; + neovim = { enable = true; }; + vscode = { enable = true; }; + zellij = { enable = true; }; + }; } diff --git a/home/xin/common/default.nix b/home/xin/common/default.nix index c76d3e8..0e0677c 100644 --- a/home/xin/common/default.nix +++ b/home/xin/common/default.nix @@ -1,10 +1,5 @@ -{ pkgs, ... }: { - imports = [ - ./fish.nix - ./git.nix - ./zellij.nix - ./vim.nix - ]; +{ inputs, pkgs, ... }: { + imports = [ ]; home.packages = with pkgs; [ dig diff --git a/home/xin/common/fish.nix b/home/xin/common/fish.nix deleted file mode 100644 index 7d8fecb..0000000 --- a/home/xin/common/fish.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ pkgs, ... }: { - programs.fish = { - enable = true; - plugins = with pkgs; [ - { - name = "pisces"; - src = fishPlugins.pisces.src; - } - { - name = "done"; - src = fishPlugins.done.src; - } - { - name = "hydro"; - src = fishPlugins.hydro.src; - } - ]; - interactiveShellInit = '' - fish_config theme choose 'ayu Dark' - fish_config prompt choose arrow - ${pkgs.nix-your-shell}/bin/nix-your-shell fish | source - function fish_right_prompt - if test -n "$IN_NIX_SHELL" - echo -n "" - else if test $SHLVL -ge 3 - echo -n "<🚀lv$SHLVL>" - end - end - function fish_command_not_found - ${pkgs.comma}/bin/comma $argv - end - ''; - functions = { - gitignore = "curl -sL https://www.gitignore.io/api/$argv"; - }; - }; -} diff --git a/home/xin/common/git.nix b/home/xin/common/git.nix deleted file mode 100644 index 98c2e84..0000000 --- a/home/xin/common/git.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - programs.git = { - enable = true; - delta.enable = true; - userName = "Xinyang Li"; - userEmail = "lixinyang411@gmail.com"; - aliases = { - graph = "log --all --oneline --graph --decorate"; - s = "status"; - d = "diff"; - }; - }; -} \ No newline at end of file diff --git a/home/xin/common/vim.nix b/home/xin/common/vim.nix deleted file mode 100644 index f73228d..0000000 --- a/home/xin/common/vim.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ pkgs, ... }: { - programs.neovim = { - enable = true; - vimAlias = true; - vimdiffAlias = true; - plugins = with pkgs.vimPlugins; [ - nvim-treesitter.withAllGrammars - dracula-nvim - ]; - extraConfig = '' - set nocompatible - - syntax on - set number - set relativenumber - set shortmess+=I - set laststatus=2 - - set ignorecase - set smartcase - set list - set listchars=tab:→· - set tabstop=4 - set shiftwidth=4 - set expandtab - - set mouse+=a - - colorscheme dracula - ''; -}; -} diff --git a/home/xin/common/zellij.nix b/home/xin/common/zellij.nix deleted file mode 100644 index e485d11..0000000 --- a/home/xin/common/zellij.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - programs.zellij = { - enable = true; - settings = { - default_shell = "fish"; - keybinds = { - unbind = [ - "Ctrl p" - "Ctrl n" - ]; - }; - theme = "dracula"; - themes.dracula = { - fg = [ 248 248 242 ]; - bg = [ 40 42 54 ]; - black = [ 0 0 0 ]; - red = [ 255 85 85 ]; - green = [ 80 250 123 ]; - yellow = [ 241 250 140 ]; - blue = [ 98 114 164 ]; - magenta = [ 255 121 198 ]; - cyan = [ 139 233 253 ]; - white = [ 255 255 255 ]; - orange = [ 255 184 108 ]; - }; - }; - }; -} diff --git a/home/xin/vscode.nix b/home/xin/vscode.nix deleted file mode 100644 index a0b9eac..0000000 --- a/home/xin/vscode.nix +++ /dev/null @@ -1,133 +0,0 @@ -{ config, pkgs, inputs, system, ... }: -{ - home.packages = with pkgs; [ - pkgs.wl-clipboard-x11 - ]; - programs.vscode = { - enable = true; - enableUpdateCheck = false; - enableExtensionUpdateCheck = false; - mutableExtensionsDir = false; - extensions = (with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace; [ - arrterian.nix-env-selector - - bbenoist.nix - ms-azuretools.vscode-docker - ms-vscode-remote.remote-ssh - vscodevim.vim - github.vscode-pull-request-github - eamodio.gitlens - gruntfuggly.todo-tree # todo highlight - - # Language support - # Python - ms-python.python - # Markdown - davidanson.vscode-markdownlint - # C/C++ - ms-vscode.cmake-tools - llvm-vs-code-extensions.vscode-clangd - # Nix - jnoortheen.nix-ide - # Latex - james-yu.latex-workshop - # Vue - vue.volar - - ms-vscode-remote.remote-ssh-edit - mushan.vscode-paste-image - ]) ++ (with pkgs.vscode-extensions; [ - # Rust - rust-lang.rust-analyzer - github.copilot - ]); - userSettings = { - "workbench.colorTheme" = "Default Dark+"; - "terminal.integrated.sendKeybindingsToShell" = true; - "extensions.ignoreRecommendations" = true; - "files.autoSave" = "afterDelay"; - "editor.inlineSuggest.enabled" = true; - "editor.rulers" = [ - 80 - ]; - "editor.mouseWheelZoom" = true; - "git.autofetch" = true; - "window.zoomLevel" = -1; - - "nix.enableLanguageServer" = true; - - "latex-workshop.latex.autoBuild.run" = "never"; - "latex-workshop.latex.tools" = [ - { - "name" = "xelatex"; - "command" = "xelatex"; - "args" = [ - "-synctex=1" - "-interaction=nonstopmode" - "-file-line-error" - "-pdf" - "%DOCFILE%" - ]; - } - { - "name" = "pdflatex"; - "command" = "pdflatex"; - "args" = [ - "-synctex=1" - "-interaction=nonstopmode" - "-file-line-error" - "%DOCFILE%" - ]; - } - { - "name" = "bibtex"; - "command" = "bibtex"; - "args" = [ - "%DOCFILE%" - ]; - } - ]; - "latex-workshop.latex.recipes" = [ - { - "name" = "xelatex"; - "tools" = [ - "xelatex" - ]; - } - { - "name" = "pdflatex"; - "tools" = [ - "pdflatex" - ]; - } - { - "name" = "xe->bib->xe->xe"; - "tools" = [ - "xelatex" - "bibtex" - "xelatex" - "xelatex" - ]; - } - { - "name" = "pdf->bib->pdf->pdf"; - "tools" = [ - "pdflatex" - "bibtex" - "pdflatex" - "pdflatex" - ]; - } - ]; - "[latex]" = { - "editor.formatOnPaste" = false; - "editor.suggestSelection" = "recentlyusedbyprefix"; - "editor.wordWrap" = "bounded"; - "editor.wordWrapColumn" = 80; - "editor.unicodeHighlight.ambiguousCharacters" = false; - }; - # Extension vscode-paste-image - "pasteImage.path" = "\${currentFileDir}/.assets"; - }; - }; -} diff --git a/machines/calcite/configuration.nix b/machines/calcite/configuration.nix index 43251e2..7017de9 100644 --- a/machines/calcite/configuration.nix +++ b/machines/calcite/configuration.nix @@ -158,10 +158,6 @@ clang-tools rnix-lsp - # C/C++ - gcc - gdb - # Python # reference: https://nixos.wiki/wiki/Python ( @@ -193,7 +189,6 @@ gnomeExtensions.paperwm gnomeExtensions.search-light gnomeExtensions.tray-icons-reloaded - gnomeExtensions.gsconnect gnome.gnome-tweaks gthumb diff --git a/machines/calcite/hardware-configuration.nix b/machines/calcite/hardware-configuration.nix index 0bd2426..c59286d 100644 --- a/machines/calcite/hardware-configuration.nix +++ b/machines/calcite/hardware-configuration.nix @@ -23,13 +23,6 @@ fsType = "vfat"; }; - fileSystems."/media/data" = - { - device = "/dev/disk/by-label/WINDATA"; - fsType = "ntfs3"; - options = [ "rw" "uid=1000" ]; - }; - swapDevices = [ { device = "/dev/disk/by-label/NIXSWAP"; } ]; diff --git a/machines/massicot/default.nix b/machines/massicot/default.nix index 7ffd7b6..98328f3 100644 --- a/machines/massicot/default.nix +++ b/machines/massicot/default.nix @@ -18,6 +18,9 @@ gts_env = { owner = "gotosocial"; }; + hedgedoc_env = { + owner = "hedgedoc"; + }; grafana_cloud_api = { owner = "prometheus"; sopsFile = ../secrets.yaml; diff --git a/machines/massicot/secrets.yaml b/machines/massicot/secrets.yaml index d2b0faa..5e5d0fe 100644 --- a/machines/massicot/secrets.yaml +++ b/machines/massicot/secrets.yaml @@ -1,5 +1,6 @@ storage_box_mount: ENC[AES256_GCM,data:9lOAL3tkfB0pN4/cuM4SX0xoMrW0UUEzTN8spw3MQ3BWrfsRc3Stsce3puXz1sRf,iv:7Q9wzpBgQ3tqcfy0n/c6Ya84Kg60nhR/e2H0pVntWsY=,tag:9a0xvNBGQpCvhxgmV3hrww==,type:str] gts_env: ENC[AES256_GCM,data:CKFKHXCJvTD0HFkVrBWhabcl/cloCT03qcZIc5JymiIAu+o6wef6gsQlkKP81vxC9S3XMYtLgXQ03D7Jetkfg+7nafF1+ogN,iv:/axRqZIatwYL++/KmBIievPPyKRkHGmVpgRe2Eet+fg=,tag:gwxyuePOYiD1vlSyq3yjXA==,type:str] +hedgedoc_env: ENC[AES256_GCM,data:zwAA+zKSJT0tZyYArCaa1lfL0y8DNHDp/thS11DrVxNvjmk38o0ydsKArfZKzFYye+qNBzz1B4sPCdW4cFgQUNgbM+n9AvoMB8CssdmQ+sALKmozA5aEV23q+khZSGlHocP6WA==,iv:SgZruOS1nanK64Ex1dvgoD1HzbGbNa4DFSBuVoaNgEc=,tag:R+I8m1AloDCXs5PdpEpS0w==,type:str] sops: kms: [] gcp_kms: [] @@ -24,8 +25,8 @@ sops: dnFBa0lDWWZtS1BHdzBoVzNTaGNkSEEKi/W1n7RT8NpTp00SBMwxsUJAPDhumJ/i V2VnaSNwouD3SswTcoBzqQpBP9XrqzjIYGke90ZODFQbMY9WDQ+O0g== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-12-15T13:06:05Z" - mac: ENC[AES256_GCM,data:ArxA3+i+W2hU0mpzjPqzBA1pQdZySwJ+LVAez2PWFMsrgT4QATi+KmlWWfuPBkOq/DYafAES8lTemDeuzuQl7bWZq06g3s35C8Q3D/TDUKFF3ALEL5grSxKTVzg4Npjc2q2OIOXrIp/j83Gn1lBuyBFg0YdGkJ+b/BmDGkTbyUg=,iv:8MB/+WklLsFTnlvxLyvCK8VUMNeXtaPTGXlp9hRGzOM=,tag:VbbnQfPewNGdrPqmZJSYlA==,type:str] + lastmodified: "2023-12-22T08:05:27Z" + mac: ENC[AES256_GCM,data:CiXU49arW+3w4/Lkh4l+6VjopyP7XNCU4AmuwZmnmQ7Vv4RCt84fC6lM6o4HiCc5jB07QY+2WZ5LvWz9zgSt636UpnCMgbG1w2Lxae38fW02RHJv90rn+cyyddB5kSucr5/P5NKBOZut54Cf4zVW9BaqajpQMxe4hEOn+xXpXz8=,iv:beWRlUvb6OUOK+mUXdvpvmM8S7xK0QIkIA2Bk9QA35c=,tag:KrBXqsAdBAhtwygdEHnUqQ==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.8.1 diff --git a/machines/massicot/services.nix b/machines/massicot/services.nix index e0b00bd..e5ecdcc 100644 --- a/machines/massicot/services.nix +++ b/machines/massicot/services.nix @@ -11,6 +11,21 @@ in domain = "vaultwarden.xinyang.life"; }; + custom.hedgedoc = { + enable = true; + caddy = true; + domain = "docs.xinyang.life"; + mediaPath = "/mnt/storage/hedgedoc"; + oidc = { + enable = true; + baseURL = "https://auth.xinyang.life/oauth2/openid/hedgedoc"; + authorizationURL = "https://auth.xinyang.life/ui/oauth2"; + tokenURL = "https://auth.xinyang.life/oauth2/token"; + userProfileURL = "https://auth.xinyang.life/oauth2/openid/hedgedoc/userinfo"; + }; + environmentFile = config.sops.secrets.hedgedoc_env.path; + }; + custom.prometheus = { enable = true; exporters.enable = true; @@ -27,7 +42,7 @@ in fsType = "cifs"; options = ["uid=${share},gid=${share},credentials=${config.sops.secrets.storage_box_mount.path}"]; }; - }) [ "forgejo" "gotosocial" "conduit" ] ); + }) [ "forgejo" "gotosocial" "conduit" "hedgedoc" ] ); system.activationScripts = { conduit-media-link.text = '' @@ -144,7 +159,7 @@ in flush_interval -1 } ''; - virtualHosts."git.xinyang.life:443".extraConfig = '' + virtualHosts."https://git.xinyang.life:443".extraConfig = '' reverse_proxy http://${config.services.gitea.settings.server.DOMAIN}:${toString config.services.gitea.settings.server.HTTP_PORT} ''; @@ -155,8 +170,8 @@ in abort } ''; - virtualHosts."https://auth.xinyang.life:443".extraConfig = '' - reverse_proxy https://auth.xinyang.life:${toString kanidm_listen_port} { + virtualHosts."https://auth.xinyang.life".extraConfig = '' + reverse_proxy https://127.0.0.1:${toString kanidm_listen_port} { header_up Host {upstream_hostport} header_down Access-Control-Allow-Origin "*" transport http { diff --git a/machines/vscode.nix b/machines/vscode.nix deleted file mode 100644 index 0ec1e87..0000000 --- a/machines/vscode.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ config, lib, pkgs, ... }: -{ - environment.systemPackages = [ - (pkgs.vscode-with-extensions.override { - vscodeExtensions = with pkgs.vscode-extensions; [ - arrterian.nix-env-selector - - bbenoist.nix - ms-azuretools.vscode-docker - ms-vscode-remote.remote-ssh - vscodevim.vim - github.copilot - github.vscode-pull-request-github - eamodio.gitlens - gruntfuggly.todo-tree # todo highlight - - vadimcn.vscode-lldb # debugger - - # Language support - ms-python.python - davidanson.vscode-markdownlint - llvm-vs-code-extensions.vscode-clangd - jnoortheen.nix-ide - james-yu.latex-workshop - rust-lang.rust-analyzer - ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ - { - name = "remote-ssh-edit"; - publisher = "ms-vscode-remote"; - version = "0.47.2"; - sha256 = "1hp6gjh4xp2m1xlm1jsdzxw9d8frkiidhph6nvl24d0h8z34w49g"; - } - ]; - }) - ]; -} diff --git a/modules/home-manager/alacritty.nix b/modules/home-manager/alacritty.nix new file mode 100644 index 0000000..7e217d8 --- /dev/null +++ b/modules/home-manager/alacritty.nix @@ -0,0 +1,31 @@ +{ config, lib, ... }: +with lib; + +let + cfg = config.custom-hm.alacritty; +in +{ + options.custom-hm.alacritty = { + enable = mkEnableOption "alacritty"; + }; + + config = mkIf cfg.enable { + programs.alacritty = { + enable = true; + settings = { + shell = { + program = config.programs.zellij.package + "/bin/zellij"; + args = [ + "attach" + "-c" + ]; + }; + font.size = 10.0; + window = { + resize_increments = true; + dynamic_padding = true; + }; + }; + }; + }; +} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 0e0dcd2..23f5c24 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,3 +1,12 @@ { - + imports = [ + ./alacritty.nix + ./direnv.nix + ./fish.nix + ./git.nix + ./tmux.nix + ./vim.nix + ./vscode.nix + ./zellij.nix + ]; } \ No newline at end of file diff --git a/modules/home-manager/direnv.nix b/modules/home-manager/direnv.nix new file mode 100644 index 0000000..850534d --- /dev/null +++ b/modules/home-manager/direnv.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: +with lib; + +let + cfg = config.custom-hm.direnv; +in +{ + options.custom-hm.direnv = { + enable = mkEnableOption "direnv"; + }; + config = { + programs = mkIf config.custom-hm.direnv.enable { + direnv = { + enable = true; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/home-manager/fish.nix b/modules/home-manager/fish.nix new file mode 100644 index 0000000..0b002e0 --- /dev/null +++ b/modules/home-manager/fish.nix @@ -0,0 +1,72 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.custom-hm.fish; +in +{ + options.custom-hm.fish = { + enable = mkEnableOption "fish"; + plugins = mkOption { + type = types.listOf types.str; + default = [ "pisces" "done" "hydro" ]; + }; + functions = { + enable = mkOption { + type = types.bool; + default = true; + }; + }; + alias = { + enable = mkOption { + type = types.bool; + default = true; + }; + }; + }; + + config = { + programs.fish = mkIf cfg.enable { + enable = true; + plugins = with pkgs; filter ( + e: hasAttr e.name (builtins.listToAttrs # { "xxx" = true; } + (map (p: { name = p; value = true; }) cfg.plugins) # { name = "xxx"; value = true; } + )) [ + { + name = "pisces"; + src = fishPlugins.pisces.src; + } + { + name = "done"; + src = fishPlugins.done.src; + } + { + name = "hydro"; + src = fishPlugins.hydro.src; + } + ]; + interactiveShellInit = let + extraInit = if cfg.functions.enable then '' + ${pkgs.nix-your-shell}/bin/nix-your-shell fish | source + function fish_right_prompt + if test -n "$IN_NIX_SHELL" + echo -n "" + else if test $SHLVL -ge 3 + echo -n "<🚀lv$SHLVL>" + end + end + function fish_command_not_found + ${pkgs.comma}/bin/comma $argv + end + '' else ""; + in '' + fish_config theme choose 'ayu Dark' + fish_config prompt choose arrow + '' + extraInit; + functions = mkIf cfg.functions.enable { + gitignore = "curl -sL https://www.gitignore.io/api/$argv"; + }; + }; + }; +} diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix new file mode 100644 index 0000000..2b19136 --- /dev/null +++ b/modules/home-manager/git.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.custom-hm.git; +in +{ + options.custom-hm.git = { + enable = mkEnableOption "Enable git configuration"; + }; + config = { + programs.git = { + enable = true; + delta.enable = true; + userName = "Xinyang Li"; + userEmail = "lixinyang411@gmail.com"; + aliases = { + graph = "log --all --oneline --graph --decorate"; + a = "add"; + d = "diff"; + s = "status"; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/home-manager/tmux.nix b/modules/home-manager/tmux.nix new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/modules/home-manager/tmux.nix @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/home-manager/vim.nix b/modules/home-manager/vim.nix new file mode 100644 index 0000000..d818132 --- /dev/null +++ b/modules/home-manager/vim.nix @@ -0,0 +1,43 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.custom-hm.neovim; +in +{ + options.custom-hm.neovim = { + enable = mkEnableOption "neovim configurations"; + }; + config = mkIf cfg.enable { + programs.neovim = { + enable = true; + vimAlias = true; + vimdiffAlias = true; + plugins = with pkgs.vimPlugins; [ + catppuccin-nvim + ]; + extraConfig = '' + set nocompatible + + syntax on + set number + set relativenumber + set shortmess+=I + set laststatus=2 + + set ignorecase + set smartcase + set list + set listchars=tab:→· + set tabstop=4 + set shiftwidth=4 + set expandtab + + set mouse+=a + + colorscheme catppuccin-macchiato + ''; + }; + }; +} diff --git a/modules/home-manager/vscode.nix b/modules/home-manager/vscode.nix new file mode 100644 index 0000000..dc9cbc1 --- /dev/null +++ b/modules/home-manager/vscode.nix @@ -0,0 +1,143 @@ +{ inputs, config, lib, pkgs, ... }: +with lib; + +let + cfg = config.custom-hm.vscode; +in +{ + options.custom-hm.vscode = { + enable = mkEnableOption "Vscode config"; + }; + config = mkIf cfg.enable { + home.packages = with pkgs; [ + pkgs.wl-clipboard-x11 + ]; + programs.vscode = { + enable = true; + enableUpdateCheck = false; + enableExtensionUpdateCheck = false; + mutableExtensionsDir = true; + extensions = (with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [ + mkhl.direnv + + bbenoist.nix + ms-azuretools.vscode-docker + ms-vscode-remote.remote-ssh + vscodevim.vim + github.vscode-pull-request-github + eamodio.gitlens + gruntfuggly.todo-tree # todo highlight + + # Language support + # Python + ms-python.python + # Markdown + davidanson.vscode-markdownlint + # C/C++ + ms-vscode.cmake-tools + llvm-vs-code-extensions.vscode-clangd + # Nix + jnoortheen.nix-ide + # Latex + james-yu.latex-workshop + # Vue + vue.volar + # Scale / chisel + scalameta.metals + + ms-vscode-remote.remote-ssh-edit + mushan.vscode-paste-image + ]) ++ (with pkgs.vscode-extensions; [ + # Rust + rust-lang.rust-analyzer + github.copilot + ]); + userSettings = { + "workbench.colorTheme" = "Default Dark+"; + "terminal.integrated.sendKeybindingsToShell" = true; + "extensions.ignoreRecommendations" = true; + "files.autoSave" = "afterDelay"; + "editor.inlineSuggest.enabled" = true; + "editor.rulers" = [ + 80 + ]; + "editor.mouseWheelZoom" = true; + "git.autofetch" = true; + "window.zoomLevel" = -1; + + "nix.enableLanguageServer" = true; + + "latex-workshop.latex.autoBuild.run" = "never"; + "latex-workshop.latex.tools" = [ + { + "name" = "xelatex"; + "command" = "xelatex"; + "args" = [ + "-synctex=1" + "-interaction=nonstopmode" + "-file-line-error" + "-pdf" + "%DOCFILE%" + ]; + } + { + "name" = "pdflatex"; + "command" = "pdflatex"; + "args" = [ + "-synctex=1" + "-interaction=nonstopmode" + "-file-line-error" + "%DOCFILE%" + ]; + } + { + "name" = "bibtex"; + "command" = "bibtex"; + "args" = [ + "%DOCFILE%" + ]; + } + ]; + "latex-workshop.latex.recipes" = [ + { + "name" = "xelatex"; + "tools" = [ + "xelatex" + ]; + } + { + "name" = "pdflatex"; + "tools" = [ + "pdflatex" + ]; + } + { + "name" = "xe->bib->xe->xe"; + "tools" = [ + "xelatex" + "bibtex" + "xelatex" + "xelatex" + ]; + } + { + "name" = "pdf->bib->pdf->pdf"; + "tools" = [ + "pdflatex" + "bibtex" + "pdflatex" + "pdflatex" + ]; + } + ]; + "[latex]" = { + "editor.formatOnPaste" = false; + "editor.suggestSelection" = "recentlyusedbyprefix"; + "editor.wordWrap" = "bounded"; + "editor.wordWrapColumn" = 80; + "editor.unicodeHighlight.ambiguousCharacters" = false; + }; + }; + }; + }; +} diff --git a/modules/home-manager/zellij.nix b/modules/home-manager/zellij.nix new file mode 100644 index 0000000..16fa32f --- /dev/null +++ b/modules/home-manager/zellij.nix @@ -0,0 +1,40 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.custom-hm.zellij; +in +{ + options.custom-hm.zellij = { + enable = mkEnableOption "zellij configurations"; + }; + config = { + programs.zellij = mkIf cfg.enable { + enable = true; + settings = { + default_shell = "fish"; + keybinds = { + unbind = [ + "Ctrl p" + "Ctrl n" + ]; + }; + theme = "catppuccin-macchiato"; + themes.dracula = { + fg = [ 248 248 242 ]; + bg = [ 40 42 54 ]; + black = [ 0 0 0 ]; + red = [ 255 85 85 ]; + green = [ 80 250 123 ]; + yellow = [ 241 250 140 ]; + blue = [ 98 114 164 ]; + magenta = [ 255 121 198 ]; + cyan = [ 139 233 253 ]; + white = [ 255 255 255 ]; + orange = [ 255 184 108 ]; + }; + }; + }; + }; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index e89ad69..f963802 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -4,5 +4,6 @@ ./restic.nix ./vaultwarden.nix ./prometheus.nix + ./hedgedoc.nix ]; -} \ No newline at end of file +} diff --git a/modules/nixos/hedgedoc.nix b/modules/nixos/hedgedoc.nix new file mode 100644 index 0000000..934420d --- /dev/null +++ b/modules/nixos/hedgedoc.nix @@ -0,0 +1,83 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.custom.hedgedoc; +in +{ + options = { + custom.hedgedoc = { + enable = mkEnableOption "HedgeDoc Markdown Editor"; + domain = mkOption { + type = types.str; + default = "docs.example.com"; + description = "Domain name of the HedgeDoc server"; + }; + caddy = mkOption { + type = types.bool; + default = true; + description = "Enable Caddy as reverse proxy"; + }; + mediaPath = mkOption { + type = types.path; + default = /var/lib/hedgedoc/uploads; + description = "Directory for storing medias"; + }; + oidc = { + enable = mkEnableOption "OIDC support for HedgeDoc"; + baseURL = mkOption { + type = types.str; + }; + authorizationURL = mkOption { + type = types.str; + }; + tokenURL = mkOption { + type = types.str; + }; + userProfileURL = mkOption { + type = types.str; + }; + }; + environmentFile = mkOption { + type = types.path; + }; + }; + }; + config = { + services.hedgedoc = mkIf cfg.enable { + enable = true; + environmentFile = cfg.environmentFile; + settings = { + domain = cfg.domain; + protocolUseSSL = cfg.caddy; + uploadsPath = cfg.mediaPath; + path = "/run/hedgedoc/hedgedoc.sock"; + email = false; + allowEmailRegister = false; + oauth2 = mkIf cfg.oidc.enable { + baseURL = cfg.oidc.baseURL; + authorizationURL = cfg.oidc.authorizationURL; + tokenURL = cfg.oidc.tokenURL; + userProfileURL = cfg.oidc.userProfileURL; + userProfileEmailAttr = "email"; + userProfileUsernameAttr = "name"; + userProfileDisplayNameAttr = "preferred_name"; + scope = "openid email profile"; + clientID = "$HEDGEDOC_CLIENT_ID"; + clientSecret = "$HEDGEDOC_CLIENT_SECRET"; + }; + allowAnonymous = false; + defaultPermission = "private"; + }; + }; + services.caddy = mkIf ( cfg.enable && cfg.enable ) { + enable = true; + virtualHosts."https://${cfg.domain}".extraConfig = '' + reverse_proxy unix/${config.services.hedgedoc.settings.path} + ''; + }; + users.users.caddy.extraGroups = mkIf ( cfg.enable && cfg.enable ) [ "hedgedoc" ]; + + }; +}