diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..2631f9a --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" +fi +use flake diff --git a/.gitignore b/.gitignore index a977026..dd518ae 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ ipl.rom !res/qoob_pro_none_upgrade.elf !res/qoob_sx_13c_upgrade.elf + +.direnv diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..60a87c9 --- /dev/null +++ b/default.nix @@ -0,0 +1,7 @@ +(import (let + lockFile = builtins.fromJSON (builtins.readFile ./flake.lock); + info = lockFile.nodes.flake-compat.locked; +in builtins.fetchTarball { + url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; + ${if info ? narHash then "sha256" else null} = info.narHash; +}) { src = ./.; }).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3be5224 --- /dev/null +++ b/flake.lock @@ -0,0 +1,81 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1702303468, + "narHash": "sha256-Rhh9iGAVSHiw6s1f+xdTsgTsDwacxlQMwp48KpOJMOE=", + "owner": "9ary", + "repo": "nixpkgs", + "rev": "1da211707bf60a6afd56f2cf96d43ef01d32ef18", + "type": "github" + }, + "original": { + "owner": "9ary", + "ref": "devkitPPC", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "flake": false, + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e9c6b0f --- /dev/null +++ b/flake.nix @@ -0,0 +1,70 @@ +{ + description = "A utilitarian bootloader for the GameCube"; + + inputs = { + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + nixpkgs.url = "github:9ary/nixpkgs/devkitPPC"; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + systems.flake = false; + }; + + outputs = { ... } @ inputs: inputs.flake-parts.lib.mkFlake { + inherit inputs; + } ({ config, flake-parts-lib, getSystem, inputs, lib, options, ... }: + let + rootConfig = config; + rootOptions = options; + in + { + _file = ./flake.nix; + imports = [ ]; + config.perSystem = { config, inputs', nixpkgs, options, pkgs, system, ... }: + let + systemConfig = config; + systemOptions = options; + in + { + _file = ./flake.nix; + config = { + devShells.default = pkgs.callPackage + ({ mkShell + , devkitPPC + , gamecube-tools + , meson + , ninja + , p7zip + , python3 + }: mkShell { + name = "iplboot"; + nativeBuildInputs = [ + # The cross toolchain + devkitPPC + gamecube-tools + + # The build system + meson ninja + + # Compressing binaries and the release archive + p7zip + + # For build scripts + python3 + ]; + + env = { + # For the libogc2 Makefile + DEVKITPPC = devkitPPC; + }; + }) + { }; + }; + }; + config.systems = import inputs.systems; + }); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..4e7ce3f --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +(import (let + lockFile = builtins.fromJSON (builtins.readFile ./flake.lock); + info = lockFile.nodes.flake-compat.locked; +in builtins.fetchTarball { + url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; + ${if info ? narHash then "sha256" else null} = info.narHash; +}) { src = ./.; }).shellNix