Skip to content

Commit

Permalink
flake.nix: switch from flake-utils to flake-parts
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Dec 12, 2023
1 parent c914912 commit efdac84
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 47 deletions.
33 changes: 25 additions & 8 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 61 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description = "A neovim configuration system for NixOS";

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

pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
Expand All @@ -14,7 +14,7 @@
outputs = {
self,
nixpkgs,
flake-utils,
flake-parts,
pre-commit-hooks,
...
} @ inputs:
Expand All @@ -38,21 +38,31 @@
};
};
}

# ./plugins/default.nix
];

wrapperArgs = {
inherit modules;
inherit self;
};
in
flake-parts.lib.mkFlake {inherit inputs;} ({
withSystem,
config,
lib,
...
}: {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

flakeOutput =
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = import nixpkgs {inherit system;};
# Some nixvim supported plugins require the use of unfree packages.
# This unfree-friendly pkgs is used for documentation and testing only.
perSystem = {
pkgs,
system,
...
}: let
pkgs-unfree = import nixpkgs {
inherit system;
config.allowUnfree = true;
Expand Down Expand Up @@ -111,6 +121,7 @@
pkgs = pkgs-unfree;
modules = modules pkgs;
});

legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs wrapperArgs;
makeNixvim = configuration:
Expand All @@ -120,40 +131,51 @@
};
};
};

formatter = pkgs.alejandra;
lib = import ./lib {
inherit pkgs;
inherit (pkgs) lib;
inherit (self.legacyPackages."${system}") makeNixvim;
};
});
in
flakeOutput
// {
nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs;
homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs;
rawModules.nixvim = nixvimModules;
};

overlays.default = final: prev: {
nixvim = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
flake = {
nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs;
homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs;
rawModules.nixvim = nixvimModules;

overlays.default = final: prev: {
nixvim = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
};
};
};
};

templates = let
simple = {
path = ./templates/simple;
description = "A simple nix flake template for getting started with nixvim";
lib = lib.genAttrs config.systems (
lib.flip withSystem (
{
pkgs,
system,
...
}:
import ./lib {
inherit pkgs;
inherit (pkgs) lib;
inherit (self.legacyPackages."${system}") makeNixvim;
}
)
);

templates = let
simple = {
path = ./templates/simple;
description = "A simple nix flake template for getting started with nixvim";
};
in {
default = simple;
};
in {
default = simple;
};
};
});
}

0 comments on commit efdac84

Please sign in to comment.