Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce Flake for development and builds #148

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
10 changes: 10 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
93 changes: 93 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
infinitime.url = "github:shymega/InfiniTime?ref=shymega-feat/nix-flake&submodules=1";
# infinitime.url = "github:InfiniTimeOrg/InfiniTime";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};

outputs = { self, ... }@inputs:
let
forAllSystems = function:
inputs.nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
]
(system: function (import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
}));
in
{
packages = forAllSystems (pkgs:
let
infinitime = inputs.infinitime.packages.${pkgs.system}.default;
in
with pkgs; {
default = stdenv.mkDerivation rec {
name = "infinisim";
srcs = [
(fetchFromGitHub {
name = "InfiniTime";
owner = "shymega";
repo = "InfiniTime";
rev = "refs/heads/shymega-feat/nix-flake";
fetchSubmodules = true;
leaveDotGit = true;
sha256 = "sha256-3x4FubKg8xXJf4t1QjSRIE8FKh89/0yT67bStH+a3HQ=";
})
(lib.cleanSource ./.)
];
sourceRoot = ".";

nativeBuildInputs = with pkgs; [
SDL2
libpng
patch
zlib
] ++ infinitime.nativeBuildInputs;

buildInputs = with pkgs; [
cmake
] ++ infinitime.buildInputs;

preConfigure = ''
patchShebangs $sourceRoot/InfiniTime/src/displayapp/fonts/generate.py \
$sourceRoot/InfiniTime/tools/mcuboot/imgtool.py \
$sourceRoot/source/img/convert_bmp_to_header.py
'';

cmakeFlags = [
"-DInfiniTime_DIR=${sourceRoot}/InfiniTime"
];
};
});

devShells = forAllSystems (pkgs:
{
default =
pkgs.mkShell {
packages = [ pkgs.ninja ] ++ self.packages.${pkgs.system}.default.nativeBuildInputs;
};
});
};
}

10 changes: 10 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).shellNix