-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
64 lines (55 loc) · 1.73 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/master"; };
outputs = { self, nixpkgs }:
with nixpkgs.lib;
with builtins;
let
dpkgs = import nixpkgs {
system = "x86_64-linux";
config = { allowUnfree = true; };
};
# TODO: move these somewhere else
getFiles = { dir, suffix ? null, allow_default ? true }:
let
hasDefault = d: hasAttr "default.nix" (readDir (dir + "/${d}"));
isImportable = name: kind:
if kind == "directory" then
allow_default && hasDefault name
else
suffix == null || hasSuffix suffix name;
files = attrNames (filterAttrs isImportable (readDir dir));
in map (f: dir + "/${f}") files;
getNixFiles = dir:
getFiles {
inherit dir;
suffix = "nix";
};
buildNeovim = { pkgs ? dpkgs, configuration }:
let
eval = evalModules {
modules = getNixFiles ./modules ++ [
(rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args.pkgs = mkForce pkgs;
_module.args.vimLib = import ./lib { lib = pkgs.lib; };
};
})
configuration
];
};
in eval.config.product.binary;
in {
description = "Declaratively configure neovim with the magic of nix!";
inherit buildNeovim;
# For nix build
defaultPackage."x86_64-linux" =
buildNeovim { configuration = ./test.nix; };
# For nix run
defaultApp."x86_64-linux" = {
type = "app";
program = "${self.defaultPackage."x86_64-linux"}/bin/nvim";
};
};
}