From c951490f9ebd9e5b3cd3088e46518da8796f700e Mon Sep 17 00:00:00 2001 From: xenia Date: Sun, 4 Feb 2024 12:10:12 +0100 Subject: [PATCH] Nix flake build system --- .envrc | 1 + .gitignore | 4 + flake.lock | 327 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 79 +++++++++++++ 4 files changed, 411 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix 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/.gitignore b/.gitignore index f9e440e..696f61a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,7 @@ **/romdisk.img **/romdisk.img.tmp **/startup.bat + +**/result +**/.direnv/ +fox32rom/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e9c0560 --- /dev/null +++ b/flake.lock @@ -0,0 +1,327 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "fox32asm": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1707042298, + "narHash": "sha256-3sAOFd6y7Qrd/FTO/w+G4VfZeaScAoZFKY4IiVd8cqo=", + "ref": "refs/heads/main", + "rev": "4d8d3d1c48852f35031de2a37bc32766da2833f4", + "revCount": 68, + "type": "git", + "url": "https://githug.xyz/xenia/fox32asm" + }, + "original": { + "type": "git", + "url": "https://githug.xyz/xenia/fox32asm" + } + }, + "fox32asm_2": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1707042298, + "narHash": "sha256-3sAOFd6y7Qrd/FTO/w+G4VfZeaScAoZFKY4IiVd8cqo=", + "ref": "refs/heads/main", + "rev": "4d8d3d1c48852f35031de2a37bc32766da2833f4", + "revCount": 68, + "type": "git", + "url": "https://githug.xyz/xenia/fox32asm" + }, + "original": { + "type": "git", + "url": "https://githug.xyz/xenia/fox32asm" + } + }, + "fox32rom": { + "inputs": { + "flake-utils": "flake-utils_3", + "fox32asm": "fox32asm_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1706972604, + "narHash": "sha256-r5R3aoFtrctpPoQIE3ynLet9L34WUFlj2PRSKRgQAYg=", + "ref": "refs/heads/main", + "rev": "f4a7e18b2803ff65eb4182a248028bef6cda7546", + "revCount": 181, + "type": "git", + "url": "https://githug.xyz/xenia/fox32rom" + }, + "original": { + "type": "git", + "url": "https://githug.xyz/xenia/fox32rom" + } + }, + "foxtools": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1707042981, + "narHash": "sha256-RJwtT0BUBM0XlpzUymrwvI5JAsP1drjggIjDJcnWq8o=", + "ref": "refs/heads/main", + "rev": "f690eb07c46d59c9430bc004f72f6fba271e2415", + "revCount": 43, + "type": "git", + "url": "https://githug.xyz/xenia/fox-tools" + }, + "original": { + "type": "git", + "url": "https://githug.xyz/xenia/fox-tools" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "fox32asm": "fox32asm", + "fox32rom": "fox32rom", + "foxtools": "foxtools", + "nixpkgs": "nixpkgs_5" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..176fb99 --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + description = "fox32os"; + + inputs = { + fox32asm.url = "git+https://githug.xyz/xenia/fox32asm"; + fox32rom.url = "git+https://githug.xyz/xenia/fox32rom"; + foxtools.url = "git+https://githug.xyz/xenia/fox-tools"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, fox32asm, fox32rom, foxtools, flake-utils }: + flake-utils.lib.eachDefaultSystem (sys: + let pkgs = import nixpkgs { system = sys; }; + asm = fox32asm.packages.${sys}.fox32asm; + gfx2inc = foxtools.packages.${sys}.gfx2inc; + rom-dev = fox32rom.packages.${sys}.fox32rom-dev; + + deps = [ pkgs.lua5_4_compat pkgs.python311 ]; # lua needed for Okameron, python for ryfs.py + + okameron = pkgs.fetchFromGitHub { + owner = "TalonFloof"; + repo = "okameron"; + rev = "c7499dff866bb6100cc4d5e688c39d1d853389f8"; + hash = "sha256-VQ/ABkiPMFZtA8XKLW2oQTihVkLmq5+gL8IVe5Kfv/I="; + }; + + ryfs = pkgs.fetchFromGitHub { + owner = "ry755"; + repo = "ryfs"; + rev = "e5034f4e11250a626388d7e9c1bcbf9af53f5702"; + hash = "sha256-wA89XLHhinxpiaKzGKKqLuRQ6Q4x4uw/NwGK8Hs2+MQ="; + }; + + fox32os = pkgs.stdenv.mkDerivation { + name = "fox32os"; + src = ./.; + nativeBuildInputs = deps; + + preBuild = '' + mkdir -p ./fox32rom + cp ${rom-dev}/dev/fox32rom.def ./fox32rom/fox32rom.def + ''; + + FOX32ASM = "${asm}/bin/fox32asm"; + GFX2INC = "${gfx2inc}/bin/gfx2inc"; + OKAMERON = "${okameron}/okameron.lua"; + RYFS = "${ryfs}/ryfs.py"; + + installPhase = '' + mkdir -p "$out/bin" + cp fox32os.img romdisk.img "$out/bin" + ''; + dontFixup = true; + }; + + fox32os-dev = pkgs.runCommand "fox32os-dev" {} '' + mkdir -p $out/dev + cp ${./fox32os.def} $out/dev/fox32os.def + ''; + in rec { + packages.fox32os = fox32os; + packages.fox32os-dev = fox32os-dev; + packages.default = fox32os; + + devShells.default = pkgs.mkShell { + packages = deps ++ [ asm gfx2inc okameron ] ; + shellHook = '' + export FOX32ASM="${asm}/bin/fox32asm"; + export GFX2INC="${gfx2inc}/bin/gfx2inc"; + export OKAMERON="${okameron}/okameron.lua"; + export RYFS="${ryfs}/ryfs.py"; + + mkdir -p ./fox32rom + cp ${rom-dev}/dev/fox32rom.def ./fox32rom/fox32rom.def + ''; + }; + } + ); +}