-
Notifications
You must be signed in to change notification settings - Fork 465
/
flake.nix
105 lines (102 loc) · 3.85 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
# This provides only NixOS module
# As of 2023/08/19, you need to depend on nixpkgs-unstable.
# because "doq" is not included in the stable version.
description = "Provide nixosModules for ayamir/nvimdots";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ { self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; }
{
imports = [
inputs.devshell.flakeModule
];
flake = {
homeManagerModules = {
nvimdots = ./nixos;
};
};
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { pkgs, system, ... }: {
packages = {
testEnv = (import ./nixos/testEnv.nix { inherit inputs pkgs; }).activationPackage;
check-linker = pkgs.writeShellApplication {
name = "check-linker";
text =
let
ldd_cmd = if pkgs.stdenv.isDarwin then "xcrun otool -L" else "${pkgs.glibc.bin}/bin/ldd";
in
''
#shellcheck disable=SC1090
source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim")
echo "Checking files under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin..."
find "''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" -type l | while read -r link; do
"${ldd_cmd}" "$(readlink -f "$link")" > /dev/zero 2>&1 || continue
linkers=$("${ldd_cmd}" "$(readlink -f "$link")" | tail -n+2)
echo "$linkers" | while read -r line; do
[ -z "$line" ] && continue
echo "$line" | grep -q "/nix/store" || printf '%s: %s does not link to /nix/store \n' "$(basename "$link")" "$line"
done
done
echo "*** Done ***"
'';
};
};
devshells.default = {
commands = [
{
help = "neovim linked to testEnv.";
name = "nvim";
command = ''
${self.packages.${system}.testEnv}/home-path/bin/nvim
'';
}
{
help = "check-linker";
package = self.packages.${system}.check-linker;
}
];
devshell = {
motd = ''
{202}🔨 Welcome to devshell{reset}
Symlink configs to "''${XDG_CONFIG_HOME}"/nvimdots!
And NVIM_APPNAME=nvimdots is already configured, so neovim will put files under "\$XDG_xxx_HOME"/nvimdots.
To uninstall, remove "\$XDG_xxx_HOME"/nvimdots.
$(type -p menu &>/dev/null && menu)
'';
startup = {
mkNvimDir = {
text = ''
mkdir -p "''${XDG_CONFIG_HOME}"/nvimdots
for path in lazy-lock.json init.lua lua snips tutor; do
ln -sf "''${PWD}/''${path}" "''${XDG_CONFIG_HOME}"/nvimdots/
done
'';
};
};
};
env = [
{
name = "NVIM_APPNAME";
value = "nvimdots";
}
{
name = "PATH";
prefix = "${self.packages.${system}.testEnv}/home-path/bin";
}
];
packages = with pkgs; [
nixd
nixpkgs-fmt
];
};
};
};
}