1 Commits

Author SHA1 Message Date
b0b9827a2e try to configure using nixosModules
doesn't seem like there's that much benefit?
2023-07-10 17:56:15 -06:00
79 changed files with 388 additions and 1292 deletions

View File

@ -1,20 +0,0 @@
name: Check Build
on:
workflow_dispatch: # allows manual triggering
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Check Nixpkgs Inputs
uses: DeterminateSystems/flake-checker-action@v5
- name: Add Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Check the Flake
run: nix flake check

View File

@ -1,38 +0,0 @@
name: Update Flake
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '33 3 * * 0' # runs weekly on Sunday at 03:33
permissions:
contents: write
pull-requests: write
jobs:
lockfile:
name: Lockfile
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Check Nixpkgs Inputs
uses: DeterminateSystems/flake-checker-action@v5
- name: Add Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v19
id: update
with:
pr-title: "Update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
- name: Check the Flake
run: nix flake check
- name: Enable Pull Request Automerge
run: gh pr merge --rebase --auto ${{ steps.update.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ github.token }}

97
flake.lock generated
View File

@ -17,22 +17,6 @@
"type": "github" "type": "github"
} }
}, },
"baleia-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1681806450,
"narHash": "sha256-jxRlIzWbnSj89032msc5w+2TVt7zVyzlxdXxiH1dQqY=",
"owner": "m00qek",
"repo": "baleia.nvim",
"rev": "00bb4af31c8c3865b735d40ebefa6c3f07b2dd16",
"type": "github"
},
"original": {
"owner": "m00qek",
"repo": "baleia.nvim",
"type": "github"
}
},
"bufferline-nvim-src": { "bufferline-nvim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -73,11 +57,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1690431538, "lastModified": 1687517837,
"narHash": "sha256-Uml8ivMMOFPB9fNSDcw72imGHRdJpaK12sRm2DTLLe8=", "narHash": "sha256-Ea+JTy6NSf+wWIFrgC8gnOnyt01xwmtDEn2KecvaBkg=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "16c07487ac9bc59f58b121d13160c67befa3342e", "rev": "6460468e7a3e1290f132fee4170ebeaa127f6f32",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -94,11 +78,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1690548222, "lastModified": 1687598357,
"narHash": "sha256-EcVjLOpbAuL/y55fLlEl3BNM4FP5Pwtp+6DbTiL6FDM=", "narHash": "sha256-70ciIe8415oQnQypawaqocEaLJcI1XtkqRNmle8vsrg=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "43f17a8b31c49f6696b8b258d317161afdc7e36b", "rev": "1e7098ee0448dc5d33df394d040f454cd42a809c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -114,11 +98,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1690505116, "lastModified": 1688605308,
"narHash": "sha256-ec0yX+DdfGtw2TQnG29jt1X/89OHTF0VsRrpp0+7s8Y=", "narHash": "sha256-B9suu7dcdX4a18loO5ul237gqIJ5/+TRuheLj8fJjwM=",
"owner": "bandithedoge", "owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin", "repo": "nixpkgs-firefox-darwin",
"rev": "69010f2ef9fbcef70d12541910ccc6db7a9997db", "rev": "78d28acf685e19d353b2ecb6c38eeb3fc624fc68",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -181,11 +165,11 @@
"systems": "systems_2" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1689068808, "lastModified": 1685518550,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -201,11 +185,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1690652600, "lastModified": 1687627695,
"narHash": "sha256-Dy09g7mezToVwtFPyY25fAx1hzqNXv73/QmY5/qyR44=", "narHash": "sha256-6Pu7nWb52PRtUmihwuDNShDmsZiXgtXR0OARtH4DSik=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "f58889c07efa8e1328fdf93dc1796ec2a5c47f38", "rev": "172d46d4b2677b32277d903bdf4cff77c2cc6477",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -261,11 +245,11 @@
}, },
"nixlib": { "nixlib": {
"locked": { "locked": {
"lastModified": 1689469483, "lastModified": 1687049841,
"narHash": "sha256-2SBhY7rZQ/iNCxe04Eqxlz9YK9KgbaTMBssq3/BgdWY=", "narHash": "sha256-FBNZQfWtA7bb/rwk92mfiWc85x4hXta2OAouDqO5W8w=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs.lib", "repo": "nixpkgs.lib",
"rev": "02fea408f27186f139153e1ae88f8ab2abd9c22c", "rev": "908af6d1fa3643c5818ea45aa92b21d6385fbbe5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -282,11 +266,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1690133435, "lastModified": 1687398392,
"narHash": "sha256-YNZiefETggroaTLsLJG2M+wpF0pJPwiauKG4q48ddNU=", "narHash": "sha256-T6kc3NMTpGJk1/dve8PGupeVcxboEb78xtTKhe3LL/A=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-generators", "repo": "nixos-generators",
"rev": "b1171de4d362c022130c92d7c8adc4bf2b83d586", "rev": "649171f56a45af13ba693c156207eafbbbf7edfe",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -297,11 +281,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1690548937, "lastModified": 1687502512,
"narHash": "sha256-x3ZOPGLvtC0/+iFAg9Kvqm/8hTAIkGjc634SqtgaXTA=", "narHash": "sha256-dBL/01TayOSZYxtY4cMXuNCBk8UMLoqRZA+94xiFpJA=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2a9d660ff0f7ffde9d73be328ee6e6f10ef66b28", "rev": "3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -313,16 +297,16 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1690470004, "lastModified": 1686929285,
"narHash": "sha256-l57RmPhPz9r1LGDg/0v8bYgJO8R+GGTQZtkIxE7negU=", "narHash": "sha256-WGtVzn+vGMPTXDO0DMNKVFtf+zUSqeW+KKk4Y/Ae99I=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9462344318b376e157c94fa60c20a25b913b2381", "rev": "93fddcf640ceca0be331210ba3101cee9d91c13d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-23.05", "ref": "nixos-22.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -330,11 +314,11 @@
"null-ls-nvim-src": { "null-ls-nvim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1688652536, "lastModified": 1686871437,
"narHash": "sha256-6KJtj9pbvBm6fOVpnyzO2fEVC+cVrw2XtZHOgq9ieIw=", "narHash": "sha256-MxIZqyRW8jStiDNXt7Bsw8peDLKpqxKEaUuIJsXkGMI=",
"owner": "jose-elias-alvarez", "owner": "jose-elias-alvarez",
"repo": "null-ls.nvim", "repo": "null-ls.nvim",
"rev": "db09b6c691def0038c456551e4e2772186449f35", "rev": "bbaf5a96913aa92281f154b08732be2f57021c45",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -345,11 +329,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1690721668, "lastModified": 1687625402,
"narHash": "sha256-550poDnDiMXLPQBJnUwhEzv0ZC4zjiFiwTaOIi3jfs4=", "narHash": "sha256-V+vSWypmm/tGbwNXGhqzmiV7vTjV2gNCEh9N7OhNnyA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nur", "repo": "nur",
"rev": "1c4ba84e2cbfd43976a0fd3f848b536611735a79", "rev": "aeaf37c7538965e45700d39e6b5dc9c9a0e0749c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -378,11 +362,11 @@
"nvim-tree-lua-src": { "nvim-tree-lua-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1690616703, "lastModified": 1687132855,
"narHash": "sha256-kTbYvT21wLfiwEpQAgGZtep2GP4F9e7e6XGVpr4D1hY=", "narHash": "sha256-ZRUoCDBv8rO8ZUBUMLgo33EBbqD9+ZOSET9rkFsA++E=",
"owner": "kyazdani42", "owner": "kyazdani42",
"repo": "nvim-tree.lua", "repo": "nvim-tree.lua",
"rev": "4bd30f0137e44dcf3e74cc1164efb568f78f2b02", "rev": "c3c6544ee00333b0f1d6a13735d0dd302dba4f70",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -411,7 +395,6 @@
"root": { "root": {
"inputs": { "inputs": {
"Comment-nvim-src": "Comment-nvim-src", "Comment-nvim-src": "Comment-nvim-src",
"baleia-nvim-src": "baleia-nvim-src",
"bufferline-nvim-src": "bufferline-nvim-src", "bufferline-nvim-src": "bufferline-nvim-src",
"cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "cmp-nvim-lsp-src": "cmp-nvim-lsp-src",
"darwin": "darwin", "darwin": "darwin",
@ -579,11 +562,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1690553050, "lastModified": 1687279045,
"narHash": "sha256-pK3kF30OykL3v6P8UP6ipihlS34KoGq9SryCj3tHrFw=", "narHash": "sha256-LR0dsXd/A07M61jclyBUW0wRojEQteWReKM35zoJXp0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NixOS-WSL", "repo": "NixOS-WSL",
"rev": "f7a95a37306c46b42e9ce751977c44c752fd5eca", "rev": "a8486b5d191f11d571f15d80b6e265d1712d01cf",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -75,10 +75,6 @@
url = "github:jose-elias-alvarez/null-ls.nvim"; url = "github:jose-elias-alvarez/null-ls.nvim";
flake = false; flake = false;
}; };
baleia-nvim-src = {
url = "github:m00qek/baleia.nvim";
flake = false;
};
Comment-nvim-src = { Comment-nvim-src = {
url = "github:numToStr/Comment.nvim/v0.8.0"; url = "github:numToStr/Comment.nvim/v0.8.0";
flake = false; flake = false;
@ -114,10 +110,20 @@
}; };
outputs = { nixpkgs, ... }@inputs: outputs = { self, nixpkgs, ... }@inputs:
let let
# Common overlays to always use
overlays = [
inputs.nur.overlay
inputs.nix2vim.overlay
(import ./overlays/neovim-plugins.nix inputs)
(import ./overlays/calibre-web.nix)
(import ./overlays/disko.nix inputs)
(import ./overlays/tree-sitter.nix inputs)
];
# Global configuration for my systems # Global configuration for my systems
globals = let baseName = "masu.rs"; globals = let baseName = "masu.rs";
in rec { in rec {
@ -128,7 +134,8 @@
mail.server = "noahmasur.com"; mail.server = "noahmasur.com";
mail.imapHost = "imap.purelymail.com"; mail.imapHost = "imap.purelymail.com";
mail.smtpHost = "smtp.purelymail.com"; mail.smtpHost = "smtp.purelymail.com";
dotfilesRepo = "https://github.com/nmasur/dotfiles"; dotfilesRepo = "git@github.com:nmasur/dotfiles";
nixpkgs.overlays = overlays;
hostnames = { hostnames = {
git = "git.${baseName}"; git = "git.${baseName}";
metrics = "metrics.${baseName}"; metrics = "metrics.${baseName}";
@ -141,17 +148,6 @@
}; };
}; };
# Common overlays to always use
overlays = [
inputs.nur.overlay
inputs.nix2vim.overlay
(import ./overlays/neovim-plugins.nix inputs)
(import ./overlays/calibre-web.nix)
(import ./overlays/disko.nix inputs)
(import ./overlays/tree-sitter.nix inputs)
(import ./overlays/betterlockscreen.nix)
];
# System types to support. # System types to support.
supportedSystems = supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
@ -161,20 +157,26 @@
in rec { in rec {
nixosModules = {
globals = { config }: { config = globals; };
common = import ./modules/common;
nixos = import ./modules/nixos;
darwin = import ./modules/darwin;
};
# Contains my full system builds, including home-manager # Contains my full system builds, including home-manager
# nixos-rebuild switch --flake .#tempest # nixos-rebuild switch --flake .#tempest
nixosConfigurations = { nixosConfigurations = {
tempest = import ./hosts/tempest { inherit inputs globals overlays; }; tempest = import ./hosts/tempest { inherit self; };
hydra = import ./hosts/hydra { inherit inputs globals overlays; }; hydra = import ./hosts/hydra { inherit self; };
flame = import ./hosts/flame { inherit inputs globals overlays; }; flame = import ./hosts/flame { inherit self; };
swan = import ./hosts/swan { inherit inputs globals overlays; }; swan = import ./hosts/swan { inherit self; };
}; };
# Contains my full Mac system builds, including home-manager # Contains my full Mac system builds, including home-manager
# darwin-rebuild switch --flake .#lookingglass # darwin-rebuild switch --flake .#lookingglass
darwinConfigurations = { darwinConfigurations = {
lookingglass = lookingglass = import ./hosts/lookingglass { inherit self; };
import ./hosts/lookingglass { inherit inputs globals overlays; };
}; };
# For quickly applying home-manager settings with: # For quickly applying home-manager settings with:
@ -190,10 +192,8 @@
diskoConfigurations = { root = import ./disks/root.nix; }; diskoConfigurations = { root = import ./disks/root.nix; };
packages = let packages = let
aws = system: aws = system: import ./hosts/aws { inherit self system; };
import ./hosts/aws { inherit inputs globals overlays system; }; staff = system: import ./hosts/staff { inherit self system; };
staff = system:
import ./hosts/staff { inherit inputs globals overlays system; };
neovim = system: neovim = system:
let pkgs = import nixpkgs { inherit system overlays; }; let pkgs = import nixpkgs { inherit system overlays; };
in import ./modules/common/neovim/package { in import ./modules/common/neovim/package {
@ -228,24 +228,6 @@
}); });
checks = forAllSystems (system:
let pkgs = import nixpkgs { inherit system 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
'';
});
# Templates for starting other projects quickly # Templates for starting other projects quickly
templates = rec { templates = rec {
default = basic; default = basic;

View File

@ -1,13 +1,14 @@
{ inputs, system, globals, overlays, ... }: { self, system, ... }:
inputs.nixos-generators.nixosGenerate { self.inputs.nixos-generators.nixosGenerate {
inherit system; inherit system;
format = "amazon"; format = "amazon";
modules = [ modules = [
globals self.inputs.home-manager.nixosModules.home-manager
inputs.home-manager.nixosModules.home-manager self.nixosModules.globals
self.nixosModules.common
self.nixosModules.nixos
{ {
nixpkgs.overlays = overlays;
networking.hostName = "sheep"; networking.hostName = "sheep";
gui.enable = false; gui.enable = false;
theme.colors = (import ../../colorscheme/gruvbox).dark; theme.colors = (import ../../colorscheme/gruvbox).dark;
@ -17,9 +18,6 @@ inputs.nixos-generators.nixosGenerate {
# AWS settings require this # AWS settings require this
permitRootLogin = "prohibit-password"; permitRootLogin = "prohibit-password";
} }
../../modules/common
../../modules/nixos
../../modules/nixos/services/sshd.nix
] ++ [ ] ++ [
# Required to fix diskSize errors during build # Required to fix diskSize errors during build
({ ... }: { amazonImage.sizeMB = 16 * 1024; }) ({ ... }: { amazonImage.sizeMB = 16 * 1024; })

View File

@ -4,24 +4,23 @@
# How to install: # How to install:
# https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/ # https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/
{ inputs, globals, overlays, ... }: { self, ... }:
inputs.nixpkgs.lib.nixosSystem { self.inputs.nixpkgs.lib.nixosSystem {
system = "aarch64-linux"; system = "aarch64-linux";
specialArgs = { }; specialArgs = { };
modules = [ modules = [
globals self.inputs.home-manager.nixosModules.home-manager
inputs.home-manager.nixosModules.home-manager self.nixosModules.globals
../../modules/common self.nixosModules.common
../../modules/nixos self.nixosModules.nixos
{ {
nixpkgs.overlays = overlays;
# Hardware # Hardware
server = true; server = true;
networking.hostName = "flame"; networking.hostName = "flame";
imports = [ (inputs.nixpkgs + "/nixos/modules/profiles/qemu-guest.nix") ]; imports =
[ (self.inputs.nixpkgs + "/nixos/modules/profiles/qemu-guest.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ];
fileSystems."/" = { fileSystems."/" = {
@ -49,8 +48,7 @@ inputs.nixpkgs.lib.nixosSystem {
services.caddy.enable = true; services.caddy.enable = true;
services.grafana.enable = true; services.grafana.enable = true;
services.openssh.enable = true; services.prometheus.enable = true;
services.victoriametrics.enable = true;
services.gitea.enable = true; services.gitea.enable = true;
services.vaultwarden.enable = true; services.vaultwarden.enable = true;
services.minecraft-server.enable = true; # Setup Minecraft server services.minecraft-server.enable = true; # Setup Minecraft server
@ -72,9 +70,6 @@ inputs.nixpkgs.lib.nixosSystem {
accessKeyId = "0026b0e73b2e2c80000000005"; accessKeyId = "0026b0e73b2e2c80000000005";
}; };
# # Grant access to Jellyfin directories from Nextcloud
# users.users.nextcloud.extraGroups = [ "jellyfin" ];
# # Wireguard config for Transmission # # Wireguard config for Transmission
# wireguard.enable = true; # wireguard.enable = true;
# networking.wireguard.interfaces.wg0 = { # networking.wireguard.interfaces.wg0 = {

View File

@ -1,21 +1,20 @@
# The Hydra # The Hydra
# System configuration for WSL # System configuration for WSL
{ inputs, globals, overlays, ... }: { self, ... }:
inputs.nixpkgs.lib.nixosSystem { self.inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { }; specialArgs = { };
modules = [ modules = [
../../modules/common self.inputs.wsl.nixosModules.wsl
../../modules/nixos self.inputs.home-manager.nixosModules.home-manager
../../modules/wsl self.nixosModules.globals
globals self.nixosModules.common
inputs.wsl.nixosModules.wsl self.nixosModules.nixos
inputs.home-manager.nixosModules.home-manager self.nixosModules.wsl
{ {
networking.hostName = "hydra"; networking.hostName = "hydra";
nixpkgs.overlays = overlays;
identityFile = "/home/${globals.user}/.ssh/id_ed25519"; identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = false; gui.enable = false;
theme = { theme = {

View File

@ -1,24 +1,23 @@
# The Looking Glass # The Looking Glass
# System configuration for my work Macbook # System configuration for my work Macbook
{ inputs, globals, overlays, ... }: { self, ... }:
inputs.darwin.lib.darwinSystem { self.inputs.darwin.lib.darwinSystem {
system = "x86_64-darwin"; system = "x86_64-darwin";
specialArgs = { }; specialArgs = { };
modules = [ modules = [
../../modules/common self.inputs.home-manager.darwinModules.home-manager
../../modules/darwin self.nixosModules.common
(globals // rec { self.nixosModules.darwin
user = "Noah.Masur"; ({ config, lib, ... }: {
gitName = "Noah-Masur_1701"; config = rec {
gitEmail = "${user}@take2games.com"; user = lib.mkForce "Noah.Masur";
}) gitName = lib.mkForce "Noah-Masur_1701";
inputs.home-manager.darwinModules.home-manager gitEmail = lib.mkForce "${user}@take2games.com";
{ nixpkgs.overlays = [ self.inputs.firefox-darwin.overlay ];
nixpkgs.overlays = [ inputs.firefox-darwin.overlay ] ++ overlays;
networking.hostName = "lookingglass"; networking.hostName = "lookingglass";
identityFile = "/Users/Noah.Masur/.ssh/id_ed25519"; identityFile = "/Users/${user}/.ssh/id_ed25519";
gui.enable = true; gui.enable = true;
theme = { theme = {
colors = (import ../../colorscheme/gruvbox-dark).dark; colors = (import ../../colorscheme/gruvbox-dark).dark;
@ -41,6 +40,7 @@ inputs.darwin.lib.darwinSystem {
kubernetes.enable = true; kubernetes.enable = true;
_1password.enable = true; _1password.enable = true;
slack.enable = true; slack.enable = true;
} };
})
]; ];
} }

View File

@ -1,13 +1,16 @@
# The Staff # The Staff
# ISO configuration for my USB drive # ISO configuration for my USB drive
{ inputs, system, overlays, ... }: { self, system, ... }:
inputs.nixos-generators.nixosGenerate { self.inputs.nixos-generators.nixosGenerate {
inherit system; inherit system;
format = "install-iso"; format = "install-iso";
modules = [{ modules = [
nixpkgs.overlays = overlays; self.nixosModules.global
self.nixosModules.common
self.nixosModules.nixos
({ config, pkgs, ... }: {
networking.hostName = "staff"; networking.hostName = "staff";
users.extraUsers.root.openssh.authorizedKeys.keys = [ users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"
@ -23,9 +26,7 @@ inputs.nixos-generators.nixosGenerate {
PermitRootLogin = "yes"; PermitRootLogin = "yes";
}; };
}; };
environment.systemPackages = environment.systemPackages = with pkgs; [
let pkgs = import inputs.nixpkgs { inherit system overlays; };
in with pkgs; [
git git
vim vim
wget wget
@ -39,5 +40,6 @@ inputs.nixos-generators.nixosGenerate {
experimental-features = nix-command flakes experimental-features = nix-command flakes
warn-dirty = false warn-dirty = false
''; '';
}]; })
];
} }

View File

@ -1,21 +1,20 @@
# The Swan # The Swan
# System configuration for my home NAS server # System configuration for my home NAS server
{ inputs, globals, overlays, ... }: { self, ... }:
inputs.nixpkgs.lib.nixosSystem { self.inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { }; specialArgs = { };
modules = [ modules = [
globals self.inputs.home-manager.nixosModules.home-manager
inputs.home-manager.nixosModules.home-manager self.inputs.disko.nixosModules.disko
inputs.disko.nixosModules.disko self.nixosModules.globals
../../modules/common self.nixosModules.common
../../modules/nixos self.nixosModules.nixos
{ {
# Hardware # Hardware
server = true; server = true;
physical = true;
networking.hostName = "swan"; networking.hostName = "swan";
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules =
@ -47,20 +46,16 @@ inputs.nixpkgs.lib.nixosSystem {
gui.enable = false; gui.enable = false;
theme = { colors = (import ../../colorscheme/gruvbox).dark; }; theme = { colors = (import ../../colorscheme/gruvbox).dark; };
nixpkgs.overlays = overlays;
neovim.enable = true; neovim.enable = true;
cloudflare.enable = true; cloudflare.enable = true;
dotfiles.enable = true; dotfiles.enable = true;
arrs.enable = true; arrs.enable = true;
services.bind.enable = true;
services.caddy.enable = true; services.caddy.enable = true;
services.jellyfin.enable = true; services.jellyfin.enable = true;
services.nextcloud.enable = true; services.nextcloud.enable = true;
services.calibre-web.enable = true; services.calibre-web.enable = true;
services.openssh.enable = true; services.prometheus.enable = true;
services.prometheus.enable = false;
services.vmagent.enable = true;
services.samba.enable = true; services.samba.enable = true;
cloudflareTunnel = { cloudflareTunnel = {

View File

@ -1,18 +1,16 @@
# The Tempest # The Tempest
# System configuration for my desktop # System configuration for my desktop
{ inputs, globals, overlays, ... }: { self, ... }:
inputs.nixpkgs.lib.nixosSystem { self.inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
globals self.inputs.home-manager.nixosModules.home-manager
inputs.home-manager.nixosModules.home-manager self.nixosModules.globals
../../modules/common self.nixosModules.common
../../modules/nixos self.nixosModules.nixos
{ {
nixpkgs.overlays = overlays;
# Hardware # Hardware
physical = true; physical = true;
networking.hostName = "tempest"; networking.hostName = "tempest";
@ -53,7 +51,7 @@ inputs.nixpkgs.lib.nixosSystem {
# Must be prepared ahead # Must be prepared ahead
identityFile = "/home/${globals.user}/.ssh/id_ed25519"; identityFile = "/home/${globals.user}/.ssh/id_ed25519";
passwordHash = inputs.nixpkgs.lib.fileContents ../../password.sha512; passwordHash = self.inputs.nixpkgs.lib.fileContents ../../password.sha512;
# Theming # Theming
gui.enable = true; gui.enable = true;
@ -61,8 +59,8 @@ inputs.nixpkgs.lib.nixosSystem {
colors = (import ../../colorscheme/gruvbox-dark).dark; colors = (import ../../colorscheme/gruvbox-dark).dark;
dark = true; dark = true;
}; };
wallpaper = "${inputs.wallpapers}/gruvbox/road.jpg"; wallpaper = "${self.inputs.wallpapers}/gruvbox/road.jpg";
gtk.theme.name = inputs.nixpkgs.lib.mkDefault "Adwaita-dark"; gtk.theme.name = self.inputs.nixpkgs.lib.mkDefault "Adwaita-dark";
# Programs and services # Programs and services
charm.enable = true; charm.enable = true;
@ -91,9 +89,7 @@ inputs.nixpkgs.lib.nixosSystem {
leagueoflegends.enable = true; leagueoflegends.enable = true;
ryujinx.enable = true; ryujinx.enable = true;
}; };
services.vmagent.enable = true;
services.openssh.enable = true; # Required for Cloudflare tunnel
cloudflareTunnel = { cloudflareTunnel = {
enable = true; enable = true;
id = "ac133a82-31fb-480c-942a-cdbcd4c58173"; id = "ac133a82-31fb-480c-942a-cdbcd4c58173";
@ -102,9 +98,6 @@ inputs.nixpkgs.lib.nixosSystem {
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPY6C0HmdFCaxYtJxFr3qV4/1X4Q8KrYQ1hlme3u1hJXK+xW+lc9Y9glWHrhiTKilB7carYTB80US0O47gI5yU4= open-ssh-ca@cloudflareaccess.org"; "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPY6C0HmdFCaxYtJxFr3qV4/1X4Q8KrYQ1hlme3u1hJXK+xW+lc9Y9glWHrhiTKilB7carYTB80US0O47gI5yU4= open-ssh-ca@cloudflareaccess.org";
}; };
# Allows requests to force machine to wake up
networking.interfaces.enp5s0.wakeOnLan.enable = true;
} }
]; ];
} }

View File

@ -73,7 +73,6 @@
"media.ffmpeg.vaapi.enabled" = "media.ffmpeg.vaapi.enabled" =
true; # Enable hardware video acceleration true; # Enable hardware video acceleration
"cookiebanners.ui.desktop.enabled" = true; # Reject cookie popups "cookiebanners.ui.desktop.enabled" = true; # Reject cookie popups
"svg.context-properties.content.enabled" = true; # Sidebery styling
}; };
userChrome = '' userChrome = ''
:root { :root {

View File

@ -28,22 +28,13 @@
programs.rofi.terminal = programs.rofi.terminal =
lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty";
# Display images in the terminal
programs.fish.shellAliases = {
icat = "kitty +kitten icat";
ssh = "kitty +kitten ssh";
};
programs.kitty = { programs.kitty = {
enable = true; enable = true;
environment = { }; environment = { };
extraConfig = ""; extraConfig = "";
font.size = 14; font.size = 14;
keybindings = { keybindings = {
# Use shift+enter to complete text suggestions in fish
"shift+enter" = "send_text all \\x1F"; "shift+enter" = "send_text all \\x1F";
# Easy fullscreen toggle (for macOS)
"super+f" = "toggle_fullscreen"; "super+f" = "toggle_fullscreen";
}; };
settings = { settings = {
@ -94,6 +85,7 @@
# Scrollback # Scrollback
scrolling_lines = 10000; scrolling_lines = 10000;
scrollback_pager_history_size = 10; # MB scrollback_pager_history_size = 10; # MB
scrollback_pager = "${pkgs.neovim}/bin/nvim -c 'normal G'";
# Window # Window
window_padding_width = 6; window_padding_width = 6;
@ -101,7 +93,7 @@
tab_bar_edge = "top"; tab_bar_edge = "top";
tab_bar_style = "slant"; tab_bar_style = "slant";
# Disable audio # Audio
enable_audio_bell = false; enable_audio_bell = false;
}; };
}; };

View File

@ -22,8 +22,8 @@
enable = true; enable = true;
bindings = { }; bindings = { };
config = { config = {
image-display-duration = 2; # For cycling through images image-display-duration = 2;
hwdec = "auto-safe"; # Attempt to use GPU decoding for video hwdec = "auto-safe";
}; };
scripts = [ scripts = [
@ -49,7 +49,7 @@
]; ];
}; };
# Set default programs for opening PDFs and other media # Set default for opening PDFs
xdg.mimeApps = { xdg.mimeApps = {
associations.added = { associations.added = {
"application/pdf" = [ "pwmt.zathura-cb.desktop" ]; "application/pdf" = [ "pwmt.zathura-cb.desktop" ];

View File

@ -59,7 +59,7 @@
}; };
dotfilesRepo = lib.mkOption { dotfilesRepo = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Link to dotfiles repository HTTPS URL."; description = "Link to dotfiles repository.";
}; };
unfreePackages = lib.mkOption { unfreePackages = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
imports = [ ./himalaya.nix ./aerc.nix ./system.nix ]; imports = [ ./himalaya.nix ./aerc.nix ];
options = { options = {
mail.enable = lib.mkEnableOption "Mail service."; mail.enable = lib.mkEnableOption "Mail service.";
@ -27,31 +27,15 @@
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
programs.mbsync = { enable = true; }; programs.mbsync = { enable = true; };
# Automatically check for mail and keep files synced locally
services.mbsync = lib.mkIf pkgs.stdenv.isLinux { services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true; enable = true;
frequency = "*:0/5"; frequency = "*:0/5";
postExec = "${pkgs.notmuch}/bin/notmuch new"; postExec = "${pkgs.notmuch}/bin/notmuch new";
}; };
# Used to watch for new mail and trigger sync
services.imapnotify.enable = pkgs.stdenv.isLinux; services.imapnotify.enable = pkgs.stdenv.isLinux;
programs.notmuch.enable = true;
# Allows sending email from CLI/sendmail
programs.msmtp.enable = true;
# Better local mail search
programs.notmuch = {
enable = true;
new.ignore = [ ".mbsyncstate.lock" ".mbsyncstate.journal" ];
};
accounts.email = { accounts.email = {
# Where email files are stored
maildirBasePath = "${config.homePath}/mail"; maildirBasePath = "${config.homePath}/mail";
accounts = { accounts = {
home = let address = "${config.mail.user}@${config.mail.server}"; home = let address = "${config.mail.user}@${config.mail.server}";
in { in {
@ -64,17 +48,13 @@
"hey" "hey"
"admin" "admin"
]; ];
# Options for contact completion
alot = { }; alot = { };
flavor = "plain";
imap = { imap = {
host = config.mail.imapHost; host = config.mail.imapHost;
port = 993; port = 993;
tls.enable = true; tls.enable = true;
}; };
# Watch for mail and run notifications or sync
imapnotify = { imapnotify = {
enable = true; enable = true;
boxes = [ "Inbox" ]; boxes = [ "Inbox" ];
@ -83,11 +63,7 @@
config.home-manager.users.${config.user}.services.dunst.enable config.home-manager.users.${config.user}.services.dunst.enable
"${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; "${pkgs.libnotify}/bin/notify-send 'New mail arrived'";
}; };
# Name of the directory in maildir for this account
maildir = { path = "main"; }; maildir = { path = "main"; };
# Bi-directional syncing options for local files
mbsync = { mbsync = {
enable = true; enable = true;
create = "both"; create = "both";
@ -98,17 +74,12 @@
CopyArrivalDate = "yes"; # Sync time of original message CopyArrivalDate = "yes"; # Sync time of original message
}; };
}; };
# Enable indexing
notmuch.enable = true; notmuch.enable = true;
# Used to login and send and receive emails
passwordCommand = passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
pkgs.writeText "mailpass.age" pkgs.writeText "mailpass.age"
(builtins.readFile ../../../private/mailpass.age) (builtins.readFile ../../../private/mailpass.age)
}"; }";
smtp = { smtp = {
host = config.mail.smtpHost; host = config.mail.smtpHost;
port = 465; port = 465;

View File

@ -1,34 +0,0 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.mail.enable || config.server) {
home-manager.users.${config.user} = {
programs.msmtp.enable = true;
# The system user for sending automatic notifications
accounts.email.accounts.system =
let address = "system@${config.mail.server}";
in {
userName = address;
realName = "NixOS System";
primary = !config.mail.enable; # Only primary if mail not enabled
inherit address;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
pkgs.writeText "mailpass-system.age"
(builtins.readFile ../../../private/mailpass-system.age)
}";
msmtp.enable = true;
smtp = {
host = config.mail.smtpHost;
port = 465;
tls.enable = true;
};
};
};
};
}

View File

@ -1,7 +1,4 @@
{ pkgs, ... }: { { pkgs, ... }: {
# Plugin for aligning text programmatically
plugins = [ pkgs.vimPlugins.tabular ]; plugins = [ pkgs.vimPlugins.tabular ];
lua = '' lua = ''
-- Align -- Align

View File

@ -1,7 +1,4 @@
{ pkgs, ... }: { { pkgs, ... }: {
# Shows buffers in a VSCode-style tab layout
plugins = [ plugins = [
pkgs.vimPlugins.bufferline-nvim pkgs.vimPlugins.bufferline-nvim
pkgs.vimPlugins.vim-bbye # Better closing of buffers pkgs.vimPlugins.vim-bbye # Better closing of buffers

View File

@ -1,7 +1,5 @@
{ pkgs, lib, config, ... }: { { pkgs, lib, config, ... }: {
# Sets Neovim colors based on Nix colorscheme
options.colors = lib.mkOption { options.colors = lib.mkOption {
type = lib.types.attrsOf lib.types.str; type = lib.types.attrsOf lib.types.str;
description = "Attrset of base16 colorscheme key value pairs."; description = "Attrset of base16 colorscheme key value pairs.";

View File

@ -24,14 +24,12 @@
end end
''; '';
# Enable Luasnip snippet completion
snippet.expand = dsl.rawLua '' snippet.expand = dsl.rawLua ''
function(args) function(args)
require("luasnip").lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end end
''; '';
# Basic completion keybinds
mapping = { mapping = {
"['<C-n>']" = dsl.rawLua "['<C-n>']" = dsl.rawLua
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })"; "require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
@ -66,26 +64,24 @@
''; '';
}; };
# These are where the completion engine gets its suggestions
sources = [ sources = [
{ name = "nvim_lua"; } # Fills in common Neovim lua functions { name = "nvim_lua"; }
{ name = "nvim_lsp"; } # LSP results { name = "nvim_lsp"; }
{ name = "luasnip"; } # Snippets { name = "luasnip"; }
{ name = "path"; } # Shell completion from current PATH { name = "path"; }
{ {
name = "buffer"; # Grep for text from the current text buffer name = "buffer";
keyword_length = 3; keyword_length = 3;
max_item_count = 10; max_item_count = 10;
} }
{ {
name = "rg"; # Grep for text from the current directory name = "rg";
keyword_length = 6; keyword_length = 6;
max_item_count = 10; max_item_count = 10;
option = { additional_arguments = "--ignore-case"; }; option = { additional_arguments = "--ignore-case"; };
} }
]; ];
# Styling of the completion menu
formatting = { formatting = {
fields = [ "kind" "abbr" "menu" ]; fields = [ "kind" "abbr" "menu" ];
format = dsl.rawLua '' format = dsl.rawLua ''

View File

@ -7,14 +7,11 @@
pkgs.vimPlugins.comment-nvim # Smart comment commands pkgs.vimPlugins.comment-nvim # Smart comment commands
pkgs.vimPlugins.glow-nvim # Markdown preview popup pkgs.vimPlugins.glow-nvim # Markdown preview popup
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
pkgs.vimPlugins.which-key-nvim # Keybind helper
]; ];
# Initialize some plugins
setup.Comment = { }; setup.Comment = { };
setup.colorizer = { }; setup.colorizer = { };
setup.glow = { }; setup.glow = { };
setup.which-key = { };
vim.o = { vim.o = {
termguicolors = true; # Set to truecolor termguicolors = true; # Set to truecolor
@ -44,10 +41,6 @@
relativenumber = true; # Relative numbers instead of absolute relativenumber = true; # Relative numbers instead of absolute
}; };
# For which-key-nvim
vim.o.timeout = true;
vim.o.timeoutlen = 300;
# Better backup, swap and undo storage # Better backup, swap and undo storage
vim.o.backup = true; # Easier to recover and more secure vim.o.backup = true; # Easier to recover and more secure
vim.bo.swapfile = false; # Instead of swaps, create backups vim.bo.swapfile = false; # Instead of swaps, create backups

View File

@ -22,7 +22,6 @@
pkgs.vimPlugins.playground # Tree-sitter experimenting pkgs.vimPlugins.playground # Tree-sitter experimenting
pkgs.vimPlugins.nginx-vim pkgs.vimPlugins.nginx-vim
pkgs.vimPlugins.vim-helm pkgs.vimPlugins.vim-helm
pkgs.baleia-nvim # Clean ANSI from kitty scrollback
(pkgs.vimUtils.buildVimPluginFrom2Nix { (pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nmasur"; pname = "nmasur";
version = "0.1"; version = "0.1";

View File

@ -1,7 +1,5 @@
{ pkgs, dsl, ... }: { { pkgs, dsl, ... }: {
# Telescope is a fuzzy finder that can work with different sub-plugins
plugins = [ plugins = [
pkgs.vimPlugins.telescope-nvim pkgs.vimPlugins.telescope-nvim
pkgs.vimPlugins.project-nvim pkgs.vimPlugins.project-nvim

View File

@ -12,8 +12,6 @@ vim.api.nvim_create_autocmd("TermOpen", {
end, end,
}) })
-- These are all the different types of terminals we can trigger
local terminal = require("toggleterm.terminal").Terminal local terminal = require("toggleterm.terminal").Terminal
local basicterminal = terminal:new() local basicterminal = terminal:new()

View File

@ -1,7 +1,5 @@
{ pkgs, dsl, ... }: { { pkgs, dsl, ... }: {
# Toggleterm provides a floating terminal inside the editor for quick access
plugins = [ pkgs.vimPlugins.toggleterm-nvim ]; plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
use.toggleterm.setup = dsl.callWith { use.toggleterm.setup = dsl.callWith {

View File

@ -1,7 +1,5 @@
{ pkgs, dsl, ... }: { { pkgs, dsl, ... }: {
# This plugin creates a side drawer for navigating the current project
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ]; plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
# Disable netrw eagerly # Disable netrw eagerly
@ -12,16 +10,16 @@
}; };
setup.nvim-tree = { setup.nvim-tree = {
disable_netrw = true; # Disable the built-in file manager disable_netrw = true;
hijack_netrw = true; # Works as the file manager hijack_netrw = true;
sync_root_with_cwd = true; # Change project whenever currend dir changes sync_root_with_cwd = true;
respect_buf_cwd = true; # Change to exact location of focused buffer respect_buf_cwd = true;
update_focused_file = { # Change project based on the focused buffer update_focused_file = {
enable = true; enable = true;
update_root = true; update_root = true;
ignore_list = { }; ignore_list = { };
}; };
diagnostics = { # Enable LSP and linter integration diagnostics = {
enable = true; enable = true;
icons = { icons = {
hint = ""; hint = "";
@ -30,7 +28,7 @@
error = ""; error = "";
}; };
}; };
renderer = { # Show files with changes vs. current commit renderer = {
icons = { icons = {
glyphs = { glyphs = {
git = { git = {
@ -45,7 +43,6 @@
}; };
}; };
}; };
# Set keybinds and initialize program
on_attach = dsl.rawLua '' on_attach = dsl.rawLua ''
function (bufnr) function (bufnr)
local api = require('nvim-tree.api') local api = require('nvim-tree.api')
@ -61,7 +58,7 @@
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
end end
''; '';
view = { # Set look and feel view = {
width = 30; width = 30;
hide_root_folder = false; hide_root_folder = false;
side = "left"; side = "left";
@ -70,7 +67,6 @@
}; };
}; };
# Toggle the sidebar
lua = '' lua = ''
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true }) vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
''; '';

View File

@ -18,16 +18,11 @@ in {
home.packages = [ neovim ]; home.packages = [ neovim ];
# Use Neovim as the editor for git commit messages
programs.git.extraConfig.core.editor = "nvim"; programs.git.extraConfig.core.editor = "nvim";
# Set Neovim as the default app for text editing and manual pages
home.sessionVariables = { home.sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
MANPAGER = "nvim +Man!"; MANPAGER = "nvim +Man!";
}; };
# Create quick aliases for launching Neovim
programs.fish = { programs.fish = {
shellAliases = { vim = "nvim"; }; shellAliases = { vim = "nvim"; };
shellAbbrs = { shellAbbrs = {
@ -36,20 +31,12 @@ in {
vll = "nvim -c 'Telescope oldfiles'"; vll = "nvim -c 'Telescope oldfiles'";
}; };
}; };
programs.kitty.settings.scrollback_pager = lib.mkForce ''
${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
# Set Neovim as the kitty terminal "scrollback" (vi mode) option.
# Requires removing some of the ANSI escape codes that are sent to the
# scrollback using sed and baleia, as well as removing several
# unnecessary features.
programs.kitty.settings.scrollback_pager = ''
$SHELL -c 'sed -r "s/[[:cntrl:]]\]133;[AC]..//g" | ${neovim}/bin/nvim -c "setlocal nonumber norelativenumber nolist laststatus=0" -c "lua baleia = require(\"baleia\").setup({}); baleia.once(0)" -c "map <silent> q :qa!<CR>" -c "autocmd VimEnter * normal G"' '';
# Create a desktop option for launching Neovim from a file manager
# (Requires launching the terminal and then executing Neovim)
xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux { xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux {
name = "Neovim wrapper"; name = "Neovim wrapper";
exec = "kitty nvim %F"; exec = "kitty nvim %F";
mimeType = [ "text/plain" "text/markdown" ];
}; };
xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux { xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux {
"text/plain" = [ "nvim.desktop" ]; "text/plain" = [ "nvim.desktop" ];
@ -58,6 +45,9 @@ in {
}; };
# # Used for icons in Vim
# fonts.fonts = with pkgs; [ nerdfonts ];
}; };
} }

View File

@ -39,7 +39,7 @@ key("n", "<Leader>fs", ":write<CR>")
key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true }) key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true })
key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true }) key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true })
key("n", "<Leader><Tab>", ":b#<CR>", { silent = true }) key("n", "<Leader><Tab>", ":b#<CR>", { silent = true })
key("n", "<Leader>gr", ":!gh browse %<CR><CR>", { silent = true }) key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", { silent = true })
key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]]) key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]])
key("n", "<Leader>jj", ":!journal<CR>:e<CR>") key("n", "<Leader>jj", ":!journal<CR>:e<CR>")

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
# Allows me to make sure I can work on my dotfiles locally
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles."; options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
config = lib.mkIf config.dotfiles.enable { config = lib.mkIf config.dotfiles.enable {
@ -16,8 +14,13 @@
[ "writeBoundary" ] '' [ "writeBoundary" ] ''
if [ ! -d "${config.dotfilesPath}" ]; then if [ ! -d "${config.dotfilesPath}" ]; then
$DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}")
$DRY_RUN_CMD ${pkgs.git}/bin/git \
clone ${config.dotfilesRepo} "${config.dotfilesPath}" # Force HTTPS because anonymous SSH doesn't work
GIT_CONFIG_COUNT=1 \
GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" \
GIT_CONFIG_VALUE_0="git@github.com:" \
$DRY_RUN_CMD \
${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}"
fi fi
''; '';

View File

@ -1,8 +1,5 @@
{ config, ... }: { { config, ... }: {
# This is just a placeholder as I expect to interact with my notes in a
# certain location
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.sessionVariables = { home.sessionVariables = {

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
# Convenience utilities from charm.sh
options.charm.enable = lib.mkEnableOption "Charm utilities."; options.charm.enable = lib.mkEnableOption "Charm utilities.";
config.home-manager.users.${config.user} = lib.mkIf config.charm.enable { config.home-manager.users.${config.user} = lib.mkIf config.charm.enable {

View File

@ -1,6 +1,5 @@
{ config, ... }: { { config, ... }: {
# Enables quickly entering Nix shells when changing directories
home-manager.users.${config.user}.programs.direnv = { home-manager.users.${config.user}.programs.direnv = {
enable = true; enable = true;
nix-direnv.enable = true; nix-direnv.enable = true;

View File

@ -1,7 +1,5 @@
{ config, ... }: { { config, ... }: {
# FZF is a fuzzy-finder for the terminal
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
programs.fzf.enable = true; programs.fzf.enable = true;

View File

@ -73,9 +73,6 @@
path = builtins.toString pkgs.path; path = builtins.toString pkgs.path;
}; };
# For security, only allow specific users
settings.allowed-users = [ "@wheel" config.user ];
}; };
} }

View File

@ -23,7 +23,6 @@ in {
dig # DNS lookup dig # DNS lookup
fd # find fd # find
htop # Show system processes htop # Show system processes
killall # Force quit
inetutils # Includes telnet, whois inetutils # Includes telnet, whois
jq # JSON manipulation jq # JSON manipulation
lf # File viewer lf # File viewer
@ -35,9 +34,6 @@ in {
tree # View directory hierarchy tree # View directory hierarchy
vimv-rs # Batch rename files vimv-rs # Batch rename files
unzip # Extract zips unzip # Extract zips
dua # File sizes (du)
du-dust # Disk usage tree (ncdu)
duf # Basic disk information (df)
]; ];
programs.zoxide.enable = true; # Shortcut jump command programs.zoxide.enable = true; # Shortcut jump command
@ -56,6 +52,10 @@ in {
}; };
}; };
programs.fish.shellAbbrs = {
cat = "bat"; # Swap cat with bat
};
programs.fish.functions = { programs.fish.functions = {
ping = { ping = {
description = "Improved ping"; description = "Improved ping";

View File

@ -20,22 +20,12 @@
}; };
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source =
./hammerspoon/Spoons/MoveWindow.spoon; ./hammerspoon/Spoons/MoveWindow.spoon;
home.activation.reloadHammerspoon =
config.home-manager.users.${config.user}.lib.dag.entryAfter
[ "writeBoundary" ] ''
$DRY_RUN_CMD /usr/local/bin/hs -c "hs.reload()"
$DRY_RUN_CMD sleep 1
$DRY_RUN_CMD /usr/local/bin/hs -c "hs.console.clearConsole()"
'';
}; };
homebrew.casks = [ "hammerspoon" ]; homebrew.casks = [ "hammerspoon" ];
system.activationScripts.postUserActivation.text = '' system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
sudo killall Dock
''; '';
}; };

View File

@ -2,4 +2,3 @@ hs.loadSpoon("ControlEscape"):start() -- Load Hammerspoon bits from https://gith
hs.loadSpoon("Launcher"):init() hs.loadSpoon("Launcher"):init()
hs.loadSpoon("DismissAlerts"):init() hs.loadSpoon("DismissAlerts"):init()
hs.loadSpoon("MoveWindow"):init() hs.loadSpoon("MoveWindow"):init()
hs.ipc.cliInstall() -- Install Hammerspoon CLI program

View File

@ -14,8 +14,6 @@
home.packages = with pkgs; [ calibre ]; home.packages = with pkgs; [ calibre ];
# home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; }; # home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; };
}; };
# Forces Calibre to use dark mode
environment.sessionVariables = { CALIBRE_USE_DARK_PALETTE = "1"; }; environment.sessionVariables = { CALIBRE_USE_DARK_PALETTE = "1"; };
}; };
} }

View File

@ -18,14 +18,12 @@
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
# Quick button for launching nautilus
xsession.windowManager.i3.config.keybindings = { xsession.windowManager.i3.config.keybindings = {
"${ "${
config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier
}+n" = "exec --no-startup-id ${pkgs.gnome.nautilus}/bin/nautilus"; }+n" = "exec --no-startup-id ${pkgs.gnome.nautilus}/bin/nautilus";
}; };
# Generates a QR code and previews it with sushi
programs.fish.functions = { programs.fish.functions = {
qr = { qr = {
body = body =
@ -33,7 +31,7 @@
}; };
}; };
# Set Nautilus as default for opening directories # Set default for opening directories
xdg.mimeApps = { xdg.mimeApps = {
associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ]; associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ];
# associations.removed = { # associations.removed = {
@ -42,7 +40,6 @@
defaultApplications."inode/directory" = defaultApplications."inode/directory" =
lib.mkBefore [ "org.gnome.Nautilus.desktop" ]; lib.mkBefore [ "org.gnome.Nautilus.desktop" ];
}; };
}; };
# # Set default for opening directories # # Set default for opening directories
@ -53,13 +50,6 @@
# lib.mkForce [ "org.gnome.Nautilus.desktop" ]; # lib.mkForce [ "org.gnome.Nautilus.desktop" ];
# }; # };
# Delete Trash files older than 1 week
systemd.user.services.empty-trash = {
description = "Empty Trash on a regular basis";
wantedBy = [ "default.target" ];
script = "${pkgs.trash-cli}/bin/trash-empty 7";
};
}; };
} }

View File

@ -6,7 +6,7 @@ in {
config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) {
fonts.packages = with pkgs; [ fonts.fonts = with pkgs; [
victor-mono # Used for Vim and Terminal victor-mono # Used for Vim and Terminal
(nerdfonts.override { fonts = [ "Hack" ]; }) # For Polybar, Rofi (nerdfonts.override { fonts = [ "Hack" ]; }) # For Polybar, Rofi
]; ];

View File

@ -36,7 +36,7 @@
module-margin = 1; module-margin = 1;
modules-left = "i3"; modules-left = "i3";
modules-center = "xwindow"; modules-center = "xwindow";
modules-right = "mailcount network pulseaudio date power"; modules-right = "mailcount pulseaudio date power";
cursor-click = "pointer"; cursor-click = "pointer";
cursor-scroll = "ns-resize"; cursor-scroll = "ns-resize";
enable-ipc = true; enable-ipc = true;
@ -106,14 +106,8 @@
interval = 10; interval = 10;
format = "<label>"; format = "<label>";
exec = builtins.toString (pkgs.writeShellScript "mailcount.sh" '' exec = builtins.toString (pkgs.writeShellScript "mailcount.sh" ''
${pkgs.notmuch}/bin/notmuch new --quiet 2>&1>/dev/null ${pkgs.notmuch}/bin/notmuch new > /dev/null
UNREAD=$( UNREAD=$(${pkgs.notmuch}/bin/notmuch count is:inbox and is:unread and folder:main/Inbox)
${pkgs.notmuch}/bin/notmuch count \
is:inbox and \
is:unread and \
folder:main/Inbox \
2>/dev/null
)
if [ $UNREAD = "0" ]; then if [ $UNREAD = "0" ]; then
echo "" echo ""
else else
@ -124,16 +118,6 @@
"i3-msg 'exec --no-startup-id kitty --class aerc aerc'; sleep 0.15; i3-msg '[class=aerc] focus'"; "i3-msg 'exec --no-startup-id kitty --class aerc aerc'; sleep 0.15; i3-msg '[class=aerc] focus'";
}; };
"module/network" = {
type = "internal/network";
interface-type = "wired";
interval = 3;
accumulate-stats = true;
format-connected = "<label-connected>";
format-disconnected = "<label-disconnected>";
label-connected = "";
label-disconnected = "";
};
"module/pulseaudio" = { "module/pulseaudio" = {
type = "internal/pulseaudio"; type = "internal/pulseaudio";
# format-volume-prefix = "VOL "; # format-volume-prefix = "VOL ";
@ -143,10 +127,10 @@
# label-volume-background = colors.background; # label-volume-background = colors.background;
format-volume-foreground = config.theme.colors.base0B; format-volume-foreground = config.theme.colors.base0B;
label-volume = "%percentage%%"; label-volume = "%percentage%%";
label-muted = "󰝟 ---"; label-muted = " ---";
label-muted-foreground = config.theme.colors.base03; label-muted-foreground = config.theme.colors.base03;
ramp-volume-0 = ""; ramp-volume-0 = "";
ramp-volume-1 = "󰕾"; ramp-volume-1 = "";
ramp-volume-2 = ""; ramp-volume-2 = "";
click-right = config.audioSwitchCommand; click-right = config.audioSwitchCommand;
}; };

View File

@ -4,13 +4,14 @@
*/ */
@import "common.rasi" @import "common.rasi"
* { * {
font: @prompt-text-font; font: @text-font;
} }
#window { #window {
height: @prompt-window-height; height: @prompt-window-height;
width: @prompt-window-width; width: @prompt-window-width;
children: [ inputbar, horibox ]; children: [ inputbar, horibox ];
border: @prompt-window-border; border: @prompt-window-border;
border-color: @accent;
} }
#inputbar { #inputbar {
enabled: false; enabled: false;
@ -18,6 +19,8 @@
#prompt { #prompt {
padding: @prompt-prompt-padding; padding: @prompt-prompt-padding;
margin: @prompt-prompt-margin; margin: @prompt-prompt-margin;
background-color: @accent;
text-color: @background-light;
} }
#listview { #listview {
padding: @prompt-listview-padding; padding: @prompt-listview-padding;
@ -28,3 +31,19 @@
font: @prompt-text-font; font: @prompt-text-font;
padding: @prompt-element-padding; padding: @prompt-element-padding;
} }
element.alternate.active,
element.normal.active,
element.alternate.urgent,
element.normal.urgent {
background-color: @background-light;
text-color: @foreground;
}
element.selected.urgent {
background-color: @off;
text-color: @background;
}
element.selected.active {
background-color: @on;
text-color: @background;
}

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
boot.loader = lib.mkIf (config.physical && !config.server) { boot.loader = lib.mkIf config.physical {
grub = { grub = {
enable = true; enable = true;

View File

@ -15,13 +15,8 @@
# Use capslock as escape and/or control # Use capslock as escape and/or control
services.keyd = { services.keyd = {
enable = true; enable = true;
keyboards = {
default = {
ids = [ "*" ];
settings = { main = { capslock = "overload(control, esc)"; }; }; settings = { main = { capslock = "overload(control, esc)"; }; };
}; };
};
};
# Enable num lock on login # Enable num lock on login
home-manager.users.${config.user}.xsession.numlock.enable = true; home-manager.users.${config.user}.xsession.numlock.enable = true;

View File

@ -1,8 +1,13 @@
{ config, pkgs, lib, ... }: { { config, lib, ... }: {
config = lib.mkIf config.physical { config = lib.mkIf config.physical {
networking.useDHCP = true; # The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.enp5s0.useDHCP = true;
networking.interfaces.wlp4s0.useDHCP = true;
networking.firewall.allowPing = lib.mkIf config.server true; networking.firewall.allowPing = lib.mkIf config.server true;
@ -10,9 +15,6 @@
services.avahi = { services.avahi = {
enable = true; enable = true;
domainName = "local"; domainName = "local";
ipv6 = false; # Should work either way
# Resolve local hostnames using Avahi DNS
nssmdns = true;
publish = { publish = {
enable = true; enable = true;
addresses = true; addresses = true;
@ -21,10 +23,8 @@
}; };
}; };
environment.systemPackages = [ # Resolve local hostnames using Avahi DNS
(pkgs.writeShellScriptBin "wake-tempest" services.avahi.nssmdns = true;
"${pkgs.wakeonlan}/bin/wakeonlan --ip=192.168.1.255 74:56:3C:40:37:5D")
];
}; };

View File

@ -1,6 +1,6 @@
{ config, lib, ... }: { { config, pkgs, lib, ... }: {
config = lib.mkIf config.server { config = lib.mkIf (pkgs.stdenv.isLinux && config.server) {
# Servers need a bootloader or they won't start # Servers need a bootloader or they won't start
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
config = lib.mkIf (config.physical && !config.server) { config = lib.mkIf config.physical {
# Prevent wake from keyboard # Prevent wake from keyboard
powerManagement.powerDownCommands = '' powerManagement.powerDownCommands = ''

View File

@ -1,20 +1,15 @@
{ config, lib, ... }: { { config, pkgs, lib, ... }: {
options = { zfs.enable = lib.mkEnableOption "ZFS file system."; }; options = { zfs.enable = lib.mkEnableOption "ZFS file system."; };
config = lib.mkIf (config.server && config.zfs.enable) { config =
lib.mkIf (pkgs.stdenv.isLinux && config.server && config.zfs.enable) {
# Only use compatible Linux kernel, since ZFS can be behind # Only use compatible Linux kernel, since ZFS can be behind
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; boot.kernelPackages =
config.boot.zfs.package.latestCompatibleLinuxPackages;
boot.kernelParams = [ "nohibernate" ]; boot.kernelParams = [ "nohibernate" ];
boot.supportedFilesystems = [ "zfs" ]; boot.supportedFilesystems = [ "zfs" ];
services.prometheus.exporters.zfs.enable =
config.prometheus.exporters.enable;
prometheus.scrapeTargets = [
"127.0.0.1:${
builtins.toString config.services.prometheus.exporters.zfs.port
}"
];
}; };

View File

@ -1,31 +1,4 @@
{ config, pkgs, lib, ... }: { config, lib, ... }: {
let
arrConfig = {
radarr = {
exportarrPort = "9707";
url = "localhost:7878";
apiKey = config.secrets.radarrApiKey.dest;
};
sonarr = {
exportarrPort = "9708";
url = "localhost:8989";
apiKey = config.secrets.sonarrApiKey.dest;
};
prowlarr = {
exportarrPort = "9709";
url = "localhost:9696";
apiKey = config.secrets.prowlarrApiKey.dest;
};
sabnzbd = {
exportarrPort = "9710";
url = "localhost:8085";
apiKey = config.secrets.sabnzbdApiKey.dest;
};
};
in {
options = { arrs.enable = lib.mkEnableOption "Arr services"; }; options = { arrs.enable = lib.mkEnableOption "Arr services"; };
@ -70,7 +43,7 @@ in {
}]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ dial = arrConfig.sonarr.url; }]; upstreams = [{ dial = "localhost:8989"; }];
}]; }];
} }
{ {
@ -81,7 +54,7 @@ in {
}]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ dial = arrConfig.radarr.url; }]; upstreams = [{ dial = "localhost:7878"; }];
}]; }];
} }
{ {
@ -103,11 +76,7 @@ in {
}]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ upstreams = [{ dial = "localhost:6767"; }];
dial = "localhost:${
builtins.toString config.services.bazarr.listenPort
}";
}];
}]; }];
} }
{ {
@ -118,7 +87,7 @@ in {
}]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ dial = arrConfig.sabnzbd.url; }]; upstreams = [{ dial = "localhost:8085"; }];
}]; }];
} }
{ {
@ -126,83 +95,11 @@ in {
match = [{ host = [ config.hostnames.download ]; }]; match = [{ host = [ config.hostnames.download ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ upstreams = [{ dial = "localhost:5055"; }];
dial =
"localhost:${builtins.toString config.services.jellyseerr.port}";
}];
}]; }];
} }
]; ];
# Enable Prometheus exporters
systemd.services = lib.mapAttrs' (name: attrs: {
name = "prometheus-${name}-exporter";
value = {
description = "Export Prometheus metrics for ${name}";
after = [ "network.target" ];
wantedBy = [ "${name}.service" ];
serviceConfig = {
Type = "simple";
DynamicUser = true;
ExecStart = let
url = if name != "sabnzbd" then
"http://${attrs.url}/${name}"
else
"http://${attrs.url}";
in ''
${pkgs.exportarr}/bin/exportarr ${name} \
--url ${url} \
--port ${attrs.exportarrPort}'';
EnvironmentFile =
lib.mkIf (builtins.hasAttr "apiKey" attrs) attrs.apiKey;
Restart = "on-failure";
ProtectHome = true;
ProtectSystem = "strict";
PrivateTmp = true;
PrivateDevices = true;
ProtectHostname = true;
ProtectClock = true;
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectKernelLogs = true;
ProtectControlGroups = true;
NoNewPrivileges = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
RemoveIPC = true;
PrivateMounts = true;
};
};
}) arrConfig;
# Secrets for Prometheus exporters
secrets.radarrApiKey = {
source = ../../../private/radarr-api-key.age;
dest = "/var/private/radarr-api";
prefix = "API_KEY=";
};
secrets.sonarrApiKey = {
source = ../../../private/sonarr-api-key.age;
dest = "/var/private/sonarr-api";
prefix = "API_KEY=";
};
secrets.prowlarrApiKey = {
source = ../../../private/prowlarr-api-key.age;
dest = "/var/private/prowlarr-api";
prefix = "API_KEY=";
};
secrets.sabnzbdApiKey = {
source = ../../../private/sabnzbd-api-key.age;
dest = "/var/private/sabnzbd-api";
prefix = "API_KEY=";
};
# Prometheus scrape targets
prometheus.scrapeTargets = map (key:
"127.0.0.1:${
lib.attrsets.getAttrFromPath [ key "exportarrPort" ] arrConfig
}") (builtins.attrNames arrConfig);
}; };
} }

