dotfiles/flake.nix

233 lines
7.7 KiB
Nix

{
description = "My awesome system config";
inputs = {
# Nix
agenix.inputs.nixpkgs.follows = "nixpkgs";
agenix.url = "github:ryantm/agenix";
devshell.url = "github:numtide/devshell";
disko.url = "github:nix-community/disko";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
impermanence.url = "github:nix-community/impermanence";
master.url = "github:nixos/nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
stable.url = "github:nixos/nixpkgs/nixos-23.05";
nur.url = "github:nix-community/NUR";
nix-index-database.url = "github:Mic92/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
# Programs
rofi-wayland.flake = false;
rofi-wayland.url = "github:lbonn/rofi/wayland";
nix-super.url = "github:privatevoid-net/nix-super";
timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git";
# Neovim
actions-preview-nvim.flake = false;
actions-preview-nvim.url = "github:aznhe21/actions-preview.nvim";
hmts-nvim.flake = false;
hmts-nvim.url = "github:calops/hmts.nvim";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim";
nvim-lspconfig.flake = false;
nvim-lspconfig.url = "github:neovim/nvim-lspconfig";
nvim-puppeteer.flake = false;
nvim-puppeteer.url = "github:chrisgrieser/nvim-puppeteer";
nvim-treesitter.flake = false;
nvim-treesitter.url = "github:nvim-treesitter/nvim-treesitter/v0.9.1"; # NOTE: to fix weird latest issues
smartcolumn-nvim.flake = false;
smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim";
telekasten-nvim.flake = false;
telekasten-nvim.url = "github:renerocksai/telekasten.nvim";
none-ls-nvim.flake = false;
none-ls-nvim.url = "github:nvimtools/none-ls.nvim";
neotest-python.flake = false;
neotest-python.url = "github:MoritzBoehme/neotest-python/fix-runtimepath-search";
statuscol-nvim.flake = false;
statuscol-nvim.url = "github:luukvbaal/statuscol.nvim/0.10"; # HACK: fix for neovim-nightly
gen-nvim.flake = false;
gen-nvim.url = "github:David-Kunz/gen.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 = inputs@{ self, flake-parts, ... }:
let
defaultOverlays = [
inputs.hypr-contrib.overlays.default
self.overlays.default
];
finalOverlays = defaultOverlays ++ [
(
_: prev: {
master = import inputs.master {
inherit (prev) system;
overlays = defaultOverlays;
};
stable = import inputs.stable {
inherit (prev) system;
overlays = defaultOverlays;
};
nur = import inputs.nur {
pkgs = prev;
nurpkgs = prev;
};
}
)
];
in
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.pre-commit-hooks.flakeModule
inputs.devshell.flakeModule
];
systems = [ "x86_64-linux" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs =
import inputs.nixpkgs {
inherit system;
overlays = finalOverlays;
};
devshells.default = {
devshell.startup.pre-commit-hook.text = config.pre-commit.installationScript;
commands = [
{
name = "agenix";
help = "wrapper around agenix";
command = ''
sudo EDITOR="${pkgs.lib.getExe pkgs.vim}" ${pkgs.lib.getExe' inputs'.agenix.packages.default "agenix"} --identity /etc/ssh/ssh_host_ed25519_key "$@"
'';
}
{
name = "build";
help = "use nom to build system";
command =
''
nom build --no-link ".#nixosConfigurations.$(hostname).config.system.build.toplevel" $@
'';
}
{
name = "apply";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild switch --flake . $@";
}
{
name = "test";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild test --flake . $@";
}
{
name = "boot";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild boot --flake . $@";
}
];
packages = with pkgs; [
stylua
sumneko-lua-language-server
];
};
pre-commit = {
check.enable = true;
settings = {
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
};
};
};
legacyPackages = pkgs;
packages =
self.lib.filterAttrs (_: self.lib.isDerivation)
(self.overlays.default pkgs pkgs);
};
flake = {
lib = inputs.nixpkgs.lib.extend
(self: _: { my = import ./lib { lib = self; }; });
overlays.default = import ./overlays {
inherit inputs;
inherit (self) lib;
};
nixosConfigurations = self.lib.my.mapModules
(path: self.lib.nixosSystem {
inherit (self) lib;
specialArgs = {
inherit inputs self;
};
modules =
[
./modules
{
nixpkgs = {
overlays = finalOverlays;
config.allowUnfree = true;
};
}
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs self; };
sharedModules = [ inputs.nix-lazy-nvim.homeManagerModules.default ];
};
}
inputs.agenix.nixosModules.age
inputs.disko.nixosModules.default
inputs.home-manager.nixosModule
inputs.impermanence.nixosModules.impermanence
inputs.nix-index-database.nixosModules.nix-index
path
];
})
./hosts;
templates = {
python = {
path = ./templates/python;
};
};
};
};
nixConfig = {
extra-substituters = [
"https://hyprland.cachix.org"
"https://nix-community.cachix.org"
"https://pre-commit-hooks.cachix.org"
"https://cache.privatevoid.net"
];
extra-trusted-public-keys = [
"cache.privatevoid.net:SErQ8bvNWANeAvtsOESUwVYr2VJynfuc9JRwlzTTkVg="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
];
};
}