From 55b15b92ffccc00a8a2774bfb079baed8b854687 Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Thu, 16 May 2024 15:39:29 +0200 Subject: [PATCH] refactor and add nixvim module --- .config/nvim/init.lua | 1 + flake.lock | 296 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 121 +++++++---------- users/anon/home.nix | 1 + users/kopatz/home.nix | 1 + users/vm/home.nix | 1 + 6 files changed, 346 insertions(+), 75 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 14c0468..9536eca 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -478,6 +478,7 @@ local servers = { jdtls = {}, vtsls = {}, clangd = {}, + gopls = {}, lua_ls = { Lua = { diff --git a/flake.lock b/flake.lock index 018d1e5..bce521f 100644 --- a/flake.lock +++ b/flake.lock @@ -59,6 +59,28 @@ "type": "github" } }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -91,6 +113,72 @@ "type": "github" } }, + "flake-compat_3": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714641030, + "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1713493429, + "narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", + "owner": "srid", + "repo": "flake-root", + "rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems_2" @@ -109,6 +197,64 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -172,6 +318,27 @@ "type": "github" } }, + "home-manager_3": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715486357, + "narHash": "sha256-4pRuzsHZOW5W4CsXI9uhKtiJeQSUoe1d2M9mWU98HC4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "44677a1c96810a8e8c4ffaeaad10c842402647c1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", @@ -191,6 +358,27 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713946171, + "narHash": "sha256-lc75rgRQLdp4Dzogv5cfqOg6qYc5Rp83oedF2t0kDp8=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "230a197063de9287128e2c68a7a4b0cd7d0b50a7", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nixos-cosmic": { "inputs": { "flake-compat": "flake-compat", @@ -312,6 +500,34 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts", + "flake-root": "flake-root", + "home-manager": "home-manager_3", + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1715807613, + "narHash": "sha256-3kL4E0Ff9TCvRNxwINzklupY7dcTpl89jTg0PGfBCJc=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "6be28a941b39a7cbe4d34b577bd095548f5d1e15", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 1715611234, @@ -327,6 +543,34 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_3", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714478972, + "narHash": "sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "2849da033884f54822af194400f8dff435ada242", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -338,6 +582,7 @@ "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable", + "nixvim": "nixvim", "nur": "nur" } }, @@ -370,6 +615,57 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714058656, + "narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 935d72c..e141d18 100644 --- a/flake.nix +++ b/flake.nix @@ -1,29 +1,33 @@ { description = "Kop's NixOS Flake"; inputs = { - # secrets management - agenix.url = "github:ryantm/agenix"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; - nixos-hardware.url = "github:NixOS/nixos-hardware/master"; - nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; - home-manager = { - url = "github:nix-community/home-manager/release-23.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - home-manager-unstable = { - url = "github:nix-community/home-manager/master"; - inputs.nixpkgs.follows = "nixpkgs-unstable"; - }; - nixos-wsl = { - url = "github:nix-community/NixOS-WSL"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - nix-colors.url = "github:misterio77/nix-colors"; - nur = { url = "github:nix-community/NUR"; }; - nixos-cosmic = { - url = "github:lilyinstarlight/nixos-cosmic"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # secrets management + agenix.url = "github:ryantm/agenix"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager/release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + home-manager-unstable = { + url = "github:nix-community/home-manager/master"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + nixos-wsl = { + url = "github:nix-community/NixOS-WSL"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nix-colors.url = "github:misterio77/nix-colors"; + nur = { url = "github:nix-community/NUR"; }; + nixos-cosmic = { + url = "github:lilyinstarlight/nixos-cosmic"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nur, @@ -36,55 +40,49 @@ home-manager-unstable, nix-colors, nixos-cosmic, + nixvim }@inputs: let inherit (self) outputs; system = "x86_64-linux"; + # helper function to create a machine + mkHost = ({modules, specialArgs ? { pkgsVersion = nixpkgs-unstable;}}: nixpkgs-unstable.lib.nixosSystem { + inherit system; + modules = modules ++ [ + ./modules + ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) + home-manager-unstable.nixosModules.home-manager + agenix.nixosModules.default + nixos-cosmic.nixosModules.default + ]; + specialArgs = specialArgs // { inherit inputs outputs;}; + }); in { overlays = import ./overlays.nix {inherit inputs;}; - nixosConfigurations.server = nixpkgs-unstable.lib.nixosSystem { - inherit system; + nixosConfigurations.server = mkHost { modules = [ - ./modules ./users/anon ./modules/collections/server.nix ./systems/server/configuration.nix - ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) - home-manager-unstable.nixosModules.home-manager - agenix.nixosModules.default - nixos-cosmic.nixosModules.default ]; specialArgs = { ## Custom variables (e.g. ip, interface, etc) vars = import ./systems/userdata-default.nix // import ./systems/server/userdata.nix; pkgsVersion = nixpkgs-unstable; - inherit inputs outputs; }; }; - nixosConfigurations."kop-pc" = nixpkgs-unstable.lib.nixosSystem { - inherit system; - specialArgs = { - pkgsVersion = nixpkgs-unstable; - inherit inputs outputs; - }; + nixosConfigurations."kop-pc" = mkHost { modules = [ - ./modules ./users/kopatz ./systems/pc/configuration.nix - ({ config, pkgs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) - agenix.nixosModules.default - nixos-cosmic.nixosModules.default - home-manager-unstable.nixosModules.home-manager ]; }; - nixosConfigurations."nix-laptop" = nixpkgs-unstable.lib.nixosSystem { - inherit system; + nixosConfigurations."nix-laptop" = mkHost { specialArgs = { ## Custom variables (e.g. ip, interface, etc) vars = import ./systems/userdata-default.nix // import ./systems/laptop/userdata.nix; pkgsVersion = nixpkgs-unstable; - inherit inputs outputs; inherit nix-colors; }; modules = [ @@ -92,7 +90,6 @@ ./users/kopatz ./systems/laptop/configuration.nix ./modules/collections/laptop.nix - ./modules ./modules/ecryptfs.nix ./modules/services/syncthing.nix ./modules/fh/scanning.nix @@ -103,61 +100,35 @@ #./modules/no-sleep-lid-closed.nix #./modules/static-ip.nix #./modules/wake-on-lan.nix - ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) - nixos-hardware.nixosModules.dell-xps-15-7590-nvidia - agenix.nixosModules.default - home-manager-unstable.nixosModules.home-manager - nixos-cosmic.nixosModules.default ]; }; - nixosConfigurations."mini-pc" = nixpkgs-unstable.lib.nixosSystem { - inherit system; + nixosConfigurations."mini-pc" = mkHost { specialArgs = { vars = import ./systems/userdata-default.nix; pkgsVersion = nixpkgs-unstable; - inherit inputs outputs; }; modules = [ - ./modules ./users/anon ./systems/mini-pc/configuration.nix - ({ config, pkgs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) - agenix.nixosModules.default - home-manager-unstable.nixosModules.home-manager - nixos-cosmic.nixosModules.default ]; }; # build vm -> nixos-rebuild build-vm --flake .#vm - nixosConfigurations."vm" = nixpkgs-unstable.lib.nixosSystem { - inherit system; + nixosConfigurations."vm" = mkHost { specialArgs = { vars = import ./systems/userdata-default.nix; pkgsVersion = nixpkgs-unstable; - inherit inputs outputs; }; modules = [ - ./modules ./users/vm ./systems/vm/configuration.nix - ({ config, pkgs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) - agenix.nixosModules.default - home-manager-unstable.nixosModules.home-manager ]; }; - nixosConfigurations."wsl" = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - pkgsVersion = nixpkgs-unstable; - }; + nixosConfigurations."wsl" = mkHost { modules = [ #"${nixpkgs}/nixos/modules/profiles/minimal.nix" ./users/anon ./modules/nix/settings.nix ./systems/wsl/configuration.nix - ({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; }) - nixos-wsl.nixosModules.wsl - home-manager.nixosModules.home-manager ]; }; }; diff --git a/users/anon/home.nix b/users/anon/home.nix index 7af933e..00dbcb0 100644 --- a/users/anon/home.nix +++ b/users/anon/home.nix @@ -17,6 +17,7 @@ ../../home-manager/gitconfig.nix ../../home-manager/zsh.nix ../../home-manager/direnv.nix + inputs.nixvim.homeManagerModules.nixvim inputs.nix-colors.homeManagerModule ]; diff --git a/users/kopatz/home.nix b/users/kopatz/home.nix index c08406a..58b9720 100644 --- a/users/kopatz/home.nix +++ b/users/kopatz/home.nix @@ -25,6 +25,7 @@ ../../home-manager/rofi.nix ../../home-manager/theme.nix ../../home-manager/zsh.nix + inputs.nixvim.homeManagerModules.nixvim inputs.nix-colors.homeManagerModule ]; diff --git a/users/vm/home.nix b/users/vm/home.nix index 78621bb..93302dd 100644 --- a/users/vm/home.nix +++ b/users/vm/home.nix @@ -7,6 +7,7 @@ imports = [ ../../home-manager/nvim.nix ../../home-manager/zsh.nix + inputs.nixvim.homeManagerModules.nixvim inputs.nix-colors.homeManagerModule ]; }