-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
executable file
·152 lines (143 loc) · 4.55 KB
/
flake.nix
File metadata and controls
executable file
·152 lines (143 loc) · 4.55 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
description = "Make a nushell instance with specific plugins and/or nushell libraries";
nixConfig = {
extra-substituters = [ "https://cache.garnix.io" ];
extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
};
inputs = {
crane.url = "github:ipetkov/crane";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Nu libraries' sources:
nu-batteries-src = {
url = "github:nome/nu-batteries";
flake = false;
};
};
outputs =
{
self,
crane,
nixpkgs,
...
}@flake-inputs:
let
# nixpkgs.lib.systems.flakeExposed, minus powerpc64le-linux
supported-systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"armv6l-linux"
"armv7l-linux"
"i686-linux"
"aarch64-darwin"
"riscv64-linux"
"x86_64-freebsd"
];
in
{
lib = import ./nix-src/lib.nix crane;
# Makes the flake directly usable as a function:
__functor = _: self.lib.nushellWith;
overlays.default =
final: prev:
let
craneLib = crane.mkLib prev;
in
self.lib.mkLib final
// {
inherit craneLib;
nushellWithStdPlugins = final.nushellWith {
name = "nushell-with-std-plugins";
plugins.nix = with final.nushellPlugins; [
formats
gstat
polars
query
];
};
# nushell packaged in nixpkgs is already built with the MCP feature
nushellMCP = final.nushell;
}
// import ./nix-src/nu-libs-and-plugins.nix {
inherit flake-inputs;
pkgs = final;
};
packages = nixpkgs.lib.genAttrs supported-systems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in
{
inherit (pkgs) nushell nushellWithStdPlugins nushellMCP;
# packages cannot export functions. So we hack around by providing
# a derivation that can be used like a function:
nushellWith = pkgs.nushellWithStdPlugins // {
__functor = _: pkgs.nushellWith;
};
}
// pkgs.nushellLibraries
// nixpkgs.lib.mapAttrs' (name: value: {
name = "nu_plugin_" + name;
inherit value;
}) pkgs.nushellPlugins
);
apps = nixpkgs.lib.genAttrs supported-systems (
system:
let
pkgs = import nixpkgs { inherit system; };
# We use nu & semver plugin straight from nixpkgs in order to avoid bootstrap problems
# The update-plugin-list.nu script is simple enough to work with any Nushell version >=0.106
nuWithSemver = self.lib.nushellWith {
inherit pkgs;
plugins.nix = [ pkgs.nushellPlugins.semver ];
};
script = nuWithSemver.writeNuScriptBin "update-plugin-list" (
builtins.readFile ./nu-src/update-plugin-list.nu
);
in
{
update-plugin-list = {
type = "app";
program = pkgs.lib.getExe script;
};
}
);
checks = nixpkgs.lib.genAttrs supported-systems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
nonBrokenPlugins = pkgs.lib.filterAttrs (_: deriv: !deriv.meta.broken) pkgs.nushellPlugins;
in
{
allStdPlugins = pkgs.nushellWithStdPlugins.runNuCommand "check-all-std-plugins" { } ''
use std/assert
assert ((plugin list | length) == 4) "4 plugins should be found"
assert (plugin list | all {$in.status == "running"}) "All plugins should be running"
"OK" | save $env.out
'';
}
// nixpkgs.lib.mapAttrs (
# For each plugin, check that it can be added to nushell without errors
plugin-name: plugin-deriv:
let
nu = pkgs.nushellWith {
name = "nushell-with-${plugin-name}";
plugins.nix = [ plugin-deriv ];
};
in
nu.runNuCommand "check-${plugin-name}" { } ''
use std/assert
assert ((plugin list | length) == 1) "The plugin should be found"
assert ((plugin list).0.status == "running") "The plugin should be found"
"OK" | save $env.out
''
) nonBrokenPlugins
);
};
}