-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (90 loc) · 3.14 KB
/
Copy pathflake.nix
File metadata and controls
96 lines (90 loc) · 3.14 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
{
inputs = {
nixpkgs.url = "github:/nixos/nixpkgs/nixpkgs-unstable";
idris2PackDbSrc = {
url = "github:/stefan-hoeck/idris2-pack-db";
flake = false;
};
idris2 = {
url = "github:/idris-lang/idris2/b51cac2d215c75ac1a05dddb7a2590695bc93d22";
inputs.nixpkgs.follows = "nixpkgs";
};
idris2Lsp = {
url = "github:/idris-community/idris2-lsp/9a2f0ad6a95815fe3ed438ddba08c95574a4de54";
inputs.idris.follows = "idris2";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixpkgs,
idris2,
idris2Lsp,
self,
...
}:
let
inherit (nixpkgs) lib;
forEachSystem = lib.genAttrs lib.systems.flakeExposed;
ps = {withSource}:
forEachSystem (
system:
import ./. {
pkgs = import nixpkgs { inherit system; };
idris2Override = idris2.packages.${system}.idris2;
idris2SupportOverride = idris2.packages.${system}.support;
idris2LspOverride = idris2Lsp.packages.${system}.idris2Lsp;
buildIdrisOverride = idris2.buildIdris.${system};
inherit system withSource;
}
);
in
{
overlays =
let
mkOverlay = withSource: import ./overlay.nix { inherit idris2 idris2Lsp withSource; };
in
{
withoutSource = mkOverlay false;
withSource = mkOverlay true;
default = self.overlays.withSource;
};
packages = ps { withSource = false; };
buildIdris = lib.mapAttrs (_: attrs: attrs.buildIdris) (ps { withSource = false;});
buildIdris' = lib.mapAttrs (_: attrs: attrs.buildIdris') (ps { withSource = false; });
experimental = lib.mapAttrs (_: attrs: attrs.experimental) (ps { withSource = false; });
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
templates = {
default = {
path = ./templates/basic;
description = "A simple template that produces results for multiple systems without using flake-utils";
};
import-from-derivation = {
path = ./templates/ifd;
description = "A simple template that creates a project that builds against dependencies from pack's packageset automatically";
};
};
impureShell =
{
system ? builtins.currentSystem,
src ? /. + builtins.getEnv "PWD",
ipkgName ?
let
fileMatches = lib.filesystem.locateDominatingFile "(.*)\.ipkg" src;
in
if fileMatches == null then
throw "Could not locate an ipkg file automatically"
else
let
inherit (fileMatches) matches path;
relative = lib.head (lib.head matches);
absolute = lib.path.append path relative;
in
lib.strings.removePrefix ((toString src) + "/") (toString absolute),
}:
nixpkgs.legacyPackages.${system}.callPackage ./ipkg-shell.nix {
inherit src ipkgName;
inherit ((ps {withSource = true;}).${system}) buildIdris' idris2 idris2Lsp;
};
};
}