flake.nix 3.7 KB

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