diff --git a/flake.lock b/flake.lock index 8c272eb..b178f67 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,38 @@ { "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1731323744, + "narHash": "sha256-SxUQm4cTHcaoPQHoXe26ZV8cZiMWBGow8MjE4L+MckM=", + "owner": "Homebrew", + "repo": "brew", + "rev": "254bf3fe9d8fa2e1b2fb55dbcf535b2d870180c4", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.4.5", + "repo": "brew", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -57,6 +90,85 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737504076, + "narHash": "sha256-/B4XJnzYU/6K1ZZOBIgsa3K4pqDJrnC2579c44c+4rI=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "65cc1fa8e36ceff067daf6cfb142331f02f524d3", + "type": "github" + }, + "original": { + "owner": "LnL7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-darwin_2": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1716329735, + "narHash": "sha256-ap51w+VqG21vuzyQ04WrhI2YbWHd3UGz0e7dc/QQmoA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "eac4f25028c1975a939c8f8fba95c12f8a25e01c", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src", + "nix-darwin": "nix-darwin_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1736041957, + "narHash": "sha256-Kk/cVtkxwfHNoB6nINUarMLTtyAEvH+ohzxKBptMzzg=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "a6d99cc7436fc18c097b3536d9c45c0548c694c8", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1736095716, + "narHash": "sha256-csysw/Szu98QDiA2lhWk9seYOyCebeVEWL89zh1cduM=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "63c3b4ed1712a3a0621002cd59bfdc80875ecbb0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "main", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1737110817, @@ -74,6 +186,51 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "path": "/nix/store/22qgs3skscd9bmrxv9xv4q5d4wwm5ppx-source", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1733384649, + "narHash": "sha256-K5DJ2LpPqht7K76bsxetI+YHhGGRyVteTPRQaIIKJpw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "190c31a89e5eec80dd6604d7f9e5af3802a58a13", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1736883708, "narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=", @@ -93,7 +250,10 @@ "inputs": { "home-manager": "home-manager", "neovim": "neovim", - "nixpkgs": "nixpkgs_2" + "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", + "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_5" } }, "systems": { diff --git a/flake.nix b/flake.nix index fbf0845..5fb5769 100644 --- a/flake.nix +++ b/flake.nix @@ -1,79 +1,149 @@ { - description = "LarssonMartin1998's dotfiles configured with Home Manager"; + description = "LarssonMartin1998's dotfiles configured with Home Manager"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - nix-darwin.url = "github:LnL7/nix-darwin/master"; - nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; - }; - - neovim = { - url = "github:LarssonMartin1998/neovim-flake"; - }; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = + nix-darwin = { + url = "github:LnL7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; + neovim.url = "github:LarssonMartin1998/neovim-flake"; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + }; + + outputs = { - nixpkgs, - home-manager, - neovim, - ... + self, + nixpkgs, + home-manager, + nix-darwin, + nixos-wsl, + neovim, + nix-homebrew, + ... }: let - lib = nixpkgs.lib; + lib = nixpkgs.lib; - makeHomeConfig = + makeSystemConfig = { - name, - system, - extraModules ? [ ], + name, + system, + builder, + extraModules ? [ ], + specialArgs ? { }, + }: + builder { + inherit system; + pkgs = import nixpkgs { inherit system; }; + modules = [ + { + nix.settings.experimental-features = "nix-command flakes"; + } + ./nix/local_system.nix + ] ++ extraModules; + + specialArgs = specialArgs; + }; + + makeHomeConfig = + { + name, + system, + extraModules ? [ ], }: home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { inherit system; }; - modules = - [ - ./nix/home.nix - ./nix/local_machine.nix - ] - ++ extraModules - ++ lib.optional (builtins.match ".*-darwin$" system != null) ./nix/darwin.nix - ++ lib.optional (builtins.match ".*-linux$" system != null) ./nix/linux.nix; + pkgs = import nixpkgs { inherit system; }; + modules = [ + ./nix/pkgs/home.nix + ./nix/local_home.nix + ] ++ extraModules; - # Pass neovim-flake to all modules - extraSpecialArgs = { - neovim-flake = neovim; - }; + # Pass neovim-flake to all modules + extraSpecialArgs = { + neovim-flake = neovim; + }; }; in { - homeConfigurations = { - "wsl" = makeHomeConfig { - name = "wsl"; - system = "x86_64-linux"; - extraModules = [ ./nix/wsl.nix ]; - }; - - "linux-x86" = makeHomeConfig { - name = "linux-x86"; - system = "x86_64-linux"; - extraModules = []; - }; - - "linux-aarch64" = makeHomeConfig { - name = "linux-aarch64"; - system = "aarch64-linux"; - extraModules = []; - }; - - "darwin-aarch64" = makeHomeConfig { - name = "darwin-aarch64"; - system = "aarch64-darwin"; - extraModules = []; - }; + nixosConfigurations = { + "wsl" = makeSystemConfig { + name = "wsl"; + system = "x86_64-linux"; + builder = lib.nixosSystem; + extraModules = [ ./nix/system/wsl.nix ]; + specialArgs = { + nixos-wsl = nixos-wsl; + }; }; + + "linux-x86" = makeSystemConfig { + name = "linux-x86"; + system = "x86_64-linux"; + builder = lib.nixosSystem; + extraModules = [ ./nix/system/linux.nix ]; + }; + + "linux-aarch" = makeSystemConfig { + name = "linux-aarch"; + system = "aarch64-linux"; + builder = lib.nixosSystem; + extraModules = [ ./nix/system/linux.nix ]; + }; + }; + + darwinConfigurations."darwin" = makeSystemConfig { + name = "darwin"; + system = "aarch64-darwin"; + builder = nix-darwin.lib.darwinSystem; + extraModules = [ + ./nix/system/darwin.nix + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + enableRosetta = true; + }; + } + ]; + specialArgs = { + self = self; + nix-homebrew = nix-homebrew; + }; + }; + + homeConfigurations = { + "wsl" = makeHomeConfig { + name = "wsl"; + system = "x86_64-linux"; + extraModules = [ ./nix/pkgs/wsl.nix ]; + }; + + "linux-x86" = makeHomeConfig { + name = "linux-x86"; + system = "x86_64-linux"; + extraModules = [ ./nix/pkgs/linux.nix ]; + }; + + "linux-aarch" = makeHomeConfig { + name = "linux-aarch"; + system = "aarch64-linux"; + extraModules = [ ./nix/pkgs/linux.nix ]; + }; + + "darwin" = makeHomeConfig { + name = "darwin"; + system = "aarch64-darwin"; + extraModules = [ ./nix/pkgs/darwin.nix ]; + }; + }; }; } diff --git a/nix/darwin.nix b/nix/darwin.nix deleted file mode 100644 index 62143aa..0000000 --- a/nix/darwin.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, ... }: { - home = { - packages = with pkgs; [ - ghostty - - ]; - file = { - ".config/ghostty".source = ../ghostty; - }; - }; -} diff --git a/nix/home.nix b/nix/home.nix deleted file mode 100644 index c6a5a63..0000000 --- a/nix/home.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ pkgs, neovim-flake, ... }: { - programs = { - zsh = { - enable = true; - }; - }; - - home = { - stateVersion = "24.05"; - packages = with pkgs; [ - neovim-flake.packages.${system}.neovim - fzf - bat - git - yazi - tmux - eza - curl - wget - ripgrep - fd - jq - starship - fastfetch - clang - clang-tools - nixfmt-rfc-style - luajit - zoxide - rustup - zig - zls - nil - lldb - gopls - delve - golangci-lint - cmake - cmake-language-server - cmake-format - cmake-lint - python313Packages.debugpy - pyright - lua-language-server - gnumake - ninja - ]; - file = { - ".zshrc".source = ../zsh/.zshrc; - ".config/nvim".source = ../nvim; - ".config/yazi".source = ../yazi; - ".config/starship.toml".source = ../starship/starship.toml; - ".tmux.conf".source = ../tmux/.tmux.conf; - ".config/tmux".source = ../tmux; - ".config/bat".source = ../bat; - ".config/ghostty".source = ../ghostty; - ".config/confutils".source = ../confutils; - ".config/wallpapers".source = ../wallpapers; - }; - }; -} diff --git a/nix/local_home.nix b/nix/local_home.nix new file mode 100644 index 0000000..6331a1d --- /dev/null +++ b/nix/local_home.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + # local_home.nix + # This is a template file that is committed to git with minimal changes. + # In order to use this and remain pure, each machine needs to create a local branch, i.e `machine-wsl` and set these variables + # accordingly, and then commit it. + home = { + # Stub values for demonstration. Override these in local branch. + username = "JohnDoe"; + homeDirectory = "/home/johndoe"; + }; +} diff --git a/nix/local_machine.nix b/nix/local_machine.nix deleted file mode 100644 index bae0eda..0000000 --- a/nix/local_machine.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: { - # local-machine.nix - # This is a template file that is committed to git with minimal changes. - # In order to use this and remain pure, each machine needs to create a local branch, i.e `machine-wsl` and set these variables - # accordingly, and then commit it. - home = { - # Stub values for demonstration. Override these in local branch. - username = "nixos"; - homeDirectory = "/home/nixos"; - }; -} diff --git a/nix/local_system.nix b/nix/local_system.nix new file mode 100644 index 0000000..cab669e --- /dev/null +++ b/nix/local_system.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + self, + nix-homebrew, + ... +}: +{ + system = { + stateVersion = 5; + }; + + nix-homebrew.user = "larssonmartin1998-mac"; +} diff --git a/nix/pkgs/darwin.nix b/nix/pkgs/darwin.nix new file mode 100644 index 0000000..623d679 --- /dev/null +++ b/nix/pkgs/darwin.nix @@ -0,0 +1,10 @@ +{ pkgs, homebrew, ... }: +{ + home = { + packages = with pkgs; [ + gawk + ]; + file = { + }; + }; +} diff --git a/nix/pkgs/home.nix b/nix/pkgs/home.nix new file mode 100644 index 0000000..3262a1a --- /dev/null +++ b/nix/pkgs/home.nix @@ -0,0 +1,68 @@ +{ + pkgs, + neovim-flake, + ... +}: +{ + programs = { + zsh = { + enable = true; + }; + }; + + home = { + stateVersion = "24.05"; + packages = with pkgs; [ + neovim-flake.packages.${system}.neovim + fzf + bat + git + yazi + tmux + eza + curl + wget + ripgrep + fd + jq + starship + fastfetch + clang + clang-tools + nixfmt-rfc-style + luajit + zoxide + rustup + zig + zls + nil + lldb + gopls + delve + golangci-lint + cmake + cmake-language-server + cmake-format + cmake-lint + python313Packages.debugpy + pyright + lua-language-server + gnumake + ninja + tldr + nerd-fonts.caskaydia-mono + ]; + file = { + ".zshrc".source = ../../zsh/.zshrc; + ".config/nvim".source = ../../nvim; + ".config/yazi".source = ../../yazi; + ".config/starship.toml".source = ../../starship/starship.toml; + ".tmux.conf".source = ../../tmux/.tmux.conf; + ".config/tmux".source = ../../tmux; + ".config/bat".source = ../../bat; + ".config/ghostty".source = ../../ghostty; + ".config/confutils".source = ../../confutils; + ".config/wallpapers".source = ../../wallpapers; + }; + }; +} diff --git a/nix/linux.nix b/nix/pkgs/linux.nix similarity index 100% rename from nix/linux.nix rename to nix/pkgs/linux.nix diff --git a/nix/wsl.nix b/nix/pkgs/wsl.nix similarity index 100% rename from nix/wsl.nix rename to nix/pkgs/wsl.nix diff --git a/nix/system/darwin.nix b/nix/system/darwin.nix new file mode 100644 index 0000000..0d745fd --- /dev/null +++ b/nix/system/darwin.nix @@ -0,0 +1,58 @@ +{ + pkgs, + config, + self, + ... +}: +{ + system.configurationRevision = self.rev or self.dirtyRev or null; + + environment.systemPackages = with pkgs; [ + home-manager + mkalias + ]; + + homebrew = { + enable = true; + casks = [ + "ghostty" + ]; + brews = [ + "mas" + ]; + masApps = { }; + onActivation.cleanup = "zap"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; + }; + + system.defaults = { + dock.autohide = true; + finder.FXPreferredViewStyle = "clmv"; + loginwindow.GuestEnabled = false; + NSGlobalDomain.AppleICUForce24HourTime = true; + NSGlobalDomain.AppleInterfaceStyle = "Dark"; + NSGlobalDomain.KeyRepeat = 2; + }; + + system.activationScripts.applications.text = + let + env = pkgs.buildEnv { + name = "system-applications"; + paths = config.environment.systemPackages; + pathsToLink = "/Applications"; + }; + in + pkgs.lib.mkForce '' + # Set up applications + echo "setting up /Applications..." >&2 + rm -rf /Applications/Nix\ Apps + mkdir -p /Applications/Nix\ Apps + find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + | + while read -r src; do + app_name=$(basename "$src") + echo "copying $src" >&2 + ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name" + done + ''; +} diff --git a/nix/system/linux.nix b/nix/system/linux.nix new file mode 100644 index 0000000..4b2c5c4 --- /dev/null +++ b/nix/system/linux.nix @@ -0,0 +1,2 @@ +{ ... }: { +} diff --git a/nix/system/wsl.nix b/nix/system/wsl.nix new file mode 100644 index 0000000..db28fae --- /dev/null +++ b/nix/system/wsl.nix @@ -0,0 +1,7 @@ +{ nixos-wsl, ... }: { + imports = [ + nixosWSL.nixosModules.default + ]; + + wsl.enable = true; +} diff --git a/nvim/lua/lsp/servers/nil.lua b/nvim/lua/lsp/servers/nil.lua index c5e65f2..4286aa2 100644 --- a/nvim/lua/lsp/servers/nil.lua +++ b/nvim/lua/lsp/servers/nil.lua @@ -12,4 +12,10 @@ return { }, }, }, + on_attach = function(_, bufnr) + vim.notify("TJENA BBY") + vim.bo[bufnr].tabstop = 2 + vim.bo[bufnr].shiftwidth = 2 + vim.bo[bufnr].softtabstop = 2 + end }