Skip to content

Commit

Permalink
templates: switch to flake-parts
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Dec 12, 2023
1 parent efdac84 commit c23968f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 40 deletions.
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you have any question, please use the [discussions page](https://github.com/n
> If you want to use NixVim with nixpkgs 23.05 you should use the `nixos-23.05` branch.
### Without flakes
NixVim now ships with `flake-compat`, which makes it usable from any system.
NixVim now ships with `flake-parts`, which makes it usable from any system.

To install it, edit your home-manager (or NixOS) configuration:

Expand Down Expand Up @@ -141,27 +141,38 @@ can use the following:
description = "A very basic flake";
inputs.nixvim.url = "github:nix-community/nixvim";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {
self,
nixpkgs,
nixvim,
flake-utils,
}: let
flake-parts,
} @ inputs: let
config = {
colorschemes.gruvbox.enable = true;
};
in
flake-utils.lib.eachDefaultSystem (system: let
nixvim' = nixvim.legacyPackages."${system}";
nvim = nixvim'.makeNixvim config;
in {
packages = {
inherit nvim;
default = nvim;
flake-parts.lib.mkFlake {inherit inputs;} {
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
perSystem = {
pkgs,
system,
...
}: let
nixvim' = nixvim.legacyPackages."${system}";
nvim = nixvim'.makeNixvim config;
in {
packages = {
inherit nvim;
default = nvim;
};
};
});
};
}
```
</details>
Expand Down
7 changes: 5 additions & 2 deletions templates/_wrapper/simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
nixvim.url = "path:../../..";
simple = {
url = "path:../../simple";
inputs.nixvim.follows = "nixvim";
inputs.flake-utils.follows = "nixvim/flake-utils";
inputs = {
nixvim.follows = "nixvim";
nixpkgs.follows = "nixvim/nixpkgs";
flake-parts.follows = "nixvim/flake-parts";
};
};
};

Expand Down
62 changes: 37 additions & 25 deletions templates/simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,55 @@
description = "A nixvim configuration";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixvim.url = "github:nix-community/nixvim";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = {
self,
nixpkgs,
nixvim,
flake-utils,
flake-parts,
...
} @ inputs: let
config = import ./config; # import the module directly
in
flake-utils.lib.eachDefaultSystem (system: let
nixvimLib = nixvim.lib.${system};
pkgs = import nixpkgs {inherit system;};
nixvim' = nixvim.legacyPackages.${system};
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
module = config;
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
inherit self;
flake-parts.lib.mkFlake {inherit inputs;} {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem = {
pkgs,
system,
...
}: let
nixvimLib = nixvim.lib.${system};
nixvim' = nixvim.legacyPackages.${system};
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
module = config;
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
inherit self;
};
};
};
in {
checks = {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNvim {
inherit nvim;
name = "A nixvim configuration";
in {
checks = {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNvim {
inherit nvim;
name = "A nixvim configuration";
};
};
};

packages = {
# Lets you run `nix run .` to start nixvim
default = nvim;
packages = {
# Lets you run `nix run .` to start nixvim
default = nvim;
};
};
});
};
}

0 comments on commit c23968f

Please sign in to comment.