View File

@ -1,55 +0,0 @@
{ config, pkgs, lib, ... }:
let
localIp = "192.168.1.218";
localServices = [
config.hostnames.stream
config.hostnames.content
config.hostnames.books
config.hostnames.download
];
mkRecord = service: "${service} A ${localIp}";
localRecords = lib.concatLines (map mkRecord localServices);
in {
config = lib.mkIf config.services.bind.enable {
caddy.cidrAllowlist = [ "192.168.0.0/16" ];
services.bind = {
cacheNetworks = [ "127.0.0.0/24" "192.168.0.0/16" ];
forwarders = [ "1.1.1.1" "1.0.0.1" ];
ipv4Only = true;
# Use rpz zone as an override
extraOptions = ''response-policy { zone "rpz"; };'';
zones = {
rpz = {
master = true;
file = pkgs.writeText "db.rpz" ''
$TTL 60 ; 1 minute
@ IN SOA localhost. root.localhost. (
2023071800 ; serial
1h ; refresh
30m ; retry
1w ; expire
30m ; minimum ttl
)
IN NS localhost.
localhost A 127.0.0.1
${localRecords}
'';
};
};
};
networking.firewall.allowedTCPPorts = [ 53 ];
networking.firewall.allowedUDPPorts = [ 53 ];
};
}

