diff --git a/flake.lock b/flake.lock index 06a254c..1bf1602 100644 --- a/flake.lock +++ b/flake.lock @@ -674,6 +674,27 @@ "type": "github" } }, + "morlana": { + "inputs": { + "nix-filter": "nix-filter", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729339890, + "narHash": "sha256-bsJo2HOytazKnsg608X6LXwZ+BiUkemgFs8OBr9VRDo=", + "owner": "ryanccn", + "repo": "morlana", + "rev": "b7628870e394cc91baced64f9849ab4fe1d3030e", + "type": "github" + }, + "original": { + "owner": "ryanccn", + "repo": "morlana", + "type": "github" + } + }, "nix": { "inputs": { "flake-compat": "flake-compat_2", @@ -707,11 +728,11 @@ ] }, "locked": { - "lastModified": 1713946171, - "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", + "lastModified": 1730448474, + "narHash": "sha256-qE/cYKBhzxHMtKtLK3hlSR3uzO1pWPGLrBuQK7r0CHc=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", + "rev": "683d0c4cd1102dcccfa3f835565378c7f3cbe05e", "type": "github" }, "original": { @@ -741,6 +762,21 @@ "type": "github" } }, + "nix-filter": { + "locked": { + "lastModified": 1710156097, + "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3342559a24e85fc164b295c3444e8a139924675b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nix-formatter-pack": { "inputs": { "nixpkgs": [ @@ -1349,6 +1385,7 @@ "flake-parts": "flake-parts", "haumea": "haumea", "home-manager": "home-manager", + "morlana": "morlana", "nix-darwin": "nix-darwin", "nix-index-database": "nix-index-database", "nix-on-droid": "nix-on-droid", diff --git a/flake.nix b/flake.nix index 0e8655c..f47ce04 100644 --- a/flake.nix +++ b/flake.nix @@ -156,5 +156,9 @@ # Nix on my phone nix-on-droid.url = "github:nix-community/nix-on-droid/master"; nix-on-droid.inputs.nixpkgs.follows = "nixpkgs"; + + # Nice CLI for deploying Nix on Darwin + morlana.url = "github:ryanccn/morlana"; + morlana.inputs.nixpkgs.follows = "nixpkgs"; }; } diff --git a/src/darwinConfigurations/magnesium.nix b/src/darwinConfigurations/magnesium.nix new file mode 100644 index 0000000..64dd922 --- /dev/null +++ b/src/darwinConfigurations/magnesium.nix @@ -0,0 +1,9 @@ +{ + root, + inputs, + ... +}: +inputs.nix-darwin.lib.darwinSystem { + modules = [root.nixosModules.machines.magnesium.default]; + specialArgs = {}; +} diff --git a/src/devShells/deploy.nix b/src/devShells/deploy.nix index e305f17..150f109 100644 --- a/src/devShells/deploy.nix +++ b/src/devShells/deploy.nix @@ -19,9 +19,11 @@ packages = [ inputs'.colmena.packages.colmena inputs'.ragenix.packages.default + inputs'.morlana.packages.default config.packages.deploy + pkgs.git pkgs.nurl pkgs.nix-init pkgs.nushell @@ -32,6 +34,7 @@ pkgs.little_boxes (root.packages.agedit {inherit pkgs;}) + (root.packages.neovim {inherit pkgs;}) ]; pre-commit = { diff --git a/src/homeModules/users/giodamelio-darwin.nix b/src/homeModules/users/giodamelio-darwin.nix index 711a207..1895662 100644 --- a/src/homeModules/users/giodamelio-darwin.nix +++ b/src/homeModules/users/giodamelio-darwin.nix @@ -15,6 +15,17 @@ root.homeModules.nix-index + # Setup ssh with the secure enclave + (_: { + programs.ssh = { + enable = true; + extraConfig = '' + AddKeysToAgent yes + UseKeychain yes + ''; + }; + }) + # This is only necessary until I get the setup working and add it per repo (_: { programs.git.ignores = [ diff --git a/src/homeModules/zsh.nix b/src/homeModules/zsh.nix index 200ef05..70e1d79 100644 --- a/src/homeModules/zsh.nix +++ b/src/homeModules/zsh.nix @@ -1,7 +1,16 @@ -_: _: { +_: { + lib, + pkgs, + ... +}: { programs.zsh = { enable = true; enableCompletion = true; + + # Setup Homebrew path on MacOS + initExtra = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin '' + eval "$(/opt/homebrew/bin/brew shellenv)" + ''; }; programs.zoxide = { diff --git a/src/nixosModules/basic-packages.nix b/src/nixosModules/basic-packages.nix index 5406d2c..8fc3f70 100644 --- a/src/nixosModules/basic-packages.nix +++ b/src/nixosModules/basic-packages.nix @@ -1,4 +1,8 @@ -{root, ...}: {pkgs, ...}: let +{root, ...}: { + pkgs, + lib, + ... +}: let customNeovim = root.packages.neovim {inherit pkgs;}; open-ports = pkgs.writeShellApplication { name = "open-ports"; @@ -22,7 +26,7 @@ in { htop # Better top tree # I always want this... zellij # Kinda like Tmux - usbutils # For lsusb command + # usbutils # For lsusb command git file @@ -43,12 +47,7 @@ in { rage # Easy encryption cachix # Nix binary caching + devenv # Easy development environment management ]; }; - - programs.neovim = { - enable = true; - vimAlias = true; - viAlias = true; - }; } diff --git a/src/nixosModules/machines/magnesium/default.nix b/src/nixosModules/machines/magnesium/default.nix new file mode 100644 index 0000000..b5b8420 --- /dev/null +++ b/src/nixosModules/machines/magnesium/default.nix @@ -0,0 +1,59 @@ +{ + super, + root, + ... +}: {lib, ...}: { + imports = [ + super.home-manager + super.gui-apps + # super.ruby + # super.homebrew + + root.nixosModules.basic-packages + root.nixosModules.core.modern-coreutils-replacements + root.nixosModules.services.atuin + + # Keybinding stuff + (_: { + system.keyboard = { + enableKeyMapping = true; + remapCapsLockToEscape = true; + swapLeftCtrlAndFn = true; + }; + }) + + (_: { + # Allow unfree software + nixpkgs.config.allowUnfree = true; + + # Enable Nix command and Flakes + nix = { + settings = { + extra-experimental-features = ["nix-command" "flakes"]; + extra-nix-path = "nixpkgs=flake:nixpkgs"; + trusted-users = lib.mkAfter [ + "giodamelio" + ]; + + # Add Devenv cachix substituter + substituters = lib.mkAfter [ + "https://devenv.cachix.org" + ]; + trusted-public-keys = lib.mkAfter [ + "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" + ]; + }; + }; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + + # Run the Nix Daemon + services.nix-daemon.enable = true; + + # Make sure we get packages from the right arch + nixpkgs.hostPlatform = "aarch64-darwin"; + }) + ]; +} diff --git a/src/nixosModules/machines/magnesium/gui-apps.nix b/src/nixosModules/machines/magnesium/gui-apps.nix new file mode 100644 index 0000000..d096fad --- /dev/null +++ b/src/nixosModules/machines/magnesium/gui-apps.nix @@ -0,0 +1,20 @@ +_: {pkgs, ...}: { + environment.systemPackages = with pkgs; [ + wezterm + raycast + ]; + + homebrew = { + enable = true; + onActivation.cleanup = "uninstall"; + + taps = []; + brews = []; + casks = [ + "firefox" + "firefox@developer-edition" + "whatsapp" + "sekey" + ]; + }; +} diff --git a/src/nixosModules/machines/magnesium/home-manager.nix b/src/nixosModules/machines/magnesium/home-manager.nix new file mode 100644 index 0000000..89879ac --- /dev/null +++ b/src/nixosModules/machines/magnesium/home-manager.nix @@ -0,0 +1,21 @@ +{ + root, + inputs, + ... +}: _: { + imports = [ + inputs.home-manager.darwinModules.home-manager + ]; + + config = { + # This is very important to make Nix Darwin and Home Manager work togather + programs.zsh.enable = true; + + users.users.giodamelio = { + home = "/Users/giodamelio"; + }; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.giodamelio = root.homeModules.users.giodamelio-darwin; + }; +} diff --git a/src/packages/_neovim_lua/lsp.lua b/src/packages/_neovim_lua/lsp.lua index 2d3b11d..3d7d2fe 100644 --- a/src/packages/_neovim_lua/lsp.lua +++ b/src/packages/_neovim_lua/lsp.lua @@ -50,7 +50,7 @@ cmp.setup({ sources = cmp.config.sources({ { name = 'path' }, { name = 'nvim_lsp', keyword_length = 2 }, - { name = 'luasnip', keyword_length = 3 }, + { name = 'luasnip', keyword_length = 3 }, }, { { name = 'buffer', keyword_length = 4 }, }), @@ -79,7 +79,7 @@ cmp.setup.cmdline(':', { -- Set the default capabilities local lsp_defaults = lspconfig.util.default_config lsp_defaults.capabilities = - vim.tbl_deep_extend('force', lsp_defaults.capabilities, require('cmp_nvim_lsp').default_capabilities()) + vim.tbl_deep_extend('force', lsp_defaults.capabilities, require('cmp_nvim_lsp').default_capabilities()) -- Attach navic lsp_defaults.on_attach = function(client, bufnr) @@ -153,7 +153,7 @@ lspconfig.yamlls.setup({ }, }) lspconfig.emmet_ls.setup({ - filetypes = { 'css', 'html', 'javascript', 'heex' }, + filetypes = { 'css', 'html', 'javascript', 'heex', 'htmldjango' }, }) -- lspconfig.elixirls.setup({ -- cmd = { os.getenv('ELIXIRLS_CMD') }, @@ -170,3 +170,11 @@ lspconfig.rust_analyzer.setup({ }, }, }) + +-- Setup html language server +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true +require 'lspconfig'.html.setup({ + capabilities = capabilities, + filetypes = { 'html', 'heex', 'htmldjango', 'templ' }, +})