From 7807c51ccf438d3a76f8ae9d16bf21cf4a3b3a50 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 30 Dec 2022 21:12:07 +0100 Subject: [PATCH] nixvim: add nix-darwin wrapper --- README.md | 15 ++++++++------ flake.nix | 1 + tests/flake.lock | 50 ++++++++------------------------------------- wrappers/darwin.nix | 30 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 wrappers/darwin.nix diff --git a/README.md b/README.md index 222078f5..885ca31a 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,12 @@ let in { imports = [ + # For home-manager nixvim.homeManagerModules.nixvim - # Or, if you're not using home-manager: + # For NixOS nixvim.nixosModules.nixvim + # For nix-darwin + nixvim.nixDarwinModules.nixvim ]; programs.nixvim.enable = true; @@ -75,14 +78,14 @@ flakes, just add the nixvim input: ``` You can now access the module using `inputs.nixvim.homeManagerModules.nixvim`, -for a home-manager instalation, and `inputs.nixvim.nixosModules.nixvim`, if -you're not using it. +for a home-manager instalation, `inputs.nixvim.nixosModules.nixvim`, for NixOS, +and `inputs.nixvim.nixDarwinModules.nixvim` for nix-darwin. ## Usage -NixVim can be used in three ways: through the home-manager and NixOS modules, +NixVim can be used in four ways: through the home-manager, nix-darwin, and NixOS modules, and through the `makeNixvim` function. To use the modules, just import the -`nixvim.homeManagerModules.${system}.nixvim` and -`nixvim.nixosModules.${system}.nixvim` modules, depending on which system +`nixvim.homeManagerModules.nixvim`, `nixvim.nixDarwinModules.nixvim`, and +`nixvim.nixosModules.nixvim` modules, depending on which system you're using. If you want to use it standalone, you can use the `makeNixvim` function: diff --git a/flake.nix b/flake.nix index 11760619..ac6957c2 100644 --- a/flake.nix +++ b/flake.nix @@ -53,5 +53,6 @@ flakeOutput // { nixosModules.nixvim = import ./wrappers/nixos.nix modules; homeManagerModules.nixvim = import ./wrappers/hm.nix modules; + nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules; }; } diff --git a/tests/flake.lock b/tests/flake.lock index 7fc1ef8c..1a49f821 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -203,17 +203,16 @@ "inputs": { "beautysh": "beautysh", "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_3", - "nmdSrc": "nmdSrc" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 0, - "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" }, "original": { - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" } }, @@ -223,52 +222,19 @@ "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs-stable" - ], - "nmdSrc": "nmdSrc_2" + ] }, "locked": { "lastModified": 0, - "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" }, "original": { - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" } }, - "nmdSrc": { - "flake": false, - "locked": { - "lastModified": 1666190571, - "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", - "owner": "rycee", - "repo": "nmd", - "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, - "nmdSrc_2": { - "flake": false, - "locked": { - "lastModified": 1666190571, - "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", - "owner": "rycee", - "repo": "nmd", - "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, "poetry2nix": { "inputs": { "flake-utils": [ diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix new file mode 100644 index 00000000..75365711 --- /dev/null +++ b/wrappers/darwin.nix @@ -0,0 +1,30 @@ +modules: +{ pkgs, config, lib, ... }: + +let + inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; + cfg = config.programs.nixvim; +in +{ + options = { + programs.nixvim = mkOption { + type = types.submodule ((modules pkgs) ++ [{ + options.enable = mkEnableOption "nixvim"; + config.wrapRc = mkForce true; + }]); + }; + nixvim.helpers = mkOption { + type = mkOptionType { + name = "helpers"; + description = "Helpers that can be used when writing nixvim configs"; + check = builtins.isAttrs; + }; + description = "Use this option to access the helpers"; + default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.finalPackage ]; + }; +}