View File

@ -1,41 +1,25 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { options = {
caddy = { caddy.tlsPolicies = lib.mkOption {
tlsPolicies = lib.mkOption {
type = lib.types.listOf lib.types.attrs; type = lib.types.listOf lib.types.attrs;
description = "Caddy JSON TLS policies"; description = "Caddy JSON TLS policies";
default = [ ]; default = [ ];
}; };
routes = lib.mkOption { caddy.routes = lib.mkOption {
type = lib.types.listOf lib.types.attrs; type = lib.types.listOf lib.types.attrs;
description = "Caddy JSON routes for http servers"; description = "Caddy JSON routes for http servers";
default = [ ]; default = [ ];
}; };
blocks = lib.mkOption { caddy.blocks = lib.mkOption {
type = lib.types.listOf lib.types.attrs; type = lib.types.listOf lib.types.attrs;
description = "Caddy JSON error blocks for http servers"; description = "Caddy JSON error blocks for http servers";
default = [ ]; default = [ ];
}; };
cidrAllowlist = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "CIDR blocks to allow for requests";
default = [ ];
};
};
}; };
config = lib.mkIf config.services.caddy.enable { config =
lib.mkIf (config.services.caddy.enable && config.caddy.routes != [ ]) {
# Force Caddy to 403 if not coming from allowlisted source
caddy.cidrAllowlist = [ "127.0.0.1/32" ];
caddy.routes = [{
match = [{ not = [{ remote_ip.ranges = config.caddy.cidrAllowlist; }]; }];
handle = [{
handler = "static_response";
status_code = "403";
}];
}];
services.caddy = { services.caddy = {
adapter = "''"; # Required to enable JSON adapter = "''"; # Required to enable JSON
@ -46,7 +30,6 @@
errors.routes = config.caddy.blocks; errors.routes = config.caddy.blocks;
# logs = { }; # Uncomment to collect access logs # logs = { }; # Uncomment to collect access logs
}; };
apps.http.servers.metrics = { }; # Enables Prometheus metrics
apps.tls.automation.policies = config.caddy.tlsPolicies; apps.tls.automation.policies = config.caddy.tlsPolicies;
logging.logs.main = { logging.logs.main = {
encoder = { format = "console"; }; encoder = { format = "console"; };
@ -64,8 +47,6 @@
networking.firewall.allowedTCPPorts = [ 80 443 ]; networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedUDPPorts = [ 443 ]; networking.firewall.allowedUDPPorts = [ 443 ];
prometheus.scrapeTargets = [ "127.0.0.1:2019" ];
}; };
} }

