-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
103 lines (86 loc) · 2.88 KB
/
flake.nix
File metadata and controls
103 lines (86 loc) · 2.88 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
{
description = "Flake for developing ironOS";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
# Add flake-utils to handle multiple systems
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
crossPkgs = pkgs.pkgsCross.x86_64-embedded;
# To ensure compatibility on all platforms, we fetch the Limine binaries
# that also include the source code and compile them locally.
limineVersion = "10.6.6";
limine-src = pkgs.fetchFromGitHub {
owner = "limine-bootloader";
repo = "limine";
rev = "v${limineVersion}-binary";
sha256 = "sha256-ulDELUBmJ2qgjsPE1KUfucmf99DxMLT0ceAEAvdKzFY=";
};
limine-cli = pkgs.stdenv.mkDerivation {
pname = "limine-cli";
version = limineVersion;
src = limine-src;
installPhase = ''
mkdir -p $out/bin
cp limine $out/bin/
'';
};
in
{
# nix develop
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
# GCC cross-compiler (includes the linker)
crossPkgs.buildPackages.gcc
# Generating compile commands for LSPs
pkgs.compiledb
# Limine bootloader
limine-cli
# Utility used to create ISO files
pkgs.xorriso
# Emulator used to test ironOS
pkgs.qemu
];
shellHook = ''
export TOOLCHAIN_PREFIX="x86_64-elf-"
export LIMINE="limine"
export LIMINE_DATADIR="${limine-src}"
'';
};
# nix build
packages.default = pkgs.stdenv.mkDerivation {
pname = "ironOS";
version = "0.0.0";
src = ./.;
nativeBuildInputs = [
crossPkgs.buildPackages.gcc
limine-cli
pkgs.xorriso
];
# Replicate the shell variables
TOOLCHAIN_PREFIX = "x86_64-elf-";
LIMINE = "limine";
LIMINE_DATADIR = "${limine-src}";
# Environment vars needed by Makefile
BUILD_DIR = "build";
OUT = "ironOS";
# Default buildPhase is make
# We need to tell Nix where to put the output ISO
installPhase = ''
mkdir -p $out
cp build/ironOS.iso $out/
'';
};
# nix run
apps.default = {
type = "app";
program = "${pkgs.writeShellScript "run-ironOS" ''
${pkgs.qemu}/bin/qemu-system-x86_64 -cdrom ${self.packages.${system}.default}/ironOS.iso -serial file:kernel.log
''}";
};
}
);
}