From 0528b3b9d75d8abef6fc488a65527d42b673b98c Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Mon, 26 Feb 2024 18:05:51 -0800 Subject: [PATCH 01/16] Nix setup for Makefile build --- default.nix | 1 + nix/.editorconfig | 2 + nix/default.nix | 15 ++++ nix/devkitppc.nix | 41 ++++++++++ nix/melee.nix | 54 +++++++++++++ nix/mwcc.nix | 23 ++++++ nix/shell.nix | 24 ++++++ nix/sources.json | 14 ++++ nix/sources.nix | 198 ++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 1 + 10 files changed, 373 insertions(+) create mode 100644 default.nix create mode 100644 nix/.editorconfig create mode 100644 nix/default.nix create mode 100644 nix/devkitppc.nix create mode 100644 nix/melee.nix create mode 100644 nix/mwcc.nix create mode 100644 nix/shell.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..4203ea986b --- /dev/null +++ b/default.nix @@ -0,0 +1 @@ +import ./nix diff --git a/nix/.editorconfig b/nix/.editorconfig new file mode 100644 index 0000000000..f2693e935e --- /dev/null +++ b/nix/.editorconfig @@ -0,0 +1,2 @@ +[*.nix] +indent_size = 2 diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000000..ee9b0f7eaf --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,15 @@ +{ + sources ? import ./sources.nix, +}: +let + pkgs = import sources.nixpkgs { + overlays = [ + (self: super: { + devkitppc = super.callPackage ./devkitppc.nix {}; + mwcc = super.callPackage ./mwcc.nix {}; + }) + ]; + }; +in + +pkgs.callPackage ./melee.nix {} diff --git a/nix/devkitppc.nix b/nix/devkitppc.nix new file mode 100644 index 0000000000..23a5326fdb --- /dev/null +++ b/nix/devkitppc.nix @@ -0,0 +1,41 @@ +{ stdenvNoCC, lib +, buildEnv +, fetchFromGitHub +, fetchpatch +, makeWrapper +, overrideCC +, pkgsCross +}: + +let + version = "43"; + + tag = "devkitPPC_r${version}"; + + ppcCrossBinutils = pkgsCross.ppc-embedded.buildPackages.binutils-unwrapped; + + bintools' = ppcCrossBinutils.overrideAttrs (oa: { + patches = oa.patches ++ [ + (fetchpatch { + url = "https://raw.githubusercontent.com/devkitPro/buildscripts/${tag}/dkppc/patches/binutils-${oa.version}.patch"; + hash = "sha256-IOqa20LQYBxfR1KKxkp0hVV21CKd9IZrvNeEyuW09us="; + }) + ]; + }); +in +stdenvNoCC.mkDerivation { + pname = "devkitppc"; + inherit version; + nativeBuildInputs = [ + makeWrapper + ]; + buildCommand = '' + for bindir in '${lib.getBin bintools'}/bin'; do + cd "$bindir" + for f in powerpc-none-eabi-*; do + short="$(echo "$f" | sed s/powerpc-none-eabi-/powerpc-eabi-/)" + makeWrapper "$bindir/$f" "$out/bin/$short" + done + done + ''; +} diff --git a/nix/melee.nix b/nix/melee.nix new file mode 100644 index 0000000000..f9f6a6187b --- /dev/null +++ b/nix/melee.nix @@ -0,0 +1,54 @@ +{ lib +, stdenv +, devkitppc +, mwcc +, python3 +, wibo +}: +stdenv.mkDerivation { + name = "doldecomp-melee"; + + src = lib.cleanSourceWith { + filter = name: type: let + basename = baseNameOf (toString name); + in !(false + || basename == "build" + || basename == "expected" + || lib.hasSuffix ".nix" basename + || lib.hasSuffix ".dump" basename + || lib.hasSuffix ".o" basename + ); + src = lib.cleanSource ../.; + }; + + postPatch = '' + ln -sfT ${mwcc}/GC tools/mwcc_compiler + ''; + + shellHook = '' + runHook postPatch + ''; + + nativeBuildInputs = [ + devkitppc + python3 + wibo + ]; + + preBuild = '' + export HOME="$(mktemp -d)" + ''; + + DEVKITPPC = devkitppc; + + WINE = "${wibo}/bin/wibo"; + + enableParallelBuilding = true; + + installPhase = '' + runHook preInstall + mkdir -p $out + cp build/ssbm.us.1.2/main.dol $out/ + runHook postInstall + ''; +} diff --git a/nix/mwcc.nix b/nix/mwcc.nix new file mode 100644 index 0000000000..21d132df34 --- /dev/null +++ b/nix/mwcc.nix @@ -0,0 +1,23 @@ +{ lib +, stdenv +, fetchzip +}: +stdenv.mkDerivation { + name = "GC_WII_COMPILERS"; + src = fetchzip { + url = "https://cdn.discordapp.com/attachments/727918646525165659/1129759991696457728/GC_WII_COMPILERS.zip"; + stripRoot = false; + sha256 = "sha256-IX3byvEUVJB6Rmc+NqO9ZNt1jl95nQpEIqxbHI+uUio="; + }; + # Patch 1.1 linker to not read garbage from stack. + # Fixes random crashes under wibo. + postPatch = '' + printf '\x51' | dd of=GC/1.1/mwldeppc.exe bs=1 seek=130933 count=1 conv=notrunc + ''; + + installPhase = '' + runHook preInstall + cp -r . $out/ + runHook postInstall + ''; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000000..7498da8a75 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,24 @@ +{ + sources ? import ./sources.nix, +}: +let + pkgs = import sources.nixpkgs { + overlays = [ + (self: super: { + devkitppc = super.callPackage ./devkitppc.nix {}; + mwcc = super.callPackage ./mwcc.nix {}; + }) + ]; + }; + + melee = import ./default.nix { inherit sources; }; +in + +melee.overrideAttrs (oa: { + nativeBuildInputs = oa.nativeBuildInputs ++ [ + (pkgs.clang-tools.override { + llvmPackages = pkgs.llvmPackages_15; + }) + pkgs.clang.cc.python + ]; +}) diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000000..5b11d44705 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,14 @@ +{ + "nixpkgs": { + "branch": "nixos-unstable", + "description": "Nix Packages collection", + "homepage": "", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "sha256": "1v9sy2i2dy3qksx4mf81gwzfl0jzpqccfkzq7fjxgq832f9d255i", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/73de017ef2d18a04ac4bfd0c02650007ccb31c2a.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000000..fe3dadf7eb --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,198 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + + fetch_git = name: spec: + let + ref = + spec.ref or ( + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" + ); + submodules = spec.submodules or false; + submoduleArg = + let + nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; + emptyArgWithWarning = + if submodules + then + builtins.trace + ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) + { } + else { }; + in + if nixSupportsSubmodules + then { inherit submodules; } + else emptyArgWithWarning; + in + builtins.fetchGit + ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); + + fetch_local = spec: spec.path; + + fetch_builtin-tarball = name: throw + ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; + + fetch_builtin-url = name: throw + ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; + + # + # Various helpers + # + + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: system: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import { } + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if ! builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name spec + else if spec.type == "local" then fetch_local spec + else if spec.type == "builtin-tarball" then fetch_builtin-tarball name + else if spec.type == "builtin-url" then fetch_builtin-url name + else + abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # If the environment variable NIV_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + replace = name: drv: + let + saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; + ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; + in + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or ( + f: set: with builtins; + listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) + ); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else { }; + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs + ( + name: spec: + if builtins.hasAttr "outPath" spec + then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) + config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; + +in +mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..7f6e2295c2 --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +import ./nix/shell.nix From a40e63d889048f6c9307707d0b4f3023ea9c3076 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Mon, 26 Feb 2024 19:36:14 -0800 Subject: [PATCH 02/16] Modify nix files for ninja/dtk build --- nix/decomp-toolkit.nix | 34 ++++++++++++++++++++++++++++++++++ nix/default.nix | 2 ++ nix/melee.nix | 30 +++++++++++++++++++----------- nix/shell.nix | 2 ++ nix/wibo.nix | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 nix/decomp-toolkit.nix create mode 100644 nix/wibo.nix diff --git a/nix/decomp-toolkit.nix b/nix/decomp-toolkit.nix new file mode 100644 index 0000000000..a197df9046 --- /dev/null +++ b/nix/decomp-toolkit.nix @@ -0,0 +1,34 @@ +{ lib +, fetchFromGitHub +, git +, rustPlatform +, stdenv +}: + +rustPlatform.buildRustPackage rec { + pname = "decomp-toolkit"; + version = "0.7.3"; + + src = fetchFromGitHub { + owner = "encounter"; + repo = "decomp-toolkit"; + rev = "v${version}"; + hash = "sha256-cpHaoxRr/Lyx6tpyUx7Sm+9h0BicrO+jVJA09BBgKJ4="; + }; + + nativeBuildInputs = [ + git + ]; + + cargoLock.lockFile = "${src}/Cargo.lock"; + cargoLock.outputHashes."ar-0.8.0" = "sha256-OLyo+cRRWMsI1i8NsgsBKRJH1XsKW1CculQnJ/wcya0="; + cargoLock.outputHashes."dol-0.1.0" = "sha256-YfMXWNtmZJhK39R3w98DEGm4y9x59osFGliG36BcuLU="; + + meta = with lib; { + description = "A GameCube & Wii decompilation toolkit"; + homepage = "https://github.com/encounter/decomp-toolkit"; + license = with licenses; [ asl20 mit ]; + maintainers = with maintainers; [ r-burns ]; + mainProgram = "dtk"; + }; +} diff --git a/nix/default.nix b/nix/default.nix index ee9b0f7eaf..ee9b4c901b 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -5,8 +5,10 @@ let pkgs = import sources.nixpkgs { overlays = [ (self: super: { + decomp-toolkit = super.callPackage ./decomp-toolkit.nix {}; devkitppc = super.callPackage ./devkitppc.nix {}; mwcc = super.callPackage ./mwcc.nix {}; + wibo = super.pkgsi686Linux.callPackage ./wibo.nix {}; }) ]; }; diff --git a/nix/melee.nix b/nix/melee.nix index f9f6a6187b..d1fcd79c1d 100644 --- a/nix/melee.nix +++ b/nix/melee.nix @@ -1,10 +1,19 @@ { lib , stdenv +, decomp-toolkit , devkitppc +, fetchurl , mwcc +, ninja , python3 , wibo }: +let + sjiswrap = fetchurl { + url = "https://github.com/encounter/sjiswrap/releases/download/v1.1.1/sjiswrap-windows-x86.exe"; + hash = "sha256-J6PF1PJj5OuW5WGc/Noi9F0zzNEhEEx/9qN+FbP0J80="; + }; +in stdenv.mkDerivation { name = "doldecomp-melee"; @@ -21,34 +30,33 @@ stdenv.mkDerivation { src = lib.cleanSource ../.; }; - postPatch = '' - ln -sfT ${mwcc}/GC tools/mwcc_compiler - ''; - shellHook = '' runHook postPatch ''; nativeBuildInputs = [ + decomp-toolkit devkitppc + ninja python3 wibo ]; - preBuild = '' - export HOME="$(mktemp -d)" + configurePhase = '' + runHook preConfigure + python3 ./configure.py --wrapper ${wibo}/bin/wibo \ + --build-dtk ${decomp-toolkit}/bin/dtk \ + --sjiswrap ${sjiswrap} \ + --compilers ${mwcc} + runHook postConfigure ''; - DEVKITPPC = devkitppc; - - WINE = "${wibo}/bin/wibo"; - enableParallelBuilding = true; installPhase = '' runHook preInstall mkdir -p $out - cp build/ssbm.us.1.2/main.dol $out/ + cp build/GALE01/main.dol $out/ runHook postInstall ''; } diff --git a/nix/shell.nix b/nix/shell.nix index 7498da8a75..847f81d225 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -5,8 +5,10 @@ let pkgs = import sources.nixpkgs { overlays = [ (self: super: { + decomp-toolkit = super.callPackage ./decomp-toolkit.nix {}; devkitppc = super.callPackage ./devkitppc.nix {}; mwcc = super.callPackage ./mwcc.nix {}; + wibo = super.pkgsi686Linux.callPackage ./wibo.nix {}; }) ]; }; diff --git a/nix/wibo.nix b/nix/wibo.nix new file mode 100644 index 0000000000..048af67e6a --- /dev/null +++ b/nix/wibo.nix @@ -0,0 +1,38 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "wibo"; + version = "0.6.12"; + + src = fetchFromGitHub { + owner = "decompals"; + repo = "wibo"; + rev = version; + hash = "sha256-Kv3jbyWouz/bmteaoJyKkFC5YWuTEEaY6OvmJbZ0Xfg="; + }; + + nativeBuildInputs = [ + cmake + ]; + + meta = with lib; { + description = "Quick-and-dirty wrapper to run 32-bit windows EXEs on linux"; + longDescription = '' + A minimal, low-fuss wrapper that can run really simple command-line + 32-bit Windows binaries on Linux - with less faff and less dependencies + than WINE. + ''; + homepage = "https://github.com/decompals/WiBo"; + license = licenses.mit; + maintainers = with maintainers; [ r-burns ]; + platforms = [ "i686-linux" ]; + mainProgram = "wibo"; + }; + + # HACK: sjiswrap triggers buffer overflow detection, is this spurious? + hardeningDisable = [ "fortify" ]; +} From f3c497d0b026ac1d40c885d0a5330d9ab3e3fe8f Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Mon, 26 Feb 2024 19:36:44 -0800 Subject: [PATCH 03/16] Allow specifying prebuilt dtk binary --- configure.py | 2 +- tools/project.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index d80da0eaf6..b2f93d00c0 100755 --- a/configure.py +++ b/configure.py @@ -84,7 +84,7 @@ "--build-dtk", dest="build_dtk", type=Path, - help="path to decomp-toolkit source (optional)", + help="path to decomp-toolkit source or binary (optional)", ) parser.add_argument( "--sjiswrap", diff --git a/tools/project.py b/tools/project.py index 35cb906fd0..fcc8b5df34 100644 --- a/tools/project.py +++ b/tools/project.py @@ -214,7 +214,9 @@ def generate_build_ninja( description="TOOL $out", ) - if config.build_dtk_path: + if config.build_dtk_path and os.path.isfile(config.build_dtk_path): + dtk = config.build_dtk_path + elif config.build_dtk_path: dtk = build_tools_path / "release" / f"dtk{EXE}" n.rule( name="cargo", From 0baa3823a44e38db05b95bb06b91500caf73ad66 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Tue, 27 Feb 2024 17:03:21 -0800 Subject: [PATCH 04/16] Fix compiler zip url --- nix/mwcc.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/mwcc.nix b/nix/mwcc.nix index 21d132df34..92e4e62d9b 100644 --- a/nix/mwcc.nix +++ b/nix/mwcc.nix @@ -5,7 +5,7 @@ stdenv.mkDerivation { name = "GC_WII_COMPILERS"; src = fetchzip { - url = "https://cdn.discordapp.com/attachments/727918646525165659/1129759991696457728/GC_WII_COMPILERS.zip"; + url = "https://files.decomp.dev/compilers_20230715.zip"; stripRoot = false; sha256 = "sha256-IX3byvEUVJB6Rmc+NqO9ZNt1jl95nQpEIqxbHI+uUio="; }; From 2a8a6423770d24d1ab77435844c542d374d85c9c Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Tue, 27 Feb 2024 17:04:18 -0800 Subject: [PATCH 05/16] Rename nix/ to .nix/ --- {nix => .nix}/.editorconfig | 0 {nix => .nix}/decomp-toolkit.nix | 0 {nix => .nix}/default.nix | 0 {nix => .nix}/devkitppc.nix | 0 {nix => .nix}/melee.nix | 0 {nix => .nix}/mwcc.nix | 0 {nix => .nix}/shell.nix | 0 {nix => .nix}/sources.json | 0 {nix => .nix}/sources.nix | 0 {nix => .nix}/wibo.nix | 0 default.nix | 2 +- shell.nix | 2 +- 12 files changed, 2 insertions(+), 2 deletions(-) rename {nix => .nix}/.editorconfig (100%) rename {nix => .nix}/decomp-toolkit.nix (100%) rename {nix => .nix}/default.nix (100%) rename {nix => .nix}/devkitppc.nix (100%) rename {nix => .nix}/melee.nix (100%) rename {nix => .nix}/mwcc.nix (100%) rename {nix => .nix}/shell.nix (100%) rename {nix => .nix}/sources.json (100%) rename {nix => .nix}/sources.nix (100%) rename {nix => .nix}/wibo.nix (100%) diff --git a/nix/.editorconfig b/.nix/.editorconfig similarity index 100% rename from nix/.editorconfig rename to .nix/.editorconfig diff --git a/nix/decomp-toolkit.nix b/.nix/decomp-toolkit.nix similarity index 100% rename from nix/decomp-toolkit.nix rename to .nix/decomp-toolkit.nix diff --git a/nix/default.nix b/.nix/default.nix similarity index 100% rename from nix/default.nix rename to .nix/default.nix diff --git a/nix/devkitppc.nix b/.nix/devkitppc.nix similarity index 100% rename from nix/devkitppc.nix rename to .nix/devkitppc.nix diff --git a/nix/melee.nix b/.nix/melee.nix similarity index 100% rename from nix/melee.nix rename to .nix/melee.nix diff --git a/nix/mwcc.nix b/.nix/mwcc.nix similarity index 100% rename from nix/mwcc.nix rename to .nix/mwcc.nix diff --git a/nix/shell.nix b/.nix/shell.nix similarity index 100% rename from nix/shell.nix rename to .nix/shell.nix diff --git a/nix/sources.json b/.nix/sources.json similarity index 100% rename from nix/sources.json rename to .nix/sources.json diff --git a/nix/sources.nix b/.nix/sources.nix similarity index 100% rename from nix/sources.nix rename to .nix/sources.nix diff --git a/nix/wibo.nix b/.nix/wibo.nix similarity index 100% rename from nix/wibo.nix rename to .nix/wibo.nix diff --git a/default.nix b/default.nix index 4203ea986b..e574df5b72 100644 --- a/default.nix +++ b/default.nix @@ -1 +1 @@ -import ./nix +import ./.nix diff --git a/shell.nix b/shell.nix index 7f6e2295c2..7592a59a0b 100644 --- a/shell.nix +++ b/shell.nix @@ -1 +1 @@ -import ./nix/shell.nix +import ./.nix/shell.nix From b114b1189ba56396cf12f6ee16ab27cf7459421b Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Tue, 27 Feb 2024 17:13:30 -0800 Subject: [PATCH 06/16] Add Nix CI workflow --- .github/workflows/nix.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000000..b59946d315 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,15 @@ +name: "Nix build" +on: + pull_request: + push: +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v25 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix-build + - run: nix-shell --run "echo OK" From 6bdc424c461693c2141a030a4d9dfbe70586f76d Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 20:44:33 -0500 Subject: [PATCH 07/16] test --- .github/workflows/nix.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index b59946d315..91186f2e43 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -7,6 +7,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Log into container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Grab Melee DOL + run: | + docker pull ghcr.io/doldecomp/build-melee:main + container_id=$(docker create ghcr.io/doldecomp/build-melee:main) + docker cp $container_id:/orig . + docker rm $container_id - uses: cachix/install-nix-action@v25 with: nix_path: nixpkgs=channel:nixos-unstable From 55d87dc859e6941f10c9ecba0313fcccd7bdfcac Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 20:46:22 -0500 Subject: [PATCH 08/16] test --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 91186f2e43..d77d7f7079 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -10,7 +10,7 @@ jobs: - name: Log into container registry uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL From cec8b5f04bb6324e2f81f02ac3051f7f48bf3313 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:17:53 -0500 Subject: [PATCH 09/16] minor cleanup --- .github/workflows/nix.yml | 11 ++++++----- tools/project.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index d77d7f7079..639c0741b1 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -5,20 +5,21 @@ on: jobs: tests: runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io steps: - uses: actions/checkout@v4 - name: Log into container registry uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | - docker pull ghcr.io/doldecomp/build-melee:main - container_id=$(docker create ghcr.io/doldecomp/build-melee:main) - docker cp $container_id:/orig . - docker rm $container_id + docker pull "$REGISTRY/doldecomp/build-melee:main" + container_id=$(docker create "$REGISTRY/doldecomp/build-melee:main") + docker cp "$container_id":/orig . - uses: cachix/install-nix-action@v25 with: nix_path: nixpkgs=channel:nixos-unstable diff --git a/tools/project.py b/tools/project.py index fcc8b5df34..d597b248e1 100644 --- a/tools/project.py +++ b/tools/project.py @@ -214,7 +214,7 @@ def generate_build_ninja( description="TOOL $out", ) - if config.build_dtk_path and os.path.isfile(config.build_dtk_path): + if config.build_dtk_path and config.build_dtk_path.is_file(): dtk = config.build_dtk_path elif config.build_dtk_path: dtk = build_tools_path / "release" / f"dtk{EXE}" From c4873aafcf01bb99d4919353d85be7942cf81e92 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:21:05 -0500 Subject: [PATCH 10/16] why did it break --- .github/workflows/nix.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 639c0741b1..4489eb2893 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -12,13 +12,13 @@ jobs: - name: Log into container registry uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | - docker pull "$REGISTRY/doldecomp/build-melee:main" - container_id=$(docker create "$REGISTRY/doldecomp/build-melee:main") + docker pull "ghcr.io/doldecomp/build-melee:main" + container_id=$(docker create "ghcr.io/doldecomp/build-melee:main") docker cp "$container_id":/orig . - uses: cachix/install-nix-action@v25 with: From c90edf1d2019c89b43bd1699b607cc4b1c26c8a8 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:25:26 -0500 Subject: [PATCH 11/16] bourne again shell --- .github/workflows/nix.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 4489eb2893..10823010b9 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -7,18 +7,20 @@ jobs: runs-on: ubuntu-latest env: REGISTRY: ghcr.io + IMAGE: doldecomp/build-melee:main steps: - uses: actions/checkout@v4 - name: Log into container registry uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | - docker pull "ghcr.io/doldecomp/build-melee:main" - container_id=$(docker create "ghcr.io/doldecomp/build-melee:main") + image="$REGISTRY/$IMAGE" + docker pull "$image" + container_id=$(docker create "$image") docker cp "$container_id":/orig . - uses: cachix/install-nix-action@v25 with: From d2b9cbff873484cbc3682a17f5c2d9a656e7c063 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:26:58 -0500 Subject: [PATCH 12/16] eoux --- .github/workflows/nix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 10823010b9..17d588b62b 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -18,6 +18,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | + set -eoux pipefail image="$REGISTRY/$IMAGE" docker pull "$image" container_id=$(docker create "$image") From f55c5320c4d6886f86b42712c29f04b6fa7112d9 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:28:22 -0500 Subject: [PATCH 13/16] idk whatever --- .github/workflows/nix.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 17d588b62b..d77d7f7079 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -5,24 +5,20 @@ on: jobs: tests: runs-on: ubuntu-latest - env: - REGISTRY: ghcr.io - IMAGE: doldecomp/build-melee:main steps: - uses: actions/checkout@v4 - name: Log into container registry uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | - set -eoux pipefail - image="$REGISTRY/$IMAGE" - docker pull "$image" - container_id=$(docker create "$image") - docker cp "$container_id":/orig . + docker pull ghcr.io/doldecomp/build-melee:main + container_id=$(docker create ghcr.io/doldecomp/build-melee:main) + docker cp $container_id:/orig . + docker rm $container_id - uses: cachix/install-nix-action@v25 with: nix_path: nixpkgs=channel:nixos-unstable From e7ce0be6881181e79e7849fa0abe922cd8180dd6 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:30:09 -0500 Subject: [PATCH 14/16] oh wait --- .github/workflows/nix.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index d77d7f7079..10823010b9 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -5,20 +5,23 @@ on: jobs: tests: runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE: doldecomp/build-melee:main steps: - uses: actions/checkout@v4 - name: Log into container registry uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Grab Melee DOL run: | - docker pull ghcr.io/doldecomp/build-melee:main - container_id=$(docker create ghcr.io/doldecomp/build-melee:main) - docker cp $container_id:/orig . - docker rm $container_id + image="$REGISTRY/$IMAGE" + docker pull "$image" + container_id=$(docker create "$image") + docker cp "$container_id":/orig . - uses: cachix/install-nix-action@v25 with: nix_path: nixpkgs=channel:nixos-unstable From cad2282546e5892c2f04e24d3fd48e95b2fd68ce Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:32:51 -0500 Subject: [PATCH 15/16] add condition --- .github/workflows/nix.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 10823010b9..10c9bedf7d 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,10 +1,15 @@ -name: "Nix build" +name: build-nix +run-name: Nix + on: pull_request: push: + jobs: tests: + name: Build Melee runs-on: ubuntu-latest + if: github.repository == 'doldecomp/melee' env: REGISTRY: ghcr.io IMAGE: doldecomp/build-melee:main From c0f67bf7d558bc0bbfaa5f46991a271303afc1ab Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 27 Feb 2024 21:35:33 -0500 Subject: [PATCH 16/16] merge workflows --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/nix.yml | 35 ----------------------------------- 2 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9b323fbe2..af75fae294 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -215,3 +215,31 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + + build-nix: + name: Nix + runs-on: ubuntu-latest + if: github.repository == 'doldecomp/melee' + env: + REGISTRY: ghcr.io + IMAGE: doldecomp/build-melee:main + steps: + - uses: actions/checkout@v4 + - name: Log into container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Grab Melee DOL + run: | + image="$REGISTRY/$IMAGE" + docker pull "$image" + container_id=$(docker create "$image") + docker cp "$container_id":/orig . + - uses: cachix/install-nix-action@v25 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix-build + - run: nix-shell --run "echo OK" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml deleted file mode 100644 index 10c9bedf7d..0000000000 --- a/.github/workflows/nix.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: build-nix -run-name: Nix - -on: - pull_request: - push: - -jobs: - tests: - name: Build Melee - runs-on: ubuntu-latest - if: github.repository == 'doldecomp/melee' - env: - REGISTRY: ghcr.io - IMAGE: doldecomp/build-melee:main - steps: - - uses: actions/checkout@v4 - - name: Log into container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Grab Melee DOL - run: | - image="$REGISTRY/$IMAGE" - docker pull "$image" - container_id=$(docker create "$image") - docker cp "$container_id":/orig . - - uses: cachix/install-nix-action@v25 - with: - nix_path: nixpkgs=channel:nixos-unstable - - uses: DeterminateSystems/magic-nix-cache-action@v2 - - run: nix-build - - run: nix-shell --run "echo OK"