-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathflake.nix
More file actions
80 lines (73 loc) · 2.29 KB
/
Copy pathflake.nix
File metadata and controls
80 lines (73 loc) · 2.29 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
{
description = "A Nix flake for the Zig programming language";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs = {
self,
nixpkgs,
}: {
releases = let
inherit (nixpkgs) lib;
addZls = release: let
matchesVersion = zls:
builtins.compareVersions
(lib.versions.majorMinor release._version)
(lib.versions.majorMinor zls._version)
== 0;
zlsFallbacks = builtins.filter matchesVersion (import ./releases/zls.nix);
zlsFallback =
if zlsFallbacks == []
then null
else lib.last zlsFallbacks;
in
{_zls = zlsFallback;} // release;
stable = map addZls (import ./releases/stable.nix);
nightly = map addZls (import ./releases/nightly.nix);
named = release: {
name =
"zig_"
+ lib.pipe release._version [
builtins.splitVersion # parse version
(lib.sublist 0 5) # strip commit hash
(lib.concatStringsSep "_") # recombine
];
value = release;
};
in
builtins.listToAttrs (map named (stable ++ nightly))
// {
default = lib.last stable;
nightly = lib.last nightly;
};
fetchRelease = ./package/fetch.nix;
packages =
builtins.mapAttrs
(system: pkgs: let
forThisSystem =
nixpkgs.lib.filterAttrs (name: rel: rel ? ${pkgs.stdenv.hostPlatform.system}) self.releases;
package = name: rel: pkgs.callPackage ./package {zigRelease = rel;};
in
# TODO: expose zls packages at top level
builtins.mapAttrs package forThisSystem)
nixpkgs.legacyPackages;
devShells =
builtins.mapAttrs
(system:
builtins.mapAttrs (name: zig: let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShellNoCC {
packages = [pkgs.bash zig] ++ pkgs.lib.optional (zig ? zls) zig.zls;
}))
self.packages;
templates = {
default = {
path = ./templates/default;
description = "Simple Nix flake for a package using the latest stable Zig release";
};
nightly = {
path = ./templates/nightly;
description = "Nix flake with devShell, for a package using the latest Zig nightly";
};
};
};
}