From c3ddd5d3fa2b1b9bed39df8f896ae7d88a16f8a5 Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Tue, 5 Aug 2025 21:54:18 +0200 Subject: [PATCH] nvim stuff --- flake.lock | 36 ++++- flake.nix | 147 ++++++++++-------- hosts/nixos/{ => tahani}/default.nix | 4 +- lib/systems.nix | 91 ----------- profiles/base/home-manager/neovim/default.nix | 2 +- profiles/base/home-manager/neovim/options.nix | 6 + .../base/home-manager/neovim/plugins/mini.nix | 5 + .../home-manager/neovim/plugins/which-key.nix | 5 - profiles/base/home-manager/zellij.nix | 1 + 9 files changed, 135 insertions(+), 162 deletions(-) rename hosts/nixos/{ => tahani}/default.nix (97%) delete mode 100644 lib/systems.nix create mode 100644 profiles/base/home-manager/neovim/options.nix delete mode 100644 profiles/base/home-manager/neovim/plugins/which-key.nix diff --git a/flake.lock b/flake.lock index 907f9fc..0bf4026 100644 --- a/flake.lock +++ b/flake.lock @@ -102,6 +102,24 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1754091436, + "narHash": "sha256-XKqDMN1/Qj1DKivQvscI4vmHfDfvYR2pfuFOJiCeewM=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "67df8c627c2c39c41dbec76a1f201929929ab0bd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nixvim", @@ -289,6 +307,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1753579242, + "narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1753939845, @@ -339,7 +372,7 @@ }, "nixvim": { "inputs": { - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs_4", "nuschtosSearch": "nuschtosSearch", "systems": "systems_3" @@ -386,6 +419,7 @@ "agenix": "agenix", "darwin": "darwin_2", "disko": "disko", + "flake-parts": "flake-parts", "home-manager": "home-manager_2", "homebrew-bundle": "homebrew-bundle", "homebrew-cask": "homebrew-cask", diff --git a/flake.nix b/flake.nix index 5f9fdd8..a806569 100644 --- a/flake.nix +++ b/flake.nix @@ -1,91 +1,114 @@ { description = "Configuration for my macOS laptops and NixOS server"; + inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; agenix.url = "github:ryantm/agenix"; home-manager.url = "github:nix-community/home-manager"; darwin = { url = "github:LnL7/nix-darwin/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - nix-homebrew = { - url = "github:zhaofengli-wip/nix-homebrew"; - }; - homebrew-bundle = { - url = "github:homebrew/homebrew-bundle"; - flake = false; - }; - homebrew-core = { - url = "github:homebrew/homebrew-core"; - flake = false; - }; - homebrew-cask = { - url = "github:homebrew/homebrew-cask"; - flake = false; - }; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + homebrew-bundle.url = "github:homebrew/homebrew-bundle"; + homebrew-core.url = "github:homebrew/homebrew-core"; + homebrew-cask.url = "github:homebrew/homebrew-cask"; disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; }; - nixvim = { - url = "github:nix-community/nixvim"; - }; + nixvim.url = "github:nix-community/nixvim"; secrets = { url = "git+ssh://git@github.com/cschmatzler/nixos-config-secrets.git"; flake = false; }; }; - outputs = { - agenix, - darwin, - disko, - home-manager, - homebrew-bundle, - homebrew-cask, - homebrew-core, - nix-homebrew, - nixpkgs, - nixvim, - secrets, - self, - } @ inputs: let - systemLib = import ./lib/systems.nix inputs; - inherit - (systemLib) - systemConfigs - mkDarwinSystem - mkNixosSystem - mkApps - ; - inherit (systemConfigs) darwinHosts nixosHosts; - allSystems = [ - "x86_64-linux" - "aarch64-darwin" - ]; - forAllSystems = f: nixpkgs.lib.genAttrs allSystems f; - devShell = system: let - pkgs = nixpkgs.legacyPackages.${system}; + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} (let + user = "cschmatzler"; + darwinHosts = builtins.attrNames (builtins.readDir ./hosts/darwin); + nixosHosts = builtins.attrNames (builtins.readDir ./hosts/nixos); in { - default = with pkgs; - mkShell { + systems = ["x86_64-linux" "aarch64-darwin"]; + + flake.darwinConfigurations = inputs.nixpkgs.lib.genAttrs darwinHosts (hostname: + inputs.darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = inputs // {inherit user hostname;}; + modules = [ + inputs.home-manager.darwinModules.home-manager + inputs.nix-homebrew.darwinModules.nix-homebrew + + { + nix-homebrew = { + inherit user; + enable = true; + taps = { + "homebrew/homebrew-core" = inputs.homebrew-core; + "homebrew/homebrew-cask" = inputs.homebrew-cask; + "homebrew/homebrew-bundle" = inputs.homebrew-bundle; + }; + mutableTaps = false; + autoMigrate = true; + }; + } + ./hosts/darwin/${hostname} + ]; + }); + + flake.nixosConfigurations = inputs.nixpkgs.lib.genAttrs nixosHosts (hostname: + inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = inputs // {inherit user hostname;}; + modules = [ + inputs.disko.nixosModules.disko + inputs.home-manager.nixosModules.home-manager + ./hosts/nixos/${hostname} + ]; + }); + + perSystem = { + pkgs, + system, + inputs', + ... + }: let + mkApp = name: { + type = "app"; + program = "${(pkgs.writeShellScriptBin name '' + PATH=${pkgs.git}/bin:$PATH + echo "Running ${name} for ${system}" + exec ${inputs.self}/apps/${system}/${name} "$@" + '')}/bin/${name}"; + }; + + appNames = [ + "apply" + "build" + "build-switch" + "copy-keys" + "create-keys" + "check-keys" + "rollback" + ]; + in { + devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ bashInteractive git age age-plugin-yubikey ]; - shellHook = with pkgs; '' - export EDITOR=nvim - ''; + shellHook = ''export EDITOR=nvim''; }; - }; - in { - devShells = forAllSystems devShell; - apps = forAllSystems mkApps; - darwinConfigurations = nixpkgs.lib.genAttrs darwinHosts mkDarwinSystem; - nixosConfigurations = nixpkgs.lib.genAttrs nixosHosts ( - hostname: mkNixosSystem hostname "x86_64-linux" - ); - }; + + apps = builtins.listToAttrs (map (n: { + name = n; + value = mkApp n; + }) + appNames); + }; + }); } diff --git a/hosts/nixos/default.nix b/hosts/nixos/tahani/default.nix similarity index 97% rename from hosts/nixos/default.nix rename to hosts/nixos/tahani/default.nix index 4294ae8..13a3153 100644 --- a/hosts/nixos/default.nix +++ b/hosts/nixos/tahani/default.nix @@ -10,8 +10,8 @@ keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOk8iAnIaa1deoc7jw8YACPNVka1ZFJxhnU4G74TmS+p"]; in { imports = [ - ../../profiles/base - ../../profiles/nixos + ../../../profiles/base + ../../../profiles/nixos agenix.nixosModules.default ]; diff --git a/lib/systems.nix b/lib/systems.nix deleted file mode 100644 index 086d307..0000000 --- a/lib/systems.nix +++ /dev/null @@ -1,91 +0,0 @@ -{ - nixpkgs, - darwin, - home-manager, - nix-homebrew, - homebrew-bundle, - homebrew-core, - homebrew-cask, - disko, - nixvim, - self, - ... -} @ inputs: let - user = "cschmatzler"; - - mkApp = scriptName: system: { - type = "app"; - program = "${ - (nixpkgs.legacyPackages.${system}.writeScriptBin scriptName '' - #!/usr/bin/env bash - PATH=${nixpkgs.legacyPackages.${system}.git}/bin:$PATH - echo "Running ${scriptName} for ${system}" - exec ${self}/apps/${system}/${scriptName} "$@" - '') - }/bin/${scriptName}"; - }; -in { - mkDarwinSystem = hostname: - darwin.lib.darwinSystem { - system = "aarch64-darwin"; - specialArgs = - inputs - // { - inherit user; - }; - modules = [ - home-manager.darwinModules.home-manager - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - inherit user; - enable = true; - taps = { - "homebrew/homebrew-core" = homebrew-core; - "homebrew/homebrew-cask" = homebrew-cask; - "homebrew/homebrew-bundle" = homebrew-bundle; - }; - mutableTaps = false; - autoMigrate = true; - }; - } - ../hosts/darwin/${hostname} - ]; - }; - - mkNixosSystem = hostname: system: - nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = - inputs - // { - inherit hostname user; - }; - modules = [ - disko.nixosModules.disko - home-manager.nixosModules.home-manager - ../hosts/nixos - ]; - }; - - mkApps = system: let - appNames = [ - "apply" - "build" - "build-switch" - "copy-keys" - "create-keys" - "check-keys" - "rollback" - ]; - in - nixpkgs.lib.genAttrs appNames (name: mkApp name system); - - systemConfigs = { - darwinHosts = [ - "chidi" - "jason" - ]; - nixosHosts = ["tahani"]; - }; -} diff --git a/profiles/base/home-manager/neovim/default.nix b/profiles/base/home-manager/neovim/default.nix index cae7b67..8a07d5c 100644 --- a/profiles/base/home-manager/neovim/default.nix +++ b/profiles/base/home-manager/neovim/default.nix @@ -1,11 +1,11 @@ {pkgs, ...}: { imports = [ + ./options.nix ./autocmd.nix ./plugins/conform.nix ./plugins/mini.nix ./plugins/oil.nix ./plugins/treesitter.nix - ./plugins/which-key.nix ]; home.shellAliases.v = "nvim"; diff --git a/profiles/base/home-manager/neovim/options.nix b/profiles/base/home-manager/neovim/options.nix new file mode 100644 index 0000000..929d544 --- /dev/null +++ b/profiles/base/home-manager/neovim/options.nix @@ -0,0 +1,6 @@ +{ + programs.nixvim.globalOpts = { + expandtab = true; + shiftwidth = 2; + }; +} diff --git a/profiles/base/home-manager/neovim/plugins/mini.nix b/profiles/base/home-manager/neovim/plugins/mini.nix index d84e0b2..10d5a17 100644 --- a/profiles/base/home-manager/neovim/plugins/mini.nix +++ b/profiles/base/home-manager/neovim/plugins/mini.nix @@ -37,6 +37,11 @@ source_func = "omnifunc"; }; }; + indentscope = {}; + move = {}; + pairs = {}; + trailspace = {}; + visits = {}; pick = {}; surround = {}; }; diff --git a/profiles/base/home-manager/neovim/plugins/which-key.nix b/profiles/base/home-manager/neovim/plugins/which-key.nix deleted file mode 100644 index 3841b71..0000000 --- a/profiles/base/home-manager/neovim/plugins/which-key.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - programs.nixvim.plugins.which-key = { - enable = true; - }; -} diff --git a/profiles/base/home-manager/zellij.nix b/profiles/base/home-manager/zellij.nix index 05aa155..99bc72f 100644 --- a/profiles/base/home-manager/zellij.nix +++ b/profiles/base/home-manager/zellij.nix @@ -6,6 +6,7 @@ theme = "catppuccin-latte"; default_layout = "compact"; default_shell = "${pkgs.fish}/bin/fish"; + no_pane_frames = true; show_startup_tips = false; show_release_notes = false; };