diff --git a/flake.lock b/flake.lock index 8443c4f..c0166fd 100644 --- a/flake.lock +++ b/flake.lock @@ -122,6 +122,22 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1720158314, + "narHash": "sha256-QNEOk6xmw3ct7P70wKzkGoqeb5gyJWEFdw7AZIul9V4=", + "owner": "CyborgPotato", + "repo": "nixos-hardware", + "rev": "c905e5bf25f9eab4cd3e014d3157fa3a62c3a5b6", + "type": "github" + }, + "original": { + "owner": "CyborgPotato", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1718530797, @@ -155,6 +171,22 @@ } }, "nixpkgs-stable_2": { + "locked": { + "lastModified": 1720553833, + "narHash": "sha256-IXMiHQMtdShDXcBW95ctA+m5Oq2kLxnBt7WlMxvDQXA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "249fbde2a178a2ea2638b65b9ecebd531b338cf9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_3": { "locked": { "lastModified": 1718478900, "narHash": "sha256-v43N1gZLcGkhg3PdcrKUNIZ1L0FBzB2JqhIYEyKAHEs=", @@ -191,14 +223,16 @@ "home-manager": "home-manager", "me-emacs": "me-emacs", "nix-darwin": "nix-darwin", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable_2", "sops-nix": "sops-nix" } }, "sops-nix": { "inputs": { "nixpkgs": "nixpkgs_2", - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { "lastModified": 1718506969, diff --git a/flake.nix b/flake.nix index 0c6cb0d..c07a75f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,8 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; + nixos-hardware.url = "github:CyborgPotato/nixos-hardware/master"; sops-nix.url = "github:Mic92/sops-nix"; me-emacs.url = "git+https://git.syzygial.cc/Syzygial/EmacsConfig.git"; me-emacs.inputs.nixpkgs.follows = "nixpkgs"; @@ -10,7 +12,7 @@ home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, sops-nix, me-emacs, nix-darwin, home-manager }@attrs: let + outputs = { self, nixpkgs, nixpkgs-stable, nixos-hardware, sops-nix, me-emacs, nix-darwin, home-manager }@attrs: let hydraGitea = import ./overlays/hydra.nix; nvidiaContainer = import ./overlays/nvidiacontainer.nix nixpkgs; me-emacs-overlay = me-emacs.overlays.default; @@ -48,6 +50,22 @@ sops-nix.nixosModules.sops ]; }; + ptv = let + patch-8gb = { + hardware.deviceTree.overlays = [{ + name = "8GB-patch"; + dtsFile = "${nixos-hardware}/pine64/pinetab-v/star64-8GB.dts"; + }]; + }; + in nixpkgs-stable.lib.nixosSystem { + specialArgs = { + inputs = attrs; + }; + modules = [ + ./machines/ptv/configuration.nix + patch-8gb + ]; + }; }; darwinConfigurations."UniverseAir" = nix-darwin.lib.darwinSystem { system = "aarch64-darwin"; @@ -77,5 +95,9 @@ inputs = attrs; }; }; + + hydraJobs = { + PinetabV = self.nixosConfigurations.ptv.config.system.build.toplevel; + }; }; } diff --git a/machines/ptv/ccache.nix b/machines/ptv/ccache.nix new file mode 100644 index 0000000..7e1182b --- /dev/null +++ b/machines/ptv/ccache.nix @@ -0,0 +1,42 @@ +{ config, pkgs, lib, inputs, ... }: { + programs.ccache.enable = true; + programs.ccache.cacheDir = "/opt/ccache"; + nix.settings.extra-sandbox-paths = [ "/opt/ccache" ]; + nixpkgs.overlays = [ + (self: super: { + ccacheWrapper = super.ccacheWrapper.override { + # TODO: Sloppiness random_seed apart of wrapper + extraConfig = '' + export CCACHE_COMPRESS=1 + export CCACHE_DIR="${config.programs.ccache.cacheDir}" + export CCACHE_UMASK=007 + if [ ! -d "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' does not exist" + echo "Please create it with:" + echo " sudo mkdir -m0770 '$CCACHE_DIR'" + echo " sudo chown root:nixbld '$CCACHE_DIR'" + echo "=====" + exit 1 + fi + if [ ! -w "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)" + echo "Please verify its access permissions" + echo "=====" + exit 1 + fi + ''; + }; + linux-ptv-ccache = pkgs.callPackage "${inputs.nixos-hardware}/pine64/pinetab-v/linux-5.15.nix" { + argsOverride = { + stdenv = self.ccacheStdenv; + }; + }; + }) + ]; + + programs.ccache.packageNames = [ "ffmpeg" "firefox-unwrapped" "tmux" ]; + + boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux-ptv-ccache; +} diff --git a/machines/ptv/configuration.nix b/machines/ptv/configuration.nix new file mode 100644 index 0000000..d4ee26d --- /dev/null +++ b/machines/ptv/configuration.nix @@ -0,0 +1,91 @@ +{ lib, pkgs, config, inputs, ... }: let + inherit (pkgs.checkpointBuildTools) prepareCheckpointBuild mkCheckpointBuild; + linux-cached = prepareCheckpointBuild pkgs.linux-ptv; + linux-changed = pkgs.linux-ptv; + linux-ptv = pkgs.checkpointBuildTools.mkCheckpointBuild linux-changed linux-cached; +in { +# boot.kernelPackages = pkgs.linuxPackagesFor linux-ptv; + boot.kernelParams = lib.mkDefault [ "console=tty0" "console=ttyS0" ]; + + systemd.services."getty@tty0".enable = lib.mkDefault true; + systemd.services."getty@tty0".wantedBy = lib.mkDefault [ "getty.target" ]; + + system.stateVersion = "24.05"; + nixpkgs.hostPlatform = "riscv64-linux"; + networking.hostName = "ptv"; + nix.registry.nixpkgs.flake = inputs.nixpkgs; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + nixpkgs.overlays = [ + (final: prev: { + # https://github.com/starfive-tech/soft_3rdpart/tree/JH7110_VisionFive2_devel + # Source of different firmware/3rd party sw and fw + img-rogue-firmware = pkgs.stdenv.mkDerivation { + pname = "img-gpu-powervr"; + version = "36-working-on-it"; + + src = ./rgx-img-gpu-firmware.tar.gz; + dontBuild = true; + + passthru = { + compressFirmware = false; + }; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib/firmware + cp * $out/lib/firmware + + runHook postInstall + ''; + }; + }) + (import ./pkgs) + ]; + + imports = [ + "${inputs.nixos-hardware}/pine64/pinetab-v/sd-image.nix" + # ./ccache.nix + ./native-bootstrap.nix + ]; + + users.users = { + pine64 = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + initialHashedPassword = "$y$j9T$cuXgVIPt3n1.v7GcoXiql1$4EBlHM7sYO.lL.DTDwQzTBqSYsD01WIDZQXleCeozl8"; + }; + root = { + initialHashedPassword = "$y$j9T$cuXgVIPt3n1.v7GcoXiql1$4EBlHM7sYO.lL.DTDwQzTBqSYsD01WIDZQXleCeozl8"; + }; + }; + + networking.wireless.enable = true; + networking.wireless.userControlled.enable = true; + + #programs.hyprland = { + # Install the packages from nixpkgs + # enable = true; + # Whether to enable XWayland + # xwayland.enable = true; + #}; + + environment.systemPackages = with pkgs; [ + dropbear + busybox + tmux + git + + weston + + # ffmpeg + # firefox + ]; + + hardware.firmware = pkgs.lib.mkOrder 1000 [ + pkgs.img-rogue-firmware + ]; + + services.openssh.enable = true; +} diff --git a/machines/ptv/img-gpu-powervr-bin-1.15.6052913.tar.gz b/machines/ptv/img-gpu-powervr-bin-1.15.6052913.tar.gz new file mode 100644 index 0000000..5f93cf0 Binary files /dev/null and b/machines/ptv/img-gpu-powervr-bin-1.15.6052913.tar.gz differ diff --git a/machines/ptv/img-gpu-powervr-bin-1.17.6210866.tar.gz b/machines/ptv/img-gpu-powervr-bin-1.17.6210866.tar.gz new file mode 100644 index 0000000..d86ae48 Binary files /dev/null and b/machines/ptv/img-gpu-powervr-bin-1.17.6210866.tar.gz differ diff --git a/machines/ptv/native-bootstrap.nix b/machines/ptv/native-bootstrap.nix new file mode 100644 index 0000000..44ffef1 --- /dev/null +++ b/machines/ptv/native-bootstrap.nix @@ -0,0 +1,37 @@ +{ config, pkgs, lib, ...}: let + stdenvStages = curStage: + [ curStage ] + ++ + (if curStage.hasCC + then [curStage.cc] ++ (stdenvStages curStage.__bootPackages.stdenv) + else []); +in { + system.includeBuildDependencies = true; + system.extraDependencies = with pkgs; + lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) + ((stdenvStages stdenv) ++ [ + stdenvNoCC + clangStdenv + clangStdenv.cc + clang + libllvm + gcc + rustc + cargo + coreutils + curl + wget + python3 + # Other common build tools + zip + unzip + cmake + meson + bison + perl + zlib + busybox + xz + binutils + ]); +} diff --git a/machines/ptv/pkgs-cross/argyllcms/default.nix b/machines/ptv/pkgs-cross/argyllcms/default.nix new file mode 100644 index 0000000..4711d88 --- /dev/null +++ b/machines/ptv/pkgs-cross/argyllcms/default.nix @@ -0,0 +1,17 @@ +final: prev: prev.argyllcms.overrideAttrs (old: { + postInstall = (prev.lib.optional (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) '' + cp imdi/imdi_make $out/bin + cp gamut/GenRMGam $out/bin + ''); + patches = (prev.lib.optionals (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) [ + ./imdi_make.patch + ]); + preBuild = (prev.lib.optional (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) '' + cd imdi; imdi_make; cd .. + cd gamut; GenRMGam; cd .. + ''); + # Need to use build version of imdi_make && host version for output + depsBuildBuild = (prev.lib.optionals (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) [ + prev.buildPackages.argyllcms + ]); +}) diff --git a/machines/ptv/pkgs-cross/argyllcms/imdi_make.patch b/machines/ptv/pkgs-cross/argyllcms/imdi_make.patch new file mode 100644 index 0000000..746a057 --- /dev/null +++ b/machines/ptv/pkgs-cross/argyllcms/imdi_make.patch @@ -0,0 +1,39 @@ +diff --git a/gamut/Jamfile b/gamut/Jamfile +index e97d0df..adc259f 100755 +--- a/gamut/Jamfile ++++ b/gamut/Jamfile +@@ -47,7 +47,7 @@ Main GenRMGam : GenRMGam.c ; + # Generate referenec medium gamut the kernel files + # (NoUpdate so that Cross Compile Win64 hack works) + NNoUpdate RefMediumGamut.gam ; +-GenFile RefMediumGamut.gam : GenRMGam ; ++# GenFile RefMediumGamut.gam : GenRMGam ; + + # Visual gamut + Main GenVisGam : GenVisGam.c ; +diff --git a/imdi/Jamfile b/imdi/Jamfile +index 79b27fb..64c3348 100755 +--- a/imdi/Jamfile ++++ b/imdi/Jamfile +@@ -41,7 +41,7 @@ LINKLIBS = ../numlib/libnum ; + + # GenFile source.c : program args ; make custom file + # Generate all the kernel files +-GenFileND imdi_k.h : imdi_make $(IMDI_MAKE_OPT) -d [ NormPaths $(DOT) ] ; ++# GenFileND imdi_k.h : imdi_make $(IMDI_MAKE_OPT) -d [ NormPaths $(DOT) ] ; + + # imdi library + Library libimdi : imdi.c imdi_tab.c ; +diff --git a/imdi/Makefile b/imdi/Makefile +index 5523893..2048875 100755 +--- a/imdi/Makefile ++++ b/imdi/Makefile +@@ -48,7 +48,7 @@ imdi_gen$(SUFOBJ): imdi_gen.c imdi_utl.h imdi_arch.h imdi_gen.h + + # Generate the kernel files + imdi_k.h imdi_k.c : imdi_make$(SUFEXE) +- .$(SLASH)imdi_make$(SUFEXE) ++ imdi_make$(SUFEXE) + + + # imdi runtime library diff --git a/machines/ptv/pkgs-cross/bundlerApp/default.nix b/machines/ptv/pkgs-cross/bundlerApp/default.nix new file mode 100644 index 0000000..fbb345c --- /dev/null +++ b/machines/ptv/pkgs-cross/bundlerApp/default.nix @@ -0,0 +1,4 @@ +final: prev: prev.bundlerApp.override (old: { + ruby = final.buildPackages.ruby; + callPackage = final.newScope { ruby = final.buildPackages.ruby; }; +}) diff --git a/machines/ptv/pkgs-cross/cryptsetup/default.nix b/machines/ptv/pkgs-cross/cryptsetup/default.nix new file mode 100644 index 0000000..0ee9292 --- /dev/null +++ b/machines/ptv/pkgs-cross/cryptsetup/default.nix @@ -0,0 +1,3 @@ +final: prev: prev.cryptsetup.overrideAttrs (old: { + doCheck = false; +}) diff --git a/machines/ptv/pkgs-cross/default.nix b/machines/ptv/pkgs-cross/default.nix new file mode 100644 index 0000000..2afa610 --- /dev/null +++ b/machines/ptv/pkgs-cross/default.nix @@ -0,0 +1,19 @@ +(final: prev: { + discount = (import ./discount) final prev; + fwupd-efi = (import ./fwupd-efi) final prev; + live555 = (import ./live555) final prev; + protobuf = (import ./protobuf) final prev; + bundlerApp = (import ./bundlerApp) final prev; + vulkan-tools = (import ./vulkan-tools) final prev; + libdrm = (import ./libdrm) final prev; + valgrind = (import ./valgrind) final prev; + valgrind-light = final.valgrind.override { gdb = null; }; + argyllcms = (import ./argyllcms) final prev; + gn = (import ./gn) final prev; + openfortivpn = (import ./openfortivpn) final prev; + vpnc = (import ./vpnc) final prev; + # perl538Packages.Testutf8 = (import ./perlTestutf8) final prev; + diffutils = (import ./diffutils) final prev; + gnugrep = (import ./gnugrep) final prev; + cryptsetup = (import ./cryptsetup) final prev; +}) diff --git a/machines/ptv/pkgs-cross/diffutils/default.nix b/machines/ptv/pkgs-cross/diffutils/default.nix new file mode 100644 index 0000000..135aef9 --- /dev/null +++ b/machines/ptv/pkgs-cross/diffutils/default.nix @@ -0,0 +1,4 @@ + +final: prev: prev.diffutils.overrideAttrs (old: { + doCheck = false; #prev.stdenv.hostPlatform != "riscv64-linux"; +}) diff --git a/machines/ptv/pkgs-cross/discount/config-sed.c b/machines/ptv/pkgs-cross/discount/config-sed.c new file mode 100644 index 0000000..d735367 --- /dev/null +++ b/machines/ptv/pkgs-cross/discount/config-sed.c @@ -0,0 +1,23 @@ +#include + +int +main(argc, argv) +int argc; +char **argv; +{ + char *p; + + if (argc != 3) + return 1; + + printf("s;@%s@;", argv[1]); + + for (p=argv[2]; *p; ++p) { + if ( *p == ';' ) + putchar('\\'); + putchar(*p); + } + + puts(";g"); + return 0; +} diff --git a/machines/ptv/pkgs-cross/discount/config-sed.patch b/machines/ptv/pkgs-cross/discount/config-sed.patch new file mode 100644 index 0000000..d46d4ae --- /dev/null +++ b/machines/ptv/pkgs-cross/discount/config-sed.patch @@ -0,0 +1,67 @@ +diff --git a/configure.inc b/configure.inc +index fd0c9ba..98066d5 100755 +--- a/configure.inc ++++ b/configure.inc +@@ -1733,52 +1733,6 @@ AC_FAIL() { + $__fail 1 + } + +-# +-# __ac_config_sed; a C program to do escaping for AC_SUB +-__ac_config_sed() { +- +- +- test -x config.sed && return +- +- echo "generating config.sed" +- +- AC_PROG_CC +- +-cat > ngc$$.c << \EOF +-#include +- +-int +-main(argc, argv) +-int argc; +-char **argv; +-{ +- char *p; +- +- if (argc != 3) +- return 1; +- +- printf("s;@%s@;", argv[1]); +- +- for (p=argv[2]; *p; ++p) { +- if ( *p == ';' ) +- putchar('\\'); +- putchar(*p); +- } +- +- puts(";g"); +- return 0; +-} +-EOF +- +- if $AC_CC -o config.sed ngc$$.c; then +- rm -f ngc$$.c +- __config_files="$__config_files config.sed" +- else +- rm -f ngc$$.c +- AC_FAIL "Cannot generate config.sed helper program" +- fi +-} +- + # + # AC_SUB writes a substitution into config.sub + AC_SUB() { +@@ -1788,8 +1742,7 @@ AC_SUB() { + + echo "target=$_target, rest=$*" + +- __ac_config_sed +- ./config.sed "$_target" "$*" >> "$__cwd"/config.sub ++ config.sed "$_target" "$*" >> "$__cwd"/config.sub + } + # + # AC_TEXT writes arbitrary text into config.h diff --git a/machines/ptv/pkgs-cross/discount/default.nix b/machines/ptv/pkgs-cross/discount/default.nix new file mode 100644 index 0000000..e8beed6 --- /dev/null +++ b/machines/ptv/pkgs-cross/discount/default.nix @@ -0,0 +1,47 @@ +final: prev: let + config-sed = prev.buildPackages.stdenv.mkDerivation { + name = "orc-discount-config-sed"; + src = ./config-sed.c; + dontUnpack = true; + buildPhase = '' + $CC -o config.sed $src + ''; + installPhase = '' + mkdir -p $out/bin + chmod +x ./config.sed + mv config.sed $out/bin + ''; + }; +in prev.discount.overrideAttrs (old: let + patches = [ + ./config-sed.patch + ./make-fix.patch + ] ++ old.patches; + orc-tools = prev.buildPackages.stdenv.mkDerivation { + name = "orc-discount-tools"; + src = old.src; + inherit patches; + configureScript = old.configureScript; + configureFlags = old.configureFlags; + buildPhase = '' + $CC -o mktags mktags.c + $CC -I ./ -o branch tools/branch.c + ''; + installPhase = '' + mkdir -p $out/bin + mv mktags $out/bin + mv branch $out/bin + ''; + }; +in { + # ./configure does not support autoconf-style --build=/--host=. + configurePlatforms = [ ]; + depsBuildBuild = [ + config-sed + orc-tools + prev.buildPackages.coreutils + ]; + nativeBuildInputs = [ + ]; + inherit patches; +}) diff --git a/machines/ptv/pkgs-cross/discount/make-fix.patch b/machines/ptv/pkgs-cross/discount/make-fix.patch new file mode 100644 index 0000000..5013c83 --- /dev/null +++ b/machines/ptv/pkgs-cross/discount/make-fix.patch @@ -0,0 +1,58 @@ +diff --git a/Makefile.in b/Makefile.in +index 085fbd5..e59d769 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -29,7 +29,7 @@ OBJS=mkdio.o markdown.o dumptree.o generate.o \ + xml.o Csio.o xmlpage.o basename.o emmatch.o \ + github_flavoured.o setup.o tags.o html5.o \ + @AMALLOC@ @H1TITLE@ flags.o +-TESTFRAMEWORK=echo cols branch pandoc_headers ++TESTFRAMEWORK=echo cols pandoc_headers + + # modules that markdown, makepage, mkd2html, &tc use + COMMON=pgm_options.o gethopt.o notspecial.o +@@ -84,19 +84,16 @@ $(DESTDIR)$(LIBDIR): + @MK_PKGCONFIG@$(DESTDIR)$(PKGDIR): + @MK_PKGCONFIG@ $(INSTALL_DIR) $(DESTDIR)$(PKGDIR) + +-version.o: version.c VERSION branch +- $(BUILD) -DBRANCH=`./branch` -DVERSION=\"`cat VERSION`\" -c version.c ++version.o: version.c VERSION ++ $(BUILD) -DBRANCH=`branch` -DVERSION=\"`cat VERSION`\" -c version.c + + VERSION: + @true + + tags.o: tags.c cstring.h tags.h blocktags + +-blocktags: mktags +- ./mktags > blocktags +- +-mktags: mktags.o +- $(LINK) -o mktags mktags.o ++blocktags: ++ mktags > blocktags + + # example programs + @THEME@theme: theme.o $(COMMON) $(MKDLIB) mkdio.h +@@ -143,11 +140,6 @@ pandoc_headers.o: tools/pandoc_headers.c config.h + pandoc_headers: pandoc_headers.o $(COMMON) $(MKDLIB) + $(LINK) -o pandoc_headers pandoc_headers.o $(COMMON) -lmarkdown + +-branch.o: tools/branch.c config.h +- $(BUILD) -c -o branch.o tools/branch.c +-branch: branch.o +- $(LINK) -o branch branch.o +- + cols.o: tools/cols.c config.h + $(BUILD) -c -o cols.o tools/cols.c + cols: cols.o +@@ -163,7 +155,7 @@ clean: + rm -f $(MKDLIB) `./librarian.sh files $(MKDLIB) VERSION` + + distclean spotless: clean +- @DISTCLEAN@ @GENERATED_FILES@ @CONFIGURE_FILES@ ./mktags ./blocktags ++ @DISTCLEAN@ @GENERATED_FILES@ @CONFIGURE_FILES@ ./blocktags + + Csio.o: Csio.c cstring.h amalloc.h config.h markdown.h + amalloc.o: amalloc.c diff --git a/machines/ptv/pkgs-cross/discount/where-tr.patch b/machines/ptv/pkgs-cross/discount/where-tr.patch new file mode 100644 index 0000000..409f8aa --- /dev/null +++ b/machines/ptv/pkgs-cross/discount/where-tr.patch @@ -0,0 +1,13 @@ +diff --git a/configure.inc b/configure.inc +index fd0c9ba..7ea98e6 100755 +--- a/configure.inc ++++ b/configure.inc +@@ -1830,7 +1830,7 @@ AC_QUIET() { + } + + +-AC_TR=`acLookFor tr` ++AC_TR=`which tr` + if [ "$AC_TR" ]; then + # try posix-style tr + ABC=`echo abc | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` diff --git a/machines/ptv/pkgs-cross/fwupd-efi/default.nix b/machines/ptv/pkgs-cross/fwupd-efi/default.nix new file mode 100644 index 0000000..e8ea696 --- /dev/null +++ b/machines/ptv/pkgs-cross/fwupd-efi/default.nix @@ -0,0 +1,19 @@ +(final: prev: + prev.fwupd-efi.overrideAttrs (old: { + mesonFlags = old.mesonFlags ++ [ + # Use this instead of patch, however it points to proper binary + "-Defi-cc=${prev.stdenv.cc.targetPrefix}cc" + ]; + preBuild = '' + cp ${prev.gnu-efi}/lib/*.lds ../efi/lds + ''; + patches = [ + (prev.fetchurl { + url = "https://github.com/fwupd/fwupd-efi/commit/986a6e3beee6b951ca3622f47ed991e0e11c065c.diff"; + hash = "sha256-UKerVzSn28QSoca6m2igVM6ai8i3B2jyB52B6e/HV5A="; + }) + # ./efi-meson.patch + ]; + }) +) + diff --git a/machines/ptv/pkgs-cross/fwupd-efi/efi-meson.patch b/machines/ptv/pkgs-cross/fwupd-efi/efi-meson.patch new file mode 100644 index 0000000..e3e525c --- /dev/null +++ b/machines/ptv/pkgs-cross/fwupd-efi/efi-meson.patch @@ -0,0 +1,13 @@ +diff --git a/efi/meson.build b/efi/meson.build +index 936ba3c..53687b1 100644 +--- a/efi/meson.build ++++ b/efi/meson.build +@@ -1,7 +1,7 @@ + generate_sbat = find_program('generate_sbat.py', native: true) + generate_binary = find_program('generate_binary.py', native: true) + +-efi_cc = get_option('efi-cc') ++efi_cc = run_command('sh', '-c', 'echo $CC') + efi_ld = get_option('efi-ld') + efi_ldsdir = get_option('efi-ldsdir') + efi_incdir = get_option('efi-includedir') diff --git a/machines/ptv/pkgs-cross/fwupd-efi/meson-rv64.patch b/machines/ptv/pkgs-cross/fwupd-efi/meson-rv64.patch new file mode 100644 index 0000000..ed9d86b --- /dev/null +++ b/machines/ptv/pkgs-cross/fwupd-efi/meson-rv64.patch @@ -0,0 +1,14 @@ +diff --git a/meson.build b/meson.build +index 7d59695..b82bcdf 100644 +--- a/meson.build ++++ b/meson.build +@@ -31,6 +31,9 @@ elif host_cpu == 'arm' + elif host_cpu == 'aarch64' + EFI_MACHINE_TYPE_NAME = 'aa64' + gnu_efi_arch = 'aarch64' ++elif host_cpu == 'riscv64' ++ EFI_MACHINE_TYPE_NAME = '.' ++ gnu_efi_arch = 'riscv64' + else + error('Unknown host_cpu ' + host_cpu) + endif diff --git a/machines/ptv/pkgs-cross/gn/default.nix b/machines/ptv/pkgs-cross/gn/default.nix new file mode 100644 index 0000000..1ca039f --- /dev/null +++ b/machines/ptv/pkgs-cross/gn/default.nix @@ -0,0 +1,10 @@ +# TODO: gn-unstable needs rev newer than 2021-01-28 +# 713a1850957b919c876c924e43ef0ddc4d8a8144 for riscv64 support + +final: prev: prev.gn.overrideAttrs (old: { + src = prev.fetchgit { + url = "https://gn.googlesource.com/gn"; + rev = "713a1850957b919c876c924e43ef0ddc4d8a8144"; + hash = "sha256-yzx7wPp/PEwGg4HZ99YntyHJ384nTVq6fyB6/vOOvOM="; + }; +}) diff --git a/machines/ptv/pkgs-cross/gnugrep/default.nix b/machines/ptv/pkgs-cross/gnugrep/default.nix new file mode 100644 index 0000000..8fcbf0d --- /dev/null +++ b/machines/ptv/pkgs-cross/gnugrep/default.nix @@ -0,0 +1,4 @@ + +final: prev: prev.gnugrep.overrideAttrs (old: { + doCheck = false; #prev.stdenv.hostPlatform != "riscv64-linux"; +}) diff --git a/machines/ptv/pkgs-cross/libdrm/default.nix b/machines/ptv/pkgs-cross/libdrm/default.nix new file mode 100644 index 0000000..583cd15 --- /dev/null +++ b/machines/ptv/pkgs-cross/libdrm/default.nix @@ -0,0 +1,5 @@ +final: prev: prev.libdrm.overrideAttrs (old: { + buildInputs = old.buildInputs ++ [ + final.libatomic_ops + ]; +}) diff --git a/machines/ptv/pkgs-cross/live555/default.nix b/machines/ptv/pkgs-cross/live555/default.nix new file mode 100644 index 0000000..df5001b --- /dev/null +++ b/machines/ptv/pkgs-cross/live555/default.nix @@ -0,0 +1,8 @@ +final: prev: prev.live555.overrideAttrs (old: { + preConfigure = (prev.lib.optional (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) '' + sed -e 's/^C_COMPILER.*=.*$/C_COMPILER = $(CC)/g' -i config.* + sed -e 's/^CPLUSPLUS_COMPILER.*=.*$/CPLUSPLUS_COMPILER = $(CXX)/g' -i config.* + sed -e 's/^LINK.*=.*$/LINK = $(CXX) -o/g' -i config.* + sed -e 's/^LIBRARY_LINK.*=.*$/LIBRARY_LINK = $(AR) cr /g' -i config.* + ''); +}) diff --git a/machines/ptv/pkgs-cross/openfortivpn/default.nix b/machines/ptv/pkgs-cross/openfortivpn/default.nix new file mode 100644 index 0000000..98c063e --- /dev/null +++ b/machines/ptv/pkgs-cross/openfortivpn/default.nix @@ -0,0 +1,5 @@ +final: prev: prev.openfortivpn.overrideAttrs (old: { + configureFlags = old.configureFlags ++ prev.lib.optionals (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) [ + "--disable-proc" + ]; +}) diff --git a/machines/ptv/pkgs-cross/perlTestutf8/default.nix b/machines/ptv/pkgs-cross/perlTestutf8/default.nix new file mode 100644 index 0000000..960a65e --- /dev/null +++ b/machines/ptv/pkgs-cross/perlTestutf8/default.nix @@ -0,0 +1,42 @@ +final: prev: prev.perl538Packages.Testutf8.overrideAttrs (old: let + perl = final.perl538; +in { + postInstall = prev.lib.optionalString (prev.stdenv.buildPlatform != prev.stdenv.hostPlatform) '' + mkdir -p $out/${perl.libPrefix}/cross_perl/${perl.version}/DBI + cat > $out/${perl.libPrefix}/cross_perl/${perl.version}/DBI.pm < $out/${perl.libPrefix}/cross_perl/${perl.version}/DBI/DBD.pm < \$(BASEEXT).xsi + + # --- + '; + } + 1; + EOF + ''; +}) diff --git a/machines/ptv/pkgs-cross/protobuf/default.nix b/machines/ptv/pkgs-cross/protobuf/default.nix new file mode 100644 index 0000000..90c1fd2 --- /dev/null +++ b/machines/ptv/pkgs-cross/protobuf/default.nix @@ -0,0 +1,11 @@ +final: prev: prev.protobuf.overrideAttrs (old: { + # https://github.com/advancedtelematic/aktualizr/issues/1427 + # atomics not supported, need either submit PR like suggested bove + # or, for now, use libatomic_ops + postPatch = old.postPatch + '' + sed -i -e 's/set(protobuf_LINK_LIBATOMIC false)/set(protobuf_LINK_LIBATOMIC true)/' CMakeLists.txt + ''; + buildInputs = [ + prev.libatomic_ops + ] ++ old.buildInputs; +}) diff --git a/machines/ptv/pkgs-cross/valgrind/default.nix b/machines/ptv/pkgs-cross/valgrind/default.nix new file mode 100644 index 0000000..56b062c --- /dev/null +++ b/machines/ptv/pkgs-cross/valgrind/default.nix @@ -0,0 +1,15 @@ +final: prev: prev.valgrind.overrideAttrs (old: { + src = prev.fetchFromGitHub { + owner = "petrpavlu"; + repo = "valgrind-riscv64"; + rev = "71272b252977fe52f03ea4fa8306b457b098cca5"; + hash = "sha256-xD84dYSzq9eD35NfnmtI/zONVRjhDAEJkge26yFK034="; + }; + outputs = [ "out" ]; + patches = [ + (prev.fetchpatch { + url = "https://bugsfiles.kde.org/attachment.cgi?id=149173"; + sha256 = "sha256-jX9hD4utWRebbXMJYZ5mu9jecvdrNP05E5J+PnKRTyQ="; + }) + ]; +}) diff --git a/machines/ptv/pkgs-cross/vpnc/default.nix b/machines/ptv/pkgs-cross/vpnc/default.nix new file mode 100644 index 0000000..51cff90 --- /dev/null +++ b/machines/ptv/pkgs-cross/vpnc/default.nix @@ -0,0 +1,3 @@ +final: prev: prev.vpnc.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ (prev.lib.optionals (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) [final.perl]); +}) diff --git a/machines/ptv/pkgs-cross/vulkan-tools/default.nix b/machines/ptv/pkgs-cross/vulkan-tools/default.nix new file mode 100644 index 0000000..2115a29 --- /dev/null +++ b/machines/ptv/pkgs-cross/vulkan-tools/default.nix @@ -0,0 +1,7 @@ +final: prev: prev.vulkan-tools.overrideAttrs (old: { + cmakeFlags = old.cmakeFlags ++ (prev.lib.optionals (prev.stdenv.hostPlatform != prev.stdenv.buildPlatform) [ + "-DBUILD_CUBE=OFF" + "-DPKG_CONFIG_EXECUTABLE=${prev.buildPackages.pkg-config}/bin/riscv64-unknown-linux-gnu-pkg-config" + ]); +}) + diff --git a/machines/ptv/pkgs/cryptsetup/default.nix b/machines/ptv/pkgs/cryptsetup/default.nix new file mode 100644 index 0000000..0ee9292 --- /dev/null +++ b/machines/ptv/pkgs/cryptsetup/default.nix @@ -0,0 +1,3 @@ +final: prev: prev.cryptsetup.overrideAttrs (old: { + doCheck = false; +}) diff --git a/machines/ptv/pkgs/default.nix b/machines/ptv/pkgs/default.nix new file mode 100644 index 0000000..4b5dd2b --- /dev/null +++ b/machines/ptv/pkgs/default.nix @@ -0,0 +1,66 @@ +(final: prev: let + noCheck = p: p.overrideAttrs (old: { + doCheck = false; + }); +in { + valgrind = (import ./valgrind) final prev; + valgrind-light = final.valgrind.override { gdb = null; }; + cryptsetup = (import ./cryptsetup) final prev; + libopus = noCheck prev.libopus; + gn = (import ./gn) final prev; + # Test Times out + openexr = noCheck prev.openexr; + ell = noCheck prev.ell; + # Checks timeout: + pixman = noCheck prev.pixman; + # Inspired by: https://github.com/systemd/systemd/issues/12534 + # and https://github.com/systemd/systemd/issues/30448 + # Seems RISC-V and the like with GCC don't play well with O3 + systemd = prev.systemd.overrideAttrs (old: { + # https://github.com/mesonbuild/meson/issues/10487 + mesonBuildType = "custom"; + mesonFlags = old.mesonFlags ++ [ "-Doptimization=2" ]; + }); + # See https://github.com/catchorg/Catch2/issues/2808 + # Fixed by https://github.com/NixOS/nixpkgs/pull/295243 + catch2_3 = prev.catch2_3.overrideAttrs ({ NIX_CFLAGS_COMPILE ? "", ... }: { + NIX_CFLAGS_COMPILE = "${NIX_CFLAGS_COMPILE} -Wno-error=cast-align"; + }); + # One test times out + json-glib = noCheck prev.json-glib; + # Openh264 doesn't support RISC-V (yet) + # freerdp requires it by default: lets make that not true + freerdp = prev.freerdp.override { + openh264 = null; + }; + tracker = noCheck prev.tracker; + openblas = prev.openblas.overrideAttrs (old: { + postPatch = (old.postPatch or "") + '' + sed -i 's/-static//g' Makefile.riscv64 + ''; + }); + python3 = prev.python3.override { + packageOverrides = final-py: prev-py: let + noCheck = p: p.overridePythonAttrs (old: { + doCheck = false; + }); + in { + dbus-python = prev-py.dbus-python.overridePythonAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ final.dbus ]; + doCheck = false; + }); + hypothesis = noCheck prev-py.hypothesis; + h2 = noCheck prev-py.h2; + numpy = prev-py.numpy.overridePythonAttrs (old: { + doCheck = false; + }); + # https://github.com/pandas-dev/pandas/pull/50349 <-- This + # but for risc-v + pandas = noCheck prev-py.pandas; + sphinx = noCheck prev-py.sphinx; + #skia-pathops = prev.skia-pathops.overridePythonAttrs (old: { + # patches = old.patches or [] ++ [ ./skia-riscv.patch ]; + #}); + }; + }; +}) diff --git a/machines/ptv/pkgs/gn/default.nix b/machines/ptv/pkgs/gn/default.nix new file mode 100644 index 0000000..1ca039f --- /dev/null +++ b/machines/ptv/pkgs/gn/default.nix @@ -0,0 +1,10 @@ +# TODO: gn-unstable needs rev newer than 2021-01-28 +# 713a1850957b919c876c924e43ef0ddc4d8a8144 for riscv64 support + +final: prev: prev.gn.overrideAttrs (old: { + src = prev.fetchgit { + url = "https://gn.googlesource.com/gn"; + rev = "713a1850957b919c876c924e43ef0ddc4d8a8144"; + hash = "sha256-yzx7wPp/PEwGg4HZ99YntyHJ384nTVq6fyB6/vOOvOM="; + }; +}) diff --git a/machines/ptv/pkgs/valgrind/default.nix b/machines/ptv/pkgs/valgrind/default.nix new file mode 100644 index 0000000..56b062c --- /dev/null +++ b/machines/ptv/pkgs/valgrind/default.nix @@ -0,0 +1,15 @@ +final: prev: prev.valgrind.overrideAttrs (old: { + src = prev.fetchFromGitHub { + owner = "petrpavlu"; + repo = "valgrind-riscv64"; + rev = "71272b252977fe52f03ea4fa8306b457b098cca5"; + hash = "sha256-xD84dYSzq9eD35NfnmtI/zONVRjhDAEJkge26yFK034="; + }; + outputs = [ "out" ]; + patches = [ + (prev.fetchpatch { + url = "https://bugsfiles.kde.org/attachment.cgi?id=149173"; + sha256 = "sha256-jX9hD4utWRebbXMJYZ5mu9jecvdrNP05E5J+PnKRTyQ="; + }) + ]; +}) diff --git a/machines/ptv/rgx-img-gpu-firmware.tar.gz b/machines/ptv/rgx-img-gpu-firmware.tar.gz new file mode 100644 index 0000000..634348f Binary files /dev/null and b/machines/ptv/rgx-img-gpu-firmware.tar.gz differ