nix/flake.nix

603 lines
17 KiB
Nix
Raw Normal View History

2023-09-04 11:40:30 -05:00
{
inputs = {
2024-06-01 20:08:59 -05:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
2024-06-29 01:40:25 -05:00
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
2024-02-29 09:02:36 -06:00
2024-06-17 13:00:23 -05:00
disko.url = "github:nix-community/disko/master";
disko.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.url = "github:Mic92/sops-nix";
2024-06-29 01:40:25 -05:00
sops-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
2024-06-17 13:00:23 -05:00
sops-nix.inputs.nixpkgs-stable.follows = "nixpkgs";
2024-07-24 13:20:06 -05:00
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
2024-06-17 13:00:23 -05:00
home-manager.url = "github:nix-community/home-manager/release-24.05";
2023-11-07 17:09:05 -06:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
2024-07-29 11:29:05 -05:00
home-manager-unstable.url = "github:nix-community/home-manager";
home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable";
2023-12-04 09:14:13 -06:00
helix.url = "github:helix-editor/helix/master";
2023-10-03 17:09:12 -05:00
hardware.url = "github:nixos/nixos-hardware";
2024-03-22 09:54:00 -05:00
hyprland.url = "github:hyprwm/Hyprland";
2024-07-30 16:36:41 -05:00
2024-08-30 11:24:53 -05:00
wezterm.url = "github:wez/wezterm?dir=nix";
wezterm.inputs.nixpkgs.follows = "nixpkgs-unstable";
2024-07-30 17:07:50 -05:00
slippi.url = "github:lytedev/slippi-nix";
# slippi.url = "git+file:///home/daniel/code/open-source/slippi-nix";
2024-07-30 15:16:46 -05:00
slippi.inputs.nixpkgs.follows = "nixpkgs-unstable";
slippi.inputs.home-manager.follows = "home-manager-unstable";
2024-07-17 14:18:35 -05:00
2024-07-17 15:08:24 -05:00
# nnf.url = "github:thelegy/nixos-nftables-firewall?rev=71fc2b79358d0dbacde83c806a0f008ece567b7b";
2023-09-04 11:40:30 -05:00
};
nixConfig = {
extra-experimental-features = ["nix-command" "flakes"];
extra-substituters = [
"https://cache.nixos.org/"
"https://helix.cachix.org"
"https://nix-community.cachix.org"
2024-09-03 20:03:24 -05:00
# "https://nix.h.lyte.dev"
"https://hyprland.cachix.org"
];
extra-trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"h.lyte.dev-2:te9xK/GcWPA/5aXav8+e5RHImKYMug8hIIbhHsKPN0M="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
];
};
2023-10-03 11:52:44 -05:00
outputs = {
self,
2023-10-18 09:14:19 -05:00
nixpkgs,
2024-06-29 01:40:25 -05:00
nixpkgs-unstable,
2024-06-28 09:51:25 -05:00
disko,
2024-06-28 14:01:32 -05:00
sops-nix,
2024-07-24 13:20:06 -05:00
git-hooks,
2024-08-30 11:24:53 -05:00
wezterm,
2023-10-03 11:52:44 -05:00
home-manager,
2024-07-29 11:29:05 -05:00
home-manager-unstable,
2024-06-28 09:51:25 -05:00
helix,
2024-02-28 09:31:58 -06:00
hardware,
2024-07-17 15:08:24 -05:00
# nnf,
2024-06-28 11:50:18 -05:00
# hyprland,
2024-06-28 09:51:25 -05:00
slippi,
2023-10-03 11:52:44 -05:00
...
2024-06-28 09:51:25 -05:00
}: let
inherit (self) outputs;
2024-06-28 14:01:32 -05:00
inherit (outputs) nixosModules homeManagerModules overlays;
2024-06-28 09:51:25 -05:00
# TODO: make @ inputs unnecessary by making arguments explicit in all modules?
2024-06-25 09:38:00 -05:00
systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"];
forSystems = nixpkgs.lib.genAttrs systems;
2024-06-28 14:01:32 -05:00
pkgsFor = system: (import nixpkgs {inherit system;}).extend overlays.default;
2024-06-28 09:51:25 -05:00
genPkgs = func: (forSystems (system: func (pkgsFor system)));
pkg = callee: overrides: genPkgs (pkgs: pkgs.callPackage callee overrides);
2024-07-28 08:31:45 -05:00
unstable = {
forSystems = nixpkgs-unstable.lib.genAttrs systems;
pkgsFor = system: (import nixpkgs-unstable {inherit system;}).extend overlays.default;
genPkgs = func: (forSystems (system: func (pkgsFor system)));
pkg = callee: overrides: genPkgs (pkgs: pkgs.callPackage callee overrides);
};
2024-06-28 14:01:32 -05:00
colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire;
2024-06-28 09:51:25 -05:00
# font = {
# name = "IosevkaLyteTerm";
# size = 12;
# };
2024-01-04 14:45:10 -06:00
2024-06-28 11:50:18 -05:00
# moduleArgs = {
# # inherit colors font;
# inherit helix slippi hyprland hardware disko home-manager;
# inherit (outputs) nixosModules homeManagerModules diskoConfigurations overlays;
# };
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAPLXOjupz3ScYjgrF+ehrbp9OvGAWQLI6fplX6w9Ijb daniel@lyte.dev";
2024-06-28 09:51:25 -05:00
in {
2024-06-28 14:01:32 -05:00
# kind of a quirk, but package definitions are actually in the "additions"
# overlay I did this to work around some recursion problems
2024-07-11 12:51:51 -05:00
# TODO: https://discourse.nixos.org/t/infinite-recursion-getting-started-with-overlays/48880
2024-07-24 12:14:01 -05:00
packages = genPkgs (pkgs: {inherit (pkgs) iosevkaLyteTerm iosevkaLyteTermSubset nix-base-container-image;});
2024-09-04 10:31:06 -05:00
diskoConfigurations = import ./disko {inherit (nixpkgs) lib;};
2024-06-28 09:51:25 -05:00
templates = import ./templates;
formatter = genPkgs (p: p.alejandra);
2023-10-06 01:30:15 -05:00
2024-07-24 13:20:06 -05:00
checks = genPkgs ({system, ...}: {
git-hooks = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
};
};
2024-07-24 13:20:06 -05:00
});
2024-07-24 13:20:06 -05:00
devShells = genPkgs ({
2024-06-28 09:51:25 -05:00
system,
pkgs,
mkShell,
2024-07-24 13:20:06 -05:00
...
2024-06-28 09:51:25 -05:00
}: {
default = mkShell {
2024-07-24 13:20:06 -05:00
inherit (outputs.checks.${system}.git-hooks) shellHook;
2024-07-30 15:16:46 -05:00
packages = with pkgs; [
2024-03-25 09:44:55 -05:00
lua-language-server
2024-06-28 09:51:25 -05:00
nodePackages.bash-language-server
2024-03-25 09:44:55 -05:00
];
2024-06-28 09:51:25 -05:00
};
2024-07-24 13:20:06 -05:00
});
2024-06-28 09:51:25 -05:00
overlays = {
2024-06-28 11:50:18 -05:00
# the default overlay composes all the other overlays together
default = final: prev: {
2024-06-28 14:01:32 -05:00
overlays = with overlays; [
2024-06-28 11:50:18 -05:00
additions
modifications
2024-06-29 01:40:25 -05:00
unstable-packages
2024-06-28 11:50:18 -05:00
];
};
2024-06-28 14:01:32 -05:00
additions = final: prev: let
iosevkaLyteTerm = prev.callPackage ./packages/iosevkaLyteTerm.nix {};
in {
inherit iosevkaLyteTerm;
iosevkaLyteTermSubset = prev.callPackage ./packages/iosevkaLyteTermSubset.nix {
inherit iosevkaLyteTerm;
};
2024-07-24 12:14:01 -05:00
nix-base-container-image = final.dockerTools.buildImageWithNixDb {
name = "git.lyte.dev/lytedev/nix";
tag = "latest";
copyToRoot = with final; [
bash
coreutils
curl
gawk
gitFull
git-lfs
gnused
nodejs
wget
sudo
nixFlakes
cacert
gnutar
gzip
openssh
xz
(pkgs.writeTextFile {
name = "nix.conf";
destination = "/etc/nix/nix.conf";
text = ''
accept-flake-config = true
experimental-features = nix-command flakes
2024-07-24 13:31:28 -05:00
build-users-group =
2024-07-24 12:34:31 -05:00
substituters = https://nix.h.lyte.dev https://cache.nixos.org/
trusted-substituters = https://nix.h.lyte.dev https://cache.nixos.org/
trusted-public-keys = h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
2024-07-24 12:14:01 -05:00
'';
})
];
extraCommands = ''
# enable /usr/bin/env for scripts
2024-07-24 12:34:31 -05:00
mkdir -p usr
ln -s ../bin usr/bin
# create /tmp
mkdir -p tmp
2024-07-24 12:14:01 -05:00
# create HOME
2024-07-24 12:34:31 -05:00
mkdir -vp root
2024-07-24 12:14:01 -05:00
'';
config = {
Cmd = ["/bin/bash"];
Env = [
"LANG=en_GB.UTF-8"
"ENV=/etc/profile.d/nix.sh"
"BASH_ENV=/etc/profile.d/nix.sh"
"NIX_BUILD_SHELL=/bin/bash"
"PAGER=cat"
"PATH=/usr/bin:/bin"
"SSL_CERT_FILE=${final.cacert}/etc/ssl/certs/ca-bundle.crt"
"USER=root"
];
};
};
2024-06-28 14:01:32 -05:00
};
2023-10-03 11:52:44 -05:00
2024-08-30 11:24:53 -05:00
modifications = final: prev: let
wezterm-input = wezterm;
in rec {
2024-07-31 21:13:37 -05:00
helix = helix.outputs.packages.${prev.system}.helix;
final.helix = helix;
2024-08-01 09:53:48 -05:00
# TODO: would love to use a current wezterm build so I can make use of ssh/mux functionality without breakage
# source: https://github.com/wez/wezterm/issues/3771
2024-09-03 20:03:24 -05:00
# not-yet-merged (abandoned?): https://github.com/wez/wezterm/pull/4737
# I did try using the latest code via the flake, but alas it did not resolve my issues with mux'ing
2024-08-30 11:24:53 -05:00
wezterm = wezterm-input.outputs.packages.${prev.system}.default;
2024-08-30 11:04:17 -05:00
final.wezterm = wezterm;
};
2023-10-03 11:52:44 -05:00
2024-06-29 01:40:25 -05:00
unstable-packages = final: _prev: {
unstable-packages = import nixpkgs-unstable {
system = final.system;
config.allowUnfree = true;
};
};
2024-06-28 11:50:18 -05:00
};
nixosModules = import ./modules/nixos {
2024-07-29 11:29:05 -05:00
inherit home-manager home-manager-unstable helix nixosModules homeManagerModules pubkey overlays colors sops-nix disko;
flakeInputs = self.inputs;
2024-06-28 11:50:18 -05:00
};
homeManagerModules = import ./modules/home-manager {
2024-07-29 11:29:05 -05:00
inherit home-manager home-manager-unstable helix nixosModules homeManagerModules pubkey overlays colors;
2024-06-28 21:36:19 -05:00
inherit (nixpkgs) lib;
flakeInputs = self.inputs;
2024-06-28 14:01:32 -05:00
};
nixosConfigurations = {
2024-06-28 14:01:32 -05:00
beefcake = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-defaults
2024-09-03 20:03:24 -05:00
# TODO: disko?
2024-06-28 14:01:32 -05:00
hardware.nixosModules.common-cpu-intel
2024-07-11 12:51:51 -05:00
outputs.nixosModules.deno-netlify-ddns-client
{
services.deno-netlify-ddns-client = {
enable = true;
username = "beefcake.h";
# TODO: router doesn't even do ipv6 yet...
ipv6 = false;
};
}
2024-07-11 12:51:51 -05:00
common
2024-09-03 20:03:24 -05:00
troubleshooting-tools
linux
2024-06-28 14:01:32 -05:00
fonts
2024-07-11 12:51:51 -05:00
./nixos/beefcake.nix
2024-06-28 14:01:32 -05:00
];
};
2024-07-29 11:29:05 -05:00
dragon = nixpkgs-unstable.lib.nixosSystem {
2024-06-28 14:01:32 -05:00
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-unstable-defaults
2024-06-28 22:04:37 -05:00
outputs.diskoConfigurations.standard
hardware.nixosModules.common-cpu-amd
hardware.nixosModules.common-pc-ssd
2024-06-28 14:01:32 -05:00
2024-07-11 12:51:51 -05:00
common
2024-07-10 09:57:10 -05:00
password-manager
wifi
graphical-workstation
music-production
gaming
slippi.nixosModules.default
2024-06-28 14:01:32 -05:00
./nixos/dragon.nix
2024-06-28 14:01:32 -05:00
{
2024-06-28 14:01:32 -05:00
home-manager.users.daniel = {
imports = with homeManagerModules; [
senpai
iex
cargo
firefox-no-tabs
linux-desktop-environment-config
slippi.homeManagerModules.default
];
};
2024-06-28 14:44:46 -05:00
}
2024-06-28 14:01:32 -05:00
];
};
2024-06-28 11:50:18 -05:00
2024-08-06 10:41:57 -05:00
bigtower = nixpkgs-unstable.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
home-manager-unstable-defaults
outputs.diskoConfigurations.unencrypted
hardware.nixosModules.common-cpu-amd
hardware.nixosModules.common-pc-ssd
common
# wifi
graphical-workstation
music-production
gaming
./nixos/bigtower.nix
{
home-manager.users.daniel = {
imports = with homeManagerModules; [
firefox-no-tabs
linux-desktop-environment-config
];
};
}
];
};
2024-06-29 00:51:22 -05:00
htpc = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-defaults
2024-06-29 00:51:22 -05:00
hardware.nixosModules.common-pc-ssd
2024-07-11 12:51:51 -05:00
common
2024-08-30 13:02:20 -05:00
gaming
2024-06-29 00:51:22 -05:00
graphical-workstation
./nixos/htpc.nix
{
home-manager.users.daniel = {
imports = with homeManagerModules; [
linux-desktop-environment-config
];
};
}
];
};
2024-07-28 08:31:45 -05:00
foxtrot = nixpkgs-unstable.lib.nixosSystem {
2024-06-28 14:44:46 -05:00
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-unstable-defaults
2024-06-28 21:36:19 -05:00
outputs.diskoConfigurations.standard
hardware.nixosModules.framework-13-7040-amd
2024-07-11 12:51:51 -05:00
common
2024-07-11 21:25:18 -05:00
password-manager
2024-06-28 21:36:19 -05:00
graphical-workstation
laptop
gaming
2024-06-28 14:44:46 -05:00
./nixos/foxtrot.nix
2024-06-28 21:36:19 -05:00
({pkgs, ...}: {
2024-06-28 21:36:19 -05:00
home-manager.users.daniel = {
imports = with homeManagerModules; [
senpai
iex
cargo
firefox-no-tabs
linux-desktop-environment-config
];
};
2024-07-14 22:29:42 -05:00
environment.systemPackages = with pkgs; [
fw-ectool
(writeShellApplication
{
name = "reset-wifi-module";
runtimeInputs = with pkgs; [kmod];
text = ''
modprobe -rv mt7921e
modprobe -v mt7921e
'';
})
];
})
2024-06-28 11:50:18 -05:00
];
};
2024-07-29 11:29:05 -05:00
thablet = nixpkgs-unstable.lib.nixosSystem {
2024-06-28 14:44:46 -05:00
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-unstable-defaults
2024-06-28 21:36:19 -05:00
outputs.diskoConfigurations.standard
hardware.nixosModules.lenovo-thinkpad-x1-yoga
2024-06-29 02:55:19 -05:00
common
2024-07-13 10:32:19 -05:00
password-manager
2024-06-29 02:55:19 -05:00
graphical-workstation
2024-07-17 20:22:16 -05:00
music-production
2024-06-29 02:55:19 -05:00
laptop
gaming
./nixos/thablet.nix
{
home-manager.users.daniel = {
imports = with homeManagerModules; [
2024-07-18 07:55:24 -05:00
senpai
2024-06-29 02:55:19 -05:00
iex
cargo
2024-07-18 07:55:24 -05:00
firefox-no-tabs
2024-06-29 02:55:19 -05:00
linux-desktop-environment-config
2024-07-31 19:00:50 -05:00
# slippi.homeManagerModules.default
2024-06-29 02:55:19 -05:00
];
};
}
];
};
2024-07-11 12:51:51 -05:00
# grablet = nixpkgs.lib.nixosSystem {
# system = "x86_64-linux";
# modules = with nixosModules; [
# common
# outputs.diskoConfigurations.standard
# hardware.nixosModules.common-cpu-intel-kaby-lake
# hardware.nixosModules.common-pc-laptopp-ssd
# graphical-workstation
# laptop
# gaming
# ./nixos/thablet.nix
# {
# home-manager.users.daniel = {
# imports = with homeManagerModules; [
# iex
# cargo
# linux-desktop-environment-config
# ];
# };
# powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
# }
# ];
# };
2024-07-29 11:29:05 -05:00
thinker = nixpkgs-unstable.lib.nixosSystem {
2024-06-28 14:44:46 -05:00
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-unstable-defaults
2024-07-17 20:49:12 -05:00
{
_module.args = {
disks = ["/dev/nvme0n1"];
swapSize = "32G";
};
}
2024-07-17 20:55:05 -05:00
outputs.diskoConfigurations.standardWithHibernateSwap
2024-07-17 22:08:32 -05:00
hardware.nixosModules.lenovo-thinkpad-t480
hardware.nixosModules.common-pc-laptop-ssd
2024-07-17 20:22:16 -05:00
music-production
2024-06-28 11:50:18 -05:00
common
2024-07-17 20:22:16 -05:00
password-manager
graphical-workstation
laptop
gaming
2024-06-28 14:44:46 -05:00
./nixos/thinker.nix
2024-07-17 20:22:16 -05:00
{
home-manager.users.daniel = {
imports = with homeManagerModules; [
2024-07-18 07:55:24 -05:00
senpai
2024-07-17 20:22:16 -05:00
iex
cargo
2024-07-18 07:55:24 -05:00
firefox-no-tabs
2024-07-17 20:22:16 -05:00
linux-desktop-environment-config
2024-07-18 07:55:24 -05:00
slippi.homeManagerModules.default
2024-07-17 20:22:16 -05:00
];
};
}
2024-06-28 11:50:18 -05:00
];
};
2024-07-19 12:15:39 -05:00
musicbox = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-defaults
2024-07-19 12:15:39 -05:00
{
_module.args = {
disks = ["/dev/sda"];
# swapSize = "8G";
};
}
outputs.diskoConfigurations.unencrypted
hardware.nixosModules.common-pc-laptop-ssd
music-production
common
graphical-workstation
wifi
# ./nixos/musicbox.nix
{
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
hardware.bluetooth.enable = true;
networking.networkmanager.enable = true;
home-manager.users.daniel = {
imports = with homeManagerModules; [
firefox-no-tabs
linux-desktop-environment-config
];
};
}
];
};
2024-06-28 09:51:25 -05:00
2024-06-28 14:44:46 -05:00
rascal = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-defaults
2024-06-28 15:50:00 -05:00
hardware.nixosModules.common-cpu-amd
2024-06-28 14:44:46 -05:00
common
2024-09-04 11:28:57 -05:00
linux
2024-06-28 14:44:46 -05:00
./nixos/rascal.nix
];
};
router = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with nixosModules; [
2024-07-29 11:29:05 -05:00
home-manager-defaults
2024-07-13 14:41:30 -05:00
outputs.diskoConfigurations.unencrypted
common
2024-07-17 15:08:24 -05:00
linux
2024-07-18 10:01:56 -05:00
troubleshooting-tools
# NOTE: maybe use this someday, but I think I need more concrete
# networking knowledge before I know how to use it well. Additionally,
# I can use my existing firewall configuration more easily if I manage
# it directly.
2024-07-17 15:08:24 -05:00
# nnf.nixosModules.default
2024-07-18 10:01:56 -05:00
./nixos/router.nix
2024-06-28 14:44:46 -05:00
];
};
};
2024-06-28 09:51:25 -05:00
2024-08-23 09:33:50 -05:00
homeConfigurations = {
"deck" = let
system = "x86_64-linux";
2024-08-23 14:11:13 -05:00
pkgs = unstable.pkgsFor system;
2024-08-23 09:33:50 -05:00
in
2024-08-23 13:33:33 -05:00
home-manager-unstable.lib.homeManagerConfiguration {
2024-08-23 09:39:36 -05:00
inherit pkgs;
2024-08-23 09:33:50 -05:00
modules = with homeManagerModules; [
common
{
home = {
homeDirectory = "/home/deck";
username = "deck";
2024-08-23 13:34:47 -05:00
stateVersion = "24.11";
2024-08-23 09:33:50 -05:00
};
}
{
home.packages = with pkgs; [
ludusavi
rclone
];
}
linux
];
};
};
2024-01-04 14:45:10 -06:00
# TODO: nix-on-droid for phone terminal usage?
# TODO: nix-darwin for work?
# TODO: nixos ISO?
2023-12-19 10:27:11 -06:00
};
2023-09-04 11:40:30 -05:00
}