View File

@ -41,7 +41,13 @@ in {
config = lib.mkIf config.cloudflare.enable { config = lib.mkIf config.cloudflare.enable {
# Forces Caddy to error if coming from a non-Cloudflare IP # Forces Caddy to error if coming from a non-Cloudflare IP
caddy.cidrAllowlist = cloudflareIpRanges; caddy.blocks = [{
match = [{ not = [{ remote_ip.ranges = cloudflareIpRanges; }]; }];
handle = [{
handler = "static_response";
abort = true;
}];
}];
# Tell Caddy to use Cloudflare DNS for ACME challenge validation # Tell Caddy to use Cloudflare DNS for ACME challenge validation
services.caddy.package = (pkgs.callPackage ../../../overlays/caddy.nix { services.caddy.package = (pkgs.callPackage ../../../overlays/caddy.nix {

View File

@ -3,7 +3,6 @@
imports = [ imports = [
./arr.nix ./arr.nix
./backups.nix ./backups.nix
./bind.nix
./caddy.nix ./caddy.nix
./calibre.nix ./calibre.nix
./cloudflare-tunnel.nix ./cloudflare-tunnel.nix
@ -25,7 +24,6 @@
./sshd.nix ./sshd.nix
./transmission.nix ./transmission.nix
./vaultwarden.nix ./vaultwarden.nix
./victoriametrics.nix
./wireguard.nix ./wireguard.nix
]; ];

View File

@ -10,9 +10,9 @@
enable = true; enable = true;
labels = [ labels = [
# Provide a Debian base with NodeJS for actions # Provide a Debian base with NodeJS for actions
# "debian-latest:docker://node:18-bullseye" "debian-latest:docker://node:18-bullseye"
# Fake the Ubuntu name, because Node provides no Ubuntu builds # Fake the Ubuntu name, because Node provides no Ubuntu builds
# "ubuntu-latest:docker://node:18-bullseye" "ubuntu-latest:docker://node:18-bullseye"
# Provide native execution on the host using below packages # Provide native execution on the host using below packages
"native:host" "native:host"
]; ];
@ -31,28 +31,6 @@
tokenFile = config.secrets.giteaRunnerToken.dest; tokenFile = config.secrets.giteaRunnerToken.dest;
}; };
# Make sure the runner doesn't start until after Gitea
systemd.services."gitea-runner-${config.networking.hostName}".after =
[ "gitea.service" ];
# API key needed to connect to Gitea
secrets.giteaRunnerToken = {
source = ../../../private/gitea-runner-token.age; # TOKEN=xyz
dest = "${config.secretsDirectory}/gitea-runner-token";
};
systemd.services.giteaRunnerToken-secret = {
requiredBy = [
"gitea-runner-${
config.services.gitea-actions-runner.instances.${config.networking.hostName}.name
}.service"
];
before = [
"gitea-runner-${
config.services.gitea-actions-runner.instances.${config.networking.hostName}.name
}.service"
];
};
}; };
} }

