This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
86 lines (71 loc) · 2.39 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
{
description = "ExpidusOS Core";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
toolchain.url = "git+ssh://[email protected]/ExpidusOS/toolchain.git";
zon2nix.url = "github:MidstallSoftware/zon2nix/expidus";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, toolchain, zon2nix, flake-utils }@inputs:
let
zon2nixOverlay = final: prev: {
zon2nix = prev.stdenv.mkDerivation {
pname = "zon2nix";
version = "0.1.2";
src = zon2nix;
nativeBuildInputs = [
prev.zig
];
dontConfigure = true;
dontInstall = true;
buildPhase = ''
mkdir -p .cache
zig build install --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache \
-Dnix=${prev.lib.getExe prev.nix} \
-Dcpu=baseline \
-Doptimize=ReleaseSafe \
--prefix $out
'';
};
};
in flake-utils.lib.eachSystem flake-utils.lib.allSystems (
system:
let
pkgs = (import nixpkgs {inherit system;}).appendOverlays [
toolchain.overlays.patches
toolchain.overlays.zig
toolchain.overlays.default
zon2nixOverlay
];
in {
packages.default = pkgs.stdenvNoCC.mkDerivation {
pname = "expidus-core";
version = self.shortRev or "dirty";
src = pkgs.lib.cleanSource self;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
expidus.toolchain
];
dontConfigure = true;
dontInstall = true;
buildPhase = ''
export ZIG_GLOBAL_CACHE_DIR=$(pwd)/.cache
mkdir -p .cache
ln -s ${pkgs.callPackage ./deps.nix { }} .cache/p
zig build install --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache \
-Dbuild-hash=${self.shortRev or "dirty"} \
-Dcpu=baseline \
-Doptimize=ReleaseSafe \
--prefix $out
'';
};
legacyPackages = pkgs;
devShells.default = pkgs.mkShell {
name = "expidus-core";
packages = with pkgs; [
expidus.toolchain
pkgs.zon2nix
];
};
});
}