2022-08-29 23:46:02 +03:00
|
|
|
{
|
|
|
|
inputs = {
|
2022-10-09 14:56:08 +03:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-11-30 23:46:01 +03:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
2023-04-14 01:31:03 +03:00
|
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2022-09-26 03:48:38 +03:00
|
|
|
hardware.url = "github:NixOS/nixos-hardware/master";
|
2024-05-26 00:21:41 +03:00
|
|
|
impermanence.url = "github:nix-community/impermanence";
|
|
|
|
disko = {
|
|
|
|
url = "github:nix-community/disko";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-09-26 03:48:38 +03:00
|
|
|
|
2024-04-16 02:51:46 +03:00
|
|
|
firefox-addons.url = "github:nix-community/nur-combined/master?dir=repos/rycee/pkgs/firefox-addons";
|
|
|
|
|
2022-10-10 11:59:05 +03:00
|
|
|
agenix = {
|
|
|
|
url = "github:ryantm/agenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2023-04-01 15:04:08 +03:00
|
|
|
inputs.darwin.follows = "";
|
2022-10-10 11:59:05 +03:00
|
|
|
};
|
|
|
|
|
2022-08-30 00:17:21 +03:00
|
|
|
home-manager = {
|
2024-11-30 23:46:01 +03:00
|
|
|
url = "github:nix-community/home-manager/release-24.11";
|
2022-08-30 00:17:21 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-23 18:17:06 +03:00
|
|
|
home-manager-unstable = {
|
|
|
|
url = "github:nix-community/home-manager/master";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-09-01 11:17:54 +03:00
|
|
|
|
2022-09-21 13:08:01 +03:00
|
|
|
wired = {
|
|
|
|
url = "github:Toqozz/wired-notify";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2024-04-16 11:28:28 +03:00
|
|
|
lan-mouse = {
|
|
|
|
url = "github:feschber/lan-mouse";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
|
|
};
|
|
|
|
|
2022-09-18 18:29:40 +03:00
|
|
|
# nix lsp
|
|
|
|
nil = {
|
2022-09-25 17:07:41 +03:00
|
|
|
url = "github:oxalica/nil";
|
2022-09-18 18:29:40 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2022-10-09 14:56:08 +03:00
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
2022-09-18 18:29:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
# my neovim configuration
|
2024-05-10 02:39:22 +03:00
|
|
|
nixeovim = {
|
|
|
|
url = "git+https://git.pleshevski.ru/pleshevskiy/nixeovim";
|
2023-11-30 16:44:36 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
2022-12-13 10:13:15 +03:00
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
};
|
2022-08-30 00:17:21 +03:00
|
|
|
};
|
2022-08-29 23:46:02 +03:00
|
|
|
|
2024-05-10 02:39:22 +03:00
|
|
|
outputs = { self, flake-utils, nixpkgs, nixeovim, ... } @ inputs:
|
2024-04-16 11:28:28 +03:00
|
|
|
let inherit (flake-utils.lib) eachSystem system; in
|
2024-04-16 02:51:46 +03:00
|
|
|
eachSystem [ system.x86_64-linux ]
|
2022-10-09 14:56:08 +03:00
|
|
|
(system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-05-20 18:44:00 +03:00
|
|
|
inherit (pkgs) lib nixos-rebuild;
|
2022-10-09 14:56:08 +03:00
|
|
|
|
2024-05-10 02:39:22 +03:00
|
|
|
nixeovimPackage = config: nixeovim.lib.mkNixeovimPackage { inherit system config; };
|
2022-10-13 07:47:31 +03:00
|
|
|
|
|
|
|
localMachines = lib.filterAttrs (h: m: m.config.deployment.targetHost == null) self.nixosConfigurations;
|
|
|
|
vpsMachines = lib.filterAttrs (h: m: m.config.deployment.targetHost != null) self.nixosConfigurations;
|
2022-10-09 14:56:08 +03:00
|
|
|
in
|
|
|
|
{
|
2024-05-10 02:39:22 +03:00
|
|
|
packages = {
|
|
|
|
neovim-dev = nixeovimPackage ./neovim/dev.nix;
|
|
|
|
};
|
|
|
|
|
2022-10-09 14:56:08 +03:00
|
|
|
apps = lib.mapAttrs
|
|
|
|
(name: program: { type = "app"; program = toString program; })
|
2022-10-09 15:04:03 +03:00
|
|
|
(flake-utils.lib.flattenTree {
|
2022-10-13 07:47:31 +03:00
|
|
|
deploy = lib.recurseIntoAttrs (lib.mapAttrs
|
2024-04-16 02:51:46 +03:00
|
|
|
(hostname: machine: pkgs.writeShellScript "deploy/${hostname}" ''
|
2022-10-13 07:47:31 +03:00
|
|
|
${nixos-rebuild}/bin/nixos-rebuild switch \
|
|
|
|
--flake .#${hostname} \
|
2024-02-18 23:08:50 +03:00
|
|
|
--target-host root@${machine.config.deployment.targetHost} \
|
2022-10-28 15:26:00 +03:00
|
|
|
$@
|
2022-10-13 07:47:31 +03:00
|
|
|
'')
|
|
|
|
vpsMachines);
|
|
|
|
|
2022-10-09 15:04:03 +03:00
|
|
|
switch = lib.recurseIntoAttrs (lib.mapAttrs
|
2024-04-16 02:51:46 +03:00
|
|
|
(hostname: machine: pkgs.writeShellScript "switch/${hostname}" ''
|
2024-05-20 18:44:00 +03:00
|
|
|
set -e
|
2022-10-28 15:26:00 +03:00
|
|
|
${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} $@
|
2022-10-09 15:04:03 +03:00
|
|
|
'')
|
2022-10-13 07:47:31 +03:00
|
|
|
localMachines);
|
2022-10-09 15:04:03 +03:00
|
|
|
});
|
2022-10-09 14:56:08 +03:00
|
|
|
|
|
|
|
devShells = {
|
|
|
|
default = pkgs.mkShell {
|
2022-10-10 11:59:05 +03:00
|
|
|
packages = with pkgs; [
|
|
|
|
stylua # lua formatter
|
|
|
|
ormolu # haskell formatter
|
|
|
|
inputs.agenix.packages.${system}.agenix
|
|
|
|
];
|
2022-10-27 22:38:43 +03:00
|
|
|
|
|
|
|
# Path to the agenix configuration file
|
|
|
|
RULES = "./.agenix_config.nix";
|
2022-10-09 14:56:08 +03:00
|
|
|
};
|
2024-05-26 00:21:41 +03:00
|
|
|
disk = pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
inputs.disko.packages.${system}.disko
|
|
|
|
];
|
|
|
|
};
|
2022-10-19 18:30:46 +03:00
|
|
|
tools = pkgs.mkShell {
|
2023-03-02 13:09:07 +03:00
|
|
|
packages = with pkgs; [
|
2023-03-03 14:40:42 +03:00
|
|
|
mkpasswd
|
2023-03-02 13:09:07 +03:00
|
|
|
gucharmap
|
|
|
|
wireguard-tools
|
|
|
|
];
|
2022-10-19 18:30:46 +03:00
|
|
|
};
|
2022-10-09 14:56:08 +03:00
|
|
|
};
|
|
|
|
})
|
|
|
|
// {
|
2022-10-08 22:45:35 +03:00
|
|
|
nixosConfigurations =
|
|
|
|
nixpkgs.lib.mapAttrs
|
|
|
|
(hostname: { system
|
|
|
|
, specialArgs ? { }
|
|
|
|
, extraModules ? [ ]
|
2022-10-13 07:47:31 +03:00
|
|
|
, targetHost ? null
|
2022-10-08 22:45:35 +03:00
|
|
|
, nixpkgs ? inputs.nixpkgs
|
|
|
|
}:
|
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
2022-08-30 00:17:21 +03:00
|
|
|
|
2024-04-16 02:51:46 +03:00
|
|
|
specialArgs = {
|
|
|
|
inherit inputs;
|
|
|
|
globalData = import ./data.nix;
|
2024-05-10 02:37:26 +03:00
|
|
|
usersPath = ./users;
|
|
|
|
hostsPath = ./hosts;
|
|
|
|
packagesPath = ./packages;
|
2024-04-16 02:51:46 +03:00
|
|
|
} // specialArgs;
|
2022-10-08 22:45:35 +03:00
|
|
|
|
|
|
|
modules =
|
2022-10-10 11:59:05 +03:00
|
|
|
(with inputs; [
|
2023-02-20 20:49:06 +03:00
|
|
|
agenix.nixosModules.default
|
2024-05-26 00:21:41 +03:00
|
|
|
home-manager.nixosModules.default
|
|
|
|
disko.nixosModules.disko
|
|
|
|
impermanence.nixosModules.impermanence
|
2022-10-10 11:59:05 +03:00
|
|
|
])
|
2022-10-13 07:47:31 +03:00
|
|
|
++ [
|
|
|
|
# deployment settings
|
|
|
|
({ lib, ... }: {
|
|
|
|
options.deployment = with lib; {
|
|
|
|
targetHost = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
readOnly = true;
|
|
|
|
internal = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config.deployment = { inherit targetHost; };
|
|
|
|
})
|
2022-10-18 00:42:23 +03:00
|
|
|
# base home manager settings
|
|
|
|
({ ... }: {
|
2024-08-22 23:10:03 +03:00
|
|
|
home-manager.backupFileExtension = "backup";
|
2022-10-18 00:42:23 +03:00
|
|
|
home-manager.useGlobalPkgs = true;
|
|
|
|
home-manager.useUserPackages = true;
|
2024-05-10 02:37:26 +03:00
|
|
|
home-manager.extraSpecialArgs = {
|
|
|
|
packagesPath = ./packages;
|
|
|
|
};
|
2024-04-16 02:51:46 +03:00
|
|
|
home-manager.sharedModules = [
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./modules/home-manager
|
|
|
|
inputs.wired.homeManagerModules.default
|
2024-04-16 11:28:28 +03:00
|
|
|
inputs.lan-mouse.homeManagerModules.default
|
2024-04-16 02:51:46 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2022-10-18 00:42:23 +03:00
|
|
|
})
|
2023-03-18 16:47:02 +03:00
|
|
|
]
|
2024-04-16 02:51:46 +03:00
|
|
|
++ extraModules
|
|
|
|
++ [ ./modules/nixos ]
|
2024-11-30 23:46:01 +03:00
|
|
|
++ [ ./hosts/${hostname}/configuration.nix ];
|
2022-10-08 22:45:35 +03:00
|
|
|
})
|
2024-04-16 02:51:46 +03:00
|
|
|
(import ./hosts inputs);
|
2024-05-26 00:21:41 +03:00
|
|
|
diskoConfigurations = {
|
|
|
|
asus-gl553vd = import ./hosts/asus-gl553vd/disk-config.nix;
|
|
|
|
};
|
2022-08-29 23:46:02 +03:00
|
|
|
};
|
|
|
|
}
|