Skip to content

Commit 0aa7f92

Browse files
committed
refactor: Refactor Flake
1 parent b88bf08 commit 0aa7f92

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

flake.nix

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-FileCopyrightText: 2024 The Cosmo-CoDiOS Developers
22
#
33
# SPDX-License-Identifier: GPL-3.0-only
4-
54
{
65
inputs = {
76
fenix = {
@@ -16,17 +15,19 @@
1615
nixpkgs.url = "nixpkgs/nixos-unstable";
1716
};
1817

19-
outputs = { self, fenix, flake-utils, naersk, nixpkgs }:
20-
flake-utils.lib.eachDefaultSystem (system:
21-
let
18+
outputs = inputs: let
19+
inherit (inputs) self flake-utils fenix naersk nixpkgs;
20+
in
21+
flake-utils.lib.eachDefaultSystem (system: let
2222
pkgs = (import nixpkgs) {
2323
inherit system;
2424
};
2525

26-
toolchain = with fenix.packages.${system}; fromToolchainFile {
27-
dir = ./.;
28-
sha256 = "sha256-oW7iyYzGcgW5TjRA2HLhYVW2WNTNadIe4SX7IWsrs3g=";
29-
};
26+
toolchain = with fenix.packages.${system};
27+
fromToolchainFile {
28+
dir = ./.;
29+
sha256 = "sha256-QmNaeezyZvl+M+EIExXMhW60xi/LupjSwtQ1RFUBCuY=";
30+
};
3031

3132
naersk' = naersk.lib.${system}.override {
3233
cargo = toolchain;
@@ -36,45 +37,41 @@
3637
naerskBuildPackage = target: args:
3738
naersk'.buildPackage (
3839
args
39-
// { CARGO_BUILD_TARGET = target; }
40+
// {CARGO_BUILD_TARGET = target;}
4041
);
41-
in
42-
rec
42+
in rec
4343
{
44-
defaultPackage = packages.x86_64-unknown-linux-musl;
45-
46-
# For `nix build .#x86_64-unknown-linux-musl`:
47-
packages.x86_64-unknown-linux-musl = naerskBuildPackage "x86_64-unknown-linux-musl" rec {
48-
src = ./.;
49-
doCheck = true;
50-
nativeBuildInputs = with pkgs; [ pkgsStatic.stdenv.cc cmake SDL SDL2 SDL.dev SDL2.dev ];
51-
buildInputs = nativeBuildInputs;
52-
};
53-
54-
# For `nix build .#x86_64-unknown-linux-musl`:
55-
packages.aarch64-unknown-linux-musl = naerskBuildPackage "aarch64-unknown-linux-musl" rec {
56-
src = ./.;
57-
doCheck = true;
58-
nativeBuildInputs = with pkgs; [ pkgsStatic.stdenv.cc cmake SDL SDL2 SDL.dev SDL2.dev ];
59-
buildInputs = nativeBuildInputs;
60-
};
61-
62-
# For `nix build .#x86_64-unknown-linux-musl`:
63-
packages.thumbv7em-none-eabihf = naerskBuildPackage "thumbv7em-none-eabihf" {
64-
src = ./.;
65-
doCheck = true;
66-
nativeBuildInputs = with pkgs; [ cmake ];
44+
packages = {
45+
emulator-x86 = naerskBuildPackage "x86_64-unknown-linux-musl" rec {
46+
src = ./.;
47+
nativeBuildInputs = with pkgs; [pkgsStatic.stdenv.cc cmake];
48+
buildInputs = with pkgs; [SDL.dev SDL2.dev];
49+
};
50+
emulator-arm64 = naerskBuildPackage "aarch64-unknown-linux-musl" rec {
51+
src = ./.;
52+
nativeBuildInputs = with pkgs; [pkgsStatic.stdenv.cc cmake];
53+
buildInputs = with pkgs; [SDL.dev SDL2.dev];
54+
};
55+
firmware-official-codi = naerskBuildPackage "thumbv7em-none-eabihf" {
56+
src = ./.;
57+
nativeBuildInputs = with pkgs; [cmake];
58+
};
6759
};
6860

69-
devShell = pkgs.mkShellNoCC (
61+
devShell =
62+
pkgs.mkShell
7063
{
71-
inputsFrom = [ packages.x86_64-unknown-linux-musl packages.aarch64-unknown-linux-musl ];
64+
inputsFrom = with self.packages.${system}; [
65+
emulator-x86
66+
emulator-arm64
67+
firmware-official-codi
68+
];
7269
packages = with pkgs; [
7370
rustup
7471
cargo-cross
7572
];
7673
CROSS_CONTAINER_OPTS = "--platform linux/amd64";
7774
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
78-
});
75+
};
7976
});
8077
}

0 commit comments

Comments
 (0)