dotfiles/flake.nix

391 lines
11 KiB
Nix
Raw Normal View History

2022-04-26 21:36:16 -04:00
{
2025-02-03 17:30:32 -05:00
description = "An opinionated flake containing the NixOS, nix-darwin, and home-manager configurations for multiple systems.";
2022-04-26 21:36:16 -04:00
2022-05-08 16:02:13 -04:00
# Other flakes that we want to pull from
2022-04-26 21:36:16 -04:00
inputs = {
2022-05-08 16:02:13 -04:00
# Used for system packages
2022-04-26 21:36:16 -04:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2022-05-08 16:02:13 -04:00
# Used for specific stable packages
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
2022-06-12 17:46:26 -04:00
# Used for MacOS system config
darwin = {
url = "github:lnl7/nix-darwin/master";
2022-06-12 17:46:26 -04:00
inputs.nixpkgs.follows = "nixpkgs";
};
2022-07-08 01:31:00 +00:00
# Used for Windows Subsystem for Linux compatibility
2024-01-07 08:51:21 -05:00
wsl = {
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-07-08 01:31:00 +00:00
# Used for user packages and dotfiles
2022-04-26 21:36:16 -04:00
home-manager = {
url = "github:nix-community/home-manager/master";
2024-04-14 08:08:57 -04:00
inputs.nixpkgs.follows = "nixpkgs"; # Use system packages list for their inputs
2022-04-26 21:36:16 -04:00
};
2022-05-08 16:02:13 -04:00
# Community packages; used for Firefox extensions
2025-02-03 17:30:32 -05:00
nur = {
url = "github:nix-community/nur";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-04-26 21:36:16 -04:00
2025-02-08 12:58:06 -05:00
# # Use official Firefox binary for macOS
# firefox-darwin = {
# url = "github:bandithedoge/nixpkgs-firefox-darwin";
# inputs.nixpkgs.follows = "nixpkgs";
# };
2024-06-18 18:22:05 -06:00
# Better App install management in macOS
mac-app-util = {
url = "github:hraban/mac-app-util";
inputs.nixpkgs.follows = "nixpkgs"; # Use system packages list for their inputs
2024-06-18 18:22:05 -06:00
};
# Manage disk format and partitioning
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
2025-02-16 16:17:39 -05:00
# # Wallpapers
# wallpapers = {
# url = "gitlab:exorcist365/wallpapers";
# flake = false;
# };
2022-09-20 04:01:45 +00:00
# Used to generate NixOS images for other platforms
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-11-27 12:29:45 -07:00
# Convert Nix to Neovim config
nix2vim = {
url = "github:gytis-ivaskevicius/nix2vim";
inputs.nixpkgs.follows = "nixpkgs";
};
2025-03-08 10:26:26 -05:00
# # Neovim plugins
# base16-nvim-src = {
# url = "github:RRethy/base16-nvim";
# flake = false;
# };
# nvim-lspconfig-src = {
# # https://github.com/neovim/nvim-lspconfig/tags
# url = "github:neovim/nvim-lspconfig/v0.1.8";
# flake = false;
# };
# cmp-nvim-lsp-src = {
# url = "github:hrsh7th/cmp-nvim-lsp";
# flake = false;
# };
# baleia-nvim-src = {
# # https://github.com/m00qek/baleia.nvim/tags
# url = "github:m00qek/baleia.nvim";
# flake = false;
# };
# nvim-treesitter-src = {
# # https://github.com/nvim-treesitter/nvim-treesitter/tags
# url = "github:nvim-treesitter/nvim-treesitter/v0.9.2";
# flake = false;
# };
# telescope-nvim-src = {
# # https://github.com/nvim-telescope/telescope.nvim/releases
# url = "github:nvim-telescope/telescope.nvim/0.1.8";
# flake = false;
# };
# telescope-project-nvim-src = {
# url = "github:nvim-telescope/telescope-project.nvim";
# flake = false;
# };
# toggleterm-nvim-src = {
# # https://github.com/akinsho/toggleterm.nvim/tags
# url = "github:akinsho/toggleterm.nvim/v2.12.0";
# flake = false;
# };
# bufferline-nvim-src = {
# # https://github.com/akinsho/bufferline.nvim/releases
# url = "github:akinsho/bufferline.nvim/v4.6.1";
# flake = false;
# };
# nvim-tree-lua-src = {
# url = "github:kyazdani42/nvim-tree.lua";
# flake = false;
# };
# hmts-nvim-src = {
# url = "github:calops/hmts.nvim";
# flake = false;
# };
# fidget-nvim-src = {
# # https://github.com/j-hui/fidget.nvim/tags
# url = "github:j-hui/fidget.nvim/v1.4.5";
# flake = false;
# };
# nvim-lint-src = {
# url = "github:mfussenegger/nvim-lint";
# flake = false;
# };
# tiny-inline-diagnostic-nvim-src = {
# url = "github:rachartier/tiny-inline-diagnostic.nvim";
# flake = false;
# };
# snipe-nvim-src = {
# url = "github:leath-dub/snipe.nvim";
# flake = false;
# };
2022-11-27 12:29:45 -07:00
# Tree-Sitter Grammars
tree-sitter-bash = {
url = "github:tree-sitter/tree-sitter-bash/master";
flake = false;
};
tree-sitter-python = {
url = "github:tree-sitter/tree-sitter-python/master";
flake = false;
};
tree-sitter-lua = {
url = "github:MunifTanjim/tree-sitter-lua/main";
flake = false;
};
tree-sitter-ini = {
url = "github:justinmk/tree-sitter-ini";
flake = false;
};
tree-sitter-puppet = {
url = "github:amaanq/tree-sitter-puppet";
flake = false;
};
tree-sitter-rasi = {
url = "github:Fymyte/tree-sitter-rasi";
flake = false;
};
tree-sitter-vimdoc = {
url = "github:neovim/tree-sitter-vimdoc";
flake = false;
};
# MPV Scripts
zenyd-mpv-scripts = {
url = "github:zenyd/mpv-scripts";
flake = false;
};
2025-02-08 12:58:06 -05:00
# # Git alternative
# # Fixes: https://github.com/martinvonz/jj/issues/4784
# jujutsu = {
# url = "github:martinvonz/jj";
# inputs.nixpkgs.follows = "nixpkgs";
# };
2024-11-16 23:46:43 +00:00
# Nextcloud Apps
nextcloud-news = {
# https://github.com/nextcloud/news/releases
2024-10-26 18:36:28 +00:00
url = "https://github.com/nextcloud/news/releases/download/25.0.0-alpha12/news.tar.gz";
flake = false;
};
nextcloud-external = {
# https://github.com/nextcloud-releases/external/releases
2024-10-26 18:36:28 +00:00
url = "https://github.com/nextcloud-releases/external/releases/download/v5.5.2/external-v5.5.2.tar.gz";
flake = false;
};
nextcloud-cookbook = {
# https://github.com/christianlupus-nextcloud/cookbook-releases/releases/
2024-10-26 18:36:28 +00:00
url = "https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.2/cookbook-0.11.2.tar.gz";
flake = false;
};
2024-01-21 02:12:57 +00:00
nextcloud-snappymail = {
# https://github.com/the-djmaze/snappymail/releases
# https://snappymail.eu/repository/nextcloud
2024-10-26 18:36:28 +00:00
url = "https://snappymail.eu/repository/nextcloud/snappymail-2.38.2-nextcloud.tar.gz";
# url = "https://github.com/nmasur/snappymail-nextcloud/releases/download/v2.36.3/snappymail-2.36.3-nextcloud.tar.gz";
2024-01-21 02:12:57 +00:00
flake = false;
};
2022-04-26 21:36:16 -04:00
};
2024-04-14 08:08:57 -04:00
outputs =
{ nixpkgs, ... }@inputs:
2022-05-15 20:46:17 -04:00
2022-04-26 21:36:16 -04:00
let
2025-03-11 02:31:22 +00:00
lib = import ./lib inputs;
2022-05-08 16:02:13 -04:00
# Global configuration for my systems
2024-04-14 08:08:57 -04:00
globals =
let
baseName = "masu.rs";
in
rec {
user = "noah";
fullName = "Noah Masur";
gitName = fullName;
gitEmail = "7386960+nmasur@users.noreply.github.com";
dotfilesRepo = "https://github.com/nmasur/dotfiles";
hostnames = {
2024-10-12 15:18:54 +00:00
audiobooks = "read.${baseName}";
2025-02-18 17:44:39 -05:00
books = "books.${baseName}";
2024-12-26 21:49:24 +00:00
budget = "money.${baseName}";
2025-02-18 17:44:39 -05:00
content = "cloud.${baseName}";
download = "download.${baseName}";
files = "files.${baseName}";
2024-04-14 08:08:57 -04:00
git = "git.${baseName}";
2025-02-18 17:44:39 -05:00
imap = "imap.purelymail.com";
2024-04-14 08:08:57 -04:00
influxdb = "influxdb.${baseName}";
irc = "irc.${baseName}";
2025-02-18 17:44:39 -05:00
mail = "noahmasur.com";
2024-04-14 08:08:57 -04:00
metrics = "metrics.${baseName}";
minecraft = "minecraft.${baseName}";
2024-08-19 20:32:57 +00:00
n8n = "n8n.${baseName}";
2024-08-25 21:04:16 +00:00
notifications = "ntfy.${baseName}";
2024-04-14 08:08:57 -04:00
paperless = "paper.${baseName}";
2024-12-05 21:58:46 +00:00
photos = "photos.${baseName}";
2025-02-18 17:44:39 -05:00
prometheus = "prom.${baseName}";
2024-04-14 08:08:57 -04:00
secrets = "vault.${baseName}";
2025-02-18 17:44:39 -05:00
smtp = "smtp.purelymail.com";
2024-09-14 22:13:13 +00:00
status = "status.${baseName}";
2025-02-18 17:44:39 -05:00
stream = "stream.${baseName}";
2024-04-14 08:08:57 -04:00
transmission = "transmission.${baseName}";
};
2023-07-07 10:16:07 -06:00
};
2022-05-08 16:02:13 -04:00
2024-04-14 08:08:57 -04:00
in
rec {
2022-05-08 16:02:13 -04:00
2025-03-11 02:31:22 +00:00
inherit lib;
2025-03-12 01:51:12 +00:00
nixosConfigurations = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (
name: module:
lib.buildNixos {
inherit system module;
specialArgs = { inherit (globals) hostnames; };
}
) hosts
) lib.linuxHosts;
darwinConfigurations = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (
name: module:
lib.buildDarwin {
inherit system module;
}
) hosts
) lib.darwinHosts;
homeModules = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (
name: module: (builtins.head (lib.attrsToList module.home-manager.users)).value
) hosts
) lib.hosts;
homeConfigurations = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (
name: module:
lib.buildHome {
inherit system module;
specialArgs = { inherit (globals) hostnames; };
}
) hosts
) homeModules;
2022-06-12 17:46:26 -04:00
# Disk formatting, only used once
2024-04-14 08:08:57 -04:00
diskoConfigurations = {
2025-03-11 02:31:22 +00:00
root = import ./hosts/x86_64-linux/swan/root.nix;
2024-04-14 08:08:57 -04:00
};
# generators = {
# arrow.aws.x86_64-linux = lib.generateImage {
# system = "x86_64-linux";
# format = "amazon";
# specialArgs = { inherit (globals) hostnames; };
# };
# arrow.iso.x86_64-linux = lib.generateImage {
# system = "x86_64-linux";
# format = "iso";
# specialArgs = { inherit (globals) hostnames; };
# };
2025-03-08 18:08:17 -05:00
# };
generators = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (name: module: {
aws = lib.generateImage {
inherit system module;
format = "amazon";
specialArgs = { inherit (globals) hostnames; };
};
iso = lib.generateImage {
inherit system module;
format = "iso";
specialArgs = { inherit (globals) hostnames; };
};
}) hosts
) lib.linuxHosts;
packages = lib.forAllSystems (
system:
# Get the configurations that we normally use
{
nixosConfigurations = nixosConfigurations.${system};
darwinConfigurations = darwinConfigurations.${system};
homeConfigurations = homeConfigurations.${system};
generators = generators.${system};
}
//
# Get the custom packages that I have placed under the nmasur namespace
lib.pkgsBySystem.${system}.nmasur
);
2022-06-05 09:24:46 -04:00
# Development environments
2025-03-11 02:31:22 +00:00
devShells = lib.forAllSystems (system: {
default = lib.pkgsBySystem.${system}.nmasur.dotfiles-devshell;
2025-03-09 18:04:01 +00:00
});
2025-03-11 02:31:22 +00:00
checks = lib.forAllSystems (
system:
let
2025-03-11 02:31:22 +00:00
pkgs = import nixpkgs {
inherit system;
overlays = lib.overlays;
};
in
{
neovim =
pkgs.runCommand "neovim-check-health" { buildInputs = [ inputs.self.packages.${system}.neovim ]; }
''
mkdir -p $out
export HOME=$TMPDIR
nvim -c "checkhealth" -c "write $out/health.log" -c "quitall"
# Check for errors inside the health log
if $(grep "ERROR" $out/health.log); then
cat $out/health.log
exit 1
fi
'';
}
);
2025-03-11 02:31:22 +00:00
formatter = lib.forAllSystems (
system:
let
2025-03-11 02:31:22 +00:00
pkgs = import nixpkgs {
inherit system;
inherit (lib) overlays;
};
in
pkgs.nixfmt-rfc-style
);
2023-07-29 15:20:14 -04:00
2022-06-20 23:34:24 -04:00
# Templates for starting other projects quickly
2025-03-08 10:26:26 -05:00
templates = (import ./templates nixpkgs.lib);
2022-04-26 21:36:16 -04:00
};
}