-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
80 lines (63 loc) · 2.33 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
{
nixConfig.extra-substituters = [ "https://pac-nix.cachix.org/" ];
nixConfig.extra-trusted-public-keys = [ "pac-nix.cachix.org-1:l29Pc2zYR5yZyfSzk1v17uEZkhEw0gI4cXuOIsxIGpc=" ];
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# inputs.nixpkgs-upstream.url = "github:nixos/nixpkgs/nixos-unstable";
# inputs.nixpkgs.url = "github:katrinafyi/nixpkgs/pac-nix";
outputs = { self, nixpkgs, ... }:
let
lib = nixpkgs.lib;
overlay = import ./overlay.nix;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
patches = fetchpatch: [ ];
nixpkgss = lib.genAttrs systems
(system:
import nixpkgs {
system = system;
overlays = [ overlay ];
}
);
applySystem = sys: lib.mapAttrs (k: v: v.${sys} or v);
forAllSystems' = f:
lib.genAttrs
systems
(sys: f (applySystem sys self // { pkgs = nixpkgss.${sys}; system = sys; }));
forAllSystems = f: forAllSystems' (x: f x.pkgs);
onlyDerivations = lib.filterAttrs (_: lib.isDerivation);
makeAll = nixpkgs: pkgs':
nixpkgs.symlinkJoin {
name = "pac-nix-all";
paths = lib.attrValues pkgs';
};
# `restrictOverlays attrs` a given attrset of packages to only those
# defined in the latest overlay, identified by _overlay attributes
# package sets.
restrictOverlays = lib.mapAttrsRecursiveCond
(as: !(as.type or null == "derivation" || as ? _overlay))
(ks: v:
if v ? _overlay
then restrictOverlays (v._overlay v v)
else v);
in
{
legacyPackages = forAllSystems
(pkgs: restrictOverlays (overlay pkgs pkgs));
packages = forAllSystems'
({ legacyPackages, pkgs, ... }:
let drvs = onlyDerivations legacyPackages;
in drvs // { all = makeAll pkgs drvs; });
devShells = forAllSystems' ({ legacyPackages, pkgs, ... }: {
ocaml = pkgs.callPackage ./ocaml-shell.nix { };
basil-tools = legacyPackages.basil-tools-shell;
update = pkgs.callPackage ./update-shell.nix { };
});
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
overlays.default = overlay;
lib.nixpkgs = nixpkgss.${builtins.currentSystem};
};
}