View File

@ -9,7 +9,6 @@ in {
database.type = "sqlite3"; database.type = "sqlite3";
settings = { settings = {
actions.ENABLED = true; actions.ENABLED = true;
metrics.ENABLED = true;
repository = { repository = {
DEFAULT_PUSH_CREATE_PRIVATE = true; DEFAULT_PUSH_CREATE_PRIVATE = true;
DISABLE_HTTP_GIT = false; DISABLE_HTTP_GIT = false;
@ -38,36 +37,13 @@ in {
networking.firewall.allowedTCPPorts = [ 122 ]; networking.firewall.allowedTCPPorts = [ 122 ];
users.users.${config.user}.extraGroups = [ "gitea" ]; users.users.${config.user}.extraGroups = [ "gitea" ];
caddy.routes = [ caddy.routes = [{
{
match = [{
host = [ config.hostnames.git ];
path = [ "/metrics*" ];
}];
handle = [{
handler = "static_response";
status_code = "403";
}];
}
{
match = [{ host = [ config.hostnames.git ]; }]; match = [{ host = [ config.hostnames.git ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ upstreams = [{ dial = "localhost:3001"; }];
dial = "localhost:${
builtins.toString
config.services.gitea.settings.server.HTTP_PORT
}";
}]; }];
}]; }];
}
];
prometheus.scrapeTargets = [
"127.0.0.1:${
builtins.toString config.services.gitea.settings.server.HTTP_PORT
}"
];
## Backup config ## Backup config

View File

@ -13,12 +13,7 @@
match = [{ host = [ config.hostnames.metrics ]; }]; match = [{ host = [ config.hostnames.metrics ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ upstreams = [{ dial = "localhost:3000"; }];
dial = "localhost:${
builtins.toString
config.services.grafana.settings.server.http_port
}";
}];
}]; }];
}]; }];

