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 e15efa8..d4d7633 100644 --- a/flake.nix +++ b/flake.nix @@ -55,23 +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}; } - self.homeManagerModules ]; }; + 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; }; @@ -81,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 { @@ -166,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 67% rename from home/xin/calcite/default.nix rename to home/xin/calcite.nix index 544e438..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; @@ -35,10 +32,13 @@ remmina ]; - # custom-hm = { - # fish = { enable = true; }; - # git = { enable = true; }; - # neovim = { enable = true; }; - # zellij = { enable = true; }; - # }; + 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/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/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 6ab8a89..23f5c24 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,10 +1,12 @@ -{ config, pkgs, ... }: { 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 index 54dda10..0b002e0 100644 --- a/modules/home-manager/fish.nix +++ b/modules/home-manager/fish.nix @@ -6,7 +6,7 @@ let cfg = config.custom-hm.fish; in { - options = { + options.custom-hm.fish = { enable = mkEnableOption "fish"; plugins = mkOption { type = types.listOf types.str; @@ -30,9 +30,9 @@ in programs.fish = mkIf cfg.enable { enable = true; plugins = with pkgs; filter ( - e: hasAttr e.name builtins.listToAttrs # { "xxx" = true; } + 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; diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix index 2eefe65..2b19136 100644 --- a/modules/home-manager/git.nix +++ b/modules/home-manager/git.nix @@ -6,7 +6,7 @@ let cfg = config.custom-hm.git; in { - options = { + options.custom-hm.git = { enable = mkEnableOption "Enable git configuration"; }; config = { diff --git a/modules/home-manager/vim.nix b/modules/home-manager/vim.nix index 0c1f886..d818132 100644 --- a/modules/home-manager/vim.nix +++ b/modules/home-manager/vim.nix @@ -6,7 +6,7 @@ let cfg = config.custom-hm.neovim; in { - options = { + options.custom-hm.neovim = { enable = mkEnableOption "neovim configurations"; }; config = mkIf cfg.enable { 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 index b795130..16fa32f 100644 --- a/modules/home-manager/zellij.nix +++ b/modules/home-manager/zellij.nix @@ -6,7 +6,7 @@ let cfg = config.custom-hm.zellij; in { - options = { + options.custom-hm.zellij = { enable = mkEnableOption "zellij configurations"; }; config = {