Skip to content

Commit d18419c

Browse files
committed
flake.nix: switch from flake-utils to flake-parts
1 parent 5281e79 commit d18419c

File tree

2 files changed

+86
-45
lines changed

2 files changed

+86
-45
lines changed

flake.lock

+25-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+61-37
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
description = "A neovim configuration system for NixOS";
33

44
inputs = {
5-
flake-utils.url = "github:numtide/flake-utils";
65
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-parts.url = "github:hercules-ci/flake-parts";
77

88
pre-commit-hooks = {
99
url = "github:cachix/pre-commit-hooks.nix";
@@ -14,7 +14,7 @@
1414
outputs = {
1515
self,
1616
nixpkgs,
17-
flake-utils,
17+
flake-parts,
1818
pre-commit-hooks,
1919
...
2020
} @ inputs:
@@ -47,13 +47,25 @@
4747
inherit modules;
4848
inherit self;
4949
};
50+
in
51+
flake-parts.lib.mkFlake {inherit inputs;} ({
52+
withSystem,
53+
config,
54+
lib,
55+
...
56+
}: {
57+
systems = [
58+
"x86_64-linux"
59+
"aarch64-linux"
60+
"x86_64-darwin"
61+
"aarch64-darwin"
62+
];
5063

51-
flakeOutput =
52-
flake-utils.lib.eachDefaultSystem
53-
(system: let
54-
pkgs = import nixpkgs {inherit system;};
55-
# Some nixvim supported plugins require the use of unfree packages.
56-
# This unfree-friendly pkgs is used for documentation and testing only.
64+
perSystem = {
65+
pkgs,
66+
system,
67+
...
68+
}: let
5769
pkgs-unfree = import nixpkgs {
5870
inherit system;
5971
config.allowUnfree = true;
@@ -111,6 +123,7 @@
111123
pkgs = pkgs-unfree;
112124
modules = modules pkgs;
113125
});
126+
114127
legacyPackages = rec {
115128
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs wrapperArgs;
116129
makeNixvim = configuration:
@@ -120,40 +133,51 @@
120133
};
121134
};
122135
};
136+
123137
formatter = pkgs.alejandra;
124-
lib = import ./lib {
125-
inherit pkgs;
126-
inherit (pkgs) lib;
127-
inherit (self.legacyPackages."${system}") makeNixvim;
128-
};
129-
});
130-
in
131-
flakeOutput
132-
// {
133-
nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs;
134-
homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs;
135-
nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs;
136-
rawModules.nixvim = nixvimModules;
138+
};
137139

138-
overlays.default = final: prev: {
139-
nixvim = rec {
140-
makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs;
141-
makeNixvim = configuration:
142-
makeNixvimWithModule {
143-
module = {
144-
config = configuration;
140+
flake = {
141+
nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs;
142+
homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs;
143+
nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs;
144+
rawModules.nixvim = nixvimModules;
145+
146+
overlays.default = final: prev: {
147+
nixvim = rec {
148+
makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs;
149+
makeNixvim = configuration:
150+
makeNixvimWithModule {
151+
module = {
152+
config = configuration;
153+
};
145154
};
146-
};
155+
};
147156
};
148-
};
149157

150-
templates = let
151-
simple = {
152-
path = ./templates/simple;
153-
description = "A simple nix flake template for getting started with nixvim";
158+
lib = lib.genAttrs config.systems (
159+
lib.flip withSystem (
160+
{
161+
pkgs,
162+
system,
163+
...
164+
}:
165+
import ./lib {
166+
inherit pkgs;
167+
inherit (pkgs) lib;
168+
inherit (self.legacyPackages."${system}") makeNixvim;
169+
}
170+
)
171+
);
172+
173+
templates = let
174+
simple = {
175+
path = ./templates/simple;
176+
description = "A simple nix flake template for getting started with nixvim";
177+
};
178+
in {
179+
default = simple;
154180
};
155-
in {
156-
default = simple;
157181
};
158-
};
182+
});
159183
}

0 commit comments

Comments
 (0)