Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

flake.nix 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {
  2. description = "Genode packages";
  3. inputs.genode = {
  4. url = "github:genodelabs/genode";
  5. flake = false;
  6. };
  7. inputs.nixpkgs.url = "github:ehmry/nixpkgs/genodepkgs";
  8. outputs = { self, genode, nixpkgs }:
  9. let
  10. localSystems = [ "x86_64-linux" ];
  11. crossSystems = [ "aarch64-genode" "x86_64-genode" ];
  12. forAllLocalSystems = f:
  13. nixpkgs.lib.genAttrs localSystems (system: f system);
  14. forAllCrossSystems = f:
  15. with builtins;
  16. let
  17. f' = localSystem: crossSystem:
  18. let system = localSystem + "-" + crossSystem;
  19. in {
  20. name = system;
  21. value = f { inherit system localSystem crossSystem; };
  22. };
  23. list = nixpkgs.lib.lists.crossLists f' [ localSystems crossSystems ];
  24. attrSet = listToAttrs list;
  25. in attrSet;
  26. forAllSystems = f:
  27. (forAllCrossSystems f) // (forAllLocalSystems (system:
  28. f {
  29. inherit system;
  30. localSystem = system;
  31. crossSystem = system;
  32. }));
  33. nixpkgsFor = forAllSystems ({ system, localSystem, crossSystem }:
  34. if localSystem == crossSystem then
  35. import nixpkgs {
  36. inherit system;
  37. overlays = [ self.overlay ];
  38. }
  39. else
  40. import nixpkgs {
  41. inherit localSystem;
  42. crossSystem = {
  43. system = crossSystem;
  44. useLLVM = true;
  45. };
  46. config.allowUnsupportedSystem = true;
  47. overlays = [ self.overlay ];
  48. });
  49. in rec {
  50. overlay =
  51. # Overlay of fixes applied to Nixpkgs
  52. import ./overlay { flake = self; };
  53. lib =
  54. # Local utilities merged with the Nixpkgs lib
  55. forAllCrossSystems ({ system, localSystem, crossSystem }:
  56. nixpkgs.lib // (import ./lib {
  57. inherit system localSystem crossSystem;
  58. pkgs = self.legacyPackages.${system};
  59. }));
  60. legacyPackages =
  61. # The nixpkgs.legacyPackages after overlaying
  62. # and with some additional Genode packages
  63. forAllSystems
  64. ({ system, localSystem, crossSystem }: nixpkgsFor.${system});
  65. # pass thru Nixpkgs
  66. packages =
  67. # Genode native packages, not packages in the traditional
  68. # sense in that these cannot be installed within a profile
  69. forAllCrossSystems ({ system, localSystem, crossSystem }:
  70. nixpkgs.lib.filterAttrs (n: v: v != null)
  71. nixpkgsFor.${system}.genodePackages);
  72. devShell =
  73. # Development shell for working with the
  74. # upstream Genode source repositories
  75. forAllLocalSystems (system:
  76. let
  77. pkgs = nixpkgsFor.${system};
  78. fhs = pkgs.buildFHSUserEnv {
  79. name = "genode-env";
  80. targetPkgs = pkgs:
  81. (with pkgs; [
  82. binutils
  83. bison
  84. expect
  85. flex
  86. git
  87. glibc.dev
  88. gnumake
  89. libxml2
  90. qemu
  91. tcl
  92. which
  93. xorriso
  94. ]);
  95. runScript = "bash";
  96. extraBuildCommands = let
  97. toolchain = pkgs.fetchzip {
  98. url =
  99. "file://${packages.x86_64-linux-x86_64-genode.genodeSources.toolchain.src}";
  100. hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o=";
  101. };
  102. in "ln -s ${toolchain}/local usr/local";
  103. };
  104. in pkgs.stdenv.mkDerivation {
  105. name = "genode-fhs-shell";
  106. nativeBuildInputs = [ fhs ];
  107. shellHook = "exec genode-env";
  108. });
  109. apps =
  110. # Utilities accessible via "nix run"
  111. forAllCrossSystems ({ system, localSystem, crossSystem }:
  112. import ./apps {
  113. inherit system;
  114. self = self.apps.${system};
  115. nixpkgs = nixpkgsFor.${system};
  116. nixpkgsLocal = nixpkgsFor.${localSystem};
  117. packages = self.packages.${system};
  118. });
  119. nixosModules =
  120. # Modules for composing Genode and NixOS
  121. import ./nixos-modules { inherit self; };
  122. checks =
  123. # Checks for continous testing
  124. let tests = import ./tests;
  125. in with (forAllCrossSystems ({ system, localSystem, crossSystem }:
  126. tests {
  127. flake = self;
  128. inherit system localSystem crossSystem;
  129. pkgs = self.legacyPackages.${system};
  130. } // {
  131. ports = nixpkgsFor.${localSystem}.symlinkJoin {
  132. name = "ports";
  133. paths = (builtins.attrValues
  134. self.packages.${system}.genodeSources.ports);
  135. };
  136. })); {
  137. x86_64-linux = x86_64-linux-aarch64-genode
  138. // x86_64-linux-x86_64-genode;
  139. };
  140. };
  141. }