dotfiles/flake.nix

199 lines
6.6 KiB
Nix

{
description = "My awesome system config";
/*
Inputs
*/
inputs = {
# Nix
master.url = "github:nixos/nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
stable.url = "github:nixos/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
agenix.inputs.nixpkgs.follows = "nixpkgs";
agenix.url = "github:ryantm/agenix";
attic.inputs.flake-utils.follows = "flake-utils";
attic.inputs.nixpkgs-stable.follows = "stable";
attic.inputs.nixpkgs.follows = "nixpkgs";
attic.url = "github:zhaofengli/attic";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
nil.inputs.flake-utils.follows = "flake-utils";
nil.inputs.nixpkgs.follows = "nixpkgs";
nil.url = "github:oxalica/nil";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
# Neovim
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
bufferline-nvim.flake = false;
bufferline-nvim.url = "github:akinsho/bufferline.nvim";
cmp-async-path.url = "github:FelipeLema/cmp-async-path";
cmp-async-path.flake = false;
comment-box-nvim.flake = false;
comment-box-nvim.url = "github:LudoPinelli/comment-box.nvim";
copilot-lua.flake = false;
copilot-lua.url = "github:zbirenbaum/copilot.lua";
gitignore-nvim.flake = false;
gitignore-nvim.url = "github:wintermute-cell/gitignore.nvim";
lspsaga-nvim.flake = false;
lspsaga-nvim.url = "github:glepnir/lspsaga.nvim";
nvim-treesitter-textsubjects.flake = false;
nvim-treesitter-textsubjects.url = "github:RRethy/nvim-treesitter-textsubjects";
smartcolumn-nvim.flake = false;
smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim";
# Hyprland
hypr-contrib.url = "github:hyprwm/contrib";
hyprland.url = "github:hyprwm/Hyprland";
hyprpaper.url = "github:hyprwm/hyprpaper";
# Laptop
asus-touchpad-numpad-driver.url = "github:MoritzBoehme/asus-touchpad-numpad-driver/german-layout";
asus-touchpad-numpad-driver.flake = false;
# Firefox user.js
arkenfox-userjs.url = "github:arkenfox/user.js";
arkenfox-userjs.flake = false;
};
/*
Outputs
*/
outputs = inputs@{ self, nixpkgs, ... }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forEachSystem = lib.genAttrs systems;
lib = nixpkgs.lib.extend
(self: _: { my = import ./lib { lib = self; }; });
overlay = import ./overlays {
inherit inputs;
inherit (self) lib;
};
config.allowUnfree = true;
overlays = [
inputs.hypr-contrib.overlays.default
inputs.hyprland.overlays.default
inputs.neovim-nightly-overlay.overlay
overlay
];
pkgsFor = system: import nixpkgs {
inherit system config;
overlays = overlays ++ [
(
_: prev: {
master = import inputs.master {
inherit (prev) system;
inherit overlays config;
};
stable = import inputs.stable {
inherit (prev) system;
inherit overlays config;
};
}
)
overlay
];
};
defaultModules = [
{ nixpkgs = { inherit config; }; }
./modules
inputs.home-manager.nixosModule
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs self; };
};
}
inputs.agenix.nixosModules.age
];
hosts = self.lib.my.mapModules
(path:
let
system = import "${path}/system.nix";
pkgs = pkgsFor system;
in
lib.nixosSystem {
inherit pkgs system lib;
specialArgs = {
inherit inputs;
};
modules = defaultModules ++ [ path ];
})
./hosts;
pre-commit-check = system: inputs.pre-commit-hooks.lib."${system}".run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
};
};
in
with lib; {
inherit lib;
pkgs = genAttrs systems pkgsFor;
# ╔══════════════════════════════════════════════════════════╗
# ║ NixOS Configurations ║
# ╚══════════════════════════════════════════════════════════╝
nixosConfigurations = hosts;
# ╔══════════════════════════════════════════════════════════╗
# ║ Other Outputs ║
# ╚══════════════════════════════════════════════════════════╝
devShells = forEachSystem (system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell
{
inherit (pre-commit-check system) shellHook;
name = "dotfiles";
packages = with pkgs; [
# Secrets
agenix
# cachix
cachix
];
};
});
checks = forEachSystem (system: {
pre-commit-check = pre-commit-check system;
});
};
}