View File

@ -5,25 +5,13 @@
services.jellyfin.group = "media"; services.jellyfin.group = "media";
users.users.jellyfin = { isSystemUser = true; }; users.users.jellyfin = { isSystemUser = true; };
caddy.routes = [ caddy.routes = [{
{
match = [{
host = [ config.hostnames.stream ];
path = [ "/metrics*" ];
}];
handle = [{
handler = "static_response";
status_code = "403";
}];
}
{
match = [{ host = [ config.hostnames.stream ]; }]; match = [{ host = [ config.hostnames.stream ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [{ dial = "localhost:8096"; }]; upstreams = [{ dial = "localhost:8096"; }];
}]; }];
} }];
];
# Create videos directory, allow anyone in Jellyfin group to manage it # Create videos directory, allow anyone in Jellyfin group to manage it
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
@ -47,9 +35,6 @@
users.users.jellyfin.extraGroups = users.users.jellyfin.extraGroups =
[ "render" "video" ]; # Access to /dev/dri [ "render" "video" ]; # Access to /dev/dri
# Requires MetricsEnable is true in /var/lib/jellyfin/config/system.xml
prometheus.scrapeTargets = [ "127.0.0.1:8096" ];
}; };
} }

View File

@ -3,7 +3,7 @@
config = lib.mkIf config.services.nextcloud.enable { config = lib.mkIf config.services.nextcloud.enable {
services.nextcloud = { services.nextcloud = {
package = pkgs.nextcloud27; # Required to specify package = pkgs.nextcloud26; # Required to specify
datadir = "/data/nextcloud"; datadir = "/data/nextcloud";
https = true; https = true;
hostName = "localhost"; hostName = "localhost";
@ -11,124 +11,22 @@
config = { config = {
adminpassFile = config.secrets.nextcloud.dest; adminpassFile = config.secrets.nextcloud.dest;
extraTrustedDomains = [ config.hostnames.content ]; extraTrustedDomains = [ config.hostnames.content ];
trustedProxies = [ "127.0.0.1" ];
}; };
}; };
# Don't let Nginx use main ports (using Caddy instead) # Don't let Nginx use main ports (using Caddy instead)
services.nginx.enable = false; services.nginx.virtualHosts."localhost".listen = [{
addr = "127.0.0.1";
services.phpfpm.pools.nextcloud.settings = { port = 8080;
"listen.owner" = config.services.caddy.user; }];
"listen.group" = config.services.caddy.group;
};
users.users.caddy.extraGroups = [ "nextcloud" ];
# Point Caddy to Nginx # Point Caddy to Nginx
caddy.routes = [{ caddy.routes = [{
match = [{ host = [ config.hostnames.content ]; }]; match = [{ host = [ config.hostnames.content ]; }];
handle = [{
handler = "subroute";
routes = [
# Sets variables and headers
{
handle = [
{
handler = "vars";
root = config.services.nextcloud.package;
}
{
handler = "headers";
response.set.Strict-Transport-Security =
[ "max-age=31536000;" ];
}
];
}
{
match = [{ path = [ "/nix-apps*" "/store-apps*" ]; }];
handle = [{
handler = "vars";
root = config.services.nextcloud.home;
}];
}
# Reroute carddav and caldav traffic
{
match =
[{ path = [ "/.well-known/carddav" "/.well-known/caldav" ]; }];
handle = [{
handler = "static_response";
headers = { Location = [ "/remote.php/dav" ]; };
status_code = 301;
}];
}
# Block traffic to sensitive files
{
match = [{
path = [
"/.htaccess"
"/data/*"
"/config/*"
"/db_structure"
"/.xml"
"/README"
"/3rdparty/*"
"/lib/*"
"/templates/*"
"/occ"
"/console.php"
];
}];
handle = [{
handler = "static_response";
status_code = 404;
}];
}
# Redirect index.php to the homepage
{
match = [{
file = { try_files = [ "{http.request.uri.path}/index.php" ]; };
not = [{ path = [ "*/" ]; }];
}];
handle = [{
handler = "static_response";
headers = { Location = [ "{http.request.orig_uri.path}/" ]; };
status_code = 308;
}];
}
# Rewrite paths to be relative
{
match = [{
file = {
split_path = [ ".php" ];
try_files = [
"{http.request.uri.path}"
"{http.request.uri.path}/index.php"
"index.php"
];
};
}];
handle = [{
handler = "rewrite";
uri = "{http.matchers.file.relative}";
}];
}
# Send all PHP traffic to Nextcloud PHP service
{
match = [{ path = [ "*.php" ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
transport = { upstreams = [{ dial = "localhost:8080"; }];
protocol = "fastcgi";
split_path = [ ".php" ];
};
upstreams = [{ dial = "unix//run/phpfpm/nextcloud.sock"; }];
}]; }];
}
# Finally, send the rest to the file server
{ handle = [{ handler = "file_server"; }]; }
];
}];
terminal = true;
}]; }];
# Create credentials file for nextcloud # Create credentials file for nextcloud
@ -176,24 +74,6 @@
requires = [ "phpfpm-nextcloud.service" ]; requires = [ "phpfpm-nextcloud.service" ];
}; };
# Log metrics to prometheus
networking.hosts."127.0.0.1" = [ config.hostnames.content ];
services.prometheus.exporters.nextcloud = {
enable = config.prometheus.exporters.enable;
username = config.services.nextcloud.config.adminuser;
url = "https://${config.hostnames.content}";
passwordFile = config.services.nextcloud.config.adminpassFile;
};
prometheus.scrapeTargets = [
"127.0.0.1:${
builtins.toString config.services.prometheus.exporters.nextcloud.port
}"
];
# Allows nextcloud-exporter to read passwordFile
users.users.nextcloud-exporter.extraGroups =
lib.mkIf config.services.prometheus.exporters.nextcloud.enable
[ "nextcloud" ];
}; };
} }

View File

