NixOS deployment for LinuxLab
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.

168 lines
3.7 KiB

2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
  1. {
  2. inputs = {
  3. nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
  4. nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
  5. flake-utils.url = "github:numtide/flake-utils";
  6. git-hooks = {
  7. url = "github:cachix/git-hooks.nix";
  8. inputs.nixpkgs.follows = "nixpkgs";
  9. };
  10. colmena = {
  11. url = "github:zhaofengli/colmena";
  12. inputs.nixpkgs.follows = "nixpkgs";
  13. inputs.flake-utils.follows = "flake-utils";
  14. };
  15. disko = {
  16. url = "github:nix-community/disko";
  17. inputs.nixpkgs.follows = "nixpkgs";
  18. };
  19. nixago = {
  20. url = "github:jmgilman/nixago";
  21. inputs.nixpkgs.follows = "nixpkgs";
  22. inputs.flake-utils.follows = "flake-utils";
  23. };
  24. sops = {
  25. url = "github:Mic92/sops-nix";
  26. inputs.nixpkgs.follows = "nixpkgs";
  27. };
  28. ldap-sync = {
  29. type = "git";
  30. url = "https://gogs.informatik.hs-fulda.de/fooker/ldap-sync.git";
  31. flake = false;
  32. };
  33. };
  34. outputs =
  35. { self
  36. , nixpkgs
  37. , flake-utils
  38. , colmena
  39. , git-hooks
  40. , nixago
  41. , ...
  42. }@inputs:
  43. let
  44. # List of all machine names as defined in the machines directory
  45. machines = builtins.attrNames (builtins.readDir ./machines);
  46. # List of all client names
  47. clients = builtins.attrNames (import ./clients.nix);
  48. in
  49. {
  50. colmena = {
  51. meta = {
  52. nixpkgs = import nixpkgs {
  53. system = "x86_64-linux";
  54. };
  55. specialArgs = {
  56. inherit inputs;
  57. };
  58. };
  59. defaults = {
  60. imports = [
  61. inputs.disko.nixosModules.disko
  62. inputs.sops.nixosModules.sops
  63. ./shared
  64. ];
  65. deployment.replaceUnknownProfiles = false;
  66. };
  67. "client" = (import ./client) null;
  68. }
  69. # Machines
  70. // (builtins.listToAttrs (builtins.map
  71. (name: {
  72. inherit name;
  73. value = ./machines/${name};
  74. })
  75. machines))
  76. # Clients
  77. // (builtins.listToAttrs (builtins.map
  78. (id: {
  79. name = "client-${id}";
  80. value = (import ./client) id;
  81. })
  82. clients))
  83. ;
  84. } // flake-utils.lib.eachDefaultSystem (system: {
  85. checks = {
  86. pre-commit = git-hooks.lib.${system}.run {
  87. src = ./.;
  88. hooks = {
  89. nixpkgs-fmt.enable = true;
  90. statix.enable = true;
  91. shellcheck.enable = true;
  92. };
  93. };
  94. };
  95. devShells.default =
  96. let
  97. pkgs = nixpkgs.legacyPackages.${system};
  98. sops-config = nixago.lib.${system}.make {
  99. data = (pkgs.callPackage ./sops-config.nix {
  100. inherit machines;
  101. }).config;
  102. output = ".sops.yaml";
  103. format = "yaml";
  104. };
  105. in
  106. pkgs.mkShell {
  107. buildInputs =
  108. self.checks.${system}.pre-commit.enabledPackages ++
  109. [ colmena.packages.${system}.colmena ] ++
  110. (with pkgs; [
  111. bash
  112. gitAndTools.git
  113. sops
  114. age
  115. openssh
  116. ssh-to-age
  117. ]);
  118. shellHook = ''
  119. ${self.checks.${system}.pre-commit.shellHook}
  120. ${sops-config.shellHook}
  121. '';
  122. };
  123. packages.disks =
  124. let
  125. pkgs = nixpkgs.legacyPackages.${system};
  126. hive = colmena.lib.makeHive self.outputs.colmena;
  127. in
  128. pkgs.linkFarm "linuxlab-testing" (builtins.mapAttrs
  129. (_: node: node.config.system.build.diskoImages)
  130. hive.nodes);
  131. });
  132. nixConfig = {
  133. extra-substituters = [
  134. "https://colmena.cachix.org"
  135. ];
  136. extra-trusted-public-keys = [
  137. "colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg="
  138. ];
  139. };
  140. }