diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..f620865 --- /dev/null +++ b/default.nix @@ -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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4365692 --- /dev/null +++ b/flake.lock @@ -0,0 +1,93 @@ +{ + "nodes": { + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "infinitime": { + "inputs": { + "flake-compat": "flake-compat_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1728830421, + "narHash": "sha256-IK0sgCbB/z2wqJb2yN/Kv4lMF1MO/hwqUqcIb6dcUI8=", + "owner": "shymega", + "repo": "InfiniTime", + "rev": "7606e3784a26e73b3af6e8cfe64a1c82e4bb4fa7", + "type": "github" + }, + "original": { + "owner": "shymega", + "ref": "shymega-feat/nix-flake", + "repo": "InfiniTime", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1728492678, + "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1728492678, + "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "infinitime": "infinitime", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6137273 --- /dev/null +++ b/flake.nix @@ -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; + }; + }); + }; +} + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..942ce01 --- /dev/null +++ b/shell.nix @@ -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