@ -1,58 +1,18 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options.prometheus = {
exporters.enable = lib.mkEnableOption "Enable Prometheus exporters";
scrapeTargets = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Prometheus scrape targets";
default = [ ];
};
};
config = let config = let
# If hosting Grafana, host local Prometheus and listen for inbound jobs. If # If hosting Grafana, host local Prometheus and listen for inbound jobs. If
# not hosting Grafana, send remote Prometheus writes to primary host. # not hosting Grafana, send remote Prometheus writes to primary host.
isServer = config.services.grafana.enable; isServer = config.services.grafana.enable;
in { in lib.mkIf config.services.prometheus.enable {
# Turn on exporters if any Prometheus scraper is running
prometheus.exporters.enable = builtins.any (x: x) [
config.services.prometheus.enable
config.services.victoriametrics.enable
config.services.vmagent.enable
];
prometheus.scrapeTargets = [
"127.0.0.1:${
builtins.toString config.services.prometheus.exporters.node.port
}"
"127.0.0.1:${
builtins.toString config.services.prometheus.exporters.systemd.port
}"
"127.0.0.1:${
builtins.toString config.services.prometheus.exporters.process.port
}"
];
services.prometheus = { services.prometheus = {
exporters.node.enable = config.prometheus.exporters.enable; exporters.node.enable = true;
exporters.node.enabledCollectors = [ ];
exporters.node.disabledCollectors = [ "cpufreq" ];
exporters.systemd.enable = config.prometheus.exporters.enable;
exporters.process.enable = config.prometheus.exporters.enable;
exporters.process.settings.process_names = [
# Remove nix store path from process name
{
name = "{{.Matches.Wrapped}} {{ .Matches.Args }}";
cmdline = [ "^/nix/store[^ ]*/(?P<Wrapped>[^ /]*) (?P<Args>.*)" ];
}
];
extraFlags = lib.mkIf isServer [ "--web.enable-remote-write-receiver" ];
scrapeConfigs = [{ scrapeConfigs = [{
job_name = config.networking.hostName; job_name = "local";
static_configs = [{ targets = config.scrapeTargets; }]; static_configs = [{ targets = [ "127.0.0.1:9100" ]; }];
}]; }];
webExternalUrl = webExternalUrl =
lib.mkIf isServer "https://${config.hostnames.prometheus}"; lib.mkIf isServer "https://${config.hostnames.prometheus}";
@ -68,7 +28,7 @@
}); });
remoteWrite = lib.mkIf (!isServer) [{ remoteWrite = lib.mkIf (!isServer) [{
name = config.networking.hostName; name = config.networking.hostName;
url = "https://${config.hostnames.prometheus}/api/v1/write"; url = "https://${config.hostnames.prometheus}";
basic_auth = { basic_auth = {
# Uses password hashed with bcrypt above # Uses password hashed with bcrypt above
username = "prometheus"; username = "prometheus";
@ -78,26 +38,23 @@
}; };
# Create credentials file for remote Prometheus push # Create credentials file for remote Prometheus push
secrets.prometheus = secrets.prometheus = lib.mkIf (!isServer) {
lib.mkIf (config.services.prometheus.enable && !isServer) {
source = ../../../private/prometheus.age; source = ../../../private/prometheus.age;
dest = "${config.secretsDirectory}/prometheus"; dest = "${config.secretsDirectory}/prometheus";
owner = "prometheus"; owner = "prometheus";
group = "prometheus"; group = "prometheus";
permissions = "0440"; permissions = "0440";
}; };
systemd.services.prometheus-secret = systemd.services.prometheus-secret = lib.mkIf (!isServer) {
lib.mkIf (config.services.prometheus.enable && !isServer) {
requiredBy = [ "prometheus.service" ]; requiredBy = [ "prometheus.service" ];
before = [ "prometheus.service" ]; before = [ "prometheus.service" ];
}; };
caddy.routes = lib.mkIf (config.services.prometheus.enable && isServer) [{ caddy.routes = lib.mkIf isServer [{
match = [{ host = [ config.hostnames.prometheus ]; }]; match = [{ host = [ config.hostnames.prometheus ]; }];
handle = [{ handle = [{
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = upstreams = [{ dial = "localhost:9090"; }];
[{ dial = "localhost:${config.services.prometheus.port}"; }];
}]; }];
}]; }];

View File

@ -39,11 +39,6 @@
type = lib.types.str; type = lib.types.str;
description = "Permissions expressed as octal."; description = "Permissions expressed as octal.";
}; };
prefix = lib.mkOption {
default = "";
type = lib.types.str;
description = "Prefix for secret value (for environment files).";
};
}; };
}); });
description = "Set of secrets to decrypt to disk."; description = "Set of secrets to decrypt to disk.";
@ -70,10 +65,10 @@
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
script = '' script = ''
echo "${attrs.prefix}$(
${pkgs.age}/bin/age --decrypt \ ${pkgs.age}/bin/age --decrypt \
--identity ${config.identityFile} ${attrs.source} --identity ${config.identityFile} \
)" > ${attrs.dest} --output ${attrs.dest} \
${attrs.source}
chown '${attrs.owner}':'${attrs.group}' '${attrs.dest}' chown '${attrs.owner}':'${attrs.group}' '${attrs.dest}'
chmod '${attrs.permissions}' '${attrs.dest}' chmod '${attrs.permissions}' '${attrs.dest}'

View File

