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

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