{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; hardware.url = "github:NixOS/nixos-hardware/master"; agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; wired = { url = "github:Toqozz/wired-notify"; inputs.nixpkgs.follows = "nixpkgs"; }; dedsec-grub-theme = { url = "gitlab:VandalByte/dedsec-grub-theme"; inputs.nixpkgs.follows = "nixpkgs"; }; # nix lsp nil = { url = "github:oxalica/nil"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; # my neovim configuration myneovim = { url = "git+https://git.pleshevski.ru/mynix/neovim?rev=8957cc62e623d2844f402f0bb4840bbedb4c7f16"; inputs.nixpkgs.follows = "nixpkgs"; }; # tool to change .env faster vnetod = { url = "git+https://git.pleshevski.ru/pleshevskiy/vnetod"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs @ { self, flake-utils, nixpkgs, hardware, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; inherit (pkgs) lib; nixos-rebuild = pkgs.nixos-rebuild.override { nix = pkgs.nixFlakes; }; in { apps = lib.mapAttrs (name: program: { type = "app"; program = toString program; }) (flake-utils.lib.flattenTree { switch = lib.recurseIntoAttrs (lib.mapAttrs (hostname: machine: pkgs.writeShellScript "switch-${hostname}" '' ${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} '') self.nixosConfigurations); test = lib.recurseIntoAttrs (lib.mapAttrs (hostname: machine: pkgs.writeShellScript "test-${hostname}" '' ${nixos-rebuild}/bin/nixos-rebuild test --flake .#${hostname} '') self.nixosConfigurations); }); devShells = { default = pkgs.mkShell { packages = with pkgs; [ stylua # lua formatter ormolu # haskell formatter inputs.agenix.packages.${system}.agenix ]; }; }; }) // { nixosConfigurations = nixpkgs.lib.mapAttrs (hostname: { system , specialArgs ? { } , extraModules ? [ ] , nixpkgs ? inputs.nixpkgs }: nixpkgs.lib.nixosSystem { inherit system; specialArgs = { inherit inputs; } // specialArgs; modules = (with inputs; [ agenix.nixosModule home-manager.nixosModule ]) ++ [ ./machines/${hostname} ] ++ extraModules; }) (import ./machines inputs); }; }