@ -13,8 +13,9 @@
}; };
}; };
config = lib.mkIf config.services.openssh.enable { config = lib.mkIf (config.publicKey != null) {
services.openssh = { services.openssh = {
enable = true;
ports = [ 22 ]; ports = [ 22 ];
allowSFTP = true; allowSFTP = true;
settings = { settings = {
@ -26,7 +27,7 @@
}; };
users.users.${config.user}.openssh.authorizedKeys.keys = users.users.${config.user}.openssh.authorizedKeys.keys =
lib.mkIf (config.publicKey != null) [ config.publicKey ]; [ config.publicKey ];
# Implement a simple fail2ban service for sshd # Implement a simple fail2ban service for sshd
services.sshguard.enable = true; services.sshguard.enable = true;

View File

@ -1,95 +0,0 @@
{ config, pkgs, lib, ... }:
let
username = "prometheus";
prometheusConfig = (pkgs.formats.yaml { }).generate "prometheus.yml" {
scrape_configs = [{
job_name = config.networking.hostName;
stream_parse = true;
static_configs = [{ targets = config.prometheus.scrapeTargets; }];
}];
};
authConfig = (pkgs.formats.yaml { }).generate "auth.yml" {
users = [{
username = username;
password = "%{PASSWORD}";
url_prefix =
"http://localhost${config.services.victoriametrics.listenAddress}";
}];
};
authPort = "8427";
in {
config = {
services.victoriametrics.extraOptions =
[ "-promscrape.config=${prometheusConfig}" ];
systemd.services.vmauth = lib.mkIf config.services.victoriametrics.enable {
description = "VictoriaMetrics basic auth proxy";
after = [ "network.target" ];
startLimitBurst = 5;
serviceConfig = {
Restart = "on-failure";
RestartSec = 1;
DynamicUser = true;
EnvironmentFile = config.secrets.vmauth.dest;
ExecStart = ''
${pkgs.victoriametrics}/bin/vmauth \
-auth.config=${authConfig} \
-httpListenAddr=:${authPort}'';
};
wantedBy = [ "multi-user.target" ];
};
secrets.vmauth = lib.mkIf config.services.victoriametrics.enable {
source = ../../../private/prometheus.age;
dest = "${config.secretsDirectory}/vmauth";
prefix = "PASSWORD=";
};
systemd.services.vmauth-secret =
lib.mkIf config.services.victoriametrics.enable {
requiredBy = [ "vmauth.service" ];
before = [ "vmauth.service" ];
};
caddy.routes = lib.mkIf config.services.victoriametrics.enable [{
match = [{ host = [ config.hostnames.prometheus ]; }];
handle = [{
handler = "reverse_proxy";
upstreams = [{ dial = "localhost:${authPort}"; }];
}];
}];
# VMAgent
services.vmagent.prometheusConfig = prometheusConfig; # Overwritten below
systemd.services.vmagent.serviceConfig =
lib.mkIf config.services.vmagent.enable {
ExecStart = lib.mkForce ''
${pkgs.victoriametrics}/bin/vmagent \
-promscrape.config=${prometheusConfig} \
-remoteWrite.url="https://${config.hostnames.prometheus}/api/v1/write" \
-remoteWrite.basicAuth.username=${username} \
-remoteWrite.basicAuth.passwordFile=${config.secrets.vmagent.dest}'';
};
secrets.vmagent = lib.mkIf config.services.vmagent.enable {
source = ../../../private/prometheus.age;
dest = "${config.secretsDirectory}/vmagent";
owner = "vmagent";
group = "vmagent";
};
systemd.services.vmagent-secret = lib.mkIf config.services.vmagent.enable {
requiredBy = [ "vmagent.service" ];
before = [ "vmagent.service" ];
};
};
}

View File

@ -1,47 +0,0 @@
{ config, pkgs, lib, ... }: {
# This setting only applies to NixOS, different on Darwin
nix.gc.dates = "03:03"; # Run every morning (but before upgrade)
# Update the system daily by pointing it at the flake repository
system.autoUpgrade = {
enable = config.server; # Only auto upgrade servers
dates = "03:33";
flake = "git+${config.dotfilesRepo}";
randomizedDelaySec = "25min";
operation = "switch";
allowReboot = true;
rebootWindow = {
lower = "00:01";
upper = "06:00";
};
};
# Create an email notification service for failed jobs
systemd.services."notify-email@" =
let address = "system@${config.mail.server}";
in {
enable = config.mail.enable;
environment.SERVICE_ID = "%i";
script = ''
TEMPFILE=$(mktemp)
echo "From: ${address}" > $TEMPFILE
echo "To: ${address}" >> $TEMPFILE
echo "Subject: Failure in $SERVICE_ID" >> $TEMPFILE
echo -e "\nGot an error with $SERVICE_ID\n\n" >> $TEMPFILE
set +e
systemctl status $SERVICE_ID >> $TEMPFILE
set -e
${pkgs.msmtp}/bin/msmtp \
--file=${config.homePath}/.config/msmtp/config \
--account=system \
${address} < $TEMPFILE
'';
};
# Send an email whenever auto upgrade fails
systemd.services.nixos-upgrade.onFailure =
lib.mkIf config.systemd.services."notify-email@".enable
[ "notify-email@%i.service" ];
}

View File

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
imports = imports = [ ./doas.nix ./journald.nix ./user.nix ./timezone.nix ];
[ ./auto-upgrade.nix ./doas.nix ./journald.nix ./user.nix ./timezone.nix ];
config = lib.mkIf pkgs.stdenv.isLinux { config = lib.mkIf pkgs.stdenv.isLinux {
@ -9,6 +8,13 @@
system.stateVersion = system.stateVersion =
config.home-manager.users.${config.user}.home.stateVersion; config.home-manager.users.${config.user}.home.stateVersion;
# This setting only applies to NixOS, different on Darwin
nix.gc.dates = "weekly";
systemd.timers.nix-gc.timerConfig = { WakeSystem = true; };
systemd.services.nix-gc.postStop =
lib.mkIf (!config.server) "systemctl suspend";
}; };
} }

View File

@ -13,11 +13,11 @@
doas = { doas = {
enable = true; enable = true;
# No password required for trusted users # No password required
wheelNeedsPassword = false; wheelNeedsPassword = false;
# Pass environment variables from user to root # Pass environment variables from user to root
# Also requires specifying that we are removing password here # Also requires removing password here
extraRules = [{ extraRules = [{
groups = [ "wheel" ]; groups = [ "wheel" ];
noPass = true; noPass = true;
@ -26,7 +26,6 @@
}; };
}; };
# Alias sudo to doas for convenience
home-manager.users.${config.user}.programs.fish.shellAliases = { home-manager.users.${config.user}.programs.fish.shellAliases = {
sudo = "doas"; sudo = "doas";
}; };

View File

@ -1,7 +1,6 @@
{ ... }: { { ... }: {
# How long to keep journalctl entries # How long to keep journalctl entries
# This helps to make sure log disk usage doesn't grow too unwieldy
services.journald.extraConfig = '' services.journald.extraConfig = ''
SystemMaxUse=100M SystemMaxUse=100M
MaxFileSec=1month MaxFileSec=1month

View File

@ -1,4 +1,4 @@
{ config, lib, ... }: { { config, pkgs, lib, ... }: {
options = { options = {
@ -11,7 +11,7 @@
}; };
config = { config = lib.mkIf (pkgs.stdenv.isLinux) {
# Allows us to declaritively set password # Allows us to declaritively set password
users.mutableUsers = false; users.mutableUsers = false;

View File

@ -1,4 +0,0 @@
# Disable dunst so that it's not attempting to reach a non-existent dunst service
_final: prev: {
betterlockscreen = prev.betterlockscreen.override { withDunst = false; };
}

View File

@ -1,5 +1,3 @@
# Adds the Cloudflare DNS validation module
{ lib, buildGo118Module, fetchFromGitHub, plugins ? [ ] }: { lib, buildGo118Module, fetchFromGitHub, plugins ? [ ] }:
let let
goImports = lib.flip lib.concatMapStrings plugins (pkg: " _ \"${pkg}\"\n"); goImports = lib.flip lib.concatMapStrings plugins (pkg: " _ \"${pkg}\"\n");

View File

@ -7,12 +7,12 @@ let
# Use nixpkgs vimPlugin but with source directly from plugin author # Use nixpkgs vimPlugin but with source directly from plugin author
withSrc = pkg: src: pkg.overrideAttrs (_: { inherit src; }); withSrc = pkg: src: pkg.overrideAttrs (_: { inherit src; });
# Package plugin - for plugins not found in nixpkgs at all # Package plugin - disabling until in use
plugin = pname: src: # plugin = pname: src:
prev.vimUtils.buildVimPluginFrom2Nix { # prev.vimUtils.buildVimPluginFrom2Nix {
inherit pname src; # inherit pname src;
version = "master"; # version = "master";
}; # };
in { in {
@ -36,7 +36,8 @@ in {
(withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim); (withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim);
nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua); nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua);
# Packaging plugins entirely with Nix # Packaging plugins with Nix
baleia-nvim = plugin "baleia-nvim" inputs.baleia-nvim-src; # comment-nvim = plugin "comment-nvim" comment-nvim-src;
# plenary-nvim = plugin "plenary-nvim" plenary-nvim-src;
} }

View File

@ -1,8 +1,8 @@
inputs: _final: prev: {
tree-sitter-grammars = prev.tree-sitter-grammars // {
# Fix: bash highlighting doesn't work as of this commit: # Fix: bash highlighting doesn't work as of this commit:
# https://github.com/NixOS/nixpkgs/commit/49cce41b7c5f6b88570a482355d9655ca19c1029 # https://github.com/NixOS/nixpkgs/commit/49cce41b7c5f6b88570a482355d9655ca19c1029
inputs: _final: prev: {
tree-sitter-grammars = prev.tree-sitter-grammars // {
tree-sitter-bash = prev.tree-sitter-grammars.tree-sitter-bash.overrideAttrs tree-sitter-bash = prev.tree-sitter-grammars.tree-sitter-bash.overrideAttrs
(old: { (old: {
src = prev.fetchFromGitHub { src = prev.fetchFromGitHub {
@ -12,20 +12,6 @@ inputs: _final: prev: {
sha256 = "sha256-gl5F3IeZa2VqyH/qFj8ey2pRbGq4X8DL5wiyvRrH56U="; sha256 = "sha256-gl5F3IeZa2VqyH/qFj8ey2pRbGq4X8DL5wiyvRrH56U=";
}; };
}); });
# Fix: invalid node in position. Broken as of this commit (replaced with newer):
# https://github.com/NixOS/nixpkgs/commit/8ec3627796ecc899e6f47f5bf3c3220856ead9c5
tree-sitter-python =
prev.tree-sitter-grammars.tree-sitter-python.overrideAttrs (old: {
src = prev.fetchFromGitHub {
owner = "tree-sitter";
repo = "tree-sitter-python";
rev = "5af00f64af6bbf822f208243cce5cf75396fb6f5";
sha256 = "sha256-2btd/NRE6NuGNlx4cq535OrwtWXihiP3VMCJjPCiDOk=";
};
});
# Add grammars not in nixpks
tree-sitter-ini = prev.tree-sitter.buildGrammar { tree-sitter-ini = prev.tree-sitter.buildGrammar {
language = "ini"; language = "ini";
version = "1.0.0"; version = "1.0.0";

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBoOVF1
NmZocHpQQnRJcWpWUHh2bU93NkdnZWNzSlFiaHdTd24rcHpsczFRCmJaSzNkNGs1
UDJCN2dYUVE3UTE1OU5RUWljQlN4dmxuUnpOMFYxQTdUaVEKLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIE5HdGd6aTlKM0lFUlYzT1VhS05nZ2ZxTndVZHBNQlJxYlovdXkx
ei96d2cKdzlUYVFFaEIzaS9LZmY3MzM1RmNnR0xjOEpHK1kxM0FMTWRQSlVnczVF
dwotPiBzc2gtZWQyNTUxOSBuanZYNUEgQ1lhMGQvUy9OWkRBR3BZV1pFNmNtb2pq
Y2VEUzhRWGVWUkZJY1l4RGtWdwphdFZtM0ZLZURvYVZQYjV4bWVPdWJxa3RmWmVh
SHl0T0pQWmxnVlFPR2drCi0tLSBnd2lwS3dqUk5Jelg0b3RxbFdEcnJ6ZkkvZTVN
UllBeUUyOXBxVDBKMG5BCkGo9kj9sMVhbnXVM35lGScAb8r5LH9vf5jOdhLC/Wj2
+uA0ONIh7F2GELzf5Cw1KZJ8aHTURM2r41vZvfAQN1RwrmYOiUzlyMrvTDe78cY=
-----END AGE ENCRYPTED FILE-----

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyA3Ynp0
UUVDdVk1MG1nQmZ3cDl5UmY5VnpMSkdyYmluTlJGWUdnRVQyVWhvCkNlQkY0RUR5
ODZTYUEzQlBmelBLcUxuWjdiYms2RUtmYlFFeEpXM3JCMlUKLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIFNySTEvUXhycFhZa3h5ZnZyaXJEZ3BGRW03WGRvM29FQlZJQ2xx
ZnMwVzgKbGFVMDlYZjVzeUJyY1kyc0ZXRnVydHkzOWtPaE1uTXllbHhaQTdIa016
VQotPiBzc2gtZWQyNTUxOSBuanZYNUEgdjh4T2FkckZYQlpsd3ZSTmc4VGRxWjg4
TVRCTUl4U1BnanVwV29POXhIZwpEcHBUOFJjTXBGTExYTWtmd01XQlZndklXTkdU
NHBnYkNBTSs5K1A3cE9vCi0tLSBBa01zRTdNYW5wRlltVkgrWG9mdHcrZ1NXRUwz
UUhsalZSeU1CVENmbnp3CphGOZ7hu3mq3UI69UCJq7ptFDMUmdmYW4ydzz2RVlYX
P1JWkX0IpnHtcFPK1XmRrBkiyto=
-----END AGE ENCRYPTED FILE-----

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyAyVkNR
d1lsUmJWVmlxb3NnNTJNN052ckRPOURYR3VCWUFpd25aQTBPVldJCnBNRTdlOTNP
SkhHZkZVU2VrV1hVcGczUVVZVHBtRTNoNUliZHNpeXltZW8KLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIGJCWktmWDE1Z1Q4M0RDKytaZndtZmlCeU5paXUxTld4d2FNV3dT
Nyt3aWsKTUlqTys0Q1RiTERlMnZRUDJMZHJheStYak0rY01jWVM3STF2QjExZzFm
UQotPiBzc2gtZWQyNTUxOSBuanZYNUEgcm9wVTlCKzFEejdlNVp0ZVpnRUxDUmpo
YmRlZWVpSGJocUtNN05KS0cwTQpYUmdpYVNVemZXWUd1ZUlQTks4VUdmaEZPZ2x2
YVdqWG0ySkt2dDNSQzJvCi0tLSBaN0gwclJpcUFvT0pHcUhyVERnZ1Nralg5bGxZ
b0hyaVB6OStpczQxclFJCmHfg8XI+AzbijptcC6Zhqigp8D3CvB8mSF5H6kPFmJU
odbXmgzihXxWjnG6tH4LgEiEI2dWfbELIwqLs4BIiLlt
-----END AGE ENCRYPTED FILE-----

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBuRldh
Um5iYmpEZlZHMmFTMTQ0WVdUUllBeE9MNFFWdXlwNmoxUU1VdUQ4Clk3aXJMYlFM
dFFWODlIamNoc0xGVUdSRktVUllhSHpXR2plbmNkcFR0VW8KLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIEp6RktOMFVLTi9NRTF3MHg0Uk4xRzRlNTlIajVKeWtxN3huNnZN
bDdwRzQKMTUvQ21BWXliOFdNRVFUNjMyS0tyeEt1bURRM2JVMXFIV2cwZDA5WldC
dwotPiBzc2gtZWQyNTUxOSBuanZYNUEgNWlWYUV5SXdCbUJjbnd4UjVqSllyNGZX
bUtIenJJanZCNUdtZkIwQUZYdwowUUE3cHpTRW5zdy9MUlg5VlZGWlNiZ2pVbmUy
c1V0WkZJckJUY25KWmowCi0tLSBxTWg3VHN4MHlVdWpLZzRtaXRYeGEvOFlLR00w
bkVzRkltY0lON0FBYXpjChPtxNyevNnkMHYc7xbsZo/7ThtPB4uOqHfF8swX1efg
AHsWemHnBEfsMBEmCtmczOhFwCNOtgc+q3rQCvmuU9tX
-----END AGE ENCRYPTED FILE-----

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBDbFRU
RjZFN0Jtd3o4eWthZ09BRUIvNXFZOHVLdVIvRTJCd09ULzJpcjI4CmVjb2szMmtI
N3I5a0FKQ2RpeHJ2NjhwbWM0OFZwUFUzZnV2QWI3VDEvZ2sKLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIHNEd1d6bGY3WVVVdVV6TFQ2V3NhN2xubWhwQVBIVVBmKzRBWStX
eVpzaW8Ka0o2a3ArSjdsTEZSa1cyVGdzZThGcUVFKys2UURaRUxwd0FjdDI0VmVJ
QQotPiBzc2gtZWQyNTUxOSBuanZYNUEgc243YjBiOFdrQlV3SDEwWjc1TVB1cita
WVk4bk0wbUk3elBJMkg0Qy9DSQoyVnNWQTJzU1laZ0pGZVlsTEVWV2o2bEVpaVNh
QVNaNXVMaUpKTzVlQW1zCi0tLSB6SG5LWng0OVFGd2NvODVXclgycXFpSVFrMnFk
VlhaL0h2MnBZZDJrN0ZFCtbPQRVZWx65T3DGVY8yG9D2tj1R9ccMcPyJNxJsmfsx
hcINJq2zJKLP2mtvADH95uoaQylwpQQiVd8s6fwMH5cX
-----END AGE ENCRYPTED FILE-----

View File

@ -1,12 +0,0 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBtV2FM
U09jOUsxNVVLQmFkOWxubGdlZGpGMlh0YjFqbTA5TG53SW9DRGt3CjNQeWRac3Ey
YlRkRnN3YXFnSkxjOTd3eXZLVHRmK3BIdTlJL0ZQNUhHaGsKLT4gc3NoLWVkMjU1
MTkgWXlTVU1RIHJaUE0rc0dXaXkvNlErTmd0R016aWZ4eFM2bVh4T1pMa1Z6NEpC
aE14Z28KS2FpU2NCclBDMDJVVC9UMWJibmlsc3hnZE9GVUl5NUxBdVMwYXJXWXhz
QQotPiBzc2gtZWQyNTUxOSBuanZYNUEgaS8zRkg4MWpLT3UwSWVBSmRUSW9KdXZ1
c2Ywcy94YXdKSTZlcG5PSkF6UQpLMWpoaTZ6cjA5dFlZbXp5dm92U25EWnFKODJN
MHM1RGtDTyt0UEdVZHEwCi0tLSA1LzRHMTN4S1ozd2FIN1g4aTR1Skx3SE0yanNM
aUpZU2tkR2xaN0ZDa3NJCjuPq+1BQBbHCbJAiTBI9EiJ9ddYrJxEt7yxjnbRx5s+
YsA15LKloxgnK+KU9TMLCFUIlgq0nheyeysMSnqgxhDv
-----END AGE ENCRYPTED FILE-----

View File

@ -1,15 +1,7 @@
{ {
description = "Python pip flake"; description = "Python pip flake";
inputs.pypi-deps-db = { inputs.mach-nix.url = "github:DavHau/mach-nix/3.5.0";
url = "github:DavHau/pypi-deps-db/b8c61fb930c9a9f95057b717bc7c701196f2ee4e";
flake = false;
};
inputs.mach-nix = {
# url = "github:DavHau/mach-nix/3.5.0";
url = "github:DavHau/mach-nix/8d903072c7b5426d90bc42a008242c76590af916";
inputs.pypi-deps-db.follows = "pypi-deps-db";
};
outputs = { nixpkgs, mach-nix }: outputs = { nixpkgs, mach-nix }:
let let