flake.nix 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. {
  2. description = "NixOS configuration";
  3. inputs = {
  4. nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11";
  5. # nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
  6. nixpkgs.follows = "nixpkgs-stable";
  7. nixos-hardware.url = "github:NixOS/nixos-hardware/master";
  8. flake-programs-sqlite = {
  9. url = "github:wamserma/flake-programs-sqlite";
  10. inputs.nixpkgs.follows = "nixpkgs";
  11. };
  12. home-manager = {
  13. url = "github:nix-community/home-manager/release-24.11";
  14. inputs.nixpkgs.follows = "nixpkgs";
  15. };
  16. lanzaboote = {
  17. url = "github:nix-community/lanzaboote/v0.4.1";
  18. inputs.nixpkgs.follows = "nixpkgs";
  19. };
  20. impermanence.url = "github:nix-community/impermanence";
  21. disko = {
  22. url = "github:nix-community/disko";
  23. inputs.nixpkgs.follows = "nixpkgs";
  24. };
  25. deploy-rs = {
  26. url = "github:serokell/deploy-rs";
  27. inputs.nixpkgs.follows = "nixpkgs";
  28. };
  29. agenix = {
  30. url = "github:ryantm/agenix";
  31. inputs = {
  32. darwin.follows = "";
  33. home-manager.follows = "home-manager";
  34. nixpkgs.follows = "nixpkgs";
  35. };
  36. };
  37. };
  38. outputs = inputs @ { self, nixpkgs, nixos-hardware, ... }:
  39. let inherit (import ./lib.nix { inherit inputs; })
  40. forAllSystems isDir listDir asAttrs mkSystem deployPkgs;
  41. in {
  42. modules = builtins.listToAttrs (builtins.map (s: {
  43. name = builtins.baseNameOf s;
  44. value = asAttrs "\\.nix" s;
  45. }) (builtins.filter isDir (listDir ./modules))) // {
  46. secrets = asAttrs "\\.age" ./secrets;
  47. };
  48. overlays = builtins.mapAttrs (_: import) (asAttrs "\\.nix" ./overlays);
  49. devShells = forAllSystems (system:
  50. with import nixpkgs {
  51. inherit system;
  52. overlays = builtins.attrValues self.overlays;
  53. }; {
  54. default = mkShell {
  55. nativeBuildInputs = with pkgs; [
  56. inputs.agenix.packages.${system}.agenix
  57. inputs.home-manager.packages.${system}.home-manager
  58. deploy-rs
  59. disko
  60. nixos-anywhere
  61. vim-with-vimrc
  62. ];
  63. };
  64. });
  65. packages = nixpkgs.lib.recursiveUpdate (forAllSystems (system:
  66. with import nixpkgs { inherit system; }; {
  67. default = writeShellScriptBin "fmt-check" ''
  68. ${deadnix}/bin/deadnix ${self}
  69. ${statix}/bin/statix check -i hardware-configuration.nix -- ${self}
  70. '';
  71. })) (import ./packages.nix { inherit inputs; });
  72. nixosConfigurations = {
  73. higan = mkSystem "x86_64-linux" [
  74. nixos-hardware.nixosModules.common-cpu-amd
  75. nixos-hardware.nixosModules.common-pc-laptop-ssd
  76. inputs.lanzaboote.nixosModules.lanzaboote
  77. inputs.disko.nixosModules.disko
  78. ./hosts/higan
  79. ];
  80. makai = mkSystem "x86_64-linux" [
  81. nixos-hardware.nixosModules.common-cpu-intel
  82. nixos-hardware.nixosModules.common-gpu-intel-sandy-bridge
  83. nixos-hardware.nixosModules.common-pc-laptop-hdd
  84. ./hosts/makai
  85. ];
  86. shrine = mkSystem "x86_64-linux" [
  87. nixos-hardware.nixosModules.common-cpu-intel
  88. nixos-hardware.nixosModules.common-pc-laptop-ssd
  89. ./hosts/shrine
  90. ];
  91. yama = mkSystem "x86_64-linux" [
  92. nixos-hardware.nixosModules.common-cpu-amd
  93. nixos-hardware.nixosModules.common-pc-ssd
  94. ./hosts/yama
  95. ];
  96. blackberry = mkSystem "x86_64-linux" [
  97. nixos-hardware.nixosModules.common-cpu-intel
  98. nixos-hardware.nixosModules.common-pc-ssd
  99. inputs.disko.nixosModules.disko
  100. ./hosts/blackberry
  101. ];
  102. };
  103. deploy.nodes = {
  104. blackberry = { # fail2banana.ru
  105. hostname = "10.0.0.50";
  106. profiles.system = {
  107. sshUser = "slark";
  108. user = "root";
  109. path = deployPkgs.x86_64-linux.deploy-rs.lib.activate.nixos self.nixosConfigurations.blackberry;
  110. };
  111. };
  112. };
  113. checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
  114. };
  115. }