Skip to content

Commit

Permalink
Format with nixpkgs-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Feb 10, 2023
1 parent f601aec commit 43735cd
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 306 deletions.
19 changes: 9 additions & 10 deletions c/derivation.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
stdenv,
cmake,
SDL2,
pkg-config,
gitignoreSource,
clang-tools ? null,
ltoSupport ? false,
debugSupport ? false
{ lib
, stdenv
, cmake
, SDL2
, pkg-config
, gitignoreSource
, clang-tools ? null
, ltoSupport ? false
, debugSupport ? false
}:

let
Expand Down
22 changes: 11 additions & 11 deletions cpp/derivation.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
lib,
stdenv,
cmake,
SDL2,
fmt_8,
pkg-config,
gitignoreSource,
clang-format ? null,
ltoSupport ? false,
debugSupport ? false,
{ lib
, stdenv
, cmake
, SDL2
, fmt_8
, pkg-config
, gitignoreSource
, clang-format ? null
, ltoSupport ? false
, debugSupport ? false
,
}:

stdenv.mkDerivation rec {
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
}
)
{ src = ./.; }
).defaultNix
).defaultNix
323 changes: 166 additions & 157 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,166 +51,175 @@
};
};

outputs = {
self,
nixpkgs,
flake-utils,
flake-compat,
gitignore,
gomod2nix-src,
nim-argparse,
php-sdl-src,
naersk,
zig-overlay,
zig-sdl,
zig-clap,
gb-autotest-roms,
cl-gameboy
}: flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
inherit (builtins) mapAttrs;
inherit (lib) hiPrio filterAttrs;
gomod2nix' = rec {
gomod2nix = pkgs.callPackage "${gomod2nix-src}" { inherit buildGoApplication mkGoEnv; };
inherit (pkgs.callPackage "${gomod2nix-src}/builder" { inherit gomod2nix; }) buildGoApplication mkGoEnv;
};
callPackage = pkgs.newScope {
inherit gb-autotest-roms cl-gameboy;
inherit (gitignore.lib) gitignoreSource;
inherit php-sdl-src;
inherit nim-argparse;
inherit (gomod2nix') gomod2nix buildGoApplication;
naersk = pkgs.callPackage naersk {};
zig = zig-overlay.packages.${system}.master-2023-02-06;
inherit zig-clap zig-sdl;
};

utils = callPackage ./utils/derivation.nix {};

mkC = {clangSupport ? false, ltoSupport ? false, debugSupport ? false}:
callPackage ./c/derivation.nix {
stdenv = if clangSupport then pkgs.clangStdenv else pkgs.stdenv;
inherit ltoSupport debugSupport;
};

mkCpp = {ltoSupport ? false, debugSupport ? false, clangSupport ? false}:
callPackage ./cpp/derivation.nix {
stdenv = if clangSupport then pkgs.clangStdenv else pkgs.stdenv;
inherit ltoSupport debugSupport;
};

mkGo = {...}:
callPackage ./go/derivation.nix {
};

mkNim = {debugSupport ? false, speedSupport ? false}:
callPackage ./nim/derivation.nix {
inherit debugSupport speedSupport;
inherit (pkgs.llvmPackages_14) bintools;
};

mkPhp = {opcacheSupport ? false}:
callPackage ./php/derivation.nix {
inherit opcacheSupport;
};

mkPy = {mypycSupport ? false}:
callPackage ./py/derivation.nix {
inherit mypycSupport;
};

mkRs = {ltoSupport ? false, debugSupport ? false}:
callPackage ./rs/derivation.nix {
inherit ltoSupport debugSupport;
outputs =
{ self
, nixpkgs
, flake-utils
, flake-compat
, gitignore
, gomod2nix-src
, nim-argparse
, php-sdl-src
, naersk
, zig-overlay
, zig-sdl
, zig-clap
, gb-autotest-roms
, cl-gameboy
}: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
inherit (builtins) mapAttrs;
inherit (lib) hiPrio filterAttrs;
gomod2nix' = rec {
gomod2nix = pkgs.callPackage "${gomod2nix-src}" { inherit buildGoApplication mkGoEnv; };
inherit (pkgs.callPackage "${gomod2nix-src}/builder" { inherit gomod2nix; }) buildGoApplication mkGoEnv;
};

mkZig = {safeSupport ? false, fastSupport ? false}:
callPackage ./zig/derivation.nix {
inherit safeSupport fastSupport;
callPackage = pkgs.newScope {
inherit gb-autotest-roms cl-gameboy;
inherit (gitignore.lib) gitignoreSource;
inherit php-sdl-src;
inherit nim-argparse;
inherit (gomod2nix') gomod2nix buildGoApplication;
naersk = pkgs.callPackage naersk { };
zig = zig-overlay.packages.${system}.master-2023-02-06;
inherit zig-clap zig-sdl;
};

in rec {
packages = rec {
inherit utils;

c-debug = mkC { debugSupport = true; };
c-lto = mkC { ltoSupport = true; };
c-release = mkC { };
c-clang-debug = mkC { debugSupport = true; clangSupport = true; };
c-clang-lto = mkC { ltoSupport = true; clangSupport = true; };
c-clang-release = mkC { clangSupport = true; };
c = hiPrio c-release;

cpp-release = mkCpp {};
cpp-debug = mkCpp { debugSupport = true; };
cpp-lto = mkCpp { ltoSupport = true; };
cpp-clang-release = mkCpp { clangSupport = true; };
cpp-clang-debug = mkCpp { debugSupport = true; clangSupport = true; };
cpp-clang-lto = mkCpp { ltoSupport = true; clangSupport = true; };
cpp = hiPrio cpp-release;

go = mkGo {};

nim-release = mkNim {};
nim-debug = mkNim { debugSupport = true; };
nim-speed = mkNim { speedSupport = true; };
nim = hiPrio nim-release;

php-release = mkPhp {};
php-opcache = mkPhp { opcacheSupport = true; };
php = hiPrio php-release;

py = mkPy {};
# match statement support is only in myypc master
# https://github.com/python/mypy/commit/d5e96e381f72ad3fafaae8707b688b3da320587d
# mypyc = mkPy { mypycSupport = true; };

rs-debug = mkRs { debugSupport = true; };
rs-release = mkRs { };
rs-lto = mkRs { ltoSupport = true; };
rs = hiPrio rs-release;

zig-fast = mkZig { fastSupport = true; };
zig-safe = mkZig { safeSupport = true; };
zig = hiPrio zig-fast;

# I don't think we can join all of them because they collide
default = pkgs.symlinkJoin {
name = "rosettaboy";
paths = [ c cpp go nim php py rs zig ];
# if we use this without adding build tags to the executable,
# it'll build all variants but not symlink them
# paths = builtins.attrValues (filterAttrs (n: v: n != "default") packages);
utils = callPackage ./utils/derivation.nix { };

mkC = { clangSupport ? false, ltoSupport ? false, debugSupport ? false }:
callPackage ./c/derivation.nix {
stdenv = if clangSupport then pkgs.clangStdenv else pkgs.stdenv;
inherit ltoSupport debugSupport;
};

mkCpp = { ltoSupport ? false, debugSupport ? false, clangSupport ? false }:
callPackage ./cpp/derivation.nix {
stdenv = if clangSupport then pkgs.clangStdenv else pkgs.stdenv;
inherit ltoSupport debugSupport;
};

mkGo = { ... }:
callPackage ./go/derivation.nix { };

mkNim = { debugSupport ? false, speedSupport ? false }:
callPackage ./nim/derivation.nix {
inherit debugSupport speedSupport;
inherit (pkgs.llvmPackages_14) bintools;
};

mkPhp = { opcacheSupport ? false }:
callPackage ./php/derivation.nix {
inherit opcacheSupport;
};

mkPy = { mypycSupport ? false }:
callPackage ./py/derivation.nix {
inherit mypycSupport;
};

mkRs = { ltoSupport ? false, debugSupport ? false }:
callPackage ./rs/derivation.nix {
inherit ltoSupport debugSupport;
};

mkZig = { safeSupport ? false, fastSupport ? false }:
callPackage ./zig/derivation.nix {
inherit safeSupport fastSupport;
};

in
rec {
packages = rec {
inherit utils;

c-debug = mkC { debugSupport = true; };
c-lto = mkC { ltoSupport = true; };
c-release = mkC { };
c-clang-debug = mkC { debugSupport = true; clangSupport = true; };
c-clang-lto = mkC { ltoSupport = true; clangSupport = true; };
c-clang-release = mkC { clangSupport = true; };
c = hiPrio c-release;

cpp-release = mkCpp { };
cpp-debug = mkCpp { debugSupport = true; };
cpp-lto = mkCpp { ltoSupport = true; };
cpp-clang-release = mkCpp { clangSupport = true; };
cpp-clang-debug = mkCpp { debugSupport = true; clangSupport = true; };
cpp-clang-lto = mkCpp { ltoSupport = true; clangSupport = true; };
cpp = hiPrio cpp-release;

go = mkGo { };

nim-release = mkNim { };
nim-debug = mkNim { debugSupport = true; };
nim-speed = mkNim { speedSupport = true; };
nim = hiPrio nim-release;

php-release = mkPhp { };
php-opcache = mkPhp { opcacheSupport = true; };
php = hiPrio php-release;

py = mkPy { };
# match statement support is only in myypc master
# https://github.com/python/mypy/commit/d5e96e381f72ad3fafaae8707b688b3da320587d
# mypyc = mkPy { mypycSupport = true; };

rs-debug = mkRs { debugSupport = true; };
rs-release = mkRs { };
rs-lto = mkRs { ltoSupport = true; };
rs = hiPrio rs-release;

zig-fast = mkZig { fastSupport = true; };
zig-safe = mkZig { safeSupport = true; };
zig = hiPrio zig-fast;

# I don't think we can join all of them because they collide
default = pkgs.symlinkJoin {
name = "rosettaboy";
paths = [ c cpp go nim php py rs zig ];
# if we use this without adding build tags to the executable,
# it'll build all variants but not symlink them
# paths = builtins.attrValues (filterAttrs (n: v: n != "default") packages);
};
};
};

checks = let
# zig-safe is too slow - skip
packagesToCheck = filterAttrs (n: p: p.meta ? mainProgram && n != "zig-safe") packages;
in mapAttrs (_: utils.mkBlargg) packagesToCheck;

devShells = let
shellHook = ''
export GB_DEFAULT_AUTOTEST_ROM_DIR=${gb-autotest-roms}
export GB_DEFAULT_BENCH_ROM=${cl-gameboy}/roms/opus5.gb
'';
langDevShells = mapAttrs (name: package: pkgs.mkShell {
inputsFrom = [ package ];
buildInputs = package.devTools or [];
inherit shellHook;
}) packages;
in langDevShells // {
default = pkgs.mkShell {
inputsFrom = builtins.attrValues langDevShells;
};
# not yet implemented
pxd = callPackage ./pxd/shell.nix {};
# something wrong with using it in `inputsFrom`
py = pkgs.mkShell {
buildInputs = packages.py.devTools;
inherit shellHook;
};
};
});
checks =
let
# zig-safe is too slow - skip
packagesToCheck = filterAttrs (n: p: p.meta ? mainProgram && n != "zig-safe") packages;
in
mapAttrs (_: utils.mkBlargg) packagesToCheck;

devShells =
let
shellHook = ''
export GB_DEFAULT_AUTOTEST_ROM_DIR=${gb-autotest-roms}
export GB_DEFAULT_BENCH_ROM=${cl-gameboy}/roms/opus5.gb
'';
langDevShells = mapAttrs
(name: package: pkgs.mkShell {
inputsFrom = [ package ];
buildInputs = package.devTools or [ ];
inherit shellHook;
})
packages;
in
langDevShells // {
default = pkgs.mkShell {
inputsFrom = builtins.attrValues langDevShells;
};
# not yet implemented
pxd = callPackage ./pxd/shell.nix { };
# something wrong with using it in `inputsFrom`
py = pkgs.mkShell {
buildInputs = packages.py.devTools;
inherit shellHook;
};
};

formatter = pkgs.nixpkgs-fmt;
});
}
Loading

0 comments on commit 43735cd

Please sign in to comment.